aboutsummaryrefslogtreecommitdiff
path: root/engine
diff options
context:
space:
mode:
Diffstat (limited to 'engine')
-rw-r--r--engine/lib/access.php30
-rw-r--r--engine/lib/admin.php19
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