repair filter type hooks

This commit is contained in:
joshp 2020-07-26 02:22:28 -04:00
parent da0d928b3c
commit 65e50a60f4
No known key found for this signature in database
GPG Key ID: 59903022E9AC64FC

View File

@ -3,7 +3,7 @@
Plugin Name: Auth Manager Plus Plugin Name: Auth Manager Plus
Plugin URI: https://github.com/joshp23/YOURLS-AuthMgrPlus Plugin URI: https://github.com/joshp23/YOURLS-AuthMgrPlus
Description: Role Based Access Controlls with seperated user data for authenticated users Description: Role Based Access Controlls with seperated user data for authenticated users
Version: 2.2.2 Version: 2.2.3
Author: Josh Panter, nicwaller, Ian Barber <ian.barber@gmail.com> Author: Josh Panter, nicwaller, Ian Barber <ian.barber@gmail.com>
Author URI: https://unfettered.net Author URI: https://unfettered.net
*/ */
@ -76,37 +76,36 @@ function amp_intercept_admin() {
yourls_add_notice('Access Denied'); yourls_add_notice('Access Denied');
} }
$action_capability_map = array( // allow manipulation of this list ( be mindfull of extending Auth mp Capability class if needed )
'add' => ampCap::AddURL, $action_capability_map = yourls_apply_filter( 'amp_action_capability_map',
'delete' => ampCap::DeleteURL, array( 'add' => ampCap::AddURL,
'edit_display' => ampCap::EditURL, 'delete' => ampCap::DeleteURL,
'edit_save' => ampCap::EditURL, 'edit_display' => ampCap::EditURL,
'activate' => ampCap::ManagePlugins, 'edit_save' => ampCap::EditURL,
'deactivate' => ampCap::ManagePlugins, 'activate' => ampCap::ManagePlugins,
); 'deactivate' => ampCap::ManagePlugins,
// allow manipulation of this list ( be mindfull of extending Authmp Capability class if needed ) ) );
yourls_apply_filter( 'amp_action_capability_map', $action_capability_map);
// Key actions like Add/Edit/Delete are AJAX requests // Key actions like Add/Edit/Delete are AJAX requests
if ( yourls_is_Ajax() ) { if ( yourls_is_Ajax() ) {
// Define some boundaries for ownership // Define some boundaries for ownership
$restricted_actions = array( 'edit_display',
'edit_save',
'delete'
);
// Allow some flexability with those boundaries // Allow some flexability with those boundaries
yourls_apply_filter( 'amp_restricted_ajax_actions', $restricted_actions ); $restricted_actions = yourls_apply_filter( 'amp_restricted_ajax_actions',
array( 'edit_display',
'edit_save',
'delete'
) );
$action_keyword = $_REQUEST['action']; $action_keyword = $_REQUEST['action'];
$cap_needed = $action_capability_map[$action_keyword];
// Check the action against those boundaries // Check the action against those boundaries
if ( in_array( $action_keyword, $restricted_actions) ) { if ( in_array( $action_keyword, $restricted_actions) ) {
$keyword = $_REQUEST['keyword']; $keyword = $_REQUEST['keyword'];
$do = amp_manage_keyword( $keyword, $action_capability_map[$action_keyword] ); $do = amp_manage_keyword( $keyword, $cap_needed );
} else { } else {
$do = amp_have_capability( $action_capability_map[$action_keyword] ); $do = amp_have_capability( $cap_needed );
} }
if ( $do !== true ) { if ( $do !== true ) {
@ -442,16 +441,6 @@ function amp_env_check() {
$amp_role_assignment = $amp_role_assignment_lower; $amp_role_assignment = $amp_role_assignment_lower;
unset($amp_role_assignment_lower); unset($amp_role_assignment_lower);
// allow manipulation of env by other plugins
// be mindfull of extending ampCap and ampRoles classes if needed
$a = $amp_anon_capabilities;
$b = $amp_role_capabilities;
$c = $amp_role_assignment;
$d = $amp_admin_ipranges;
$e = $amp_allowed_plugin_pages;
yourls_apply_filter( 'amp_env_check', $a, $b, $c, $d, $e );
return true; return true;
} }
@ -500,16 +489,14 @@ function amp_current_capabilities() {
ampCap::ViewStats, ampCap::ViewStats,
ampCap::ViewAll, ampCap::ViewAll,
); );
// allow manipulation of this list ( be mindfull of extending the ampCap class if needed )
yourls_apply_filter( 'amp_current_capabilities', $all_capabilities);
foreach ( $all_capabilities as $cap ) { foreach ( $all_capabilities as $cap ) {
if ( amp_have_capability( $cap ) ) { if ( amp_have_capability( $cap ) ) {
$current_capabilities[] = $cap; $current_capabilities[] = $cap;
} }
} }
// allow manipulation of this list ( be mindfull of extending the ampCap class if needed )
return $current_capabilities; return yourls_apply_filter( 'amp_current_capabilities', $current_capabilities);
} }
// Check for IP in a range // Check for IP in a range