aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>2009-06-29 21:18:52 +0000
committerbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>2009-06-29 21:18:52 +0000
commit82f85ba30f16ec6cfb8abb86a94af08f84fdf825 (patch)
tree9e19d74cd090fc5b404efe5a09a7d61fd3348051
parent55147bdc2632652ee5d06240650e7b1d85773141 (diff)
downloadelgg-82f85ba30f16ec6cfb8abb86a94af08f84fdf825.tar.gz
elgg-82f85ba30f16ec6cfb8abb86a94af08f84fdf825.tar.bz2
Closes #502: Removing unfriended users from access lists upon unfriending.
git-svn-id: https://code.elgg.org/elgg/trunk@3362 36083f99-b078-4883-b0ff-0f9b5a30f544
-rw-r--r--engine/lib/users.php21
1 files changed, 20 insertions, 1 deletions
diff --git a/engine/lib/users.php b/engine/lib/users.php
index b271d4b4f..5f562845c 100644
--- a/engine/lib/users.php
+++ b/engine/lib/users.php
@@ -557,9 +557,28 @@
* @return true|false Depending on success
*/
function user_remove_friend($user_guid, $friend_guid) {
+ global $CONFIG;
+
$user_guid = (int) $user_guid;
$friend_guid = (int) $friend_guid;
- return remove_entity_relationship($user_guid, "friend", $friend_guid);
+ if (!remove_entity_relationship($user_guid, "friend", $friend_guid)){
+ return false;
+ }
+
+ // perform cleanup for access lists.
+ $collections = get_user_access_collections($user_guid);
+ $in_arr = array();
+ foreach ($collections as $collection) {
+ $in_arr[] = $collection->id;
+ }
+ $query = "DELETE FROM `{$CONFIG->dbprefix}access_collection_membership`
+ WHERE `user_guid` = '$friend_guid'
+ AND `access_collection_id` IN(" . implode($in_arr, ',') . ")";
+ delete_data($query);
+
+ // delete_data() might return nothing if no rows were affected.
+ // the users has been removed already, so we safely return true.
+ return true;
}
/**