From ab7d70b9d870d69a5b79c3fbb005565302112efc Mon Sep 17 00:00:00 2001 From: ben Date: Thu, 31 Jul 2008 15:22:48 +0000 Subject: Picker saves correctly! git-svn-id: https://code.elgg.org/elgg/trunk@1635 36083f99-b078-4883-b0ff-0f9b5a30f544 --- engine/lib/access.php | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) (limited to 'engine/lib/access.php') diff --git a/engine/lib/access.php b/engine/lib/access.php index 2c9a886e6..a1741f8bf 100644 --- a/engine/lib/access.php +++ b/engine/lib/access.php @@ -201,6 +201,33 @@ } + /** + * Updates the membership in an access collection. + * + * @param int $collection_id The ID of the collection. + * @param array $members Array of member GUIDs + * @return true|false Depending on success + */ + function update_access_collection($collection_id, $members) { + + global $CONFIG; + $collection_id = (int) $collection_id; + + if ($collection = get_access_collection($collection_id)) { + delete_data("delete from {$CONFIG->dbprefix}access_collection_membership where access_collection_id = {$collection_id}"); + } + + if (is_array($members) && sizeof($members) > 0) { + foreach($members as $member) { + $member = (int) $member; + add_user_to_access_collection($member, $collection_id); + } + return true; + } + + return false; + } + /** * Deletes a specified access collection * @@ -232,7 +259,7 @@ $collection_id = (int) $collection_id; global $CONFIG; - $get_collection = get_data("SELECT * FROM {$CONFIG->dbprefix}access_collections WHERE id = {$collection_id}"); + $get_collection = get_data_row("SELECT * FROM {$CONFIG->dbprefix}access_collections WHERE id = {$collection_id}"); return $get_collection; @@ -252,7 +279,7 @@ $collections = get_write_access_array(); 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}"); return true; -- cgit v1.2.3