PluginProbe ʕ •ᴥ•ʔ
Advanced Access Manager – Access Governance for WordPress / 5.0
Advanced Access Manager – Access Governance for WordPress v5.0
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
261 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_Post::register();
40 AAM_Backend_Feature_Main_Redirect::register();
41 AAM_Backend_Feature_Main_LoginRedirect::register();
42 AAM_Backend_Feature_Main_LogoutRedirect::register();
43 AAM_Backend_Feature_Main_404Redirect::register();
44
45 AAM_Backend_Feature_Settings_Core::register();
46 AAM_Backend_Feature_Settings_Content::register();
47 AAM_Backend_Feature_Settings_Tools::register();
48
49 //feature registration hook
50 do_action('aam-feature-registration-action');
51 }
52
53 /**
54 * Run the Manager
55 *
56 * @return string
57 *
58 * @access public
59 */
60 public function renderPage() {
61 ob_start();
62 require_once(dirname(__FILE__) . '/phtml/index.phtml');
63 $content = ob_get_contents();
64 ob_end_clean();
65
66 return $content;
67 }
68
69 /**
70 * Run the Manager
71 *
72 * @return string
73 *
74 * @access public
75 */
76 public function renderAccessFrame() {
77 ob_start();
78 require_once(dirname(__FILE__) . '/phtml/frame.phtml');
79 $content = ob_get_contents();
80 ob_end_clean();
81
82 return $content;
83 }
84
85 /**
86 *
87 * @param type $post
88 * @return type
89 */
90 public function renderPostMetabox($post) {
91 ob_start();
92 require_once(dirname(__FILE__) . '/phtml/post-metabox.phtml');
93 $content = ob_get_contents();
94 ob_end_clean();
95
96 return $content;
97 }
98
99 /**
100 *
101 * @param type $term
102 * @return type
103 */
104 public function renderTermMetabox($term) {
105 ob_start();
106 require_once(dirname(__FILE__) . '/phtml/term-metabox.phtml');
107 $content = ob_get_contents();
108 ob_end_clean();
109
110 return $content;
111 }
112
113 /**
114 * Process the ajax call
115 *
116 * @return string
117 *
118 * @access public
119 */
120 public function processAjax() {
121 $response = null;
122
123 $action = AAM_Core_Request::request('sub_action');
124 $parts = explode('.', $action);
125
126 if (method_exists($this, $parts[0])) {
127 $response = call_user_func(array($this, $parts[0]));
128 } elseif (count($parts) == 2) { //cover the Model.method pattern
129 try {
130 $classname = 'AAM_Backend_Feature_' . $parts[0];
131 if (class_exists($classname)) {
132 $response = call_user_func(array(new $classname, $parts[1]));
133 }
134 } catch (Exception $e) {
135 $response = $e->getMessage();
136 }
137 }
138
139 return apply_filters(
140 'aam-ajax-filter',
141 $response,
142 AAM_Backend_Subject::getInstance()->get(),
143 $action
144 );
145 }
146
147 /**
148 * Render the Main Control Area
149 *
150 * @param string $type
151 *
152 * @return void
153 *
154 * @access public
155 */
156 public function renderContent($type = 'main') {
157 ob_start();
158 if ($type == 'extensions') {
159 AAM_Backend_Feature_Extension_Manager::getInstance()->render();
160 } else {
161 require_once(dirname(__FILE__) . '/phtml/main-panel.phtml');
162 }
163 $content = ob_get_contents();
164 ob_end_clean();
165
166 return $content;
167 }
168
169 /**
170 *
171 * @param type $partial
172 * @return type
173 */
174 public function loadPartial($partial) {
175 ob_start();
176 require_once(dirname(__FILE__) . '/phtml/partial/' . $partial);
177 $content = ob_get_contents();
178 ob_end_clean();
179
180 return $content;
181 }
182
183 /**
184 * Save AAM options
185 *
186 * Important notice! This function excepts "value" to be only boolean value
187 *
188 * @return string
189 *
190 * @access public
191 */
192 public function save() {
193 $object = trim(AAM_Core_Request::post('object'));
194 $objectId = intval(AAM_Core_Request::post('objectId', 0));
195
196 $param = AAM_Core_Request::post('param');
197 $value = AAM_Core_Request::post('value');
198
199 $result = AAM_Backend_Subject::getInstance()->save(
200 $param, $value, $object, $objectId
201 );
202
203 return json_encode(array('status' => ($result ? 'success' : 'failure')));
204 }
205
206 /**
207 *
208 * @return type
209 */
210 public function reset() {
211 return AAM_Backend_Subject::getInstance()->resetObject(
212 AAM_Core_Request::post('object')
213 );
214 }
215
216 /**
217 *
218 * @return type
219 */
220 public function switchToUser() {
221 $response = array(
222 'status' => 'failure',
223 'reason' => 'You are not allowed to switch to this user'
224 );
225
226 if (current_user_can('aam_switch_users')) {
227 $user = new WP_User(AAM_Core_Request::post('user'));
228 $max = AAM_Core_API::maxLevel(wp_get_current_user()->allcaps);
229
230 if ($max >= AAM_Core_API::maxLevel($user->allcaps)) {
231 AAM_Core_API::updateOption(
232 'aam-user-switch-' . $user->ID, get_current_user_id()
233 );
234
235 wp_clear_auth_cookie();
236 wp_set_auth_cookie( $user->ID, true );
237 wp_set_current_user( $user->ID );
238
239 $response = array('status' => 'success', 'redirect' => admin_url());
240 }
241 }
242
243 return json_encode($response);
244 }
245
246 /**
247 * Get instance of itself
248 *
249 * @return AAM_Backend_View
250 *
251 * @access public
252 */
253 public static function getInstance() {
254 if (is_null(self::$_instance)) {
255 self::$_instance = new self;
256 }
257
258 return self::$_instance;
259 }
260
261 }