Skip to content

Commit

Permalink
Fixes #4606 made unlike code consistent and functional
Browse files Browse the repository at this point in the history
  • Loading branch information
cash committed Jun 19, 2012
1 parent d713090 commit e322253
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 14 deletions.
17 changes: 6 additions & 11 deletions mod/likes/actions/likes/delete.php
Expand Up @@ -4,17 +4,12 @@
*
*/

$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);
}
$id = (int) get_input('id');
$like = elgg_get_annotation_from_id($id);
if ($like && $like->canEdit()) {
$like->delete();
system_message(elgg_echo("likes:deleted"));
forward(REFERER);
}

register_error(elgg_echo("likes:notdeleted"));
Expand Down
1 change: 1 addition & 0 deletions mod/likes/languages/en.php
Expand Up @@ -17,6 +17,7 @@
'likes:userlikedthis' => '%s like',
'likes:userslikedthis' => '%s likes',
'likes:river:annotate' => 'likes',
'likes:delete:confirm' => 'Are you sure you want to unlike this?',

'river:likes' => 'likes %s %s',

Expand Down
4 changes: 2 additions & 2 deletions mod/likes/views/default/annotation/likes.php
Expand Up @@ -29,9 +29,9 @@

if ($like->canEdit()) {
$delete_button = elgg_view("output/confirmlink",array(
'href' => "action/likes/delete?annotation_id={$like->id}",
'href' => "action/likes/delete?id={$like->id}",
'text' => "<span class=\"elgg-icon elgg-icon-delete float-alt\"></span>",
'confirm' => elgg_echo('deleteconfirm'),
'confirm' => elgg_echo('likes:delete:confirm'),
'encode_text' => false,
));
}
Expand Down
8 changes: 7 additions & 1 deletion mod/likes/views/default/likes/button.php
Expand Up @@ -24,7 +24,13 @@
);
$likes_button = elgg_view('output/url', $params);
} else {
$url = elgg_get_site_url() . "action/likes/delete?guid={$guid}";
$like = elgg_get_annotations(array(
'guid' => $guid,
'annotation_owner_guid' => elgg_get_logged_in_user_guid(),
'annotation_name' => 'likes',
));
$like = $like[0];
$url = elgg_get_site_url() . "action/likes/delete?id={$like->id}";
$params = array(
'href' => $url,
'text' => elgg_view_icon('thumbs-up-alt'),
Expand Down

0 comments on commit e322253

Please sign in to comment.