X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;ds=sidebyside;f=include%2Flike.php;h=793ea04215e62b0be9607b667d70373c7f5ce7fd;hb=b3e6a1d2832be024819328e51e9e1df4c25b560f;hp=05bb758c2a08b8e0c136edf469f2d1c64a8901da;hpb=fc0031f4ba37117c25b2a613731951a82eb41a6c;p=friendica.git diff --git a/include/like.php b/include/like.php index 05bb758c2a..793ea04215 100644 --- a/include/like.php +++ b/include/like.php @@ -79,27 +79,28 @@ function do_like($item_id, $verb) { } $item = $items[0]; + $uid = $item['uid']; - if (!can_write_wall($a, $item['uid']) && ($item['uid'] != 0)) { - logger('like: unable to write on wall ' . $item['uid']); + if (($uid == 0) && local_user()) { + $uid = local_user(); + } + + if (!can_write_wall($uid)) { + logger('like: unable to write on wall ' . $uid); return false; } // Retrieves the local post owner - if ($item['uid'] != 0) { - $owners = q("SELECT `contact`.* FROM `contact` - WHERE `contact`.`self` - AND `contact`.`uid` = %d", - intval($item['uid']) - ); - if (DBM::is_result($owners)) { - $owner_self_contact = $owners[0]; - } else { - logger('like: unknown owner ' . $item['uid']); - return false; - } + $owners = q("SELECT `contact`.* FROM `contact` + WHERE `contact`.`self` + AND `contact`.`uid` = %d", + intval($uid) + ); + if (DBM::is_result($owners)) { + $owner_self_contact = $owners[0]; } else { - $owner_self_contact = ['uid' => 0, 'nick' => 'feed-item']; + logger('like: unknown owner ' . $uid); + return false; } // Retrieve the current logged in user's public contact @@ -116,11 +117,11 @@ function do_like($item_id, $verb) { } // Contact-id is the uid-dependant author contact - if (local_user() == $item['uid']) { + if (local_user() == $uid) { $item_contact_id = $owner_self_contact['id']; $item_contact = $owner_self_contact; } else { - $item_contact_id = Contact::getIdForURL($author_contact['url'], $item['uid']); + $item_contact_id = Contact::getIdForURL($author_contact['url'], $uid); $contacts = q("SELECT * FROM `contact` WHERE `id` = %d", intval($item_contact_id) @@ -244,9 +245,8 @@ EOT; // @todo: Explain this block if (! $item['visible']) { - q("UPDATE `item` SET `visible` = 1 WHERE `id` = %d AND `uid` = %d", - intval($item['id']), - intval($item['uid']) + q("UPDATE `item` SET `visible` = 1 WHERE `id` = %d", + intval($item['id']) ); }