aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mod/likes/actions/likes/delete.php32
-rw-r--r--mod/likes/languages/en.php1
-rw-r--r--mod/likes/views/default/annotation/likes.php10
3 files changed, 27 insertions, 16 deletions
diff --git a/mod/likes/actions/likes/delete.php b/mod/likes/actions/likes/delete.php
index db3036bb4..322d512e8 100644
--- a/mod/likes/actions/likes/delete.php
+++ b/mod/likes/actions/likes/delete.php
@@ -4,17 +4,27 @@
*
*/
-$likes = elgg_get_annotations(array(
- 'guid' => (int) get_input('guid'),
- 'annotation_owner_guid' => elgg_get_logged_in_user_guid(),
- 'annotation_name' => 'likes',
-));
-if ($likes) {
- if ($likes[0]->canEdit()) {
- $likes[0]->delete();
- system_message(elgg_echo("likes:deleted"));
- forward(REFERER);
- }
+// Support deleting by id in case we're deleting another user's likes
+$id = (int) get_input('id');
+
+$like = NULL;
+if ($id) {
+ $like = elgg_get_annotation_from_id($id);
+}
+
+if (!$like) {
+ $likes = elgg_get_annotations(array(
+ 'guid' => (int) get_input('guid'),
+ 'annotation_owner_guid' => elgg_get_logged_in_user_guid(),
+ 'annotation_name' => 'likes',
+ ));
+ $like = $likes[0];
+}
+
+if ($like && $like->canEdit()) {
+ $like->delete();
+ system_message(elgg_echo("likes:deleted"));
+ forward(REFERER);
}
register_error(elgg_echo("likes:notdeleted"));
diff --git a/mod/likes/languages/en.php b/mod/likes/languages/en.php
index 4a98d7cfe..bdbd2a963 100644
--- a/mod/likes/languages/en.php
+++ b/mod/likes/languages/en.php
@@ -17,6 +17,7 @@ $english = array(
'likes:userlikedthis' => '%s like',
'likes:userslikedthis' => '%s likes',
'likes:river:annotate' => 'likes',
+ 'likes:delete:confirm' => 'Are you sure you want to delete this like?',
'river:likes' => 'likes %s %s',
diff --git a/mod/likes/views/default/annotation/likes.php b/mod/likes/views/default/annotation/likes.php
index d41522fc4..2b5acc520 100644
--- a/mod/likes/views/default/annotation/likes.php
+++ b/mod/likes/views/default/annotation/likes.php
@@ -29,11 +29,11 @@ $friendlytime = elgg_view_friendly_time($like->time_created);
if ($like->canEdit()) {
$delete_button = elgg_view("output/confirmlink",array(
- 'href' => "action/likes/delete?annotation_id={$like->id}",
- 'text' => "<span class=\"elgg-icon elgg-icon-delete float-alt\"></span>",
- 'confirm' => elgg_echo('deleteconfirm'),
- 'encode_text' => false,
- ));
+ 'href' => "action/likes/delete?id={$like->id}",
+ 'text' => "<span class=\"elgg-icon elgg-icon-delete float-alt\"></span>",
+ 'confirm' => elgg_echo('likes:delete:confirm'),
+ 'encode_text' => false,
+ ));
}
$body = <<<HTML