aboutsummaryrefslogtreecommitdiff
path: root/engine/lib/access.php
diff options
context:
space:
mode:
Diffstat (limited to 'engine/lib/access.php')
-rw-r--r--engine/lib/access.php26
1 files changed, 26 insertions, 0 deletions
diff --git a/engine/lib/access.php b/engine/lib/access.php
index e39a9f165..5205b7a55 100644
--- a/engine/lib/access.php
+++ b/engine/lib/access.php
@@ -86,6 +86,32 @@
return $access_array[$user_id];
+ }
+
+ /**
+ * Add access restriction sql code to a given query.
+ *
+ * Note that if this code is executed in privileged mode it will return blank.
+ *
+ * TODO: DELETE once Query classes are fully integrated
+ *
+ * @param string $table_prefix Optional xxx. prefix for the access code.
+ */
+ function get_access_sql_suffix($table_prefix = "")
+ {
+ $sql = "";
+
+ if (!is_privileged())
+ {
+ $access = get_access_list();
+
+ if ($table_prefix)
+ $table_prefix = sanitise_string($table_prefix) . ".";
+
+ $sql = " and ({$table_prefix}access_id in {$access} or ({$table_prefix}access_id = 0 and {$table_prefix}owner_guid = {$_SESSION['id']}))";
+ }
+
+ return $sql;
}
/**