PluginProbe
User Access Manager / 2.2.2
User Access Manager v2.2.2
2.3.20 2.3.19 2.3.18 2.3.17 2.3.16 2.3.15 2.3.14 2.3.13 trunk 0.6 0.6.1 0.6.2 0.7 0.7 Beta 0.7.0.1 0.8 0.8.0.1 0.8.0.2 0.9 0.9.1 0.9.1.1 0.9.1.2 0.9.1.3 0.9.1.4 1.0 All 136 releases
← All changes | src/Controller/Backend/BackendController.php +73 -9 2.3.142.2.2 View file →
@@ -1,5 +1,18 @@
1 1 <?php
2 +/**
3 + * BackendController.php
4 + *
5 + * The BackendController class file.
6 + *
7 + * PHP versions 5
8 + *
9 + * @author Alexander Schneider <alexanderschneider85@gmail.com>
10 + * @copyright 2008-2017 Alexander Schneider
11 + * @license http://www.gnu.org/licenses/gpl-2.0.html GNU General Public License, version 2
12 + * @version SVN: $id$
13 + * @link http://wordpress.org/extend/plugins/user-access-manager/
14 + */
2 15
3 16 declare(strict_types=1);
4 17
5 18 namespace UserAccessManager\Controller\Backend;
@@ -5,9 +18,9 @@
5 18 namespace UserAccessManager\Controller\Backend;
6 19
7 20 use UserAccessManager\Config\WordpressConfig;
8 21 use UserAccessManager\Controller\Controller;
9 -use UserAccessManager\Setup\Database\MissingColumnsException;
22 +use UserAccessManager\File\FileHandler;
10 23 use UserAccessManager\Setup\SetupHandler;
11 24 use UserAccessManager\User\UserHandler;
12 25 use UserAccessManager\UserAccessManager;
13 26 use UserAccessManager\Wrapper\Php;
@@ -12,8 +25,13 @@
12 25 use UserAccessManager\UserAccessManager;
13 26 use UserAccessManager\Wrapper\Php;
14 27 use UserAccessManager\Wrapper\Wordpress;
15 28
29 +/**
30 + * Class BackendController
31 + *
32 + * @package UserAccessManager\Controller
33 + */
16 34 class BackendController extends Controller
17 35 {
18 36 public const HANDLE_STYLE_ADMIN = 'UserAccessManagerAdmin';
19 37 public const HANDLE_SCRIPT_GROUP_SUGGEST = 'UserAccessManagerGroupSuggest';
@@ -20,24 +38,55 @@
20 38 public const HANDLE_SCRIPT_TIME_INPUT = 'UserAccessManagerTimeInput';
21 39 public const HANDLE_SCRIPT_ADMIN = 'UserAccessManagerFunctions';
22 40 public const UAM_ERRORS = 'UAM_ERRORS';
23 41
24 - private string $notice = '';
42 + /**
43 + * @var UserHandler
44 + */
45 + private $userHandler;
25 46
47 + /**
48 + * @var FileHandler
49 + */
50 + private $fileHandler;
51 +
52 + /**
53 + * @var SetupHandler
54 + */
55 + private $setupHandler;
56 +
57 + /**
58 + * @var string
59 + */
60 + private $notice = '';
61 +
62 + /**
63 + * BackendController constructor.
64 + * @param Php $php
65 + * @param Wordpress $wordpress
66 + * @param WordpressConfig $wordpressConfig
67 + * @param UserHandler $userHandler
68 + * @param FileHandler $fileHandler
69 + * @param SetupHandler $setupHandler
70 + */
26 71 public function __construct(
27 72 Php $php,
28 73 Wordpress $wordpress,
29 74 WordpressConfig $wordpressConfig,
30 - private UserHandler $userHandler,
31 - private SetupHandler $setupHandler
75 + UserHandler $userHandler,
76 + FileHandler $fileHandler,
77 + SetupHandler $setupHandler
32 78 ) {
33 79 parent::__construct($php, $wordpress, $wordpressConfig);
80 + $this->userHandler = $userHandler;
81 + $this->fileHandler = $fileHandler;
82 + $this->setupHandler = $setupHandler;
34 83 }
35 84
36 85 /**
37 - * @throws MissingColumnsException
86 + * Shows the admin notices.
38 87 */
39 - public function showAdminNotice(): void
88 + public function showAdminNotice()
40 89 {
41 90 $messages = isset($_SESSION[self::UAM_ERRORS]) === true ? $_SESSION[self::UAM_ERRORS] : [];
42 91 $updateAction = $this->getRequestParameter('uam_update_db');
43 92
@@ -53,14 +102,21 @@
53 102 echo $this->getIncludeContents('AdminNotice.php');
54 103 }
55 104 }
56 105
106 + /**
107 + * Returns the set notice.
108 + * @return string
109 + */
57 110 public function getNotice(): string
58 111 {
59 112 return $this->notice;
60 113 }
61 114
62 - private function registerStylesAndScripts(): void
115 + /**
116 + * Register styles and scripts with handle for admin panel.
117 + */
118 + private function registerStylesAndScripts()
63 119 {
64 120 $urlPath = $this->wordpressConfig->getUrlPath();
65 121
66 122 $this->wordpress->registerStyle(
@@ -92,9 +148,12 @@
92 148 UserAccessManager::VERSION
93 149 );
94 150 }
95 151
96 - public function enqueueStylesAndScripts(): void
152 + /**
153 + * The function for the admin_enqueue_scripts action for styles and scripts.
154 + */
155 + public function enqueueStylesAndScripts()
97 156 {
98 157 $this->registerStylesAndScripts();
99 158 $this->wordpress->enqueueStyle(self::HANDLE_STYLE_ADMIN);
100 159 $this->wordpress->enqueueScript(self::HANDLE_SCRIPT_GROUP_SUGGEST);
@@ -101,9 +160,14 @@
101 160 $this->wordpress->enqueueScript(self::HANDLE_SCRIPT_TIME_INPUT);
102 161 $this->wordpress->enqueueScript(self::HANDLE_SCRIPT_ADMIN);
103 162 }
104 163
105 - public function setupAdminDashboard(): void
164 +
165 + /**
166 + * The function for the wp_dashboard_setup action.
167 + * Removes widgets to which a user should not have access.
168 + */
169 + public function setupAdminDashboard()
106 170 {
107 171 if ($this->userHandler->checkUserAccess(UserHandler::MANAGE_USER_GROUPS_CAPABILITY) === false) {
108 172 $metaBoxes = $this->wordpress->getMetaBoxes();
109 173 unset($metaBoxes['dashboard']['normal']['core']['dashboard_recent_comments']);