|
3 | 3 | Plugin Name: Auth Manager Plus
|
4 | 4 | Plugin URI: https://github.com/joshp23/YOURLS-AuthMgrPlus
|
5 | 5 | Description: Role Based Access Controlls with seperated user data for authenticated users
|
6 |
| -Version: 2.2.2 |
| 6 | +Version: 2.2.3 |
7 | 7 | Author: Josh Panter, nicwaller, Ian Barber <[email protected]>
|
8 | 8 | Author URI: https://unfettered.net
|
9 | 9 | */
|
@@ -76,37 +76,36 @@ function amp_intercept_admin() {
|
76 | 76 | yourls_add_notice('Access Denied');
|
77 | 77 | }
|
78 | 78 |
|
79 |
| - $action_capability_map = array( |
80 |
| - 'add' => ampCap::AddURL, |
81 |
| - 'delete' => ampCap::DeleteURL, |
82 |
| - 'edit_display' => ampCap::EditURL, |
83 |
| - 'edit_save' => ampCap::EditURL, |
84 |
| - 'activate' => ampCap::ManagePlugins, |
85 |
| - 'deactivate' => ampCap::ManagePlugins, |
86 |
| - ); |
87 |
| - // allow manipulation of this list ( be mindfull of extending Authmp Capability class if needed ) |
88 |
| - yourls_apply_filter( 'amp_action_capability_map', $action_capability_map); |
| 79 | + // allow manipulation of this list ( be mindfull of extending Auth mp Capability class if needed ) |
| 80 | + $action_capability_map = yourls_apply_filter( 'amp_action_capability_map', |
| 81 | + array( 'add' => ampCap::AddURL, |
| 82 | + 'delete' => ampCap::DeleteURL, |
| 83 | + 'edit_display' => ampCap::EditURL, |
| 84 | + 'edit_save' => ampCap::EditURL, |
| 85 | + 'activate' => ampCap::ManagePlugins, |
| 86 | + 'deactivate' => ampCap::ManagePlugins, |
| 87 | + ) ); |
89 | 88 |
|
90 | 89 | // Key actions like Add/Edit/Delete are AJAX requests
|
91 | 90 | if ( yourls_is_Ajax() ) {
|
92 | 91 |
|
93 | 92 | // Define some boundaries for ownership
|
94 |
| - $restricted_actions = array( 'edit_display', |
95 |
| - 'edit_save', |
96 |
| - 'delete' |
97 |
| - ); |
98 |
| - |
99 | 93 | // Allow some flexability with those boundaries
|
100 |
| - yourls_apply_filter( 'amp_restricted_ajax_actions', $restricted_actions ); |
| 94 | + $restricted_actions = yourls_apply_filter( 'amp_restricted_ajax_actions', |
| 95 | + array( 'edit_display', |
| 96 | + 'edit_save', |
| 97 | + 'delete' |
| 98 | + ) ); |
101 | 99 |
|
102 | 100 | $action_keyword = $_REQUEST['action'];
|
| 101 | + $cap_needed = $action_capability_map[$action_keyword]; |
103 | 102 |
|
104 | 103 | // Check the action against those boundaries
|
105 | 104 | if ( in_array( $action_keyword, $restricted_actions) ) {
|
106 | 105 | $keyword = $_REQUEST['keyword'];
|
107 |
| - $do = amp_manage_keyword( $keyword, $action_capability_map[$action_keyword] ); |
| 106 | + $do = amp_manage_keyword( $keyword, $cap_needed ); |
108 | 107 | } else {
|
109 |
| - $do = amp_have_capability( $action_capability_map[$action_keyword] ); |
| 108 | + $do = amp_have_capability( $cap_needed ); |
110 | 109 | }
|
111 | 110 |
|
112 | 111 | if ( $do !== true ) {
|
@@ -442,16 +441,6 @@ function amp_env_check() {
|
442 | 441 | $amp_role_assignment = $amp_role_assignment_lower;
|
443 | 442 | unset($amp_role_assignment_lower);
|
444 | 443 |
|
445 |
| - // allow manipulation of env by other plugins |
446 |
| - // be mindfull of extending ampCap and ampRoles classes if needed |
447 |
| - $a = $amp_anon_capabilities; |
448 |
| - $b = $amp_role_capabilities; |
449 |
| - $c = $amp_role_assignment; |
450 |
| - $d = $amp_admin_ipranges; |
451 |
| - $e = $amp_allowed_plugin_pages; |
452 |
| - |
453 |
| - yourls_apply_filter( 'amp_env_check', $a, $b, $c, $d, $e ); |
454 |
| - |
455 | 444 | return true;
|
456 | 445 | }
|
457 | 446 |
|
@@ -500,16 +489,14 @@ function amp_current_capabilities() {
|
500 | 489 | ampCap::ViewStats,
|
501 | 490 | ampCap::ViewAll,
|
502 | 491 | );
|
503 |
| - // allow manipulation of this list ( be mindfull of extending the ampCap class if needed ) |
504 |
| - yourls_apply_filter( 'amp_current_capabilities', $all_capabilities); |
505 | 492 |
|
506 | 493 | foreach ( $all_capabilities as $cap ) {
|
507 | 494 | if ( amp_have_capability( $cap ) ) {
|
508 | 495 | $current_capabilities[] = $cap;
|
509 | 496 | }
|
510 | 497 | }
|
511 |
| - |
512 |
| - return $current_capabilities; |
| 498 | + // allow manipulation of this list ( be mindfull of extending the ampCap class if needed ) |
| 499 | + return yourls_apply_filter( 'amp_current_capabilities', $current_capabilities); |
513 | 500 | }
|
514 | 501 |
|
515 | 502 | // Check for IP in a range
|
|
0 commit comments