Version Description
- Fixed Bug: Very minor UI issue with Access Policy Delete pop-up
- Added New: Enhanced Access Policy with new POLICY_META token
- Change: Access Policy post type supports custom fields now
Download this release
Release Info
Developer | vasyltech |
Plugin | Advanced Access Manager |
Version | 6.2.1 |
Comparing to | |
See all releases |
Code changes from version 6.2.0 to 6.2.1
- aam.php +2 -2
- application/Backend/Feature/Main/Policy.php +22 -6
- application/Backend/View/Localization.php +5 -2
- application/Core/Policy/Condition.php +4 -77
- application/Core/Policy/Manager.php +18 -4
- application/Core/Policy/Token.php +22 -2
- application/Core/Policy/Typecast.php +115 -0
- application/Service/AccessPolicy.php +5 -2
- media/js/aam.js +7 -2
- readme.txt +6 -1
aam.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
/**
|
4 |
* Plugin Name: Advanced Access Manager
|
5 |
* Description: Collection of features to manage your WordPress website authentication, authorization and monitoring
|
6 |
-
* Version: 6.2.
|
7 |
* Author: Vasyl Martyniuk <vasyl@vasyltech.com>
|
8 |
* Author URI: https://vasyltech.com
|
9 |
* Text Domain: advanced-access-manager
|
@@ -264,7 +264,7 @@ if (defined('ABSPATH')) {
|
|
264 |
//define few common constants
|
265 |
define('AAM_MEDIA', plugins_url('/media', __FILE__));
|
266 |
define('AAM_KEY', 'advanced-access-manager');
|
267 |
-
define('AAM_VERSION', '6.2.
|
268 |
define('AAM_BASEDIR', __DIR__);
|
269 |
|
270 |
//load vendor
|
3 |
/**
|
4 |
* Plugin Name: Advanced Access Manager
|
5 |
* Description: Collection of features to manage your WordPress website authentication, authorization and monitoring
|
6 |
+
* Version: 6.2.1
|
7 |
* Author: Vasyl Martyniuk <vasyl@vasyltech.com>
|
8 |
* Author URI: https://vasyltech.com
|
9 |
* Text Domain: advanced-access-manager
|
264 |
//define few common constants
|
265 |
define('AAM_MEDIA', plugins_url('/media', __FILE__));
|
266 |
define('AAM_KEY', 'advanced-access-manager');
|
267 |
+
define('AAM_VERSION', '6.2.1');
|
268 |
define('AAM_BASEDIR', __DIR__);
|
269 |
|
270 |
//load vendor
|
application/Backend/Feature/Main/Policy.php
CHANGED
@@ -356,18 +356,22 @@ extends AAM_Backend_Feature_Abstract implements AAM_Backend_Feature_ISubjectAwar
|
|
356 |
*
|
357 |
* @return string
|
358 |
*
|
|
|
|
|
|
|
359 |
* @access public
|
360 |
-
* @version 6.2.
|
361 |
*/
|
362 |
public function install()
|
363 |
{
|
364 |
-
$metadata
|
365 |
|
366 |
// Do some basic validation & normalization
|
367 |
$title = esc_js($metadata->title);
|
368 |
$excerpt = esc_js($metadata->description);
|
369 |
$assignee = $metadata->assignee;
|
370 |
$override = $metadata->override;
|
|
|
371 |
$policy = $this->getFromPost('aam-policy');
|
372 |
|
373 |
$id = wp_insert_post(array(
|
@@ -394,14 +398,26 @@ extends AAM_Backend_Feature_Abstract implements AAM_Backend_Feature_ISubjectAwar
|
|
394 |
$errors[] = $error;
|
395 |
}
|
396 |
}
|
|
|
|
|
|
|
|
|
|
|
397 |
} else {
|
398 |
$errors[] = $id->get_error_message();
|
399 |
}
|
400 |
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
405 |
}
|
406 |
|
407 |
/**
|
356 |
*
|
357 |
* @return string
|
358 |
*
|
359 |
+
* @since 6.2.1 Added support for the policy_meta property
|
360 |
+
* @since 6.2.0 Initial implementation of the method
|
361 |
+
*
|
362 |
* @access public
|
363 |
+
* @version 6.2.1
|
364 |
*/
|
365 |
public function install()
|
366 |
{
|
367 |
+
$metadata = json_decode($this->getFromPost('metadata'));
|
368 |
|
369 |
// Do some basic validation & normalization
|
370 |
$title = esc_js($metadata->title);
|
371 |
$excerpt = esc_js($metadata->description);
|
372 |
$assignee = $metadata->assignee;
|
373 |
$override = $metadata->override;
|
374 |
+
$consts = !empty($metadata->policy_meta) ? $metadata->policy_meta: array();
|
375 |
$policy = $this->getFromPost('aam-policy');
|
376 |
|
377 |
$id = wp_insert_post(array(
|
398 |
$errors[] = $error;
|
399 |
}
|
400 |
}
|
401 |
+
|
402 |
+
// Insert policy meta values if any
|
403 |
+
foreach($consts as $key => $value) {
|
404 |
+
add_post_meta($id, $key, $value);
|
405 |
+
}
|
406 |
} else {
|
407 |
$errors[] = $id->get_error_message();
|
408 |
}
|
409 |
|
410 |
+
if (!empty($errors)) {
|
411 |
+
$response = array(
|
412 |
+
'status' => 'failure', 'errors' => implode('; ', $errors)
|
413 |
+
);
|
414 |
+
} else {
|
415 |
+
$response = array(
|
416 |
+
'status' => 'success', 'redirect' => get_edit_post_link($id, 'link')
|
417 |
+
);
|
418 |
+
}
|
419 |
+
|
420 |
+
return wp_json_encode($response);
|
421 |
}
|
422 |
|
423 |
/**
|
application/Backend/View/Localization.php
CHANGED
@@ -10,11 +10,12 @@
|
|
10 |
/**
|
11 |
* JS localization for AAM backend UI
|
12 |
*
|
|
|
13 |
* @since 6.2.0 Added couple new labels
|
14 |
* @since 6.0.0 Initial implementation of the class
|
15 |
*
|
16 |
* @package AAM
|
17 |
-
* @version 6.2.
|
18 |
*/
|
19 |
class AAM_Backend_View_Localization
|
20 |
{
|
@@ -24,11 +25,12 @@ class AAM_Backend_View_Localization
|
|
24 |
*
|
25 |
* @return array
|
26 |
*
|
|
|
27 |
* @since 6.2.0 Added couple new labels
|
28 |
* @since 6.0.0 Initial implementation of the method
|
29 |
*
|
30 |
* @access public
|
31 |
-
* @version 6.2.
|
32 |
*/
|
33 |
public static function get()
|
34 |
{
|
@@ -142,6 +144,7 @@ class AAM_Backend_View_Localization
|
|
142 |
'All settings has been cleared successfully' => __('All settings has been cleared successfully', AAM_KEY),
|
143 |
'Clear' => __('Clear', AAM_KEY),
|
144 |
'Select Role' => __('Select Role', AAM_KEY),
|
|
|
145 |
'Data has been saved to clipboard' => __('Data has been saved to clipboard', AAM_KEY),
|
146 |
'Failed to save data to clipboard' => __('Failed to save data to clipboard', AAM_KEY),
|
147 |
'Operation completed successfully' => __('Operation completed successfully', AAM_KEY),
|
10 |
/**
|
11 |
* JS localization for AAM backend UI
|
12 |
*
|
13 |
+
* @since 6.2.1 Added new label "Policy is not assigned to anybody"
|
14 |
* @since 6.2.0 Added couple new labels
|
15 |
* @since 6.0.0 Initial implementation of the class
|
16 |
*
|
17 |
* @package AAM
|
18 |
+
* @version 6.2.1
|
19 |
*/
|
20 |
class AAM_Backend_View_Localization
|
21 |
{
|
25 |
*
|
26 |
* @return array
|
27 |
*
|
28 |
+
* @since 6.2.1 Added new label "Policy is not assigned to anybody"
|
29 |
* @since 6.2.0 Added couple new labels
|
30 |
* @since 6.0.0 Initial implementation of the method
|
31 |
*
|
32 |
* @access public
|
33 |
+
* @version 6.2.1
|
34 |
*/
|
35 |
public static function get()
|
36 |
{
|
144 |
'All settings has been cleared successfully' => __('All settings has been cleared successfully', AAM_KEY),
|
145 |
'Clear' => __('Clear', AAM_KEY),
|
146 |
'Select Role' => __('Select Role', AAM_KEY),
|
147 |
+
'Policy is not assigned to anybody' => __('Policy is not assigned to anybody', AAM_KEY),
|
148 |
'Data has been saved to clipboard' => __('Data has been saved to clipboard', AAM_KEY),
|
149 |
'Failed to save data to clipboard' => __('Failed to save data to clipboard', AAM_KEY),
|
150 |
'Operation completed successfully' => __('Operation completed successfully', AAM_KEY),
|
application/Core/Policy/Condition.php
CHANGED
@@ -384,12 +384,13 @@ class AAM_Core_Policy_Condition
|
|
384 |
*
|
385 |
* @return mixed Prepared part of the condition or false on failure
|
386 |
*
|
|
|
387 |
* @since 6.2.0 Added support for new `date` type
|
388 |
* @since 6.1.0 Improved type casing functionality
|
389 |
* @since 6.0.0 Initial implementation of the method
|
390 |
*
|
391 |
* @access protected
|
392 |
-
* @version 6.2.
|
393 |
*/
|
394 |
public function parseExpression($exp, $args)
|
395 |
{
|
@@ -398,15 +399,8 @@ class AAM_Core_Policy_Condition
|
|
398 |
$exp = AAM_Core_Policy_Token::evaluate($exp, $match[1], $args);
|
399 |
}
|
400 |
|
401 |
-
|
402 |
-
|
403 |
-
// Note! It make no sense to have multiple type casting for one expression
|
404 |
-
// due to the fact that they all would have to be concatenated as a string
|
405 |
-
|
406 |
-
// If there is type casting, perform it too
|
407 |
-
if (preg_match('/^\(\*(' . $types . ')\)(.*)/i', $exp, $scale)) {
|
408 |
-
$exp = $this->_typecast($scale[2], $scale[1]);
|
409 |
-
}
|
410 |
} elseif (is_array($exp) || is_object($exp)) {
|
411 |
foreach ($exp as &$value) {
|
412 |
$value = $this->parseExpression($value, $args);
|
@@ -418,71 +412,4 @@ class AAM_Core_Policy_Condition
|
|
418 |
return $exp;
|
419 |
}
|
420 |
|
421 |
-
/**
|
422 |
-
* Cast value to specific type
|
423 |
-
*
|
424 |
-
* @param mixed $value
|
425 |
-
* @param string $type
|
426 |
-
*
|
427 |
-
* @return mixed
|
428 |
-
*
|
429 |
-
* @version 6.2.0 Added support for the `date` type
|
430 |
-
* @version 6.1.0 Renamed the method from `castValue` to `_typecast`. Added new
|
431 |
-
* filter `aam_token_typecast_filter`
|
432 |
-
* @version 6.0.0 Initial implementation of the method
|
433 |
-
*
|
434 |
-
* @access protected
|
435 |
-
* @version 6.2.0
|
436 |
-
*/
|
437 |
-
private function _typecast($value, $type)
|
438 |
-
{
|
439 |
-
switch (strtolower($type)) {
|
440 |
-
case 'string':
|
441 |
-
$value = (string) $value;
|
442 |
-
break;
|
443 |
-
|
444 |
-
case 'ip':
|
445 |
-
$value = inet_pton($value);
|
446 |
-
break;
|
447 |
-
|
448 |
-
case 'int':
|
449 |
-
$value = (int) $value;
|
450 |
-
break;
|
451 |
-
|
452 |
-
case 'boolean':
|
453 |
-
case 'bool':
|
454 |
-
$value = filter_var($value, FILTER_VALIDATE_BOOLEAN);
|
455 |
-
break;
|
456 |
-
|
457 |
-
case 'array':
|
458 |
-
$value = json_decode($value, true);
|
459 |
-
break;
|
460 |
-
|
461 |
-
case 'null':
|
462 |
-
$value = ($value === '' ? null : $value);
|
463 |
-
break;
|
464 |
-
|
465 |
-
case 'date':
|
466 |
-
try {
|
467 |
-
$value = new DateTime(
|
468 |
-
$value,
|
469 |
-
new DateTimeZone('UTC')
|
470 |
-
);
|
471 |
-
} catch(Exception $e) {
|
472 |
-
_doing_it_wrong(
|
473 |
-
__CLASS__ . '::' . __METHOD__,
|
474 |
-
'Cannot typecast value to DateTime',
|
475 |
-
AAM_VERSION
|
476 |
-
);
|
477 |
-
$value = null;
|
478 |
-
}
|
479 |
-
break;
|
480 |
-
|
481 |
-
default:
|
482 |
-
$value = apply_filters('aam_token_typecast_filter', $value, $type);
|
483 |
-
break;
|
484 |
-
}
|
485 |
-
|
486 |
-
return $value;
|
487 |
-
}
|
488 |
}
|
384 |
*
|
385 |
* @return mixed Prepared part of the condition or false on failure
|
386 |
*
|
387 |
+
* @since 6.2.1 Moved type casting to the separate class
|
388 |
* @since 6.2.0 Added support for new `date` type
|
389 |
* @since 6.1.0 Improved type casing functionality
|
390 |
* @since 6.0.0 Initial implementation of the method
|
391 |
*
|
392 |
* @access protected
|
393 |
+
* @version 6.2.1
|
394 |
*/
|
395 |
public function parseExpression($exp, $args)
|
396 |
{
|
399 |
$exp = AAM_Core_Policy_Token::evaluate($exp, $match[1], $args);
|
400 |
}
|
401 |
|
402 |
+
// Perform type casting if necessary
|
403 |
+
$exp = AAM_Core_Policy_Typecast::execute($exp);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
404 |
} elseif (is_array($exp) || is_object($exp)) {
|
405 |
foreach ($exp as &$value) {
|
406 |
$value = $this->parseExpression($value, $args);
|
412 |
return $exp;
|
413 |
}
|
414 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
415 |
}
|
application/Core/Policy/Manager.php
CHANGED
@@ -10,13 +10,14 @@
|
|
10 |
/**
|
11 |
* AAM policy manager for a specific subject
|
12 |
*
|
|
|
13 |
* @since 6.2.0 Fetched the way access policies are fetched
|
14 |
* @since 6.1.0 Implemented `=>` operator. Improved inheritance mechanism
|
15 |
* @since 6.0.4 Potential bug fix with improperly merged Param option:* values
|
16 |
* @since 6.0.0 Initial implementation of the class
|
17 |
*
|
18 |
* @package AAM
|
19 |
-
* @version 6.2.
|
20 |
*/
|
21 |
class AAM_Core_Policy_Manager
|
22 |
{
|
@@ -342,12 +343,21 @@ class AAM_Core_Policy_Manager
|
|
342 |
*
|
343 |
* @return array
|
344 |
*
|
|
|
|
|
|
|
345 |
* @access protected
|
346 |
-
* @version 6.
|
347 |
*/
|
348 |
protected function parsePolicy($policy)
|
349 |
{
|
350 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
351 |
|
352 |
// Do not load the policy if any errors
|
353 |
if (json_last_error() === JSON_ERROR_NONE) {
|
@@ -406,11 +416,12 @@ class AAM_Core_Policy_Manager
|
|
406 |
*
|
407 |
* @return array
|
408 |
*
|
|
|
409 |
* @since 6.1.0 Added support for the `=>` (map to) operator
|
410 |
* @since 6.0.0 Initial implementation of the method
|
411 |
*
|
412 |
* @access protected
|
413 |
-
* @version 6.1
|
414 |
*/
|
415 |
protected function updatePolicyTree(&$tree, $addition)
|
416 |
{
|
@@ -467,6 +478,9 @@ class AAM_Core_Policy_Manager
|
|
467 |
$id = $param['Key'];
|
468 |
}
|
469 |
|
|
|
|
|
|
|
470 |
if (!isset($params[$id]) || empty($params[$id]['Enforce'])) {
|
471 |
$params[$id] = $param;
|
472 |
|
10 |
/**
|
11 |
* AAM policy manager for a specific subject
|
12 |
*
|
13 |
+
* @since 6.2.1 Added support for the POLICY_META token
|
14 |
* @since 6.2.0 Fetched the way access policies are fetched
|
15 |
* @since 6.1.0 Implemented `=>` operator. Improved inheritance mechanism
|
16 |
* @since 6.0.4 Potential bug fix with improperly merged Param option:* values
|
17 |
* @since 6.0.0 Initial implementation of the class
|
18 |
*
|
19 |
* @package AAM
|
20 |
+
* @version 6.2.1
|
21 |
*/
|
22 |
class AAM_Core_Policy_Manager
|
23 |
{
|
343 |
*
|
344 |
* @return array
|
345 |
*
|
346 |
+
* @since 6.2.1 Added support for the POLICY_META token
|
347 |
+
* @since 6.0.0 Initial implementation of the method
|
348 |
+
*
|
349 |
* @access protected
|
350 |
+
* @version 6.2.1
|
351 |
*/
|
352 |
protected function parsePolicy($policy)
|
353 |
{
|
354 |
+
// Any ${POLICY_META. replace with ${POLICY_META.123
|
355 |
+
$json = str_replace(
|
356 |
+
'${POLICY_META.',
|
357 |
+
'${POLICY_META.' . $policy->ID . '.',
|
358 |
+
$policy->post_content
|
359 |
+
);
|
360 |
+
$val = json_decode($json, true);
|
361 |
|
362 |
// Do not load the policy if any errors
|
363 |
if (json_last_error() === JSON_ERROR_NONE) {
|
416 |
*
|
417 |
* @return array
|
418 |
*
|
419 |
+
* @since 6.2.1 Typecasting param's value
|
420 |
* @since 6.1.0 Added support for the `=>` (map to) operator
|
421 |
* @since 6.0.0 Initial implementation of the method
|
422 |
*
|
423 |
* @access protected
|
424 |
+
* @version 6.2.1
|
425 |
*/
|
426 |
protected function updatePolicyTree(&$tree, $addition)
|
427 |
{
|
478 |
$id = $param['Key'];
|
479 |
}
|
480 |
|
481 |
+
// If necessary typecast the params value
|
482 |
+
$param['Value'] = AAM_Core_Policy_Typecast::execute($param['Value']);
|
483 |
+
|
484 |
if (!isset($params[$id]) || empty($params[$id]['Enforce'])) {
|
485 |
$params[$id] = $param;
|
486 |
|
application/Core/Policy/Token.php
CHANGED
@@ -10,13 +10,14 @@
|
|
10 |
/**
|
11 |
* AAM core policy token evaluator
|
12 |
*
|
|
|
13 |
* @since 6.2.0 Enhanced access policy with more tokens. DATETIME now returns time in
|
14 |
* UTC timezone
|
15 |
* @since 6.1.0 Added support for the new token `AAM_CONFIG`
|
16 |
* @since 6.0.0 Initial implementation of the class
|
17 |
*
|
18 |
* @package AAM
|
19 |
-
* @version 6.2.
|
20 |
*/
|
21 |
class AAM_Core_Policy_Token
|
22 |
{
|
@@ -26,13 +27,14 @@ class AAM_Core_Policy_Token
|
|
26 |
*
|
27 |
* @var array
|
28 |
*
|
|
|
29 |
* @since 6.2.0 Added `POLICY_PARAM`, `WP_SITE` token & changed the
|
30 |
* DATETIME callback
|
31 |
* @since 6.1.0 Added `AAM_CONFIG` token
|
32 |
* @since 6.0.0 Initial implementation of the property
|
33 |
*
|
34 |
* @access protected
|
35 |
-
* @version 6.2.
|
36 |
*/
|
37 |
protected static $map = array(
|
38 |
'USER' => 'AAM_Core_Policy_Token::getUserValue',
|
@@ -51,6 +53,7 @@ class AAM_Core_Policy_Token
|
|
51 |
'JWT' => 'AAM_Core_Policy_Token::getJwtClaim',
|
52 |
'AAM_CONFIG' => 'AAM_Core_Policy_Token::getConfig',
|
53 |
'POLICY_PARAM' => 'AAM_Core_Policy_Token::getParam',
|
|
|
54 |
'WP_SITE' => 'AAM_Core_Policy_Token::getSiteParam'
|
55 |
);
|
56 |
|
@@ -285,6 +288,23 @@ class AAM_Core_Policy_Token
|
|
285 |
return AAM::api()->getAccessPolicyManager()->getParam($param);
|
286 |
}
|
287 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
288 |
/**
|
289 |
* Get current datetime
|
290 |
*
|
10 |
/**
|
11 |
* AAM core policy token evaluator
|
12 |
*
|
13 |
+
* @since 6.2.1 Added POLICY_META token
|
14 |
* @since 6.2.0 Enhanced access policy with more tokens. DATETIME now returns time in
|
15 |
* UTC timezone
|
16 |
* @since 6.1.0 Added support for the new token `AAM_CONFIG`
|
17 |
* @since 6.0.0 Initial implementation of the class
|
18 |
*
|
19 |
* @package AAM
|
20 |
+
* @version 6.2.1
|
21 |
*/
|
22 |
class AAM_Core_Policy_Token
|
23 |
{
|
27 |
*
|
28 |
* @var array
|
29 |
*
|
30 |
+
* @since 6.2.1 Added `POLICY_META` token
|
31 |
* @since 6.2.0 Added `POLICY_PARAM`, `WP_SITE` token & changed the
|
32 |
* DATETIME callback
|
33 |
* @since 6.1.0 Added `AAM_CONFIG` token
|
34 |
* @since 6.0.0 Initial implementation of the property
|
35 |
*
|
36 |
* @access protected
|
37 |
+
* @version 6.2.1
|
38 |
*/
|
39 |
protected static $map = array(
|
40 |
'USER' => 'AAM_Core_Policy_Token::getUserValue',
|
53 |
'JWT' => 'AAM_Core_Policy_Token::getJwtClaim',
|
54 |
'AAM_CONFIG' => 'AAM_Core_Policy_Token::getConfig',
|
55 |
'POLICY_PARAM' => 'AAM_Core_Policy_Token::getParam',
|
56 |
+
'POLICY_META' => 'AAM_Core_Policy_Token::getPolicyMeta',
|
57 |
'WP_SITE' => 'AAM_Core_Policy_Token::getSiteParam'
|
58 |
);
|
59 |
|
288 |
return AAM::api()->getAccessPolicyManager()->getParam($param);
|
289 |
}
|
290 |
|
291 |
+
/**
|
292 |
+
* Get access policy metadata
|
293 |
+
*
|
294 |
+
* @param string $meta
|
295 |
+
*
|
296 |
+
* @return mixed
|
297 |
+
*
|
298 |
+
* @access protected
|
299 |
+
* @version 6.2.1
|
300 |
+
*/
|
301 |
+
protected static function getPolicyMeta($meta)
|
302 |
+
{
|
303 |
+
list($policyId, $param) = explode('.', $meta, 2);
|
304 |
+
|
305 |
+
return get_post_meta($policyId, $param, true);
|
306 |
+
}
|
307 |
+
|
308 |
/**
|
309 |
* Get current datetime
|
310 |
*
|
application/Core/Policy/Typecast.php
ADDED
@@ -0,0 +1,115 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* ======================================================================
|
5 |
+
* LICENSE: This file is subject to the terms and conditions defined in *
|
6 |
+
* file 'license.txt', which is part of this source code package. *
|
7 |
+
* ======================================================================
|
8 |
+
*/
|
9 |
+
|
10 |
+
/**
|
11 |
+
* AAM core policy type casting
|
12 |
+
*
|
13 |
+
* @package AAM
|
14 |
+
* @version 6.2.1
|
15 |
+
*/
|
16 |
+
class AAM_Core_Policy_Typecast
|
17 |
+
{
|
18 |
+
|
19 |
+
/**
|
20 |
+
* Support types
|
21 |
+
*
|
22 |
+
* @version 6.2.1
|
23 |
+
*/
|
24 |
+
const SUPPORTED_TYPES = 'string|ip|int|boolean|bool|array|null|date';
|
25 |
+
|
26 |
+
/**
|
27 |
+
* Execute type casting
|
28 |
+
*
|
29 |
+
* @param string $expression
|
30 |
+
*
|
31 |
+
* @return mixed
|
32 |
+
*
|
33 |
+
* @access public
|
34 |
+
* @version 6.2.1
|
35 |
+
*/
|
36 |
+
public static function execute($expression)
|
37 |
+
{
|
38 |
+
$regex = '/^\(\*(' . self::SUPPORTED_TYPES . ')\)(.*)/i';
|
39 |
+
|
40 |
+
// Note! It make no sense to have multiple type casting for one expression
|
41 |
+
// due to the fact that they all would have to be concatenated as a string
|
42 |
+
|
43 |
+
// If there is type casting, perform it
|
44 |
+
if (preg_match( $regex, $expression, $scale)) {
|
45 |
+
$expression = self::_typecast($scale[2], $scale[1]);
|
46 |
+
}
|
47 |
+
|
48 |
+
return $expression;
|
49 |
+
}
|
50 |
+
|
51 |
+
|
52 |
+
/**
|
53 |
+
* Cast value to specific type
|
54 |
+
*
|
55 |
+
* @param mixed $value
|
56 |
+
* @param string $type
|
57 |
+
*
|
58 |
+
* @return mixed
|
59 |
+
*
|
60 |
+
* @access protected
|
61 |
+
* @version 6.2.1
|
62 |
+
*/
|
63 |
+
private static function _typecast($value, $type)
|
64 |
+
{
|
65 |
+
switch (strtolower($type)) {
|
66 |
+
case 'string':
|
67 |
+
$value = (string) $value;
|
68 |
+
break;
|
69 |
+
|
70 |
+
case 'ip':
|
71 |
+
$value = inet_pton($value);
|
72 |
+
break;
|
73 |
+
|
74 |
+
case 'int':
|
75 |
+
$value = (int) $value;
|
76 |
+
break;
|
77 |
+
|
78 |
+
case 'boolean':
|
79 |
+
case 'bool':
|
80 |
+
$value = filter_var($value, FILTER_VALIDATE_BOOLEAN);
|
81 |
+
break;
|
82 |
+
|
83 |
+
case 'array':
|
84 |
+
$value = json_decode($value, true);
|
85 |
+
break;
|
86 |
+
|
87 |
+
case 'null':
|
88 |
+
$value = ($value === '' ? null : $value);
|
89 |
+
break;
|
90 |
+
|
91 |
+
case 'date':
|
92 |
+
try {
|
93 |
+
$value = new DateTime(
|
94 |
+
$value,
|
95 |
+
new DateTimeZone('UTC')
|
96 |
+
);
|
97 |
+
} catch(Exception $e) {
|
98 |
+
_doing_it_wrong(
|
99 |
+
__CLASS__ . '::' . __METHOD__,
|
100 |
+
'Cannot typecast value to DateTime',
|
101 |
+
AAM_VERSION
|
102 |
+
);
|
103 |
+
$value = null;
|
104 |
+
}
|
105 |
+
break;
|
106 |
+
|
107 |
+
default:
|
108 |
+
$value = apply_filters('aam_token_typecast_filter', $value, $type);
|
109 |
+
break;
|
110 |
+
}
|
111 |
+
|
112 |
+
return $value;
|
113 |
+
}
|
114 |
+
|
115 |
+
}
|
application/Service/AccessPolicy.php
CHANGED
@@ -158,12 +158,13 @@ class AAM_Service_AccessPolicy
|
|
158 |
*
|
159 |
* @return void
|
160 |
*
|
|
|
161 |
* @since 6.2.0 Added new hook into Multisite service through `aam_allowed_site_filter`
|
162 |
* @since 6.1.1 Refactored the way access policy is applied to object
|
163 |
* @since 6.0.0 Initial implementation of the method
|
164 |
*
|
165 |
* @access protected
|
166 |
-
* @version 6.2.
|
167 |
*/
|
168 |
protected function initializeHooks()
|
169 |
{
|
@@ -185,7 +186,9 @@ class AAM_Service_AccessPolicy
|
|
185 |
'exclude_from_search' => true,
|
186 |
'publicly_queryable' => false,
|
187 |
'hierarchical' => false,
|
188 |
-
'supports' => array(
|
|
|
|
|
189 |
'delete_with_user' => false,
|
190 |
'capabilities' => array(
|
191 |
'edit_post' => 'aam_edit_policy',
|
158 |
*
|
159 |
* @return void
|
160 |
*
|
161 |
+
* @since 6.2.1 Access support for custom-fields
|
162 |
* @since 6.2.0 Added new hook into Multisite service through `aam_allowed_site_filter`
|
163 |
* @since 6.1.1 Refactored the way access policy is applied to object
|
164 |
* @since 6.0.0 Initial implementation of the method
|
165 |
*
|
166 |
* @access protected
|
167 |
+
* @version 6.2.1
|
168 |
*/
|
169 |
protected function initializeHooks()
|
170 |
{
|
186 |
'exclude_from_search' => true,
|
187 |
'publicly_queryable' => false,
|
188 |
'hierarchical' => false,
|
189 |
+
'supports' => array(
|
190 |
+
'title', 'excerpt', 'revisions', 'custom-fields'
|
191 |
+
),
|
192 |
'delete_with_user' => false,
|
193 |
'capabilities' => array(
|
194 |
'edit_post' => 'aam_edit_policy',
|
media/js/aam.js
CHANGED
@@ -1441,7 +1441,7 @@
|
|
1441 |
var message = $('.aam-confirm-message', '#delete-policy-modal').data('message');
|
1442 |
|
1443 |
// replace some dynamic parts
|
1444 |
-
message = message.replace('%s', '<b>' + data[
|
1445 |
$('.aam-confirm-message', '#delete-policy-modal').html(message);
|
1446 |
|
1447 |
$('#delete-policy-btn').attr('data-id', data[0]);
|
@@ -1532,7 +1532,11 @@
|
|
1532 |
assignees.push(buildSubject(val, false));
|
1533 |
});
|
1534 |
|
1535 |
-
|
|
|
|
|
|
|
|
|
1536 |
|
1537 |
policy = response;
|
1538 |
},
|
@@ -1565,6 +1569,7 @@
|
|
1565 |
);
|
1566 |
$('#policy-list').DataTable().ajax.reload();
|
1567 |
$('#modal-install-policy').modal('hide');
|
|
|
1568 |
} else {
|
1569 |
getAAM().notification('danger', response.errors);
|
1570 |
}
|
1441 |
var message = $('.aam-confirm-message', '#delete-policy-modal').data('message');
|
1442 |
|
1443 |
// replace some dynamic parts
|
1444 |
+
message = message.replace('%s', '<b>' + data[4] + '</b>');
|
1445 |
$('.aam-confirm-message', '#delete-policy-modal').html(message);
|
1446 |
|
1447 |
$('#delete-policy-btn').attr('data-id', data[0]);
|
1532 |
assignees.push(buildSubject(val, false));
|
1533 |
});
|
1534 |
|
1535 |
+
if (assignees.length) {
|
1536 |
+
$('#policy-subjects').html(assignees.join('; '));
|
1537 |
+
} else {
|
1538 |
+
$('#policy-subjects').html(getAAM().__('Policy is not assigned to anybody'));
|
1539 |
+
}
|
1540 |
|
1541 |
policy = response;
|
1542 |
},
|
1569 |
);
|
1570 |
$('#policy-list').DataTable().ajax.reload();
|
1571 |
$('#modal-install-policy').modal('hide');
|
1572 |
+
window.open(response.redirect, '_blank');
|
1573 |
} else {
|
1574 |
getAAM().notification('danger', response.errors);
|
1575 |
}
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Tags: access control, membership, backend menu, user role, restricted content, s
|
|
4 |
Requires at least: 4.7.0
|
5 |
Requires PHP: 5.6.0
|
6 |
Tested up to: 5.3.2
|
7 |
-
Stable tag: 6.2.
|
8 |
|
9 |
All you need to manage access to WordPress websites on the frontend, backend and API levels for any role, user or visitors.
|
10 |
|
@@ -91,6 +91,11 @@ We take security and privacy very seriously, that is why there are several non-n
|
|
91 |
|
92 |
== Changelog ==
|
93 |
|
|
|
|
|
|
|
|
|
|
|
94 |
= 6.2.0 =
|
95 |
* Fixed Bug: Access policy was not applied to visitors
|
96 |
* Fixed Bug: Bug fixing that is related to unwanted PHP notices [https://forum.aamplugin.com/d/456-notice-undefined-index-expire](https://forum.aamplugin.com/d/456-notice-undefined-index-expire)
|
4 |
Requires at least: 4.7.0
|
5 |
Requires PHP: 5.6.0
|
6 |
Tested up to: 5.3.2
|
7 |
+
Stable tag: 6.2.1
|
8 |
|
9 |
All you need to manage access to WordPress websites on the frontend, backend and API levels for any role, user or visitors.
|
10 |
|
91 |
|
92 |
== Changelog ==
|
93 |
|
94 |
+
= 6.2.1 =
|
95 |
+
* Fixed Bug: Very minor UI issue with Access Policy Delete pop-up
|
96 |
+
* Added New: Enhanced Access Policy with new [POLICY_META](https://aamplugin.com/reference/policy#policy_meta) token
|
97 |
+
* Change: Access Policy post type supports custom fields now
|
98 |
+
|
99 |
= 6.2.0 =
|
100 |
* Fixed Bug: Access policy was not applied to visitors
|
101 |
* Fixed Bug: Bug fixing that is related to unwanted PHP notices [https://forum.aamplugin.com/d/456-notice-undefined-index-expire](https://forum.aamplugin.com/d/456-notice-undefined-index-expire)
|