add authmgr_action_capability_map filter

This commit is contained in:
root 2018-09-06 17:36:06 -04:00
parent d246a2b905
commit 04bdfc1ed0

View File

@ -3,7 +3,7 @@
Plugin Name: Authorization Manager Plugin Name: Authorization Manager
Plugin URI: https://github.com/nicwaller/yourls-authmgr-plugin Plugin URI: https://github.com/nicwaller/yourls-authmgr-plugin
Description: Restrict classes of users to specific functions Description: Restrict classes of users to specific functions
Version: 0.9.2 Version: 0.9.3
Author: nicwaller Author: nicwaller
Author URI: https://github.com/nicwaller Author URI: https://github.com/nicwaller
*/ */
@ -43,13 +43,17 @@ class AuthmgrCapability {
yourls_add_action( 'load_template_infos', 'authmgr_intercept_stats' ); yourls_add_action( 'load_template_infos', 'authmgr_intercept_stats' );
function authmgr_intercept_stats() { function authmgr_intercept_stats() {
if ( YOURLS_PRIVATE_INFOS === true ) {
authmgr_require_capability( AuthmgrCapability::ViewStats ); authmgr_require_capability( AuthmgrCapability::ViewStats );
} }
}
yourls_add_action( 'api', 'authmgr_intercept_api' ); yourls_add_action( 'api', 'authmgr_intercept_api' );
function authmgr_intercept_api() { function authmgr_intercept_api() {
if ( YOURLS_PRIVATE_API === true ) {
authmgr_require_capability( AuthmgrCapability::API ); authmgr_require_capability( AuthmgrCapability::API );
} }
}
yourls_add_action( 'auth_successful', 'authmgr_intercept_admin' ); yourls_add_action( 'auth_successful', 'authmgr_intercept_admin' );
@ -78,6 +82,8 @@ function authmgr_intercept_admin() {
'activate' => AuthmgrCapability::ManagePlugins, 'activate' => AuthmgrCapability::ManagePlugins,
'deactivate' => AuthmgrCapability::ManagePlugins, 'deactivate' => AuthmgrCapability::ManagePlugins,
); );
// allow manipulation of this list
yourls_apply_filter( authmgr_action_capability_map, $action_capability_map);
// intercept requests for plugin management // intercept requests for plugin management
if ( isset( $_REQUEST['plugin'] ) ) { if ( isset( $_REQUEST['plugin'] ) ) {