PluginProbe ʕ •ᴥ•ʔ
Advanced Access Manager – Access Governance for WordPress / 5.3
Advanced Access Manager – Access Governance for WordPress v5.3
6.8.4 6.8.5 6.9.0 6.9.1 6.9.10 6.9.11 6.9.12 6.9.13 6.9.14 6.9.15 6.9.16 6.9.17 6.9.18 6.9.19 6.9.2 6.9.20 6.9.21 6.9.22 6.9.23 6.9.24 6.9.25 6.9.26 6.9.27 6.9.28 6.9.29 6.9.3 6.9.30 6.9.31 6.9.32 6.9.33 6.9.34 6.9.35 6.9.36 6.9.37 6.9.38 6.9.39 6.9.4 6.9.41 6.9.42 6.9.43 6.9.44 6.9.45 6.9.46 6.9.47 6.9.48 6.9.49 6.9.5 6.9.51 6.9.6 6.9.7 6.9.8 6.9.9 7.0.0 7.0.0-alpha.6 7.0.0-alpha.7 7.0.0-beta.1 7.0.0-rc1 7.0.0-rc2 7.0.0-rc3 7.0.1 7.0.10 7.0.11 7.0.2 7.0.3 7.0.4 7.0.5 7.0.6 7.0.7 7.0.8 7.0.9 7.1.0 7.1.1 trunk 3.0 4.0 4.0.1 4.1 4.2 4.3 4.4 4.4.1 4.5 4.6 4.6.1 4.6.2 4.7 4.7.1 4.7.2 4.7.5 4.7.6 4.8 4.8.1 4.9 4.9.1 4.9.2 4.9.3 4.9.4 4.9.5 4.9.5.1 4.9.5.2 5.0 5.0.1 5.0.2 5.0.3 5.0.4 5.0.5 5.0.6 5.0.7 5.0.8 5.1 5.1.1 5.10 5.11 5.2 5.2.1 5.2.5 5.2.6 5.2.7 5.3 5.3.1 5.3.2 5.3.3 5.3.4 5.3.5 5.4 5.4.1 5.4.2 5.4.3 5.4.3.1 5.4.3.2 5.5 5.5.1 5.5.2 5.6 5.6.1 5.6.1.1 5.7 5.7.1 5.7.2 5.7.3 5.8 5.8.1 5.8.2 5.8.3 5.9 5.9.1 5.9.1.1 5.9.2 5.9.2.1 5.9.3 5.9.4 5.9.5 5.9.6 5.9.6.1 5.9.6.2 5.9.6.3 5.9.7 5.9.7.1 5.9.7.2 5.9.7.3 5.9.8 5.9.8.1 5.9.9 5.9.9.1 6.0.0 6.0.1 6.0.2 6.0.3 6.0.4 6.0.5 6.1.0 6.1.1 6.2.0 6.2.1 6.2.2 6.3.0 6.3.1 6.3.2 6.3.3 6.4.0 6.4.1 6.4.2 6.4.3 6.5.0 6.5.1 6.5.2 6.5.3 6.5.4 6.6.0 6.6.1 6.6.2 6.6.3 6.6.4 6.7.0 6.7.1 6.7.2 6.7.3 6.7.4 6.7.5 6.7.6 6.7.7 6.7.8 6.7.9 6.8.0 6.8.1 6.8.2 6.8.3
advanced-access-manager / Application / Backend / View.php
advanced-access-manager / Application / Backend Last commit date
Feature 8 years ago View 8 years ago Widget 8 years ago phtml 8 years ago Authorization.php 8 years ago Feature.php 8 years ago Filter.php 8 years ago Manager.php 8 years ago Subject.php 8 years ago View.php 8 years ago
View.php
269 lines
1 <?php
2
3 /**
4 * ======================================================================
5 * LICENSE: This file is subject to the terms and conditions defined in *
6 * file 'license.txt', which is part of this source code package. *
7 * ======================================================================
8 */
9
10 /**
11 * Backend view manager
12 *
13 * @package AAM
14 * @author Vasyl Martyniuk <vasyl@vasyltech.com>
15 */
16 class AAM_Backend_View {
17
18 /**
19 * Instance of itself
20 *
21 * @var AAM_Backend_View
22 *
23 * @access private
24 */
25 private static $_instance = null;
26
27 /**
28 * Construct the view object
29 *
30 * @return void
31 *
32 * @access protected
33 */
34 protected function __construct() {
35 //register default features
36 AAM_Backend_Feature_Main_Menu::register();
37 AAM_Backend_Feature_Main_Metabox::register();
38 AAM_Backend_Feature_Main_Capability::register();
39 AAM_Backend_Feature_Main_Route::register();
40 AAM_Backend_Feature_Main_Post::register();
41 AAM_Backend_Feature_Main_Redirect::register();
42 AAM_Backend_Feature_Main_LoginRedirect::register();
43 AAM_Backend_Feature_Main_LogoutRedirect::register();
44 AAM_Backend_Feature_Main_404Redirect::register();
45
46 AAM_Backend_Feature_Settings_Core::register();
47 AAM_Backend_Feature_Settings_Content::register();
48 AAM_Backend_Feature_Settings_Tools::register();
49 AAM_Backend_Feature_Settings_ConfigPress::register();
50
51 //feature registration hook
52 do_action('aam-feature-registration-action');
53 }
54
55 /**
56 * Run the Manager
57 *
58 * @return string
59 *
60 * @access public
61 */
62 public function renderPage() {
63 ob_start();
64 require_once(dirname(__FILE__) . '/phtml/index.phtml');
65 $content = ob_get_contents();
66 ob_end_clean();
67
68 return $content;
69 }
70
71 /**
72 * Run the Manager
73 *
74 * @return string
75 *
76 * @access public
77 */
78 public function renderAccessFrame() {
79 ob_start();
80 require_once(dirname(__FILE__) . '/phtml/metabox/metabox-content.phtml');
81 $content = ob_get_contents();
82 ob_end_clean();
83
84 return $content;
85 }
86
87 /**
88 *
89 * @param type $post
90 * @return type
91 */
92 public function renderPostMetabox($post) {
93 ob_start();
94 require_once(dirname(__FILE__) . '/phtml/metabox/post-metabox.phtml');
95 $content = ob_get_contents();
96 ob_end_clean();
97
98 return $content;
99 }
100
101 /**
102 *
103 * @param type $term
104 * @return type
105 */
106 public function renderTermMetabox($term) {
107 ob_start();
108 require_once(dirname(__FILE__) . '/phtml/metabox/term-metabox.phtml');
109 $content = ob_get_contents();
110 ob_end_clean();
111
112 return $content;
113 }
114
115 /**
116 * Process the ajax call
117 *
118 * @return string
119 *
120 * @access public
121 */
122 public function processAjax() {
123 $response = null;
124
125 $action = AAM_Core_Request::request('sub_action');
126 $parts = explode('.', $action);
127
128 if (method_exists($this, $parts[0])) {
129 $response = call_user_func(array($this, $parts[0]));
130 } elseif (count($parts) == 2) { //cover the Model.method pattern
131 try {
132 $classname = 'AAM_Backend_Feature_' . $parts[0];
133 if (class_exists($classname)) {
134 $response = call_user_func(array(new $classname, $parts[1]));
135 }
136 } catch (Exception $e) {
137 $response = $e->getMessage();
138 }
139 }
140
141 return apply_filters(
142 'aam-ajax-filter',
143 $response,
144 AAM_Backend_Subject::getInstance()->get(),
145 $action
146 );
147 }
148
149 /**
150 * Render the Main Control Area
151 *
152 * @param string $type
153 *
154 * @return void
155 *
156 * @access public
157 */
158 public function renderContent($type = 'main') {
159 $content = apply_filters('aam-ui-content-filter', null, $type);
160
161 if (is_null($content)) {
162 ob_start();
163 if ($type == 'extensions') {
164 AAM_Backend_Feature_Extension_Manager::getInstance()->render();
165 } elseif ($type == 'postform') {
166 echo AAM_Backend_Feature_Main_Post::renderAccessForm();
167 } else {
168 require_once(dirname(__FILE__) . '/phtml/main-panel.phtml');
169 }
170 $content = ob_get_contents();
171 ob_end_clean();
172 }
173
174 return $content;
175 }
176
177 /**
178 *
179 * @param type $partial
180 * @return type
181 */
182 public function loadPartial($partial) {
183 ob_start();
184 require_once(dirname(__FILE__) . '/phtml/partial/' . $partial);
185 $content = ob_get_contents();
186 ob_end_clean();
187
188 return $content;
189 }
190
191 /**
192 * Save AAM options
193 *
194 * Important notice! This function excepts "value" to be only boolean value
195 *
196 * @return string
197 *
198 * @access public
199 */
200 public function save() {
201 $object = trim(AAM_Core_Request::post('object'));
202 $objectId = intval(AAM_Core_Request::post('objectId', 0));
203
204 $param = AAM_Core_Request::post('param');
205 $value = filter_input(INPUT_POST, 'value');
206
207 $result = AAM_Backend_Subject::getInstance()->save(
208 $param, $value, $object, $objectId
209 );
210
211 return json_encode(array('status' => ($result ? 'success' : 'failure')));
212 }
213
214 /**
215 *
216 * @return type
217 */
218 public function reset() {
219 return AAM_Backend_Subject::getInstance()->resetObject(
220 AAM_Core_Request::post('object')
221 );
222 }
223
224 /**
225 *
226 * @return type
227 */
228 public function switchToUser() {
229 $response = array(
230 'status' => 'failure',
231 'reason' => 'You are not allowed to switch to this user'
232 );
233
234 if (current_user_can('aam_switch_users')) {
235 $user = new WP_User(AAM_Core_Request::post('user'));
236 $max = AAM_Core_API::maxLevel(wp_get_current_user()->allcaps);
237
238 if ($max >= AAM_Core_API::maxLevel($user->allcaps)) {
239 AAM_Core_API::updateOption(
240 'aam-user-switch-' . $user->ID, get_current_user_id()
241 );
242
243 wp_clear_auth_cookie();
244 wp_set_auth_cookie( $user->ID, true );
245 wp_set_current_user( $user->ID );
246
247 $response = array('status' => 'success', 'redirect' => admin_url());
248 }
249 }
250
251 return json_encode($response);
252 }
253
254 /**
255 * Get instance of itself
256 *
257 * @return AAM_Backend_View
258 *
259 * @access public
260 */
261 public static function getInstance() {
262 if (is_null(self::$_instance)) {
263 self::$_instance = new self;
264 }
265
266 return self::$_instance;
267 }
268
269 }