Enumerate capabilities with filter

This commit is contained in:
Nic Waller 2013-06-01 18:01:36 +00:00
parent 910ea51ca4
commit 704a690c12

View File

@ -27,15 +27,21 @@ class AuthmgrRoles {
const Contributor = 'Contributor'; const Contributor = 'Contributor';
} }
// Define constants used for naming capabilities // Declare capability names for YOURLS built-in functionality
class AuthmgrCapability { class AuthmgrCapability {
const ShowAdmin = 'ShowAdmin'; // only display admin panel const ShowAdmin = 'ShowAdmin';
const AddURL = 'AddURL'; const AddURL = 'AddURL';
const DeleteURL = 'DeleteURL'; const DeleteURL = 'DeleteURL';
const EditURL = 'EditURL'; const EditURL = 'EditURL';
const ManagePlugins = 'ManagePlugins'; const ManagePlugins = 'ManagePlugins';
const API = 'API'; const API = 'API';
const ViewStats = 'ViewStats'; const ViewStats = 'ViewStats';
public function all()
{
$reflect = new ReflectionClass(get_class($this));
return $reflect->getConstants();
}
} }
@ -154,16 +160,15 @@ function authmgr_enumerate_current_capabilities() {
return $current_capabilities; return $current_capabilities;
} }
/**
* Returns a list of all capabilities that authmgr is aware of.
* This list will be used to build the authmgr GUI.
* Other plugins can take advantage of authmgr by hooking this filter.
*/
function authmgr_enumerate_all_capabilities() { function authmgr_enumerate_all_capabilities() {
return array( $default_caps = AuthmgrCapability::all();
AuthmgrCapability::ShowAdmin, $all_caps = yourls_apply_filter( 'authmgr_capabilities', $default_caps);
AuthmgrCapability::AddURL, return $all_caps;
AuthmgrCapability::DeleteURL,
AuthmgrCapability::EditURL,
AuthmgrCapability::ManagePlugins,
AuthmgrCapability::API,
AuthmgrCapability::ViewStats,
);
} }
/* /*