From 8d90e1b4719d052398b4d7c6b5618fea11399f4d Mon Sep 17 00:00:00 2001 From: marcus Date: Wed, 13 Aug 2008 13:37:54 +0000 Subject: Refs #237, #46 and #227: Added override code. git-svn-id: https://code.elgg.org/elgg/trunk@1902 36083f99-b078-4883-b0ff-0f9b5a30f544 --- engine/lib/access.php | 39 ++++++++++++++++++++++++++++++++++----- 1 file changed, 34 insertions(+), 5 deletions(-) (limited to 'engine') diff --git a/engine/lib/access.php b/engine/lib/access.php index d83683462..b21971c09 100644 --- a/engine/lib/access.php +++ b/engine/lib/access.php @@ -98,6 +98,34 @@ return $access_array[$user_id]; } + + /** + * Override the default behaviour and allow results to show hidden entities as well. + * THIS IS A HACK. + * + * TODO: Replace this with query object! + */ + $ENTITY_SHOW_HIDDEN_OVERRIDE = false; + + /** + * This will be replaced. Do not use in plugins! + * + * @param bool $show + */ + function access_show_hidden_entities($show_hidden) + { + global $ENTITY_SHOW_HIDDEN_OVERRIDE; + $ENTITY_SHOW_HIDDEN_OVERRIDE = $show_hidden; + } + + /** + * This will be replaced. Do not use in plugins! + */ + function access_get_show_hidden_status() + { + global $ENTITY_SHOW_HIDDEN_OVERRIDE; + return $ENTITY_SHOW_HIDDEN_OVERRIDE; + } /** * Add access restriction sql code to a given query. @@ -106,11 +134,12 @@ * * TODO: DELETE once Query classes are fully integrated * - * @param string $table_prefix Optional xxx. prefix for the access code. - * @param bool $active_only Option to select only active entities or include deactive ones. + * @param string $table_prefix Optional xxx. prefix for the access code. */ - function get_access_sql_suffix($table_prefix = "", $active_only = true) - { + function get_access_sql_suffix($table_prefix = "") + { + global $ENTITY_SHOW_HIDDEN_OVERRIDE; + $sql = ""; if ($table_prefix) @@ -130,7 +159,7 @@ if (empty($sql)) $sql = " ({$table_prefix}access_id in {$access} or ({$table_prefix}access_id = 0 and {$table_prefix}owner_guid = $owner))"; - if ($active_only) + if (!$ENTITY_SHOW_HIDDEN_OVERRIDE) $sql .= " and {$table_prefix}enabled='yes'"; return $sql; -- cgit v1.2.3