user_remove_friend() uses remove_user_from_access_collection() instead of raw SQL.
Deleting an access collection prompts using output/confirmlink.
git-svn-id: https://code.elgg.org/elgg/trunk@3368
36083f99-b078-4883-b0ff-
0f9b5a30f544
\r
$user_guid = (int) $user_guid; \r
$friend_guid = (int) $friend_guid;\r
- if (!remove_entity_relationship($user_guid, "friend", $friend_guid)){\r
- return false;\r
- }\r
\r
// perform cleanup for access lists.\r
$collections = get_user_access_collections($user_guid);\r
- $in_arr = array();\r
foreach ($collections as $collection) {\r
- $in_arr[] = $collection->id;\r
+ remove_user_from_access_collection($friend_guid, $collection->id);\r
}\r
- $query = "DELETE FROM `{$CONFIG->dbprefix}access_collection_membership`\r
- WHERE `user_guid` = '$friend_guid'\r
- AND `access_collection_id` IN(" . implode($in_arr, ',') . ")";\r
- delete_data($query);\r
\r
- // delete_data() might return nothing if no rows were affected.\r
- // the users has been removed already, so we safely return true.\r
- return true;\r
+ return remove_entity_relationship($user_guid, "friend", $friend_guid);\r
}\r
\r
/**\r
\r
//as collections are private, check that the logged in user is the owner\r
if($coll->owner_guid == $_SESSION['user']->getGUID()) {\r
- $confirm = addslashes(elgg_echo('question:areyousure'));\r
- 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>";\r
+ echo "<div class=\"friends_collections_controls\">";\r
+ echo elgg_view('output/confirmlink', array(\r
+ 'href' => $vars['url'] . 'action/friends/deletecollection?collection=' . $coll->id,\r
+ 'class' => 'delete_collection'\r
+ ));\r
echo "</div>";\r
}\r
echo $coll->name;\r
if (strpos($link, '?')>0) $sep = "&";
$link = "$link{$sep}__elgg_token=$token&__elgg_ts=$ts";
}\r
+ \r
+ if ($vars['class']) {\r
+ $class = 'class="' . $vars['class'] . '"';\r
+ } else {\r
+ $class = '';\r
+ }\r
?>\r
-<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