aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engine/lib/users.php14
-rw-r--r--views/default/friends/collection.php7
-rw-r--r--views/default/output/confirmlink.php8
3 files changed, 14 insertions, 15 deletions
diff --git a/engine/lib/users.php b/engine/lib/users.php
index 5f562845c..46636548b 100644
--- a/engine/lib/users.php
+++ b/engine/lib/users.php
@@ -561,24 +561,14 @@
$user_guid = (int) $user_guid;
$friend_guid = (int) $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;
+ remove_user_from_access_collection($friend_guid, $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;
+ return remove_entity_relationship($user_guid, "friend", $friend_guid);
}
/**
diff --git a/views/default/friends/collection.php b/views/default/friends/collection.php
index a12ad6e6a..1a9949cc9 100644
--- a/views/default/friends/collection.php
+++ b/views/default/friends/collection.php
@@ -28,8 +28,11 @@
//as collections are private, check that the logged in user is the owner
if($coll->owner_guid == $_SESSION['user']->getGUID()) {
- $confirm = addslashes(elgg_echo('question:areyousure'));
- echo "<div class=\"friends_collections_controls\"> <a href=\"" . $vars['url'] . "action/friends/deletecollection?collection={$coll->id}\" class=\"delete_collection\" onclick=\"if (!confirm('{$confirm}')) { return false; }; $('div.friends_picker').empty();\"> </a>";
+ echo "<div class=\"friends_collections_controls\">";
+ echo elgg_view('output/confirmlink', array(
+ 'href' => $vars['url'] . 'action/friends/deletecollection?collection=' . $coll->id,
+ 'class' => 'delete_collection'
+ ));
echo "</div>";
}
echo $coll->name;
diff --git a/views/default/output/confirmlink.php b/views/default/output/confirmlink.php
index 0843083f0..a89299300 100644
--- a/views/default/output/confirmlink.php
+++ b/views/default/output/confirmlink.php
@@ -32,5 +32,11 @@
if (strpos($link, '?')>0) $sep = "&";
$link = "$link{$sep}__elgg_token=$token&__elgg_ts=$ts";
}
+
+ if ($vars['class']) {
+ $class = 'class="' . $vars['class'] . '"';
+ } else {
+ $class = '';
+ }
?>
-<a href="<?php echo $link; ?>" onclick="return confirm('<?php echo addslashes($confirm); ?>');"><?php echo htmlentities($vars['text'], ENT_QUOTES, 'UTF-8'); ?></a> \ No newline at end of file
+<a href="<?php echo $link; ?>" <?php echo $class; ?> onclick="return confirm('<?php echo addslashes($confirm); ?>');"><?php echo htmlentities($vars['text'], ENT_QUOTES, 'UTF-8'); ?></a> \ No newline at end of file