diff options
author | brettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2009-10-15 22:48:01 +0000 |
---|---|---|
committer | brettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2009-10-15 22:48:01 +0000 |
commit | 721763663962364485e5a9958854a6311f32298b (patch) | |
tree | e37f278fb0698d4be6bf78fca9bbe506d3a07772 | |
parent | 35ecb0f617d5a24eb7ed3e767cf323ef959a188f (diff) | |
download | elgg-721763663962364485e5a9958854a6311f32298b.tar.gz elgg-721763663962364485e5a9958854a6311f32298b.tar.bz2 |
Merged admin access override hook with ignore access system override hook.
get_sql_access_prefix() now correctly uses elgg_check_access_overrides() instead of elgg_get_ignore_access().
git-svn-id: http://code.elgg.org/elgg/trunk@3552 36083f99-b078-4883-b0ff-0f9b5a30f544
-rw-r--r-- | engine/lib/access.php | 30 | ||||
-rw-r--r-- | engine/lib/admin.php | 19 |
2 files changed, 28 insertions, 21 deletions
diff --git a/engine/lib/access.php b/engine/lib/access.php index 0942c2e61..5bc14fe46 100644 --- a/engine/lib/access.php +++ b/engine/lib/access.php @@ -272,7 +272,7 @@ function get_access_sql_suffix($table_prefix = "", $owner = null) { $owner = -1; } - $ignore_access = elgg_get_ignore_access($owner); + $ignore_access = elgg_check_access_overrides($owner); $access = get_access_list($owner); if ($ignore_access) { @@ -836,5 +836,31 @@ function access_init() { $init_finished = true; } +/** + * Override permissions system + * + * @return true|null + */ +function elgg_override_permissions_hook($hook, $type, $returnval, $params) { + $user_guid = get_loggedin_userid(); + + // check for admin + if ($user_guid && elgg_is_admin_user($user_guid)) { + return true; + } + + // check access overrides + if ((elgg_check_access_overrides($user_guid))) { + return true; + } + + // consult other hooks + return NULL; +} + // This function will let us know when 'init' has finished -register_elgg_event_handler('init', 'system', 'access_init', 9999);
\ No newline at end of file +register_elgg_event_handler('init', 'system', 'access_init', 9999); + +// For overrided permissions +register_plugin_hook('permissions_check', 'all', 'elgg_override_permissions_hook'); +register_plugin_hook('container_permissions_check', 'all', 'elgg_override_permissions_hook');
\ No newline at end of file diff --git a/engine/lib/admin.php b/engine/lib/admin.php index 1ba971347..c680f0a7f 100644 --- a/engine/lib/admin.php +++ b/engine/lib/admin.php @@ -104,21 +104,6 @@ function admin_settings_page_handler($page) { include($path); } - -/** - * Admin permissions system - * - * @return true|null True if the current user is an admin. - */ -function admin_permissions($hook, $type, $returnval, $params) { - if (elgg_check_access_overrides()) { - return true; - } - - // consult other hooks - return NULL; -} - /** * Write a persistent message to the administrator's notification window. * @@ -165,7 +150,3 @@ function clear_admin_message($guid) { /// Register init functions register_elgg_event_handler('init', 'system', 'admin_init'); register_elgg_event_handler('pagesetup', 'system', 'admin_pagesetup'); - -// Register a plugin hook for permissions -register_plugin_hook('permissions_check', 'all', 'admin_permissions'); -register_plugin_hook('container_permissions_check', 'all', 'admin_permissions');
\ No newline at end of file |