Advanced Access Manager - Version 4.7

Version Description

  • Significantly improved the ability to manage access to AAM interface
  • Added new group of capabilities AAM Interface
  • Optimized Posts & Pages UI feature for extra large amount of records
  • BIGGEST DEAL! From now no more 10 posts limit. It is unlimited!
  • Fixed bug with custom HTML message for access denied redirect
  • Added option to redirect to login page and back after login when access is denied
  • Significantly improved media access control
  • Improved CSS to keep to suppress "bad behavior" from other plugins and themes
Download this release

Release Info

Developer vasyl_m
Plugin Icon 128x128 Advanced Access Manager
Version 4.7
Comparing to
See all releases

Code changes from version 4.6.2 to 4.7

Files changed (38) hide show
  1. Application/Backend/Feature.php +2 -2
  2. Application/Backend/Feature/404Redirect.php +7 -1
  3. Application/Backend/Feature/Abstract.php +3 -2
  4. Application/Backend/Feature/Capability.php +21 -6
  5. Application/Backend/Feature/Contact.php +7 -1
  6. Application/Backend/Feature/Extension.php +8 -1
  7. Application/Backend/Feature/LoginRedirect.php +7 -1
  8. Application/Backend/Feature/LogoutRedirect.php +7 -1
  9. Application/Backend/Feature/Menu.php +7 -1
  10. Application/Backend/Feature/Metabox.php +7 -1
  11. Application/Backend/Feature/Post.php +152 -76
  12. Application/Backend/Feature/Redirect.php +16 -2
  13. Application/Backend/Feature/Role.php +93 -69
  14. Application/Backend/Feature/Security.php +7 -1
  15. Application/Backend/Feature/Teaser.php +7 -1
  16. Application/Backend/Feature/User.php +44 -42
  17. Application/Backend/Feature/Utility.php +7 -1
  18. Application/Backend/Filter.php +3 -13
  19. Application/Backend/Manager.php +67 -35
  20. Application/Backend/View.php +47 -16
  21. Application/Backend/phtml/extension.phtml +1 -1
  22. Application/Backend/phtml/frame.phtml +16 -6
  23. Application/Backend/phtml/index.phtml +22 -6
  24. Application/Backend/phtml/main-panel.phtml +23 -17
  25. Application/Backend/phtml/object/login-redirect.phtml +2 -2
  26. Application/Backend/phtml/object/logout-redirect.phtml +2 -2
  27. Application/Backend/phtml/object/menu.phtml +7 -0
  28. Application/Backend/phtml/object/post.phtml +2 -2
  29. Application/Backend/phtml/object/redirect.phtml +8 -2
  30. Application/Backend/phtml/object/teaser.phtml +2 -2
  31. Application/Core/API.php +22 -1
  32. Application/Core/Media.php +57 -47
  33. Application/Frontend/Manager.php +24 -8
  34. Application/Shortcode/Strategy/Login.php +2 -3
  35. aam.php +7 -5
  36. media/css/aam.css +1 -1
  37. media/js/aam-interface.js +11 -11
  38. readme.txt +13 -3
Application/Backend/Feature.php CHANGED
@@ -33,7 +33,7 @@ class AAM_Backend_Feature {
33
  $response = false;
34
 
35
  if (empty($feature->capability)){
36
- $cap = AAM_Core_Config::get('page.capability', 'administrator');
37
  } else {
38
  $cap = $feature->capability;
39
  }
@@ -76,7 +76,7 @@ class AAM_Backend_Feature {
76
  */
77
  public static function retriveList() {
78
  $response = array();
79
-
80
  $subject = AAM_Backend_View::getSubject();
81
  foreach (self::$_features as $feature) {
82
  if (in_array(get_class($subject), $feature->subjects)) {
33
  $response = false;
34
 
35
  if (empty($feature->capability)){
36
+ $cap = AAM_Backend_View::getAAMCapability();
37
  } else {
38
  $cap = $feature->capability;
39
  }
76
  */
77
  public static function retriveList() {
78
  $response = array();
79
+
80
  $subject = AAM_Backend_View::getSubject();
81
  foreach (self::$_features as $feature) {
82
  if (in_array(get_class($subject), $feature->subjects)) {
Application/Backend/Feature/404Redirect.php CHANGED
@@ -54,7 +54,13 @@ class AAM_Backend_Feature_404Redirect extends AAM_Backend_Feature_Abstract {
54
  */
55
  public static function register() {
56
  if (is_main_site()) {
57
- $cap = AAM_Core_Config::get(self::getAccessOption(), 'administrator');
 
 
 
 
 
 
58
 
59
  AAM_Backend_Feature::registerFeature((object) array(
60
  'uid' => '404redirect',
54
  */
55
  public static function register() {
56
  if (is_main_site()) {
57
+ if (AAM_Core_API::capabilityExists('aam_manage_404_redirect')) {
58
+ $cap = 'aam_manage_404_redirect';
59
+ } else {
60
+ $cap = AAM_Core_Config::get(
61
+ self::getAccessOption(), AAM_Backend_View::getAAMCapability()
62
+ );
63
+ }
64
 
65
  AAM_Backend_Feature::registerFeature((object) array(
66
  'uid' => '404redirect',
Application/Backend/Feature/Abstract.php CHANGED
@@ -25,8 +25,9 @@ abstract class AAM_Backend_Feature_Abstract {
25
  */
26
  public function __construct() {
27
  if (is_admin()) {
28
- $cap = AAM_Core_Config::get($this->getAccessOption(), 'administrator');
29
- if (!AAM::getUser()->hasCapability($cap)) {
 
30
  wp_die(__('Access Denied', AAM_KEY));
31
  }
32
  }
25
  */
26
  public function __construct() {
27
  if (is_admin()) {
28
+ $capability = AAM_Backend_View::getAAMCapability();
29
+
30
+ if (!AAM::getUser()->hasCapability($capability)) {
31
  wp_die(__('Access Denied', AAM_KEY));
32
  }
33
  }
Application/Backend/Feature/Capability.php CHANGED
@@ -45,6 +45,15 @@ class AAM_Backend_Feature_Capability extends AAM_Backend_Feature_Abstract {
45
  'unfiltered_html', 'unfiltered_upload', 'update_themes',
46
  'update_core', 'upload_files', 'delete_plugins', 'remove_users',
47
  'switch_themes', 'list_users', 'promote_users', 'create_users'
 
 
 
 
 
 
 
 
 
48
  )
49
  );
50
 
@@ -70,12 +79,9 @@ class AAM_Backend_Feature_Capability extends AAM_Backend_Feature_Abstract {
70
  $updated = AAM_Core_Request::post('updated');
71
  $roles = AAM_Core_API::getRoles();
72
 
73
- //first make sure that similar capability does not exist already
74
- $allcaps = AAM_Core_API::getAllCapabilities();
75
-
76
- if (!isset($allcaps[$updated])) {
77
  foreach($roles->role_objects as $role) {
78
- //check if capability is present for current role! Please note, we
79
  //can not use the native WP_Role::has_cap function because it will
80
  //return false if capability exists but not checked
81
  if (isset($role->capabilities[$capability])) {
@@ -217,6 +223,7 @@ class AAM_Backend_Feature_Capability extends AAM_Backend_Feature_Abstract {
217
  __('System', AAM_KEY),
218
  __('Posts & Pages', AAM_KEY),
219
  __('Backend', AAM_KEY),
 
220
  __('Miscellaneous', AAM_KEY)
221
  ));
222
  }
@@ -259,6 +266,8 @@ class AAM_Backend_Feature_Capability extends AAM_Backend_Feature_Abstract {
259
  $response = __('Posts & Pages', AAM_KEY);
260
  } elseif (in_array($capability, $this->_groups['backend'])) {
261
  $response = __('Backend', AAM_KEY);
 
 
262
  } else {
263
  $response = __('Miscellaneous', AAM_KEY);
264
  }
@@ -276,7 +285,13 @@ class AAM_Backend_Feature_Capability extends AAM_Backend_Feature_Abstract {
276
  * @access public
277
  */
278
  public static function register() {
279
- $cap = AAM_Core_Config::get(self::getAccessOption(), 'administrator');
 
 
 
 
 
 
280
 
281
  AAM_Backend_Feature::registerFeature((object) array(
282
  'uid' => 'capability',
45
  'unfiltered_html', 'unfiltered_upload', 'update_themes',
46
  'update_core', 'upload_files', 'delete_plugins', 'remove_users',
47
  'switch_themes', 'list_users', 'promote_users', 'create_users'
48
+ ),
49
+ 'aam' => array(
50
+ 'aam_manage_admin_menu', 'aam_manage_metaboxes', 'aam_manage_capabilities',
51
+ 'aam_manage_posts', 'aam_manage_access_denied_redirect', 'aam_create_roles',
52
+ 'aam_manage_login_redirect', 'aam_manage_logout_redirect', 'aam_manager',
53
+ 'aam_manage_content_teaser', 'aam_manage_security', 'aam_manage_utilities',
54
+ 'aam_manage_extensions', 'aam_view_contact', 'aam_manage_404_redirect',
55
+ 'aam_manage_default', 'aam_manage_visitors', 'aam_list_roles',
56
+ 'aam_edit_roles', 'aam_delete_roles', 'aam_toggle_users', 'aam_switch_users'
57
  )
58
  );
59
 
79
  $updated = AAM_Core_Request::post('updated');
80
  $roles = AAM_Core_API::getRoles();
81
 
82
+ if (AAM_Core_API::capabilityExists($updated) === false) {
 
 
 
83
  foreach($roles->role_objects as $role) {
84
+ //check if capability is present for current role! Note, we
85
  //can not use the native WP_Role::has_cap function because it will
86
  //return false if capability exists but not checked
87
  if (isset($role->capabilities[$capability])) {
223
  __('System', AAM_KEY),
224
  __('Posts & Pages', AAM_KEY),
225
  __('Backend', AAM_KEY),
226
+ __('AAM Interface', AAM_KEY),
227
  __('Miscellaneous', AAM_KEY)
228
  ));
229
  }
266
  $response = __('Posts & Pages', AAM_KEY);
267
  } elseif (in_array($capability, $this->_groups['backend'])) {
268
  $response = __('Backend', AAM_KEY);
269
+ } elseif (in_array($capability, $this->_groups['aam'])) {
270
+ $response = __('AAM Interface', AAM_KEY);
271
  } else {
272
  $response = __('Miscellaneous', AAM_KEY);
273
  }
285
  * @access public
286
  */
287
  public static function register() {
288
+ if (AAM_Core_API::capabilityExists('aam_manage_capabilities')) {
289
+ $cap = 'aam_manage_capabilities';
290
+ } else {
291
+ $cap = AAM_Core_Config::get(
292
+ self::getAccessOption(), AAM_Backend_View::getAAMCapability()
293
+ );
294
+ }
295
 
296
  AAM_Backend_Feature::registerFeature((object) array(
297
  'uid' => 'capability',
Application/Backend/Feature/Contact.php CHANGED
@@ -37,7 +37,13 @@ class AAM_Backend_Feature_Contact extends AAM_Backend_Feature_Abstract {
37
  * @access public
38
  */
39
  public static function register() {
40
- $cap = AAM_Core_Config::get(self::getAccessOption(), 'administrator');
 
 
 
 
 
 
41
 
42
  AAM_Backend_Feature::registerFeature((object) array(
43
  'uid' => 'contact',
37
  * @access public
38
  */
39
  public static function register() {
40
+ if (AAM_Core_API::capabilityExists('aam_view_contact')) {
41
+ $cap = 'aam_view_contact';
42
+ } else {
43
+ $cap = AAM_Core_Config::get(
44
+ self::getAccessOption(), AAM_Backend_View::getAAMCapability()
45
+ );
46
+ }
47
 
48
  AAM_Backend_Feature::registerFeature((object) array(
49
  'uid' => 'contact',
Application/Backend/Feature/Extension.php CHANGED
@@ -149,7 +149,13 @@ class AAM_Backend_Feature_Extension extends AAM_Backend_Feature_Abstract {
149
  */
150
  public static function register() {
151
  if (is_main_site()) {
152
- $cap = AAM_Core_Config::get(self::getAccessOption(), 'administrator');
 
 
 
 
 
 
153
  $updated = self::hasUpdates();
154
 
155
  AAM_Backend_Feature::registerFeature((object) array(
@@ -162,6 +168,7 @@ class AAM_Backend_Feature_Extension extends AAM_Backend_Feature_Abstract {
162
  'AAM_Core_Subject_Role',
163
  'AAM_Core_Subject_User',
164
  'AAM_Core_Subject_Visitor',
 
165
  ),
166
  'view' => __CLASS__
167
  ));
149
  */
150
  public static function register() {
151
  if (is_main_site()) {
152
+ if (AAM_Core_API::capabilityExists('aam_manage_extensions')) {
153
+ $cap = 'aam_manage_extensions';
154
+ } else {
155
+ $cap = AAM_Core_Config::get(
156
+ self::getAccessOption(), AAM_Backend_View::getAAMCapability()
157
+ );
158
+ }
159
  $updated = self::hasUpdates();
160
 
161
  AAM_Backend_Feature::registerFeature((object) array(
168
  'AAM_Core_Subject_Role',
169
  'AAM_Core_Subject_User',
170
  'AAM_Core_Subject_Visitor',
171
+ 'AAM_Core_Subject_Default',
172
  ),
173
  'view' => __CLASS__
174
  ));
Application/Backend/Feature/LoginRedirect.php CHANGED
@@ -95,7 +95,13 @@ class AAM_Backend_Feature_LoginRedirect extends AAM_Backend_Feature_Abstract {
95
  * @access public
96
  */
97
  public static function register() {
98
- $cap = AAM_Core_Config::get(self::getAccessOption(), 'administrator');
 
 
 
 
 
 
99
 
100
  AAM_Backend_Feature::registerFeature((object) array(
101
  'uid' => 'login_redirect',
95
  * @access public
96
  */
97
  public static function register() {
98
+ if (AAM_Core_API::capabilityExists('aam_manage_login_redirect')) {
99
+ $cap = 'aam_manage_login_redirect';
100
+ } else {
101
+ $cap = AAM_Core_Config::get(
102
+ self::getAccessOption(), AAM_Backend_View::getAAMCapability()
103
+ );
104
+ }
105
 
106
  AAM_Backend_Feature::registerFeature((object) array(
107
  'uid' => 'login_redirect',
Application/Backend/Feature/LogoutRedirect.php CHANGED
@@ -96,7 +96,13 @@ class AAM_Backend_Feature_LogoutRedirect extends AAM_Backend_Feature_Abstract {
96
  * @access public
97
  */
98
  public static function register() {
99
- $cap = AAM_Core_Config::get(self::getAccessOption(), 'administrator');
 
 
 
 
 
 
100
 
101
  AAM_Backend_Feature::registerFeature((object) array(
102
  'uid' => 'logout_redirect',
96
  * @access public
97
  */
98
  public static function register() {
99
+ if (AAM_Core_API::capabilityExists('aam_manage_logout_redirect')) {
100
+ $cap = 'aam_manage_logout_redirect';
101
+ } else {
102
+ $cap = AAM_Core_Config::get(
103
+ self::getAccessOption(), AAM_Backend_View::getAAMCapability()
104
+ );
105
+ }
106
 
107
  AAM_Backend_Feature::registerFeature((object) array(
108
  'uid' => 'logout_redirect',
Application/Backend/Feature/Menu.php CHANGED
@@ -195,7 +195,13 @@ class AAM_Backend_Feature_Menu extends AAM_Backend_Feature_Abstract {
195
  * @access public
196
  */
197
  public static function register() {
198
- $cap = AAM_Core_Config::get(self::getAccessOption(), 'administrator');
 
 
 
 
 
 
199
 
200
  AAM_Backend_Feature::registerFeature((object) array(
201
  'uid' => 'admin_menu',
195
  * @access public
196
  */
197
  public static function register() {
198
+ if (AAM_Core_API::capabilityExists('aam_manage_admin_menu')) {
199
+ $cap = 'aam_manage_admin_menu';
200
+ } else {
201
+ $cap = AAM_Core_Config::get(
202
+ self::getAccessOption(), AAM_Backend_View::getAAMCapability()
203
+ );
204
+ }
205
 
206
  AAM_Backend_Feature::registerFeature((object) array(
207
  'uid' => 'admin_menu',
Application/Backend/Feature/Metabox.php CHANGED
@@ -231,7 +231,13 @@ class AAM_Backend_Feature_Metabox extends AAM_Backend_Feature_Abstract {
231
  * @access public
232
  */
233
  public static function register() {
234
- $cap = AAM_Core_Config::get(self::getAccessOption(), 'administrator');
 
 
 
 
 
 
235
 
236
  AAM_Backend_Feature::registerFeature((object) array(
237
  'uid' => 'metabox',
231
  * @access public
232
  */
233
  public static function register() {
234
+ if (AAM_Core_API::capabilityExists('aam_manage_metaboxes')) {
235
+ $cap = 'aam_manage_metaboxes';
236
+ } else {
237
+ $cap = AAM_Core_Config::get(
238
+ self::getAccessOption(), AAM_Backend_View::getAAMCapability()
239
+ );
240
+ }
241
 
242
  AAM_Backend_Feature::registerFeature((object) array(
243
  'uid' => 'metabox',
Application/Backend/Feature/Post.php CHANGED
@@ -138,64 +138,162 @@ class AAM_Backend_Feature_Post extends AAM_Backend_Feature_Abstract {
138
  * @return type
139
  */
140
  protected function prepareContentList($type) {
141
- $list = array();
142
- $filtered = array();
143
-
144
  //filters
145
  $s = AAM_Core_Request::post('search.value');
146
  $length = AAM_Core_Request::post('length');
147
  $start = AAM_Core_Request::post('start');
148
 
 
 
 
149
  //first retrieve all hierarchical terms that belong to Post Type
150
- foreach (get_object_taxonomies($type, 'objects') as $tax) {
151
- if (is_taxonomy_hierarchical($tax->name)) {
152
- //get all terms that have no parent category
153
- $list = array_merge($list, $this->retrieveTermList($tax->name, $s));
154
- }
155
  }
156
 
157
  //retrieve all posts
158
- $combined = array_merge(
159
- $list,
160
- get_posts(array(
161
- 'post_type' => $type, 'category' => 0, 's' => $s,
162
- 'numberposts' => -1, 'post_status' => 'any', 'fields' => 'ids'
163
- ))
 
 
 
 
164
  );
 
 
 
 
 
 
 
 
 
165
 
166
- foreach(array_slice($combined, $start, $length) as $row) {
167
- if (isset($row['taxonomy'])) { //this is term
168
- $filtered[] = get_term($row['id'], $row['taxonomy']);
169
- } else { //this is post
170
- $filtered[] = get_post($row);
171
  }
172
  }
173
 
174
- return (object) array(
175
- 'total' => count($list),
176
- 'filtered' => count($combined),
177
- 'records' => $filtered
178
- );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
179
  }
180
 
181
  /**
182
  * Retrieve term list
183
  *
184
- * @param string $taxonomy
185
  *
186
  * @return array
187
  *
188
  * @access protected
189
  */
190
- protected function retrieveTermList($taxonomy, $s = null) {
191
- $response = array();
192
- $args = array('fields' => 'ids', 'hide_empty' => false, 'search' => $s);
193
-
194
- foreach (get_terms($taxonomy, $args) as $term) {
195
- $response[] = array('taxonomy' => $taxonomy, 'id' => $term);
196
- }
 
 
197
 
198
- return $response;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
199
  }
200
 
201
  /**
@@ -245,31 +343,25 @@ class AAM_Backend_Feature_Post extends AAM_Backend_Feature_Abstract {
245
  * @access public
246
  */
247
  public function save() {
248
- if ($this->checkLimit()) {
249
- $subject = AAM_Backend_View::getSubject();
250
-
251
- $object = trim(AAM_Core_Request::post('object'));
252
- $id = AAM_Core_Request::post('objectId', null);
253
 
254
- $param = AAM_Core_Request::post('param');
255
- $value = AAM_Core_Request::post('value');
256
-
257
- if (strpos($param, 'frontend.expire_datetime') !== false) {
258
- $value = date('F jS g:i:s a', strtotime($value));
259
- }
260
-
261
- //clear cache
262
- AAM_Core_Cache::clear();
263
-
264
- $result = $subject->save($param, $value, $object, $id);
265
- } else {
266
- $result = false;
267
- $error = __('You reached your limitation.', AAM_KEY);
268
  }
269
 
 
 
 
 
 
270
  return json_encode(array(
271
  'status' => ($result ? 'success' : 'failure'),
272
- 'error' => (empty($error) ? '' : $error),
273
  'value' => $value
274
  ));
275
  }
@@ -297,28 +389,6 @@ class AAM_Backend_Feature_Post extends AAM_Backend_Feature_Abstract {
297
  return json_encode(array('status' => ($result ? 'success' : 'failure')));
298
  }
299
 
300
- /**
301
- *
302
- * @global type $wpdb
303
- * @return type
304
- */
305
- public static function checkLimit() {
306
- global $wpdb;
307
-
308
- $limit = apply_filters('aam-post-limit', 0);
309
-
310
- if ($limit != -1) {
311
- //count number of posts that have access saved
312
- $query = "SELECT COUNT(*) as `total` FROM {$wpdb->postmeta} "
313
- . "WHERE meta_key LIKE %s";
314
-
315
- $row = $wpdb->get_row($wpdb->prepare($query, 'aam_post_access_%'));
316
- $limit = ($row->total < 10 ? -1 : 0);
317
- }
318
-
319
- return ($limit == -1);
320
- }
321
-
322
  /**
323
  * @inheritdoc
324
  */
@@ -379,7 +449,13 @@ class AAM_Backend_Feature_Post extends AAM_Backend_Feature_Abstract {
379
  * @access public
380
  */
381
  public static function register() {
382
- $cap = AAM_Core_Config::get(self::getAccessOption(), 'administrator');
 
 
 
 
 
 
383
 
384
  AAM_Backend_Feature::registerFeature((object) array(
385
  'uid' => 'post',
138
  * @return type
139
  */
140
  protected function prepareContentList($type) {
141
+ $list = array();
 
 
142
  //filters
143
  $s = AAM_Core_Request::post('search.value');
144
  $length = AAM_Core_Request::post('length');
145
  $start = AAM_Core_Request::post('start');
146
 
147
+ //calculate how many term and/or posts we need to fetch
148
+ $paging = $this->getFetchPagination($type, $s, $start, $length);
149
+
150
  //first retrieve all hierarchical terms that belong to Post Type
151
+ if ($paging['terms']) {
152
+ $list = $this->retrieveTermList(
153
+ $this->getTypeTaxonomies($type), $s, $paging['term_offset'], $paging['terms']
154
+ );
 
155
  }
156
 
157
  //retrieve all posts
158
+ if ($paging['posts']) {
159
+ $list = array_merge(
160
+ $list, $this->retrievePostList($type, $s, $paging['post_offset'], $paging['posts'])
161
+ );
162
+ }
163
+
164
+ return (object) array(
165
+ 'total' => $paging['total'],
166
+ 'filtered' => $paging['total'],
167
+ 'records' => $list
168
  );
169
+ }
170
+
171
+ /**
172
+ *
173
+ * @param type $type
174
+ * @return type
175
+ */
176
+ protected function getTypeTaxonomies($type) {
177
+ $list = array();
178
 
179
+ foreach (get_object_taxonomies($type) as $name) {
180
+ if (is_taxonomy_hierarchical($name)) {
181
+ //get all terms that have no parent category
182
+ $list[] = $name;
 
183
  }
184
  }
185
 
186
+ return $list;
187
+ }
188
+
189
+ /**
190
+ *
191
+ * @param type $type
192
+ * @param type $search
193
+ * @param type $offset
194
+ * @param type $limit
195
+ * @return type
196
+ */
197
+ protected function getFetchPagination($type, $search, $offset, $limit) {
198
+ $result = array('terms' => 0, 'posts' => 0, 'term_offset' => $offset);
199
+
200
+ //get terms count
201
+ $taxonomy = $this->getTypeTaxonomies($type);
202
+
203
+ if (!empty($taxonomy)) {
204
+ $terms = get_terms(array(
205
+ 'fields' => 'count',
206
+ 'search' => $search,
207
+ 'hide_empty' => false,
208
+ 'taxonomy' => $taxonomy
209
+ ));
210
+ } else {
211
+ $terms = 0;
212
+ }
213
+
214
+ //get posts count
215
+ $posts = $this->getPostCount($type, $search);
216
+
217
+ if ($offset < $terms) {
218
+ if ($terms - $limit >= $offset) {
219
+ $result['terms'] = $limit;
220
+ } else {
221
+ $result['terms'] = $terms - $offset;
222
+ $result['posts'] = $limit - $result['terms'];
223
+ }
224
+ } else {
225
+ $result['posts'] = $limit;
226
+ }
227
+
228
+ $result['total'] = $terms + $posts;
229
+ $result['post_offset'] = $offset - $terms;
230
+
231
+ return $result;
232
+ }
233
+
234
+ /**
235
+ *
236
+ * @global type $wpdb
237
+ * @param type $type
238
+ * @param type $search
239
+ * @return type
240
+ */
241
+ protected function getPostCount($type, $search) {
242
+ global $wpdb;
243
+
244
+ $query = "SELECT COUNT( * ) AS total FROM {$wpdb->posts} ";
245
+ $query .= "WHERE (post_type = %s) AND (post_title LIKE %s)";
246
+
247
+ $args = array($type, "{$search}%");
248
+
249
+ foreach (get_post_stati(array( 'exclude_from_search' => true)) as $status ) {
250
+ $query .= " AND ({$wpdb->posts}.post_status <> %s)";
251
+ $args[] = $status;
252
+ }
253
+
254
+ return $wpdb->get_var($wpdb->prepare($query, $args));
255
  }
256
 
257
  /**
258
  * Retrieve term list
259
  *
260
+ * @param array $taxonomies
261
  *
262
  * @return array
263
  *
264
  * @access protected
265
  */
266
+ protected function retrieveTermList($taxonomies, $search, $offset, $limit) {
267
+ $args = array(
268
+ 'fields' => 'all',
269
+ 'hide_empty' => false,
270
+ 'search' => $search,
271
+ 'taxonomy' => $taxonomies,
272
+ 'offset' => $offset,
273
+ 'number' => $limit
274
+ );
275
 
276
+ return get_terms($args);
277
+ }
278
+
279
+ /**
280
+ *
281
+ * @param type $type
282
+ * @param type $search
283
+ * @param type $offset
284
+ * @param type $limit
285
+ * @return type
286
+ */
287
+ protected function retrievePostList($type, $search, $offset, $limit) {
288
+ return get_posts(array(
289
+ 'post_type' => $type,
290
+ 'category' => 0,
291
+ 's' => $search,
292
+ 'offset' => $offset,
293
+ 'numberposts' => $limit,
294
+ 'post_status' => 'any',
295
+ 'fields' => 'all'
296
+ ));
297
  }
298
 
299
  /**
343
  * @access public
344
  */
345
  public function save() {
346
+ $subject = AAM_Backend_View::getSubject();
 
 
 
 
347
 
348
+ $object = trim(AAM_Core_Request::post('object'));
349
+ $id = AAM_Core_Request::post('objectId', null);
350
+
351
+ $param = AAM_Core_Request::post('param');
352
+ $value = AAM_Core_Request::post('value');
353
+
354
+ if (strpos($param, 'frontend.expire_datetime') !== false) {
355
+ $value = date('F jS g:i:s a', strtotime($value));
 
 
 
 
 
 
356
  }
357
 
358
+ //clear cache
359
+ AAM_Core_Cache::clear();
360
+
361
+ $result = $subject->save($param, $value, $object, $id);
362
+
363
  return json_encode(array(
364
  'status' => ($result ? 'success' : 'failure'),
 
365
  'value' => $value
366
  ));
367
  }
389
  return json_encode(array('status' => ($result ? 'success' : 'failure')));
390
  }
391
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
392
  /**
393
  * @inheritdoc
394
  */
449
  * @access public
450
  */
451
  public static function register() {
452
+ if (AAM_Core_API::capabilityExists('aam_manage_posts')) {
453
+ $cap = 'aam_manage_posts';
454
+ } else {
455
+ $cap = AAM_Core_Config::get(
456
+ self::getAccessOption(), AAM_Backend_View::getAAMCapability()
457
+ );
458
+ }
459
 
460
  AAM_Backend_Feature::registerFeature((object) array(
461
  'uid' => 'post',
Application/Backend/Feature/Redirect.php CHANGED
@@ -20,7 +20,7 @@ class AAM_Backend_Feature_Redirect extends AAM_Backend_Feature_Abstract {
20
  */
21
  public function save() {
22
  $param = AAM_Core_Request::post('param');
23
- $value = AAM_Core_Request::post('value');
24
 
25
  AAM_Backend_View::getSubject()->getObject('redirect')->save($param, $value);
26
 
@@ -46,6 +46,14 @@ class AAM_Backend_Feature_Redirect extends AAM_Backend_Feature_Abstract {
46
  return AAM_Backend_View::getSubject()->getUID() == 'default';
47
  }
48
 
 
 
 
 
 
 
 
 
49
  /**
50
  * Check inheritance status
51
  *
@@ -95,7 +103,13 @@ class AAM_Backend_Feature_Redirect extends AAM_Backend_Feature_Abstract {
95
  * @access public
96
  */
97
  public static function register() {
98
- $cap = AAM_Core_Config::get(self::getAccessOption(), 'administrator');
 
 
 
 
 
 
99
 
100
  AAM_Backend_Feature::registerFeature((object) array(
101
  'uid' => 'redirect',
20
  */
21
  public function save() {
22
  $param = AAM_Core_Request::post('param');
23
+ $value = stripslashes(AAM_Core_Request::post('value'));
24
 
25
  AAM_Backend_View::getSubject()->getObject('redirect')->save($param, $value);
26
 
46
  return AAM_Backend_View::getSubject()->getUID() == 'default';
47
  }
48
 
49
+ /**
50
+ *
51
+ * @return type
52
+ */
53
+ public function isVisitor() {
54
+ return AAM_Backend_View::getSubject()->getUID() == 'visitor';
55
+ }
56
+
57
  /**
58
  * Check inheritance status
59
  *
103
  * @access public
104
  */
105
  public static function register() {
106
+ if (AAM_Core_API::capabilityExists('aam_manage_access_denied_redirect')) {
107
+ $cap = 'aam_manage_access_denied_redirect';
108
+ } else {
109
+ $cap = AAM_Core_Config::get(
110
+ self::getAccessOption(), AAM_Backend_View::getAAMCapability()
111
+ );
112
+ }
113
 
114
  AAM_Backend_Feature::registerFeature((object) array(
115
  'uid' => 'redirect',
Application/Backend/Feature/Role.php CHANGED
@@ -15,21 +15,6 @@
15
  */
16
  class AAM_Backend_Feature_Role {
17
 
18
- /**
19
- * Constructor
20
- *
21
- * @return void
22
- *
23
- * @access public
24
- * @throws Exception
25
- */
26
- public function __construct() {
27
- $cap = AAM_Core_Config::get('page.capability', 'administrator');
28
- if (!AAM::getUser()->hasCapability($cap)) {
29
- Throw new Exception(__('Access Denied', AAM_KEY));
30
- }
31
- }
32
-
33
  /**
34
  * Get role list
35
  *
@@ -40,39 +25,68 @@ class AAM_Backend_Feature_Role {
40
  * @access public
41
  */
42
  public function getTable() {
43
- //retrieve list of users
44
- $count = count_users();
45
- $stats = $count['avail_roles'];
 
46
 
47
- $filtered = $this->fetchRoleList();
48
 
49
- $response = array(
50
- 'recordsTotal' => count(get_editable_roles()),
51
- 'recordsFiltered' => count($filtered),
52
- 'draw' => AAM_Core_Request::request('draw'),
53
- 'data' => array(),
54
- );
55
-
56
- foreach ($filtered as $id => $data) {
57
- $uc = (isset($stats[$id]) ? $stats[$id] : 0);
58
- $allow = current_user_can('delete_users');
59
-
60
- $response['data'][] = array(
61
- $id,
62
- $uc,
63
- translate_user_role($data['name']),
64
- apply_filters(
65
- 'aam-role-row-actions-filter',
66
- 'manage,edit,clone' . ($uc || !$allow ? '' : ',delete'),
67
- $data
68
- ),
69
- AAM_Core_API::maxLevel($data['capabilities'])
 
 
 
 
 
 
 
70
  );
71
  }
72
 
73
  return json_encode(apply_filters('aam-get-role-list-filter', $response));
74
  }
75
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
76
  /**
77
  * Retrieve Pure Role List
78
  *
@@ -117,29 +131,31 @@ class AAM_Backend_Feature_Role {
117
  * @access public
118
  */
119
  public function add() {
120
- $name = sanitize_text_field(filter_input(INPUT_POST, 'name'));
121
- $roles = AAM_Core_API::getRoles();
122
- $role_id = strtolower($name);
123
 
124
- //if inherited role is set get capabilities from it
125
- $parent = $roles->get_role(trim(filter_input(INPUT_POST, 'inherit')));
126
- $caps = ($parent ? $parent->capabilities : array());
 
127
 
128
- if ($role = $roles->add_role($role_id, $name, $caps)) {
129
- $response = array(
130
- 'status' => 'success',
131
- 'role' => array(
132
- 'id' => $role_id,
133
- 'name' => $name,
134
- 'level' => AAM_Core_API::maxLevel($caps)
135
- )
136
- );
137
- if (AAM_Core_Request::post('clone')) {
138
- $this->cloneSettings($role, $parent);
 
 
 
 
 
 
139
  }
140
- do_action('aam-post-add-role-action', $role, $parent);
141
- } else {
142
- $response = array('status' => 'failure');
143
  }
144
 
145
  return json_encode($response);
@@ -186,12 +202,18 @@ class AAM_Backend_Feature_Role {
186
  * @access public
187
  */
188
  public function edit() {
189
- $role = AAM_Backend_View::getSubject();
190
- $role->update(trim(filter_input(INPUT_POST, 'name')));
191
-
192
- do_action('aam-post-update-role-action', $role);
 
 
 
 
 
 
193
 
194
- return json_encode(array('status' => 'success'));
195
  }
196
 
197
  /**
@@ -202,10 +224,12 @@ class AAM_Backend_Feature_Role {
202
  * @access public
203
  */
204
  public function delete() {
205
- if (AAM_Backend_View::getSubject()->delete()) {
206
- $status = 'success';
207
- } else {
208
- $status = 'failure';
 
 
209
  }
210
 
211
  return json_encode(array('status' => $status));
15
  */
16
  class AAM_Backend_Feature_Role {
17
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18
  /**
19
  * Get role list
20
  *
25
  * @access public
26
  */
27
  public function getTable() {
28
+ if (AAM_Backend_View::userCan('aam_list_roles')) {
29
+ //retrieve list of users
30
+ $count = count_users();
31
+ $stats = $count['avail_roles'];
32
 
33
+ $filtered = $this->fetchRoleList();
34
 
35
+ $response = array(
36
+ 'recordsTotal' => count(get_editable_roles()),
37
+ 'recordsFiltered' => count($filtered),
38
+ 'draw' => AAM_Core_Request::request('draw'),
39
+ 'data' => array(),
40
+ );
41
+
42
+ foreach ($filtered as $id => $data) {
43
+ $uc = (isset($stats[$id]) ? $stats[$id] : 0);
44
+
45
+ $response['data'][] = array(
46
+ $id,
47
+ $uc,
48
+ translate_user_role($data['name']),
49
+ apply_filters(
50
+ 'aam-role-row-actions-filter',
51
+ implode(',', $this->prepareRowActions($uc)),
52
+ $data
53
+ ),
54
+ AAM_Core_API::maxLevel($data['capabilities'])
55
+ );
56
+ }
57
+ } else {
58
+ $response = array(
59
+ 'recordsTotal' => 0,
60
+ 'recordsFiltered' => 0,
61
+ 'draw' => AAM_Core_Request::request('draw'),
62
+ 'data' => array(),
63
  );
64
  }
65
 
66
  return json_encode(apply_filters('aam-get-role-list-filter', $response));
67
  }
68
 
69
+ /**
70
+ *
71
+ * @param type $count
72
+ * @return string
73
+ */
74
+ protected function prepareRowActions($count) {
75
+ $actions = array('manage');
76
+
77
+ if (AAM_Backend_View::userCan('aam_edit_roles')) {
78
+ $actions[] = 'edit';
79
+ }
80
+ if (AAM_Backend_View::userCan('aam_create_roles')) {
81
+ $actions[] = 'clone';
82
+ }
83
+ if (AAM_Backend_View::userCan('aam_delete_roles') && !$count) {
84
+ $actions[] = 'delete';
85
+ }
86
+
87
+ return $actions;
88
+ }
89
+
90
  /**
91
  * Retrieve Pure Role List
92
  *
131
  * @access public
132
  */
133
  public function add() {
134
+ $response = array('status' => 'failure');
 
 
135
 
136
+ if (AAM_Backend_View::userCan('aam_create_roles')) {
137
+ $name = sanitize_text_field(filter_input(INPUT_POST, 'name'));
138
+ $roles = AAM_Core_API::getRoles();
139
+ $role_id = strtolower($name);
140
 
141
+ //if inherited role is set get capabilities from it
142
+ $parent = $roles->get_role(trim(filter_input(INPUT_POST, 'inherit')));
143
+ $caps = ($parent ? $parent->capabilities : array());
144
+
145
+ if ($role = $roles->add_role($role_id, $name, $caps)) {
146
+ $response = array(
147
+ 'status' => 'success',
148
+ 'role' => array(
149
+ 'id' => $role_id,
150
+ 'name' => $name,
151
+ 'level' => AAM_Core_API::maxLevel($caps)
152
+ )
153
+ );
154
+ if (AAM_Core_Request::post('clone')) {
155
+ $this->cloneSettings($role, $parent);
156
+ }
157
+ do_action('aam-post-add-role-action', $role, $parent);
158
  }
 
 
 
159
  }
160
 
161
  return json_encode($response);
202
  * @access public
203
  */
204
  public function edit() {
205
+ if (AAM_Backend_View::userCan('aam_edit_roles')) {
206
+ $role = AAM_Backend_View::getSubject();
207
+ $role->update(trim(filter_input(INPUT_POST, 'name')));
208
+
209
+ do_action('aam-post-update-role-action', $role);
210
+
211
+ $response = array('status' => 'success');
212
+ } else {
213
+ $response = array('status' => 'failure');
214
+ }
215
 
216
+ return json_encode($response);
217
  }
218
 
219
  /**
224
  * @access public
225
  */
226
  public function delete() {
227
+ $status = 'failure';
228
+
229
+ if (AAM_Backend_View::userCan('aam_delete_roles')) {
230
+ if (AAM_Backend_View::getSubject()->delete()) {
231
+ $status = 'success';
232
+ }
233
  }
234
 
235
  return json_encode(array('status' => $status));
Application/Backend/Feature/Security.php CHANGED
@@ -65,7 +65,13 @@ class AAM_Backend_Feature_Security extends AAM_Backend_Feature_Abstract {
65
  */
66
  public static function register() {
67
  if (is_main_site()) {
68
- $cap = AAM_Core_Config::get(self::getAccessOption(), 'administrator');
 
 
 
 
 
 
69
 
70
  AAM_Backend_Feature::registerFeature((object) array(
71
  'uid' => 'security',
65
  */
66
  public static function register() {
67
  if (is_main_site()) {
68
+ if (AAM_Core_API::capabilityExists('aam_manage_security')) {
69
+ $cap = 'aam_manage_security';
70
+ } else {
71
+ $cap = AAM_Core_Config::get(
72
+ self::getAccessOption(), AAM_Backend_View::getAAMCapability()
73
+ );
74
+ }
75
 
76
  AAM_Backend_Feature::registerFeature((object) array(
77
  'uid' => 'security',
Application/Backend/Feature/Teaser.php CHANGED
@@ -95,7 +95,13 @@ class AAM_Backend_Feature_Teaser extends AAM_Backend_Feature_Abstract {
95
  * @access public
96
  */
97
  public static function register() {
98
- $cap = AAM_Core_Config::get(self::getAccessOption(), 'administrator');
 
 
 
 
 
 
99
 
100
  AAM_Backend_Feature::registerFeature((object) array(
101
  'uid' => 'teaser',
95
  * @access public
96
  */
97
  public static function register() {
98
+ if (AAM_Core_API::capabilityExists('aam_manage_content_teaser')) {
99
+ $cap = 'aam_manage_content_teaser';
100
+ } else {
101
+ $cap = AAM_Core_Config::get(
102
+ self::getAccessOption(), AAM_Backend_View::getAAMCapability()
103
+ );
104
+ }
105
 
106
  AAM_Backend_Feature::registerFeature((object) array(
107
  'uid' => 'teaser',
Application/Backend/Feature/User.php CHANGED
@@ -15,21 +15,6 @@
15
  */
16
  class AAM_Backend_Feature_User {
17
 
18
- /**
19
- * Constructor
20
- *
21
- * @return void
22
- *
23
- * @access public
24
- * @throws Exception
25
- */
26
- public function __construct() {
27
- $cap = AAM_Core_Config::get('page.capability', 'administrator');
28
- if (!AAM::getUser()->hasCapability($cap)) {
29
- Throw new Exception(__('Access Denied', AAM_KEY));
30
- }
31
- }
32
-
33
  /**
34
  * Retrieve list of users
35
  *
@@ -40,24 +25,33 @@ class AAM_Backend_Feature_User {
40
  * @access public
41
  */
42
  public function getTable() {
43
- //get total number of users
44
- $total = count_users();
45
- $result = $this->query();
46
-
47
- $response = array(
48
- 'recordsTotal' => $total['total_users'],
49
- 'recordsFiltered' => $result->get_total(),
50
- 'draw' => AAM_Core_Request::request('draw'),
51
- 'data' => array(),
52
- );
53
-
54
- foreach ($result->get_results() as $user) {
55
- $response['data'][] = array(
56
- $user->ID,
57
- implode(', ', $this->getUserRoles($user->roles)),
58
- ($user->display_name ? $user->display_name : $user->user_nicename),
59
- implode(',', $this->prepareRowActions($user)),
60
- AAM_Core_API::maxLevel($user->allcaps)
 
 
 
 
 
 
 
 
 
61
  );
62
  }
63
 
@@ -106,9 +100,15 @@ class AAM_Backend_Feature_User {
106
  if ($allowed || ($user->ID == get_current_user_id())) {
107
  $actions = array('manage');
108
 
109
- $actions[] = ($user->user_status ? 'unlock' : 'lock');
110
- $actions[] = 'edit';
111
- $actions[] = 'switch';
 
 
 
 
 
 
112
  } else {
113
  $actions = array();
114
  }
@@ -152,13 +152,15 @@ class AAM_Backend_Feature_User {
152
  * @access public
153
  */
154
  public function block() {
155
- $subject = AAM_Backend_View::getSubject();
 
 
 
156
 
157
- //user is not allowed to lock himself
158
- if ($subject->getId() != get_current_user_id()) {
159
- $result = $subject->block();
160
- } else {
161
- $result = false;
162
  }
163
 
164
  return json_encode(
15
  */
16
  class AAM_Backend_Feature_User {
17
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18
  /**
19
  * Retrieve list of users
20
  *
25
  * @access public
26
  */
27
  public function getTable() {
28
+ if (AAM_Backend_View::userCan('list_users')) {
29
+ //get total number of users
30
+ $total = count_users();
31
+ $result = $this->query();
32
+
33
+ $response = array(
34
+ 'recordsTotal' => $total['total_users'],
35
+ 'recordsFiltered' => $result->get_total(),
36
+ 'draw' => AAM_Core_Request::request('draw'),
37
+ 'data' => array(),
38
+ );
39
+
40
+ foreach ($result->get_results() as $user) {
41
+ $response['data'][] = array(
42
+ $user->ID,
43
+ implode(', ', $this->getUserRoles($user->roles)),
44
+ ($user->display_name ? $user->display_name : $user->user_nicename),
45
+ implode(',', $this->prepareRowActions($user)),
46
+ AAM_Core_API::maxLevel($user->allcaps)
47
+ );
48
+ }
49
+ } else {
50
+ $response = array(
51
+ 'recordsTotal' => 0,
52
+ 'recordsFiltered' => 0,
53
+ 'draw' => AAM_Core_Request::request('draw'),
54
+ 'data' => array(),
55
  );
56
  }
57
 
100
  if ($allowed || ($user->ID == get_current_user_id())) {
101
  $actions = array('manage');
102
 
103
+ if (AAM_Backend_View::userCan('aam_toggle_users')) {
104
+ $actions[] = ($user->user_status ? 'unlock' : 'lock');
105
+ }
106
+ if (AAM_Backend_View::userCan('edit_users')) {
107
+ $actions[] = 'edit';
108
+ }
109
+ if (AAM_Backend_View::userCan('aam_switch_users')) {
110
+ $actions[] = 'switch';
111
+ }
112
  } else {
113
  $actions = array();
114
  }
152
  * @access public
153
  */
154
  public function block() {
155
+ $result = false;
156
+
157
+ if (AAM_Backend_View::userCan('aam_toggle_users')) {
158
+ $subject = AAM_Backend_View::getSubject();
159
 
160
+ //user is not allowed to lock himself
161
+ if ($subject->getId() != get_current_user_id()) {
162
+ $result = $subject->block();
163
+ }
 
164
  }
165
 
166
  return json_encode(
Application/Backend/Feature/Utility.php CHANGED
@@ -106,7 +106,13 @@ class AAM_Backend_Feature_Utility extends AAM_Backend_Feature_Abstract {
106
  */
107
  public static function register() {
108
  if (is_main_site()) {
109
- $cap = AAM_Core_Config::get(self::getAccessOption(), 'administrator');
 
 
 
 
 
 
110
 
111
  AAM_Backend_Feature::registerFeature((object) array(
112
  'uid' => 'utilities',
106
  */
107
  public static function register() {
108
  if (is_main_site()) {
109
+ if (AAM_Core_API::capabilityExists('aam_manage_utilities')) {
110
+ $cap = 'aam_manage_utilities';
111
+ } else {
112
+ $cap = AAM_Core_Config::get(
113
+ self::getAccessOption(), AAM_Backend_View::getAAMCapability()
114
+ );
115
+ }
116
 
117
  AAM_Backend_Feature::registerFeature((object) array(
118
  'uid' => 'utilities',
Application/Backend/Filter.php CHANGED
@@ -164,7 +164,7 @@ class AAM_Backend_Filter {
164
  );
165
  }
166
  }
167
-
168
  /**
169
  * Filter the Admin Menu
170
  *
@@ -474,12 +474,7 @@ class AAM_Backend_Filter {
474
  * @return type
475
  */
476
  public function screenOptions($flag) {
477
- //IMPORTANT!! Do not use AAM::getUser()->hasCapability because
478
- //show_screen_options is custom capability and it may not be present for new
479
- //website
480
- $caps = AAM_Core_API::getAllCapabilities();
481
-
482
- if (isset($caps['show_screen_options'])) {
483
  $flag = AAM::getUser()->hasCapability('show_screen_options');
484
  }
485
 
@@ -494,12 +489,7 @@ class AAM_Backend_Filter {
494
  * @return array
495
  */
496
  public function helpOptions($help, $id, $screen) {
497
- //IMPORTANT!! Do not use AAM::getUser()->hasCapability because
498
- //show_screen_options is custom capability and it may not be present for new
499
- //website
500
- $caps = AAM_Core_API::getAllCapabilities();
501
-
502
- if (isset($caps['show_help_tabs'])) {
503
  if (!AAM::getUser()->hasCapability('show_help_tabs')) {
504
  $screen->remove_help_tabs();
505
  $help = array();
164
  );
165
  }
166
  }
167
+
168
  /**
169
  * Filter the Admin Menu
170
  *
474
  * @return type
475
  */
476
  public function screenOptions($flag) {
477
+ if (AAM_Core_API::capabilityExists('show_screen_options')) {
 
 
 
 
 
478
  $flag = AAM::getUser()->hasCapability('show_screen_options');
479
  }
480
 
489
  * @return array
490
  */
491
  public function helpOptions($help, $id, $screen) {
492
+ if (AAM_Core_API::capabilityExists('show_help_tabs')) {
 
 
 
 
 
493
  if (!AAM::getUser()->hasCapability('show_help_tabs')) {
494
  $screen->remove_help_tabs();
495
  $help = array();
Application/Backend/Manager.php CHANGED
@@ -102,9 +102,15 @@ class AAM_Backend_Manager {
102
  */
103
  public function adminInit() {
104
  $user = AAM::getUser();
105
- $cap = AAM_Core_Config::get(
106
- AAM_Backend_Feature_Post::getAccessOption(), 'administrator'
107
- );
 
 
 
 
 
 
108
 
109
  if (AAM_Core_Request::get('aamframe') && $user->hasCapability($cap)) {
110
  echo AAM_Backend_View::getInstance()->renderAccessFrame();
@@ -135,9 +141,9 @@ class AAM_Backend_Manager {
135
  *
136
  */
137
  protected function checkUserAccess() {
138
- $all = AAM_Core_API::getAllCapabilities();
139
 
140
- if (isset($all['access_dashboard']) && get_current_user_id()) {
141
  if (empty(AAM::getUser()->allcaps['access_dashboard'])) {
142
  AAM_Core_API::reject('backend', array('hook' => 'access_dashboard'));
143
  }
@@ -195,9 +201,14 @@ class AAM_Backend_Manager {
195
  *
196
  */
197
  public function metabox() {
198
- $cap = AAM_Core_Config::get(
199
- AAM_Backend_Feature_Post::getAccessOption(), 'administrator'
200
- );
 
 
 
 
 
201
 
202
  if (AAM::getUser()->hasCapability($cap)) {
203
  add_meta_box(
@@ -229,8 +240,14 @@ class AAM_Backend_Manager {
229
  */
230
  public function renderTermMetabox($term) {
231
  if (is_a($term, 'WP_Term') && is_taxonomy_hierarchical($term->taxonomy)) {
232
- $option = AAM_Backend_Feature_Post::getAccessOption();
233
- $cap = AAM_Core_Config::get($option, 'administrator');
 
 
 
 
 
 
234
 
235
  if (AAM::getUser()->hasCapability($cap)) {
236
  echo AAM_Backend_View::getInstance()->renderTermMetabox($term);
@@ -285,9 +302,7 @@ class AAM_Backend_Manager {
285
  * @return string
286
  */
287
  public function postRowActions($actions, $post) {
288
- $cap = AAM_Core_Config::get('page.capability', 'administrator');
289
-
290
- if (AAM::getUser()->hasCapability($cap)) {
291
  $url = admin_url('admin.php?page=aam&oid=' . $post->ID . '&otype=post#post');
292
 
293
  $actions['aam'] = '<a href="' . $url . '" target="_blank">';
@@ -304,9 +319,7 @@ class AAM_Backend_Manager {
304
  * @return string
305
  */
306
  public function tagRowActions($actions, $term) {
307
- $cap = AAM_Core_Config::get('page.capability', 'administrator');
308
-
309
- if (AAM::getUser()->hasCapability($cap)) {
310
  $oid = $term->term_id . '|' . $term->taxonomy;
311
  $url = admin_url('admin.php?page=aam&oid=' . $oid . '&otype=term#post');
312
 
@@ -330,9 +343,7 @@ class AAM_Backend_Manager {
330
  * @access public
331
  */
332
  public function userActions($actions, $user) {
333
- $cap = AAM_Core_Config::get('page.capability', 'administrator');
334
-
335
- if (current_user_can($cap, $user->ID)) {
336
  $url = admin_url('admin.php?page=aam&user=' . $user->ID);
337
 
338
  $actions['aam'] = '<a href="' . $url . '" target="_blank">';
@@ -380,15 +391,19 @@ class AAM_Backend_Manager {
380
  'editUser' => admin_url('user-edit.php'),
381
  'addUser' => admin_url('user-new.php')
382
  ),
383
- 'level' => AAM_Core_API::maxLevel(wp_get_current_user()->allcaps),
384
- 'subject' => array(
385
- 'type' => $subject->type,
386
- 'id' => $subject->id,
387
- 'name' => $subject->name,
388
  'level' => $subject->level,
389
- 'blog' => get_current_blog_id()
390
  ),
391
- 'translation' => require (dirname(__FILE__) . '/View/Localization.php')
 
 
 
 
392
  );
393
 
394
  if (AAM_Core_Request::get('aamframe')) {
@@ -407,7 +422,7 @@ class AAM_Backend_Manager {
407
  */
408
  protected function getCurrentSubject() {
409
  $userId = AAM_Core_Request::get('user');
410
- if ($userId) {
411
  $u = get_user_by('id', $userId);
412
  $subject = array(
413
  'type' => 'user',
@@ -415,7 +430,7 @@ class AAM_Backend_Manager {
415
  'name' => ($u->display_name ? $u->display_name : $u->user_nicename),
416
  'level' => AAM_Core_API::maxLevel($u->allcaps)
417
  );
418
- } else {
419
  $roles = array_keys(get_editable_roles());
420
  $id = array_shift($roles);
421
  $role = AAM_Core_API::getRoles()->get_role($id);
@@ -426,6 +441,27 @@ class AAM_Backend_Manager {
426
  'name' => $role->name,
427
  'level' => AAM_Core_API::maxLevel($role->capabilities)
428
  );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
429
  }
430
 
431
  return (object) $subject;
@@ -466,7 +502,7 @@ class AAM_Backend_Manager {
466
  add_menu_page(
467
  'AAM',
468
  'AAM' . $counter,
469
- AAM_Core_Config::get('page.capability', 'administrator'),
470
  'aam',
471
  array($this, 'renderPage'),
472
  AAM_MEDIA . '/active-menu.svg'
@@ -497,9 +533,7 @@ class AAM_Backend_Manager {
497
  public function renderContent() {
498
  check_ajax_referer('aam_ajax');
499
 
500
- $cap = AAM_Core_Config::get('page.capability', 'administrator');
501
-
502
- if (AAM::getUser()->hasCapability($cap)) {
503
  echo AAM_Backend_View::getInstance()->renderContent();
504
  } else {
505
  echo __('Access Denied', AAM_KEY);
@@ -522,9 +556,7 @@ class AAM_Backend_Manager {
522
  while (@ob_end_clean()){}
523
 
524
  //process ajax request
525
- $cap = AAM_Core_Config::get('page.capability', 'administrator');
526
-
527
- if (AAM::getUser()->hasCapability($cap)) {
528
  echo AAM_Backend_View::getInstance()->processAjax();
529
  } else {
530
  echo __('Access Denied', AAM_KEY);
102
  */
103
  public function adminInit() {
104
  $user = AAM::getUser();
105
+
106
+ if (AAM_Core_API::capabilityExists('aam_manage_posts')) {
107
+ $cap = 'aam_manage_posts';
108
+ } else {
109
+ $cap = AAM_Core_Config::get(
110
+ AAM_Backend_Feature_Post::getAccessOption(),
111
+ AAM_Backend_View::getAAMCapability()
112
+ );
113
+ }
114
 
115
  if (AAM_Core_Request::get('aamframe') && $user->hasCapability($cap)) {
116
  echo AAM_Backend_View::getInstance()->renderAccessFrame();
141
  *
142
  */
143
  protected function checkUserAccess() {
144
+ $uid = get_current_user_id();
145
 
146
+ if ($uid && AAM_Core_API::capabilityExists('access_dashboard')) {
147
  if (empty(AAM::getUser()->allcaps['access_dashboard'])) {
148
  AAM_Core_API::reject('backend', array('hook' => 'access_dashboard'));
149
  }
201
  *
202
  */
203
  public function metabox() {
204
+ if (AAM_Core_API::capabilityExists('aam_manage_posts')) {
205
+ $cap = 'aam_manage_posts';
206
+ } else {
207
+ $cap = AAM_Core_Config::get(
208
+ AAM_Backend_Feature_Post::getAccessOption(),
209
+ AAM_Backend_View::getAAMCapability()
210
+ );
211
+ }
212
 
213
  if (AAM::getUser()->hasCapability($cap)) {
214
  add_meta_box(
240
  */
241
  public function renderTermMetabox($term) {
242
  if (is_a($term, 'WP_Term') && is_taxonomy_hierarchical($term->taxonomy)) {
243
+ if (AAM_Core_API::capabilityExists('aam_manage_posts')) {
244
+ $cap = 'aam_manage_posts';
245
+ } else {
246
+ $option = AAM_Backend_Feature_Post::getAccessOption();
247
+ $cap = AAM_Core_Config::get(
248
+ $option, AAM_Backend_View::getAAMCapability()
249
+ );
250
+ }
251
 
252
  if (AAM::getUser()->hasCapability($cap)) {
253
  echo AAM_Backend_View::getInstance()->renderTermMetabox($term);
302
  * @return string
303
  */
304
  public function postRowActions($actions, $post) {
305
+ if (AAM::getUser()->hasCapability(AAM_Backend_View::getAAMCapability())) {
 
 
306
  $url = admin_url('admin.php?page=aam&oid=' . $post->ID . '&otype=post#post');
307
 
308
  $actions['aam'] = '<a href="' . $url . '" target="_blank">';
319
  * @return string
320
  */
321
  public function tagRowActions($actions, $term) {
322
+ if (AAM::getUser()->hasCapability(AAM_Backend_View::getAAMCapability())) {
 
 
323
  $oid = $term->term_id . '|' . $term->taxonomy;
324
  $url = admin_url('admin.php?page=aam&oid=' . $oid . '&otype=term#post');
325
 
343
  * @access public
344
  */
345
  public function userActions($actions, $user) {
346
+ if (current_user_can(AAM_Backend_View::getAAMCapability(), $user->ID)) {
 
 
347
  $url = admin_url('admin.php?page=aam&user=' . $user->ID);
348
 
349
  $actions['aam'] = '<a href="' . $url . '" target="_blank">';
391
  'editUser' => admin_url('user-edit.php'),
392
  'addUser' => admin_url('user-new.php')
393
  ),
394
+ 'level' => AAM_Core_API::maxLevel(wp_get_current_user()->allcaps),
395
+ 'subject' => array(
396
+ 'type' => $subject->type,
397
+ 'id' => $subject->id,
398
+ 'name' => $subject->name,
399
  'level' => $subject->level,
400
+ 'blog' => get_current_blog_id()
401
  ),
402
+ 'translation' => require (dirname(__FILE__) . '/View/Localization.php'),
403
+ 'caps' => array(
404
+ 'create_roles' => AAM_Backend_View::userCan('aam_create_roles'),
405
+ 'create_users' => AAM_Backend_View::userCan('create_users')
406
+ )
407
  );
408
 
409
  if (AAM_Core_Request::get('aamframe')) {
422
  */
423
  protected function getCurrentSubject() {
424
  $userId = AAM_Core_Request::get('user');
425
+ if ($userId && AAM_Backend_View::userCan('list_users')) {
426
  $u = get_user_by('id', $userId);
427
  $subject = array(
428
  'type' => 'user',
430
  'name' => ($u->display_name ? $u->display_name : $u->user_nicename),
431
  'level' => AAM_Core_API::maxLevel($u->allcaps)
432
  );
433
+ } elseif (AAM_Backend_View::userCan('aam_list_roles')) {
434
  $roles = array_keys(get_editable_roles());
435
  $id = array_shift($roles);
436
  $role = AAM_Core_API::getRoles()->get_role($id);
441
  'name' => $role->name,
442
  'level' => AAM_Core_API::maxLevel($role->capabilities)
443
  );
444
+ } elseif (AAM_Backend_View::userCan('aam_manage_visitors')) {
445
+ $subject = array(
446
+ 'type' => 'visitor',
447
+ 'id' => null,
448
+ 'name' => __('Anonymous', AAM_KEY),
449
+ 'level' => 0
450
+ );
451
+ } elseif (AAM_Backend_View::userCan('aam_manage_default')) {
452
+ $subject = array(
453
+ 'type' => 'default',
454
+ 'id' => null,
455
+ 'name' => __('All Users, Roles and Visitor', AAM_KEY),
456
+ 'level' => 0
457
+ );
458
+ } else {
459
+ $subject = array(
460
+ 'type' => null,
461
+ 'id' => null,
462
+ 'name' => null,
463
+ 'level' => 0
464
+ );
465
  }
466
 
467
  return (object) $subject;
502
  add_menu_page(
503
  'AAM',
504
  'AAM' . $counter,
505
+ AAM_Backend_View::getAAMCapability(),
506
  'aam',
507
  array($this, 'renderPage'),
508
  AAM_MEDIA . '/active-menu.svg'
533
  public function renderContent() {
534
  check_ajax_referer('aam_ajax');
535
 
536
+ if (AAM::getUser()->hasCapability(AAM_Backend_View::getAAMCapability())) {
 
 
537
  echo AAM_Backend_View::getInstance()->renderContent();
538
  } else {
539
  echo __('Access Denied', AAM_KEY);
556
  while (@ob_end_clean()){}
557
 
558
  //process ajax request
559
+ if (AAM::getUser()->hasCapability(AAM_Backend_View::getAAMCapability())) {
 
 
560
  echo AAM_Backend_View::getInstance()->processAjax();
561
  } else {
562
  echo __('Access Denied', AAM_KEY);
Application/Backend/View.php CHANGED
@@ -218,29 +218,60 @@ class AAM_Backend_View {
218
  * @return type
219
  */
220
  public function switchToUser() {
221
- $user = new WP_User(AAM_Core_Request::post('user'));
222
- $max = AAM_Core_API::maxLevel(wp_get_current_user()->allcaps);
223
-
224
- if ($max >= AAM_Core_API::maxLevel($user->allcaps)) {
225
- AAM_Core_API::updateOption(
226
- 'aam-user-switch-' . $user->ID, get_current_user_id()
227
- );
228
-
229
- wp_clear_auth_cookie();
230
- wp_set_auth_cookie( $user->ID, true );
231
- wp_set_current_user( $user->ID );
232
-
233
- $response = array('status' => 'success', 'redirect' => admin_url());
234
- } else {
235
- $response = array(
236
  'status' => 'failure',
237
  'reason' => 'You are not allowed to switch to this user'
238
- );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
239
  }
240
 
241
  return json_encode($response);
242
  }
243
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
244
  /**
245
  * Get Subject
246
  *
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 (self::userCan('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
+ *
248
+ * @param type $capability
249
+ * @return type
250
+ */
251
+ public static function userCan($capability) {
252
+ if (AAM_Core_API::capabilityExists($capability)) {
253
+ $can = AAM::getUser()->hasCapability($capability);
254
+ } else {
255
+ $can = AAM::getUser()->hasCapability(self::getAAMCapability());
256
+ }
257
+
258
+ return ($can ? 1 : 0);
259
+ }
260
+
261
+ /**
262
+ *
263
+ * @return type
264
+ */
265
+ public static function getAAMCapability() {
266
+ if (AAM_Core_API::capabilityExists('aam_manager')) {
267
+ $cap = 'aam_manager';
268
+ } else {
269
+ $cap = AAM_Core_Config::get('page.capability', 'administrator');
270
+ }
271
+
272
+ return $cap;
273
+ }
274
+
275
  /**
276
  * Get Subject
277
  *
Application/Backend/phtml/extension.phtml CHANGED
@@ -3,7 +3,7 @@
3
  <div class="row">
4
  <div class="col-xs-12">
5
  <p class="aam-info">
6
- <?php echo AAM_Backend_View_Helper::preparePhrase('By purchasing any extension below you obtain a license that does not expire but is limited to one website. However, the license can be used for unlimited number of test or development environments where URL is either [localhost] or starts with [dev.], [staging.], [test.] or [demo.] Contact us immediately if you have troubles installing license on your website. [Money back guaranteed] within 30 day from the time of purchase.', 'i', 'i', 'i', 'i', 'i', 'b'); ?><br/>
7
  </p>
8
  </div>
9
  </div>
3
  <div class="row">
4
  <div class="col-xs-12">
5
  <p class="aam-info">
6
+ <?php echo AAM_Backend_View_Helper::preparePhrase('By purchasing any extension below you obtain the license key that does not expire but is limited to one website, however, the license can be used for unlimited number of test or development environments where URL is either [localhost] or starts with [dev.], [staging.], [test.] or [demo.] Contact us immediately if you have troubles installing extension on your website. [Money back guaranteed] within 30 day from the time of purchase.', 'i', 'i', 'i', 'i', 'i', 'b'); ?><br/>
7
  </p>
8
  </div>
9
  </div>
Application/Backend/phtml/frame.phtml CHANGED
@@ -17,23 +17,26 @@
17
  </head>
18
 
19
  <body>
20
- <?php if (AAM_Backend_Feature_Post::checkLimit() === false) { ?>
21
- <div style="border-left: 4px solid #ffb900; background-color: #FFF1CC; padding: 10px; font-size: 1em; margin: 10px 0px;">
22
- You've reached the limit. Consider to purchase <strong><a href="<?php echo admin_url('admin.php?page=aam#extension'); ?>" target="_blank">AAM Plus Package</a></strong> extension.
23
- </div>
24
- <?php } ?>
25
-
26
  <div class="row" style="margin: 10px 0 0 0;">
27
  <div class="col-sm-4" style="padding: 0;">
28
  <div class="panel panel-default" style="border-radius:0;">
29
  <div class="panel-body">
30
  <ul class="nav nav-tabs" role="tablist">
 
31
  <li role="presentation" class="active"><a href="#roles" aria-controls="roles" role="tab" data-toggle="tab"><i class="icon-users" data-toggle="tooltip" data-placement="top" title="Roles"></i></a></li>
 
 
32
  <li role="presentation"><a href="#users" aria-controls="users" role="tab" data-toggle="tab"><i class="icon-user" data-toggle="tooltip" data-placement="top" title="Users"></i></a></li>
 
 
33
  <li role="presentation"><a href="#visitor" aria-controls="visitor" role="tab" data-toggle="tab"><i class="icon-user-secret" data-toggle="tooltip" data-placement="top" title="Visitor"></i></a></li>
 
 
34
  <li role="presentation"><a href="#default" aria-controls="default" role="tab" data-toggle="tab" class="text-danger"><i class="icon-asterisk" data-toggle="tooltip" data-placement="top" title="Default"></i></a></li>
 
35
  </ul>
36
  <div class="tab-content">
 
37
  <div role="tabpanel" class="tab-pane active" id="roles">
38
  <table id="role-list" class="table table-striped table-bordered">
39
  <thead>
@@ -48,6 +51,8 @@
48
  <tbody></tbody>
49
  </table>
50
  </div>
 
 
51
  <div role="tabpanel" class="tab-pane" id="users">
52
  <table id="user-list" class="table table-striped table-bordered">
53
  <thead>
@@ -62,12 +67,16 @@
62
  <tbody></tbody>
63
  </table>
64
  </div>
 
 
65
  <div role="tabpanel" class="tab-pane" id="visitor">
66
  <div class="visitor-message">
67
  <span class="aam-bordered"><?php echo sprintf(__('Manage access to %s for visitors (any user that is not authenticated)', AAM_KEY), '<b>' . ($object->type == 'post' ? $object->post->post_title : $object->term->name) . '</b>'); ?>.</span>
68
  <button class="btn btn-primary btn-block" id="manage-visitor"><i class="icon-cog"></i> <?php echo __('Manage Visitors', AAM_KEY); ?></button>
69
  </div>
70
  </div>
 
 
71
  <div role="tabpanel" class="tab-pane" id="default">
72
  <div class="visitor-message">
73
  <span class="aam-bordered"><?php echo sprintf(__('Manage default access to %s for all users, roles and visitor. This includes Administrator role and yourself', AAM_KEY), '<b>' . ($object->type == 'post' ? $object->post->post_title : $object->term->name) . '</b>'); ?>.</span>
@@ -80,6 +89,7 @@
80
  <?php } ?>
81
  </div>
82
  </div>
 
83
  </div>
84
  </div>
85
  </div>
17
  </head>
18
 
19
  <body>
 
 
 
 
 
 
20
  <div class="row" style="margin: 10px 0 0 0;">
21
  <div class="col-sm-4" style="padding: 0;">
22
  <div class="panel panel-default" style="border-radius:0;">
23
  <div class="panel-body">
24
  <ul class="nav nav-tabs" role="tablist">
25
+ <?php if (AAM_Backend_View::userCan('aam_list_roles')) { ?>
26
  <li role="presentation" class="active"><a href="#roles" aria-controls="roles" role="tab" data-toggle="tab"><i class="icon-users" data-toggle="tooltip" data-placement="top" title="Roles"></i></a></li>
27
+ <?php } ?>
28
+ <?php if (AAM_Backend_View::userCan('list_users')) { ?>
29
  <li role="presentation"><a href="#users" aria-controls="users" role="tab" data-toggle="tab"><i class="icon-user" data-toggle="tooltip" data-placement="top" title="Users"></i></a></li>
30
+ <?php } ?>
31
+ <?php if (AAM_Backend_View::userCan('aam_manage_visitors')) { ?>
32
  <li role="presentation"><a href="#visitor" aria-controls="visitor" role="tab" data-toggle="tab"><i class="icon-user-secret" data-toggle="tooltip" data-placement="top" title="Visitor"></i></a></li>
33
+ <?php } ?>
34
+ <?php if (AAM_Backend_View::userCan('aam_manage_default')) { ?>
35
  <li role="presentation"><a href="#default" aria-controls="default" role="tab" data-toggle="tab" class="text-danger"><i class="icon-asterisk" data-toggle="tooltip" data-placement="top" title="Default"></i></a></li>
36
+ <?php } ?>
37
  </ul>
38
  <div class="tab-content">
39
+ <?php if (AAM_Backend_View::userCan('aam_list_roles')) { ?>
40
  <div role="tabpanel" class="tab-pane active" id="roles">
41
  <table id="role-list" class="table table-striped table-bordered">
42
  <thead>
51
  <tbody></tbody>
52
  </table>
53
  </div>
54
+ <?php } ?>
55
+ <?php if (AAM_Backend_View::userCan('list_users')) { ?>
56
  <div role="tabpanel" class="tab-pane" id="users">
57
  <table id="user-list" class="table table-striped table-bordered">
58
  <thead>
67
  <tbody></tbody>
68
  </table>
69
  </div>
70
+ <?php } ?>
71
+ <?php if (AAM_Backend_View::userCan('aam_manage_visitors')) { ?>
72
  <div role="tabpanel" class="tab-pane" id="visitor">
73
  <div class="visitor-message">
74
  <span class="aam-bordered"><?php echo sprintf(__('Manage access to %s for visitors (any user that is not authenticated)', AAM_KEY), '<b>' . ($object->type == 'post' ? $object->post->post_title : $object->term->name) . '</b>'); ?>.</span>
75
  <button class="btn btn-primary btn-block" id="manage-visitor"><i class="icon-cog"></i> <?php echo __('Manage Visitors', AAM_KEY); ?></button>
76
  </div>
77
  </div>
78
+ <?php } ?>
79
+ <?php if (AAM_Backend_View::userCan('aam_manage_default')) { ?>
80
  <div role="tabpanel" class="tab-pane" id="default">
81
  <div class="visitor-message">
82
  <span class="aam-bordered"><?php echo sprintf(__('Manage default access to %s for all users, roles and visitor. This includes Administrator role and yourself', AAM_KEY), '<b>' . ($object->type == 'post' ? $object->post->post_title : $object->term->name) . '</b>'); ?>.</span>
89
  <?php } ?>
90
  </div>
91
  </div>
92
+ <?php } ?>
93
  </div>
94
  </div>
95
  </div>
Application/Backend/phtml/index.phtml CHANGED
@@ -74,12 +74,21 @@
74
  <div class="inside" id="user-role-manager-inside">
75
  <div class="aam-postbox-inside">
76
  <ul class="nav nav-tabs" role="tablist">
77
- <li role="presentation" class="active text-center"><a href="#roles" aria-controls="roles" role="tab" data-toggle="tab"><i class="icon-users"></i><br/><?php echo __('Roles', AAM_KEY); ?></a></li>
78
- <li role="presentation" class="text-center"><a href="#users" aria-controls="users" role="tab" data-toggle="tab"><i class="icon-user"></i><br/><?php echo __('Users', AAM_KEY); ?></a></li>
79
- <li role="presentation" class="text-center"><a href="#visitor" aria-controls="visitor" role="tab" data-toggle="tab"><i class="icon-user-secret"></i><br/><?php echo __('Visitor', AAM_KEY); ?></a></li>
80
- <li role="presentation" class="text-center"><a href="#default" aria-controls="default" role="tab" data-toggle="tab" class="text-danger"><i class="icon-asterisk"></i><br/><?php echo __('Default', AAM_KEY); ?></a></li>
 
 
 
 
 
 
 
 
81
  </ul>
82
  <div class="tab-content">
 
83
  <div role="tabpanel" class="tab-pane active" id="roles">
84
  <table id="role-list" class="table table-striped table-bordered">
85
  <thead>
@@ -156,6 +165,8 @@
156
  </div>
157
  </div>
158
  </div>
 
 
159
  <div role="tabpanel" class="tab-pane" id="users">
160
  <table id="user-list" class="table table-striped table-bordered">
161
  <thead>
@@ -170,18 +181,23 @@
170
  <tbody></tbody>
171
  </table>
172
  </div>
 
 
173
  <div role="tabpanel" class="tab-pane" id="visitor">
174
  <div class="visitor-message">
175
  <span class="aam-bordered"><?php echo __('Manage access to your website for visitors (any user that is not authenticated)', AAM_KEY); ?>.</span>
176
  <button class="btn btn-primary btn-block" id="manage-visitor"><i class="icon-cog"></i> <?php echo __('Manage Visitors', AAM_KEY); ?></button>
177
  </div>
178
  </div>
 
 
179
  <div role="tabpanel" class="tab-pane" id="default">
180
  <div class="visitor-message">
181
  <span class="aam-bordered"><?php echo __('Manage default access to your website resources for all users, roles and visitor. This includes Administrator role and your user', AAM_KEY); ?>.</span>
182
  <button class="btn btn-danger btn-block" id="manage-default"><i class="icon-cog"></i> <?php echo __('Manage Default Access', AAM_KEY); ?></button>
183
  </div>
184
  </div>
 
185
  </div>
186
  </div>
187
  <div class="aam-help-context">
@@ -244,8 +260,8 @@
244
  <hr/>
245
 
246
  <div class="text-center">
247
- <p class="aam-promo">Need for professional developer?</p>
248
- <a href="http://dev.vasyltech/hire-developer" class="btn btn-primary" target="_blank">Get in touch today</a>
249
  </div>
250
  </div>
251
  </div>
74
  <div class="inside" id="user-role-manager-inside">
75
  <div class="aam-postbox-inside">
76
  <ul class="nav nav-tabs" role="tablist">
77
+ <?php if (AAM_Backend_View::userCan('aam_list_roles')) { ?>
78
+ <li role="presentation" class="active text-center"><a href="#roles" aria-controls="roles" role="tab" data-toggle="tab"><i class="icon-users"></i><br/><?php echo __('Roles', AAM_KEY); ?></a></li>
79
+ <?php } ?>
80
+ <?php if (AAM_Backend_View::userCan('list_users')) { ?>
81
+ <li role="presentation" class="text-center"><a href="#users" aria-controls="users" role="tab" data-toggle="tab"><i class="icon-user"></i><br/><?php echo __('Users', AAM_KEY); ?></a></li>
82
+ <?php } ?>
83
+ <?php if (AAM_Backend_View::userCan('aam_manage_visitors')) { ?>
84
+ <li role="presentation" class="text-center"><a href="#visitor" aria-controls="visitor" role="tab" data-toggle="tab"><i class="icon-user-secret"></i><br/><?php echo __('Visitor', AAM_KEY); ?></a></li>
85
+ <?php } ?>
86
+ <?php if (AAM_Backend_View::userCan('aam_manage_default')) { ?>
87
+ <li role="presentation" class="text-center"><a href="#default" aria-controls="default" role="tab" data-toggle="tab" class="text-danger"><i class="icon-asterisk"></i><br/><?php echo __('Default', AAM_KEY); ?></a></li>
88
+ <?php } ?>
89
  </ul>
90
  <div class="tab-content">
91
+ <?php if (AAM_Backend_View::userCan('aam_list_roles')) { ?>
92
  <div role="tabpanel" class="tab-pane active" id="roles">
93
  <table id="role-list" class="table table-striped table-bordered">
94
  <thead>
165
  </div>
166
  </div>
167
  </div>
168
+ <?php } ?>
169
+ <?php if (AAM_Backend_View::userCan('list_users')) { ?>
170
  <div role="tabpanel" class="tab-pane" id="users">
171
  <table id="user-list" class="table table-striped table-bordered">
172
  <thead>
181
  <tbody></tbody>
182
  </table>
183
  </div>
184
+ <?php } ?>
185
+ <?php if (AAM_Backend_View::userCan('aam_manage_visitors')) { ?>
186
  <div role="tabpanel" class="tab-pane" id="visitor">
187
  <div class="visitor-message">
188
  <span class="aam-bordered"><?php echo __('Manage access to your website for visitors (any user that is not authenticated)', AAM_KEY); ?>.</span>
189
  <button class="btn btn-primary btn-block" id="manage-visitor"><i class="icon-cog"></i> <?php echo __('Manage Visitors', AAM_KEY); ?></button>
190
  </div>
191
  </div>
192
+ <?php } ?>
193
+ <?php if (AAM_Backend_View::userCan('aam_manage_default')) { ?>
194
  <div role="tabpanel" class="tab-pane" id="default">
195
  <div class="visitor-message">
196
  <span class="aam-bordered"><?php echo __('Manage default access to your website resources for all users, roles and visitor. This includes Administrator role and your user', AAM_KEY); ?>.</span>
197
  <button class="btn btn-danger btn-block" id="manage-default"><i class="icon-cog"></i> <?php echo __('Manage Default Access', AAM_KEY); ?></button>
198
  </div>
199
  </div>
200
+ <?php } ?>
201
  </div>
202
  </div>
203
  <div class="aam-help-context">
260
  <hr/>
261
 
262
  <div class="text-center">
263
+ <p class="aam-promo"><strong>Need help?</strong><br/>Get in touch today. It is free.</p>
264
+ <a href="mailto:support@aamplugin.com" class="btn btn-success" target="_blank">support@aamplugin.com</a>
265
  </div>
266
  </div>
267
  </div>
Application/Backend/phtml/main-panel.phtml CHANGED
@@ -1,24 +1,30 @@
1
  <?php if (defined('AAM_KEY')) { ?>
2
  <div class="row">
3
- <div class="col-xs-12 col-md-4">
4
- <ul class="list-group" id="feature-list">
 
 
 
 
 
 
 
 
 
 
 
 
5
  <?php
6
- foreach (AAM_Backend_Feature::retriveList() as $i => $feature) {
7
- echo '<li class="list-group-item" data-feature="' . $feature->uid . '">';
8
- echo $feature->title;
9
- echo (empty($feature->notification) ? '' : ' <span class="badge">' . $feature->notification . '</span>');
10
- echo '</li>';
11
  }
 
12
  ?>
13
- </ul>
14
- </div>
15
- <div class="col-xs-12 col-md-8">
16
- <?php
17
- foreach (AAM_Backend_Feature::retriveList() as $feature) {
18
- echo $feature->view->getContent();
19
- }
20
- do_action('aam-content-action');
21
- ?>
22
- </div>
23
  </div>
24
  <?php }
1
  <?php if (defined('AAM_KEY')) { ?>
2
  <div class="row">
3
+ <?php if (count(AAM_Backend_Feature::retriveList())) { ?>
4
+ <div class="col-xs-12 col-md-4">
5
+ <ul class="list-group" id="feature-list">
6
+ <?php
7
+ foreach (AAM_Backend_Feature::retriveList() as $i => $feature) {
8
+ echo '<li class="list-group-item" data-feature="' . $feature->uid . '">';
9
+ echo $feature->title;
10
+ echo (empty($feature->notification) ? '' : ' <span class="badge">' . $feature->notification . '</span>');
11
+ echo '</li>';
12
+ }
13
+ ?>
14
+ </ul>
15
+ </div>
16
+ <div class="col-xs-12 col-md-8">
17
  <?php
18
+ foreach (AAM_Backend_Feature::retriveList() as $feature) {
19
+ echo $feature->view->getContent();
 
 
 
20
  }
21
+ do_action('aam-content-action');
22
  ?>
23
+ </div>
24
+ <?php } else { ?>
25
+ <div class="col-xs-12">
26
+ <p class="aam-notification text-center"><?php echo __('You are not allowed to manage any of the existing features.', 'AAM_KEY'); ?></p>
27
+ </div>
28
+ <?php } ?>
 
 
 
 
29
  </div>
30
  <?php }
Application/Backend/phtml/object/login-redirect.phtml CHANGED
@@ -4,11 +4,11 @@
4
  <div class="col-xs-12">
5
  <?php if ($this->isDefault()) { ?>
6
  <p class="aam-info">
7
- <?php echo AAM_Backend_View_Helper::preparePhrase('Setup [default] login redirect for all users, roles when the authentication completed successfully.', 'strong'); ?>
8
  </p>
9
  <?php } else { ?>
10
  <p class="aam-info">
11
- <?php echo sprintf(AAM_Backend_View_Helper::preparePhrase('Setup customized login redirect for the [%s] when the authentication completed successfully.', 'strong'), AAM_Backend_View::getSubject()->getUID()); ?>
12
  </p>
13
  <?php } ?>
14
  <div class="aam-overwrite" id="aam-login-redirect-overwrite" style="display: <?php echo ($this->isOverwritten() ? 'block' : 'none'); ?>">
4
  <div class="col-xs-12">
5
  <?php if ($this->isDefault()) { ?>
6
  <p class="aam-info">
7
+ <?php echo AAM_Backend_View_Helper::preparePhrase('Define the [default] login redirect for all users, roles when the authentication completed successfully.', 'strong'); ?>
8
  </p>
9
  <?php } else { ?>
10
  <p class="aam-info">
11
+ <?php echo sprintf(AAM_Backend_View_Helper::preparePhrase('Customize login redirect for this %s when the authentication completed successfully.'), AAM_Backend_View::getSubject()->getUID()); ?>
12
  </p>
13
  <?php } ?>
14
  <div class="aam-overwrite" id="aam-login-redirect-overwrite" style="display: <?php echo ($this->isOverwritten() ? 'block' : 'none'); ?>">
Application/Backend/phtml/object/logout-redirect.phtml CHANGED
@@ -4,11 +4,11 @@
4
  <div class="col-xs-12">
5
  <?php if ($this->isDefault()) { ?>
6
  <p class="aam-info">
7
- <?php echo AAM_Backend_View_Helper::preparePhrase('Setup [default] logout redirect for all users and roles.', 'strong'); ?>
8
  </p>
9
  <?php } else { ?>
10
  <p class="aam-info">
11
- <?php echo sprintf(AAM_Backend_View_Helper::preparePhrase('Setup customized logout redirect for the [%s].', 'strong'), AAM_Backend_View::getSubject()->getUID()); ?>
12
  </p>
13
  <?php } ?>
14
  <div class="aam-overwrite" id="aam-logout-redirect-overwrite" style="display: <?php echo ($this->isOverwritten() ? 'block' : 'none'); ?>">
4
  <div class="col-xs-12">
5
  <?php if ($this->isDefault()) { ?>
6
  <p class="aam-info">
7
+ <?php echo AAM_Backend_View_Helper::preparePhrase('Define the [default] logout redirect for all users and roles.', 'strong'); ?>
8
  </p>
9
  <?php } else { ?>
10
  <p class="aam-info">
11
+ <?php echo sprintf(AAM_Backend_View_Helper::preparePhrase('Customize logout redirect for this %s.'), AAM_Backend_View::getSubject()->getUID()); ?>
12
  </p>
13
  <?php } ?>
14
  <div class="aam-overwrite" id="aam-logout-redirect-overwrite" style="display: <?php echo ($this->isOverwritten() ? 'block' : 'none'); ?>">
Application/Backend/phtml/object/menu.phtml CHANGED
@@ -1,5 +1,12 @@
1
  <?php if (defined('AAM_KEY')) { ?>
2
  <div class="aam-feature" id="admin_menu-content">
 
 
 
 
 
 
 
3
  <?php if ($this->isOverwritten()) { ?>
4
  <div class="row">
5
  <div class="col-xs-12">
1
  <?php if (defined('AAM_KEY')) { ?>
2
  <div class="aam-feature" id="admin_menu-content">
3
+ <div class="row">
4
+ <div class="col-xs-12">
5
+ <p class="aam-info">
6
+ <?php echo sprintf(AAM_Backend_View_Helper::preparePhrase('Protect your backend area. The list of menus and submenus is based on list of capabilities that current %s has. For more information about this feature, please check %sHow to manage WordPress backend menu%s.', 'b'), AAM_Backend_View::getSubject()->getUID(), '<a href="https://aamplugin.com/help/how-to-manage-wordpress-backend-menu" target="_blank">', '</a>'); ?>
7
+ </p>
8
+ </div>
9
+ </div>
10
  <?php if ($this->isOverwritten()) { ?>
11
  <div class="row">
12
  <div class="col-xs-12">
Application/Backend/phtml/object/post.phtml CHANGED
@@ -3,8 +3,8 @@
3
  <?php if (!defined('AAM_PLUS_PACKAGE')) { ?>
4
  <div class="row">
5
  <div class="col-xs-12">
6
- <p class="aam-notification">
7
- <?php echo sprintf(AAM_Backend_View_Helper::preparePhrase('You are allowed to manage access up to 10 posts, pages or custom post types but only on role, user or visitor levels. Consider to purchase [AAM Plus Package] extension to unlock this limitation. For more information about post access control check %sthis article%s.', 'b'), '<a href="https://aamplugin.com/help/how-to-manage-wordpress-post-and-category-access" target="_blank">', '</a>'); ?>
8
  </p>
9
  </div>
10
  </div>
3
  <?php if (!defined('AAM_PLUS_PACKAGE')) { ?>
4
  <div class="row">
5
  <div class="col-xs-12">
6
+ <p class="aam-info">
7
+ <?php echo sprintf(AAM_Backend_View_Helper::preparePhrase('You are allowed to manage access to unlimited number of posts, pages or custom post types but only on role, user or visitor levels. Consider to purchase [AAM Plus Package] extension to have the ability to manage access also to categories or custom taxonomies and to have the ability to define the default access to all posts, pages or custom post types. For more information check %sthis article%s.', 'b'), '<a href="https://aamplugin.com/help/aam-plus-package-extension" target="_blank">', '</a>'); ?>
8
  </p>
9
  </div>
10
  </div>
Application/Backend/phtml/object/redirect.phtml CHANGED
@@ -4,11 +4,11 @@
4
  <div class="col-xs-12">
5
  <?php if ($this->isDefault()) { ?>
6
  <p class="aam-info">
7
- <?php echo AAM_Backend_View_Helper::preparePhrase('Setup [default] redirect for all users, roles and visitors when access is denied to any restricted resources on your website.', 'strong'); ?>
8
  </p>
9
  <?php } else { ?>
10
  <p class="aam-info">
11
- <?php echo sprintf(AAM_Backend_View_Helper::preparePhrase('Setup customized redirect for the [%s] when access is denied to the restricted resources like posts, categories, menus, etc.', 'strong'), AAM_Backend_View::getSubject()->getUID()); ?>
12
  </p>
13
  <?php } ?>
14
  <div class="aam-overwrite" id="aam-redirect-overwrite" style="display: <?php echo ($this->isOverwritten() ? 'block' : 'none'); ?>">
@@ -39,6 +39,12 @@
39
  <input type="radio" name="frontend.redirect.type" id="frontend-redirect-message" data-action="#frontend-message-action" value="message" data-group="frontend-redirect"<?php echo ($frontendType == 'message' ? ' checked' : ''); ?> />
40
  <label for="frontend-redirect-message"><?php echo AAM_Backend_View_Helper::preparePhrase('Show customized message [(plain text or HTML)]', 'small'); ?></label>
41
  </div>
 
 
 
 
 
 
42
  <div class="radio">
43
  <input type="radio" name="frontend.redirect.type" id="frontend-redirect-page" data-action="#frontend-page-action" value="page" data-group="frontend-redirect"<?php echo ($frontendType == 'page' ? ' checked' : ''); ?> />
44
  <label for="frontend-redirect-page"><?php echo AAM_Backend_View_Helper::preparePhrase('Redirected to existing page [(select from the drop-down)]', 'small'); ?></label>
4
  <div class="col-xs-12">
5
  <?php if ($this->isDefault()) { ?>
6
  <p class="aam-info">
7
+ <?php echo AAM_Backend_View_Helper::preparePhrase('Define the [default] redirect for all users, roles and visitors when access is denied to any restricted resources on your website.', 'strong'); ?>
8
  </p>
9
  <?php } else { ?>
10
  <p class="aam-info">
11
+ <?php echo sprintf(AAM_Backend_View_Helper::preparePhrase('Customize redirect for this %s when access is denied to restricted resources like posts, categories, menus, etc. For more information about this feature, please check %sHow to redirect WordPress user when access is denied%s.'), AAM_Backend_View::getSubject()->getUID(), '<a href="https://aamplugin.com/help/how-to-redirect-wordpress-user-when-access-is-denied" target="_blank">', '</a>'); ?>
12
  </p>
13
  <?php } ?>
14
  <div class="aam-overwrite" id="aam-redirect-overwrite" style="display: <?php echo ($this->isOverwritten() ? 'block' : 'none'); ?>">
39
  <input type="radio" name="frontend.redirect.type" id="frontend-redirect-message" data-action="#frontend-message-action" value="message" data-group="frontend-redirect"<?php echo ($frontendType == 'message' ? ' checked' : ''); ?> />
40
  <label for="frontend-redirect-message"><?php echo AAM_Backend_View_Helper::preparePhrase('Show customized message [(plain text or HTML)]', 'small'); ?></label>
41
  </div>
42
+ <?php if ($this->isVisitor()) { ?>
43
+ <div class="radio">
44
+ <input type="radio" name="frontend.redirect.type" id="frontend-redirect-login" value="login" data-action="none" data-group="frontend-redirect"<?php echo ($frontendType == 'login' ? ' checked' : ''); ?> />
45
+ <label for="frontend-redirect-login"><?php echo AAM_Backend_View_Helper::preparePhrase('Redirect to the login page [(after login, user will be redirected back to the restricted page)]', 'small'); ?></label>
46
+ </div>
47
+ <?php } ?>
48
  <div class="radio">
49
  <input type="radio" name="frontend.redirect.type" id="frontend-redirect-page" data-action="#frontend-page-action" value="page" data-group="frontend-redirect"<?php echo ($frontendType == 'page' ? ' checked' : ''); ?> />
50
  <label for="frontend-redirect-page"><?php echo AAM_Backend_View_Helper::preparePhrase('Redirected to existing page [(select from the drop-down)]', 'small'); ?></label>
Application/Backend/phtml/object/teaser.phtml CHANGED
@@ -4,11 +4,11 @@
4
  <div class="col-xs-12">
5
  <?php if ($this->isDefault()) { ?>
6
  <p class="aam-info">
7
- <?php echo AAM_Backend_View_Helper::preparePhrase('Setup [default] teaser message for all users, roles and visitors when access is limited to any post on your website.', 'strong'); ?>
8
  </p>
9
  <?php } else { ?>
10
  <p class="aam-info">
11
- <?php echo sprintf(AAM_Backend_View_Helper::preparePhrase('Setup customized teaser message for the [%s] when access is limited to post on your website.', 'strong'), AAM_Backend_View::getSubject()->getUID()); ?>
12
  </p>
13
  <?php } ?>
14
  <div class="aam-overwrite" id="aam-teaser-overwrite" style="display: <?php echo ($this->isOverwritten() ? 'block' : 'none'); ?>">
4
  <div class="col-xs-12">
5
  <?php if ($this->isDefault()) { ?>
6
  <p class="aam-info">
7
+ <?php echo AAM_Backend_View_Helper::preparePhrase('Define the [default] teaser message for all users, roles and visitors when access is limited to any post on your website.', 'strong'); ?>
8
  </p>
9
  <?php } else { ?>
10
  <p class="aam-info">
11
+ <?php echo sprintf(AAM_Backend_View_Helper::preparePhrase('Customize the teaser message for this %s when access is limited to any post, page or custom post type on your website.'), AAM_Backend_View::getSubject()->getUID()); ?>
12
  </p>
13
  <?php } ?>
14
  <div class="aam-overwrite" id="aam-teaser-overwrite" style="display: <?php echo ($this->isOverwritten() ? 'block' : 'none'); ?>">
Application/Core/API.php CHANGED
@@ -202,6 +202,22 @@ final class AAM_Core_API {
202
  return $caps;
203
  }
204
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
205
  /**
206
  * Reject the request
207
  *
@@ -218,7 +234,12 @@ final class AAM_Core_API {
218
  $object = AAM::getUser()->getObject('redirect');
219
  $type = $object->get("{$area}.redirect.type");
220
 
221
- if (!empty($type) && ($type != 'default')) {
 
 
 
 
 
222
  $redirect = $object->get("{$area}.redirect.{$type}");
223
  } else { //ConfigPress setup
224
  $redirect = AAM_Core_Config::get(
202
  return $caps;
203
  }
204
 
205
+ /**
206
+ * Check if capability exists
207
+ *
208
+ * @param string $cap
209
+ *
210
+ * @return boolean
211
+ *
212
+ * @access public
213
+ * @static
214
+ */
215
+ public static function capabilityExists($cap) {
216
+ $caps = self::getAllCapabilities();
217
+
218
+ return (isset($caps[$cap]) ? true : false);
219
+ }
220
+
221
  /**
222
  * Reject the request
223
  *
234
  $object = AAM::getUser()->getObject('redirect');
235
  $type = $object->get("{$area}.redirect.type");
236
 
237
+ if (!empty($type) && ($type == 'login')) {
238
+ $redirect = add_query_arg(
239
+ array('aam-redirect' => 'login'),
240
+ wp_login_url(AAM_Core_Request::server('REQUEST_URI'))
241
+ );
242
+ } elseif (!empty($type) && ($type != 'default')) {
243
  $redirect = $object->get("{$area}.redirect.{$type}");
244
  } else { //ConfigPress setup
245
  $redirect = AAM_Core_Config::get(
Application/Core/Media.php CHANGED
@@ -24,6 +24,18 @@ class AAM_Core_Media {
24
  */
25
  private static $_instance = null;
26
 
 
 
 
 
 
 
 
 
 
 
 
 
27
  /**
28
  * Initialize the extension
29
  *
@@ -33,6 +45,16 @@ class AAM_Core_Media {
33
  */
34
  protected function __construct() {
35
  if (AAM_Core_Request::get('aam-media')) {
 
 
 
 
 
 
 
 
 
 
36
  if (AAM_Core_Config::get('media-access-control', false)) {
37
  $area = (is_admin() ? 'backend' : 'frontend');
38
  if (AAM_Core_Config::get("{$area}-access-control", true)) {
@@ -46,6 +68,18 @@ class AAM_Core_Media {
46
  }
47
  }
48
 
 
 
 
 
 
 
 
 
 
 
 
 
49
  /**
50
  * Check media access
51
  *
@@ -54,10 +88,8 @@ class AAM_Core_Media {
54
  * @access protected
55
  */
56
  protected function checkMediaAccess() {
57
- $request = AAM_Core_Request::server('REQUEST_URI');
58
-
59
- if ($this->isMediaRequest($request)) {
60
- $media = $this->findMedia($request);
61
  $area = (is_admin() ? 'backend' : 'frontend');
62
 
63
  if (empty($media) || !$media->has("{$area}.read")) {
@@ -81,54 +113,29 @@ class AAM_Core_Media {
81
  }
82
  }
83
 
84
- /**
85
- *
86
- * @param type $request
87
- * @return type
88
- */
89
- protected function isMediaRequest($request) {
90
- $directory = wp_get_upload_dir();
91
-
92
- $abspath = str_replace('\\', '/', ABSPATH);
93
- $uploads = str_replace('\\', '/', $directory['basedir']);
94
-
95
- return apply_filters(
96
- 'aam-media-request',
97
- (strpos($request, str_replace($abspath, '/', $uploads)) === 0),
98
- $request
99
- );
100
- }
101
-
102
  /**
103
  *
104
  * @param type $media
105
  */
106
  protected function printMedia($media = null) {
107
- $abspath = str_replace('\\', '/', ABSPATH);
108
-
109
  if (is_null($media)) {
110
- $request = AAM_Core_Request::server('REQUEST_URI');
111
- $media = $this->findMedia($request);
112
- } else {
113
- $request = str_replace(WP_CONTENT_URL, '/wp-content', $media->guid);
114
  }
115
 
116
  if (!empty($media)) {
117
- $mime = $media->post_mime_type;
118
  }
119
 
120
- if (@is_readable($abspath . $request)) {
121
- $content = file_get_contents($abspath . $request);
122
-
123
- if (empty($mime)) {
124
- if (function_exists('mime_content_type')) {
125
- $mime = mime_content_type($abspath . $request);
126
- }
127
  }
128
-
129
- @header('Content-Type: ' . (empty($mime) ? 'application/octet-stream' : $mime));
130
- echo $content;
131
  }
 
 
 
132
  exit;
133
  }
134
 
@@ -137,22 +144,25 @@ class AAM_Core_Media {
137
  *
138
  * @global Wpdb $wpdb
139
  *
140
- * @param string $uri
141
- *
142
  * @return AAM_Core_Object_Post|null
143
  *
144
  * @access protected
145
  */
146
- protected function findMedia($uri) {
147
  global $wpdb;
148
 
149
- $s = addslashes(preg_replace('/(-[\d]+x[\d]+)(\.[\w]+)$/', '$2', $uri));
150
- $id = apply_filters(
151
  'aam-find-media',
152
- $wpdb->get_var("SELECT ID FROM {$wpdb->posts} WHERE guid LIKE '%$s'"),
153
- $uri
 
 
 
 
 
154
  );
155
-
156
  return ($id ? AAM::getUser()->getObject('post', $id) : null);
157
  }
158
 
24
  */
25
  private static $_instance = null;
26
 
27
+ /**
28
+ *
29
+ * @var type
30
+ */
31
+ protected $request = '';
32
+
33
+ /**
34
+ *
35
+ * @var type
36
+ */
37
+ protected $request_uri = '';
38
+
39
  /**
40
  * Initialize the extension
41
  *
45
  */
46
  protected function __construct() {
47
  if (AAM_Core_Request::get('aam-media')) {
48
+ if (AAM_Core_Request::get('debug')) {
49
+ file_put_contents(
50
+ dirname(__FILE__) . '/debug.log',
51
+ print_r(AAM_Core_Request::server(), 1) . "\n",
52
+ FILE_APPEND
53
+ );
54
+ }
55
+
56
+ $this->initialize();
57
+
58
  if (AAM_Core_Config::get('media-access-control', false)) {
59
  $area = (is_admin() ? 'backend' : 'frontend');
60
  if (AAM_Core_Config::get("{$area}-access-control", true)) {
68
  }
69
  }
70
 
71
+ /**
72
+ *
73
+ */
74
+ protected function initialize() {
75
+ $media = filter_input(INPUT_GET, 'aam-media');
76
+ $request = ($media != '1' ? $media : AAM_Core_Request::server('REQUEST_URI'));
77
+ $root = AAM_Core_Request::server('DOCUMENT_ROOT');
78
+
79
+ $this->request = str_replace('\\', '/', $root . $request);
80
+ $this->request_uri = $request;
81
+ }
82
+
83
  /**
84
  * Check media access
85
  *
88
  * @access protected
89
  */
90
  protected function checkMediaAccess() {
91
+ if (apply_filters('aam-media-request', true, $this->request)) {
92
+ $media = $this->findMedia();
 
 
93
  $area = (is_admin() ? 'backend' : 'frontend');
94
 
95
  if (empty($media) || !$media->has("{$area}.read")) {
113
  }
114
  }
115
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
116
  /**
117
  *
118
  * @param type $media
119
  */
120
  protected function printMedia($media = null) {
121
+ $type = 'application/octet-stream';
122
+
123
  if (is_null($media)) {
124
+ $media = $this->findMedia();
 
 
 
125
  }
126
 
127
  if (!empty($media)) {
128
+ $mime = $media->post_mime_type;
129
  }
130
 
131
+ if (empty($mime)) {
132
+ if (function_exists('mime_content_type')) {
133
+ $mime = mime_content_type($this->request);
 
 
 
 
134
  }
 
 
 
135
  }
136
+
137
+ @header('Content-Type: ' . (empty($mime) ? $type : $mime));
138
+ echo file_get_contents($this->request);
139
  exit;
140
  }
141
 
144
  *
145
  * @global Wpdb $wpdb
146
  *
 
 
147
  * @return AAM_Core_Object_Post|null
148
  *
149
  * @access protected
150
  */
151
+ protected function findMedia() {
152
  global $wpdb;
153
 
154
+ $s = preg_replace('/(-[\d]+x[\d]+)(\.[\w]+)$/', '$2', $this->request_uri);
155
+ $id = apply_filters(
156
  'aam-find-media',
157
+ $wpdb->get_var(
158
+ $wpdb->prepare(
159
+ "SELECT ID FROM {$wpdb->posts} WHERE guid LIKE %s",
160
+ array('%' . $s)
161
+ )
162
+ ),
163
+ $this->request_uri
164
  );
165
+
166
  return ($id ? AAM::getUser()->getObject('post', $id) : null);
167
  }
168
 
Application/Frontend/Manager.php CHANGED
@@ -75,6 +75,9 @@ class AAM_Frontend_Manager {
75
  //core AAM filter
76
  add_filter('aam-object-filter', array($this, 'getObject'), 10, 4);
77
 
 
 
 
78
  //admin bar
79
  $this->checkAdminBar();
80
  }
@@ -87,6 +90,24 @@ class AAM_Frontend_Manager {
87
  add_action('login_form_login', array($this, 'loginSubmit'), 1);
88
  }
89
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
90
  /**
91
  *
92
  * @param type $object
@@ -144,12 +165,9 @@ class AAM_Frontend_Manager {
144
  $object = $subject->getObject('loginRedirect');
145
 
146
  //if Login redirect is defined
147
- $type = $object->get('login.redirect.type');
148
- $redirect = AAM_Core_Request::request('aam_redirect');
149
 
150
- if (!empty($redirect)) {
151
- AAM_Core_API::redirect($redirect);
152
- }elseif (!empty($type) && $type !== 'default') {
153
  $redirect = $object->get("login.redirect.{$type}");
154
  AAM_Core_API::redirect($redirect);
155
  }
@@ -534,9 +552,7 @@ class AAM_Frontend_Manager {
534
  * @access public
535
  */
536
  public function checkAdminBar() {
537
- $caps = AAM_Core_API::getAllCapabilities();
538
-
539
- if (isset($caps['show_admin_bar'])) {
540
  if (!AAM::getUser()->hasCapability('show_admin_bar')) {
541
  show_admin_bar(false);
542
  }
75
  //core AAM filter
76
  add_filter('aam-object-filter', array($this, 'getObject'), 10, 4);
77
 
78
+ //login process
79
+ add_filter('login_message', array($this, 'loginMessage'));
80
+
81
  //admin bar
82
  $this->checkAdminBar();
83
  }
90
  add_action('login_form_login', array($this, 'loginSubmit'), 1);
91
  }
92
 
93
+ /**
94
+ *
95
+ * @param type $message
96
+ * @return type
97
+ */
98
+ public function loginMessage($message) {
99
+ $redirect = AAM_Core_Request::get('aam-redirect');
100
+
101
+ if (empty($message) && ($redirect == 'login')) {
102
+ $message = AAM_Core_Config::get(
103
+ 'redirect.login.message',
104
+ '<p class="message">Access denied. Please login to get access.</p>'
105
+ );
106
+ }
107
+
108
+ return $message;
109
+ }
110
+
111
  /**
112
  *
113
  * @param type $object
165
  $object = $subject->getObject('loginRedirect');
166
 
167
  //if Login redirect is defined
168
+ $type = $object->get('login.redirect.type');
 
169
 
170
+ if (!empty($type) && $type !== 'default') {
 
 
171
  $redirect = $object->get("login.redirect.{$type}");
172
  AAM_Core_API::redirect($redirect);
173
  }
552
  * @access public
553
  */
554
  public function checkAdminBar() {
555
+ if (AAM_Core_API::capabilityExists('show_admin_bar')) {
 
 
556
  if (!AAM::getUser()->hasCapability('show_admin_bar')) {
557
  show_admin_bar(false);
558
  }
Application/Shortcode/Strategy/Login.php CHANGED
@@ -55,9 +55,8 @@ class AAM_Shortcode_Strategy_Login implements AAM_Shortcode_Strategy_Interface {
55
  if (isset($this->args['callback'])) {
56
  $button = call_user_func($this->args['callback'], $this);
57
  } else {
58
- $url = str_replace(
59
- 'redirect_to=', 'aam_redirect=', wp_login_url($redirect)
60
- );
61
  $button = '<a href="' . $url . '" ';
62
  $button .= 'class="' . $class . '">' . $label . '</a>';
63
  }
55
  if (isset($this->args['callback'])) {
56
  $button = call_user_func($this->args['callback'], $this);
57
  } else {
58
+ $url = wp_login_url($redirect);
59
+
 
60
  $button = '<a href="' . $url . '" ';
61
  $button .= 'class="' . $class . '">' . $label . '</a>';
62
  }
aam.php CHANGED
@@ -2,10 +2,10 @@
2
 
3
  /**
4
  Plugin Name: Advanced Access Manager
5
- Description: Manage website access for any user, role or visitors
6
- Version: 4.6.2
7
  Author: Vasyl Martyniuk <vasyl@vasyltech.com>
8
- Author URI: https://www.vasyltech.com
9
 
10
  -------
11
  LICENSE: This file is subject to the terms and conditions defined in
@@ -152,7 +152,9 @@ class AAM {
152
  */
153
  public static function cron() {
154
  //grab the server extension list
155
- AAM_Core_API::updateOption('aam-check', AAM_Extension_Server::check(), 'site');
 
 
156
  }
157
 
158
  /**
@@ -228,7 +230,7 @@ if (defined('ABSPATH')) {
228
  wp_schedule_event(time(), 'daily', 'aam-cron');
229
  }
230
  add_action('aam-cron', 'AAM::cron');
231
-
232
  //activation & deactivation hooks
233
  register_activation_hook(__FILE__, array('AAM', 'activate'));
234
  register_uninstall_hook(__FILE__, array('AAM', 'uninstall'));
2
 
3
  /**
4
  Plugin Name: Advanced Access Manager
5
+ Description: All you need to manage access to your WordPress website
6
+ Version: 4.7
7
  Author: Vasyl Martyniuk <vasyl@vasyltech.com>
8
+ Author URI: https://vasyltech.com
9
 
10
  -------
11
  LICENSE: This file is subject to the terms and conditions defined in
152
  */
153
  public static function cron() {
154
  //grab the server extension list
155
+ AAM_Core_API::updateOption(
156
+ 'aam-check', AAM_Extension_Server::check(), 'site'
157
+ );
158
  }
159
 
160
  /**
230
  wp_schedule_event(time(), 'daily', 'aam-cron');
231
  }
232
  add_action('aam-cron', 'AAM::cron');
233
+
234
  //activation & deactivation hooks
235
  register_activation_hook(__FILE__, array('AAM', 'activate'));
236
  register_uninstall_hook(__FILE__, array('AAM', 'uninstall'));
media/css/aam.css CHANGED
@@ -28,7 +28,7 @@
28
  */
29
 
30
  [class^="icon-"]:before, [class*=" icon-"]:before {
31
- font-family: "fontello";
32
  font-style: normal;
33
  font-weight: normal;
34
  speak: none;
28
  */
29
 
30
  [class^="icon-"]:before, [class*=" icon-"]:before {
31
+ font-family: "fontello" !important;
32
  font-style: normal;
33
  font-weight: normal;
34
  speak: none;
media/js/aam-interface.js CHANGED
@@ -92,7 +92,7 @@
92
  infoFiltered: ''
93
  },
94
  initComplete: function () {
95
- if (!aam.isUI()) {
96
  var create = $('<a/>', {
97
  'href': '#',
98
  'class': 'btn btn-primary'
@@ -548,17 +548,17 @@
548
  infoFiltered: ''
549
  },
550
  initComplete: function () {
551
- if (!aam.isUI()) {
552
- var create = $('<a/>', {
553
- 'href': '#',
554
- 'class': 'btn btn-primary'
555
- }).html('<i class="icon-plus"></i> ' + aam.__('Create')).bind('click', function (event) {
556
- event.preventDefault();
557
- window.open(aamLocal.url.addUser, '_blank');
558
- });
559
 
560
- $('.dataTables_filter', '#user-list_wrapper').append(create);
561
- }
562
  },
563
  createdRow: function (row, data) {
564
  if (isCurrent(data[0])) {
92
  infoFiltered: ''
93
  },
94
  initComplete: function () {
95
+ if (!aam.isUI() && parseInt(aamLocal.caps.create_roles)) {
96
  var create = $('<a/>', {
97
  'href': '#',
98
  'class': 'btn btn-primary'
548
  infoFiltered: ''
549
  },
550
  initComplete: function () {
551
+ if (!aam.isUI() && parseInt(aamLocal.caps.create_users)) {
552
+ var create = $('<a/>', {
553
+ 'href': '#',
554
+ 'class': 'btn btn-primary'
555
+ }).html('<i class="icon-plus"></i> ' + aam.__('Create')).bind('click', function (event) {
556
+ event.preventDefault();
557
+ window.open(aamLocal.url.addUser, '_blank');
558
+ });
559
 
560
+ $('.dataTables_filter', '#user-list_wrapper').append(create);
561
+ }
562
  },
563
  createdRow: function (row, data) {
564
  if (isCurrent(data[0])) {
readme.txt CHANGED
@@ -2,8 +2,8 @@
2
  Contributors: vasyltech
3
  Tags: access, role, user, capability, page access, post access, security, login redirect, brute force attack, double authentication, membership, backend lockdown, wp-admin, 404, activity tracking
4
  Requires at least: 3.8
5
- Tested up to: 4.7.3
6
- Stable tag: 4.6.2
7
 
8
  Manage access to your website for any user, role or visitors for both frontend and backend.
9
 
@@ -19,7 +19,7 @@ Restrict access to your website backend side for any user or role. For more info
19
  refer to the [How to lockdown WordPress backend](https://aamplugin.com/help/how-to-lockdown-wordpress-backend)
20
 
21
  = Manage Posts & Categories =
22
- Manage access to any post, page or custom post type. With premium AAM Plus Package extension
23
  also manage access to categories, custom hierarchical taxonomies or setup the default
24
  access to all posts and categories. Refer to [How to manage WordPress post and category access](https://aamplugin.com/help/how-to-manage-wordpress-post-and-category-access)
25
  to learn more about this feature.
@@ -110,6 +110,16 @@ Check our [help page](https://aamplugin.com/help) to find out more about AAM.
110
 
111
  == Changelog ==
112
 
 
 
 
 
 
 
 
 
 
 
113
  = 4.6.2 =
114
  * Added ability to logout automatically locked user
115
  * Updated capability feature to allow set custom capabilities on user level
2
  Contributors: vasyltech
3
  Tags: access, role, user, capability, page access, post access, security, login redirect, brute force attack, double authentication, membership, backend lockdown, wp-admin, 404, activity tracking
4
  Requires at least: 3.8
5
+ Tested up to: 4.7.4
6
+ Stable tag: 4.7
7
 
8
  Manage access to your website for any user, role or visitors for both frontend and backend.
9
 
19
  refer to the [How to lockdown WordPress backend](https://aamplugin.com/help/how-to-lockdown-wordpress-backend)
20
 
21
  = Manage Posts & Categories =
22
+ Manage access to unlimited number of post, page or custom post type. With premium AAM Plus Package extension
23
  also manage access to categories, custom hierarchical taxonomies or setup the default
24
  access to all posts and categories. Refer to [How to manage WordPress post and category access](https://aamplugin.com/help/how-to-manage-wordpress-post-and-category-access)
25
  to learn more about this feature.
110
 
111
  == Changelog ==
112
 
113
+ = 4.7 =
114
+ * Significantly improved the ability to manage access to AAM interface
115
+ * Added new group of capabilities AAM Interface
116
+ * Optimized Posts & Pages UI feature for extra large amount of records
117
+ * BIGGEST DEAL! From now no more 10 posts limit. It is unlimited!
118
+ * Fixed bug with custom HTML message for access denied redirect
119
+ * Added option to redirect to login page and back after login when access is denied
120
+ * Significantly improved media access control
121
+ * Improved CSS to keep to suppress "bad behavior" from other plugins and themes
122
+
123
  = 4.6.2 =
124
  * Added ability to logout automatically locked user
125
  * Updated capability feature to allow set custom capabilities on user level