PluginProbe
User Access Manager / 2.1.9
User Access Manager v2.1.9
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
user-access-manager / src / Controller / Backend / BackendController.php

BackendController.php in User Access Manager 2.1.9, at src/Controller/Backend/BackendController.php

155 lines 4.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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 */
15 namespace UserAccessManager\Controller\Backend;
16
17 use UserAccessManager\Config\WordpressConfig;
18 use UserAccessManager\Controller\Controller;
19 use UserAccessManager\File\FileHandler;
20 use UserAccessManager\UserAccessManager;
21 use UserAccessManager\User\UserHandler;
22 use UserAccessManager\Wrapper\Php;
23 use UserAccessManager\Wrapper\Wordpress;
24
25 /**
26 * Class BackendController
27 *
28 * @package UserAccessManager\Controller
29 */
30 class BackendController extends Controller
31 {
32 const HANDLE_STYLE_ADMIN = 'UserAccessManagerAdmin';
33 const HANDLE_SCRIPT_GROUP_SUGGEST = 'UserAccessManagerGroupSuggest';
34 const HANDLE_SCRIPT_TIME_INPUT = 'UserAccessManagerTimeInput';
35 const HANDLE_SCRIPT_ADMIN = 'UserAccessManagerFunctions';
36
37 /**
38 * @var UserHandler
39 */
40 private $userHandler;
41
42 /**
43 * @var FileHandler
44 */
45 private $fileHandler;
46
47 /**
48 * @var string
49 */
50 private $notice = '';
51
52 /**
53 * BackendController constructor.
54 *
55 * @param Php $php
56 * @param Wordpress $wordpress
57 * @param WordpressConfig $wordpressConfig
58 * @param UserHandler $userHandler
59 * @param FileHandler $fileHandler
60 */
61 public function __construct(
62 Php $php,
63 Wordpress $wordpress,
64 WordpressConfig $wordpressConfig,
65 UserHandler $userHandler,
66 FileHandler $fileHandler
67 ) {
68 parent::__construct($php, $wordpress, $wordpressConfig);
69 $this->userHandler = $userHandler;
70 $this->fileHandler = $fileHandler;
71 }
72
73 /**
74 * Shows the database notice.
75 */
76 public function showDatabaseNotice()
77 {
78 $this->notice = sprintf(TXT_UAM_NEED_DATABASE_UPDATE, 'admin.php?page=uam_setup');
79 echo $this->getIncludeContents('AdminNotice.php');
80 }
81
82 /**
83 * Returns the set notice.
84 *
85 * @return string
86 */
87 public function getNotice()
88 {
89 return $this->notice;
90 }
91
92 /**
93 * Register styles and scripts with handle for admin panel.
94 */
95 private function registerStylesAndScripts()
96 {
97 $urlPath = $this->wordpressConfig->getUrlPath();
98
99 $this->wordpress->registerStyle(
100 self::HANDLE_STYLE_ADMIN,
101 $urlPath.'assets/css/uamAdmin.css',
102 [],
103 UserAccessManager::VERSION,
104 'screen'
105 );
106
107 $this->wordpress->registerScript(
108 self::HANDLE_SCRIPT_GROUP_SUGGEST,
109 $urlPath.'assets/js/jquery.uam-group-suggest.js',
110 ['jquery'],
111 UserAccessManager::VERSION
112 );
113
114 $this->wordpress->registerScript(
115 self::HANDLE_SCRIPT_TIME_INPUT,
116 $urlPath.'assets/js/jquery.uam-time-input.js',
117 ['jquery'],
118 UserAccessManager::VERSION
119 );
120
121 $this->wordpress->registerScript(
122 self::HANDLE_SCRIPT_ADMIN,
123 $urlPath.'assets/js/functions.js',
124 ['jquery'],
125 UserAccessManager::VERSION
126 );
127 }
128
129 /**
130 * The function for the admin_enqueue_scripts action for styles and scripts.
131 */
132 public function enqueueStylesAndScripts()
133 {
134 $this->registerStylesAndScripts();
135 $this->wordpress->enqueueStyle(self::HANDLE_STYLE_ADMIN);
136 $this->wordpress->enqueueScript(self::HANDLE_SCRIPT_GROUP_SUGGEST);
137 $this->wordpress->enqueueScript(self::HANDLE_SCRIPT_TIME_INPUT);
138 $this->wordpress->enqueueScript(self::HANDLE_SCRIPT_ADMIN);
139 }
140
141
142 /**
143 * The function for the wp_dashboard_setup action.
144 * Removes widgets to which a user should not have access.
145 */
146 public function setupAdminDashboard()
147 {
148 if ($this->userHandler->checkUserAccess(UserHandler::MANAGE_USER_GROUPS_CAPABILITY) === false) {
149 $metaBoxes = $this->wordpress->getMetaBoxes();
150 unset($metaBoxes['dashboard']['normal']['core']['dashboard_recent_comments']);
151 $this->wordpress->setMetaBoxes($metaBoxes);
152 }
153 }
154 }
155