Skip to content
This repository was archived by the owner on May 19, 2025. It is now read-only.

Commit 65e50a6

Browse files
committed
repair filter type hooks
1 parent da0d928 commit 65e50a6

File tree

1 file changed

+20
-33
lines changed

1 file changed

+20
-33
lines changed

authMgrPlus/plugin.php

Lines changed: 20 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Plugin Name: Auth Manager Plus
44
Plugin URI: https://github.com/joshp23/YOURLS-AuthMgrPlus
55
Description: Role Based Access Controlls with seperated user data for authenticated users
6-
Version: 2.2.2
6+
Version: 2.2.3
77
Author: Josh Panter, nicwaller, Ian Barber <[email protected]>
88
Author URI: https://unfettered.net
99
*/
@@ -76,37 +76,36 @@ function amp_intercept_admin() {
7676
yourls_add_notice('Access Denied');
7777
}
7878

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+
) );
8988

9089
// Key actions like Add/Edit/Delete are AJAX requests
9190
if ( yourls_is_Ajax() ) {
9291

9392
// Define some boundaries for ownership
94-
$restricted_actions = array( 'edit_display',
95-
'edit_save',
96-
'delete'
97-
);
98-
9993
// 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+
) );
10199

102100
$action_keyword = $_REQUEST['action'];
101+
$cap_needed = $action_capability_map[$action_keyword];
103102

104103
// Check the action against those boundaries
105104
if ( in_array( $action_keyword, $restricted_actions) ) {
106105
$keyword = $_REQUEST['keyword'];
107-
$do = amp_manage_keyword( $keyword, $action_capability_map[$action_keyword] );
106+
$do = amp_manage_keyword( $keyword, $cap_needed );
108107
} else {
109-
$do = amp_have_capability( $action_capability_map[$action_keyword] );
108+
$do = amp_have_capability( $cap_needed );
110109
}
111110

112111
if ( $do !== true ) {
@@ -442,16 +441,6 @@ function amp_env_check() {
442441
$amp_role_assignment = $amp_role_assignment_lower;
443442
unset($amp_role_assignment_lower);
444443

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-
455444
return true;
456445
}
457446

@@ -500,16 +489,14 @@ function amp_current_capabilities() {
500489
ampCap::ViewStats,
501490
ampCap::ViewAll,
502491
);
503-
// allow manipulation of this list ( be mindfull of extending the ampCap class if needed )
504-
yourls_apply_filter( 'amp_current_capabilities', $all_capabilities);
505492

506493
foreach ( $all_capabilities as $cap ) {
507494
if ( amp_have_capability( $cap ) ) {
508495
$current_capabilities[] = $cap;
509496
}
510497
}
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);
513500
}
514501

515502
// Check for IP in a range

0 commit comments

Comments
 (0)