aboutsummaryrefslogtreecommitdiff
path: root/engine/lib/access.php
diff options
context:
space:
mode:
authorben <ben@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-05-23 17:19:15 +0000
committerben <ben@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-05-23 17:19:15 +0000
commitf13ffaf15ac87e1a465167c02edf374e3683e828 (patch)
tree6499a5584b4e28710e59a2c536deaa302a8955f5 /engine/lib/access.php
parent42cda8751ae6237f4ab9439b1daf6650b3db0f63 (diff)
downloadelgg-f13ffaf15ac87e1a465167c02edf374e3683e828.tar.gz
elgg-f13ffaf15ac87e1a465167c02edf374e3683e828.tar.bz2
Introducing a visual widget for inputting access permissions.
git-svn-id: https://code.elgg.org/elgg/trunk@706 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'engine/lib/access.php')
-rw-r--r--engine/lib/access.php41
1 files changed, 40 insertions, 1 deletions
diff --git a/engine/lib/access.php b/engine/lib/access.php
index e81bd2da0..46e8b2e77 100644
--- a/engine/lib/access.php
+++ b/engine/lib/access.php
@@ -60,7 +60,7 @@
if (!isset($access_array))
$access_array = array();
- if ($user_id == 0) $user_id = $_SESSION['id'];
+ if ($user_id == 0) $user_id = $_SESSION['guid'];
if (($site_id == 0) && (isset($CONFIG->site_id))) $site_id = $CONFIG->site_id;
$user_id = (int) $user_id;
$site_id = (int) $site_id;
@@ -87,6 +87,45 @@
return $access_array[$user_id];
}
+
+ /**
+ * Returns an array of access permissions that the specified user is allowed to save objects with.
+ * Permissions are of the form ('id' => 'Description')
+ *
+ * @param int $user_id The user's GUID.
+ * @param int $site_id The current site.
+ * @param true|false $flush If this is set to true, this will shun any cached version
+ * @return array List of access permissions=
+ */
+ function get_write_access_array($user_id = 0, $site_id = 0, $flush = false) {
+
+ global $CONFIG;
+ static $access_array;
+
+ if ($user_id == 0) $user_id = $_SESSION['guid'];
+ if (($site_id == 0) && (isset($CONFIG->site_id))) $site_id = $CONFIG->site_id;
+ $user_id = (int) $user_id;
+ $site_id = (int) $site_id;
+
+ if (empty($access_array[$user_id]) || $flush == true) {
+
+ $query = "select ag.* from {$CONFIG->dbprefix}access_groups ag ";
+ $query .= " where (ag.site_guid = {$site_id} or ag.site_guid = 0)";
+ $query .= " and (ag.owner_guid = {$user_id} or ag.owner_guid = 0)";
+
+ $tmp_access_array = array();
+ if ($groups = get_data($query)) {
+ foreach($groups as $group)
+ $tmp_access_array[$group->id] = elgg_echo($group->name);
+ }
+
+ $access_array[$user_id] = $tmp_access_array;
+
+ }
+
+ return $access_array[$user_id];
+
+ }
/**
* Some useful constant definitions