aboutsummaryrefslogtreecommitdiff
path: root/engine/lib/access.php
diff options
context:
space:
mode:
authorcash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>2011-03-04 02:45:14 +0000
committercash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>2011-03-04 02:45:14 +0000
commit693c78e16e51b80f0eaba5d8c27c3d942924b398 (patch)
tree176f2a4c7dbac36067f7394bb5e8a6888de58b3e /engine/lib/access.php
parentb83ab22d23d5c5d5e46ce64f1e1aea3056bfabc0 (diff)
downloadelgg-693c78e16e51b80f0eaba5d8c27c3d942924b398.tar.gz
elgg-693c78e16e51b80f0eaba5d8c27c3d942924b398.tar.bz2
Refs #1926 made 'access:collections:add_user', 'collection' plugin hook more useful
git-svn-id: http://code.elgg.org/elgg/trunk@8576 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'engine/lib/access.php')
-rw-r--r--engine/lib/access.php48
1 files changed, 29 insertions, 19 deletions
diff --git a/engine/lib/access.php b/engine/lib/access.php
index 68a01dfad..30febb799 100644
--- a/engine/lib/access.php
+++ b/engine/lib/access.php
@@ -592,31 +592,41 @@ function add_user_to_access_collection($user_guid, $collection_id) {
return false;
}
- if ((array_key_exists($collection_id, $collections) || $collection->owner_guid == 0)
- && $user = get_user($user_guid)) {
- global $CONFIG;
+ $user = get_user($user_guid);
+ if (!$user) {
+ return false;
+ }
- $params = array(
- 'collection_id' => $collection_id,
- 'user_guid' => $user_guid
- );
+ // to add someone to a collection, the user must be a member of the collection or
+ // no one must own it
+ if ((array_key_exists($collection_id, $collections) || $collection->owner_guid == 0)) {
+ $result = true;
+ } else {
+ $result = false;
+ }
+
+ $params = array(
+ 'collection_id' => $collection_id,
+ 'collection' => $collection,
+ 'user_guid' => $user_guid
+ );
- if (!elgg_trigger_plugin_hook('access:collections:add_user', 'collection', $params, true)) {
- return false;
- }
+ $result = elgg_trigger_plugin_hook('access:collections:add_user', 'collection', $params, $result);
+ if ($result == false) {
+ return false;
+ }
- try {
- $query = "insert into {$CONFIG->dbprefix}access_collection_membership"
+ try {
+ global $CONFIG;
+ $query = "insert into {$CONFIG->dbprefix}access_collection_membership"
. " set access_collection_id = {$collection_id}, user_guid = {$user_guid}";
- insert_data($query);
- } catch (DatabaseException $e) {
- // nothing.
- }
- return true;
-
+ insert_data($query);
+ } catch (DatabaseException $e) {
+ // nothing.
+ return false;
}
- return false;
+ return true;
}
/**