aboutsummaryrefslogtreecommitdiff
path: root/engine/lib
diff options
context:
space:
mode:
authordave <dave@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-07-18 08:07:26 +0000
committerdave <dave@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-07-18 08:07:26 +0000
commit5d66ada2b5adbd697bf801a3a2a1919380394553 (patch)
treeb39484b65fd93f867767744af46f3f79bc8d1b4d /engine/lib
parent3907c4d693a829d477b1f39e0ba2af9348e140ca (diff)
downloadelgg-5d66ada2b5adbd697bf801a3a2a1919380394553.tar.gz
elgg-5d66ada2b5adbd697bf801a3a2a1919380394553.tar.bz2
new functions added to access in order to allow collections to be created
git-svn-id: https://code.elgg.org/elgg/trunk@1462 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'engine/lib')
-rw-r--r--engine/lib/access.php76
1 files changed, 61 insertions, 15 deletions
diff --git a/engine/lib/access.php b/engine/lib/access.php
index c1987e159..471b85236 100644
--- a/engine/lib/access.php
+++ b/engine/lib/access.php
@@ -65,9 +65,6 @@
$user_id = (int) $user_id;
$site_id = (int) $site_id;
- if (!$user = get_entity($user_id))
- $user = null;
-
if (empty($access_array[$user_id]) || $flush == true) {
$query = "select am.access_collection_id from {$CONFIG->dbprefix}access_collection_membership am ";
@@ -87,9 +84,7 @@
}
- $access_array_temp = trigger_plugin_hook('access:collections','user',array('user' => $user, 'site_id' => $site_id),$access_array[$user_id]);
-
- return $access_array_temp;
+ return $access_array[$user_id];
}
@@ -143,9 +138,6 @@
$user_id = (int) $user_id;
$site_id = (int) $site_id;
- if (!$user = get_entity($user_id))
- $user = null;
-
if (empty($access_array[$user_id]) || $flush == true) {
$query = "select ag.* from {$CONFIG->dbprefix}access_collections ag ";
@@ -158,13 +150,13 @@
$tmp_access_array[$collection->id] = elgg_echo($collection->name);
}
+ $tmp_access_array = trigger_plugin_hook('access','user',array('user_id' => $user_id, 'site_id' => $site_id),$tmp_access_array);
+
$access_array[$user_id] = $tmp_access_array;
}
- $tmp_access_array = trigger_plugin_hook('access:collections:write','user',array('user' => $user, 'site_id' => $site_id),$tmp_access_array);
-
- return $tmp_access_array;
+ return $access_array[$user_id];
}
@@ -201,7 +193,7 @@
$collection_id = (int) $collection_id;
$collections = get_write_access_array();
- if (in_array($collection_id,$collections)) {
+ if (array_key_exists($collection_id, $collections)) {
global $CONFIG;
delete_data("delete from {$CONFIG->dbprefix}access_collection_membership where access_collection_id = {$collection_id}");
delete_data("delete from {$CONFIG->dbprefix}access_collections where id = {$collection_id}");
@@ -213,6 +205,22 @@
}
/**
+ * Get a specified access collection
+ *
+ * @param int $collection_id The collection ID
+ * @return array|false Depending on success
+ */
+ function get_access_collection($collection_id) {
+
+ $collection_id = (int) $collection_id;
+ global $CONFIG;
+ $get_collection = get_data("SELECT * FROM {$CONFIG->dbprefix}access_collections WHERE id = {$collection_id}");
+
+ return $get_collection;
+
+ }
+
+ /**
* Adds a user to the specified user collection
*
* @param int $user_guid The GUID of the user to add
@@ -225,7 +233,7 @@
$user_guid = (int) $user_guid;
$collections = get_write_access_array();
- if (in_array($collection_id, $collections) && $user = get_user($user_guid)) {
+ if (array_key_exists($collection_id, $collections) && $user = get_user($user_guid)) {
global $CONFIG;
insert_data("insert into {$CONFIG->dbprefix}access_collection_membership set access_collection_id = {$collection_id}, user_guid = {$user_guid}");
@@ -250,7 +258,7 @@
$user_guid = (int) $user_guid;
$collections = get_write_access_array();
- if (in_array($collection_id, $collections) && $user = get_user($user_guid)) {
+ if (array_key_exists($collection_id, $collections) && $user = get_user($user_guid)) {
global $CONFIG;
delete_data("delete from {$CONFIG->dbprefix}access_collection_membership where access_collection_id = {$collection_id} and user_guid = {$user_guid}");
@@ -262,6 +270,44 @@
}
+ /**
+ * Get all of a users collections
+ *
+ * @param int $owner_guid The user ID
+ * @return true|false Depending on success
+ */
+ function get_user_access_collections($owner_guid) {
+
+ $owner_guid = (int) $owner_guid;
+
+ global $CONFIG;
+
+ $collections = get_data("SELECT * FROM {$CONFIG->dbprefix}access_collections WHERE owner_guid = {$owner_guid}");
+
+ return $collections;
+
+ }
+
+ /**
+ * Get all of members of a friend collection
+ *
+ * @param int $collection The collection's ID
+ * @return ElggUser entities if successful, false if not
+ */
+ function get_members_of_access_collection($collection) {
+
+ $collection = (int)$collection;
+
+ global $CONFIG;
+
+ $query = "select e.* from {$CONFIG->dbprefix}access_collection_membership m join {$CONFIG->dbprefix}entities e on e.guid = m.user_guid WHERE m.access_collection_id = {$collection}";
+
+ $collection_members = get_data($query, "entity_row_to_elggstar");
+
+ return $collection_members;
+
+ }
+
/**
* Some useful constant definitions
*/