From 417d1080d4495ea52469f5292d7bac00f1953eca Mon Sep 17 00:00:00 2001 From: friendica Date: Tue, 6 Nov 2012 00:30:40 -0800 Subject: likes working a bit better - not translateable yet --- include/conversation.php | 9 ++++++--- mod/like.php | 19 ++++++++++++------- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/include/conversation.php b/include/conversation.php index 532fe0ba1..f763bb0b9 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -89,15 +89,17 @@ function localize_item(&$item){ $item['body'] = item_redir_and_replace_images($extracted['body'], $extracted['images'], $item['contact-id']); $xmlhead="<"."?xml version='1.0' encoding='UTF-8' ?".">"; +/* if (activity_match($item['verb'],ACTIVITY_LIKE) || activity_match($item['verb'],ACTIVITY_DISLIKE)){ +// FIXME we shouldn't have a DB lookup on every item $r = q("SELECT * from `item`,`contact` WHERE `item`.`contact-id`=`contact`.`id` AND `item`.`uri`='%s';", dbesc($item['parent_uri'])); if(count($r)==0) return; $obj=$r[0]; - $author = '[url=' . $item['author-link'] . ']' . $item['author-name'] . '[/url]'; + $author = '[url=' . $item['author']['xchan_url'] . ']' . $item['author']['xchan_name'] . '[/url]'; $objauthor = '[url=' . $obj['author-link'] . ']' . $obj['author-name'] . '[/url]'; switch($obj['verb']){ @@ -131,6 +133,7 @@ function localize_item(&$item){ $item['body'] = sprintf($bodyverb, $author, $objauthor, $plink); } +*/ if (activity_match($item['verb'],ACTIVITY_FRIEND)) { if ($item['obj_type']=="" || $item['obj_type']!== ACTIVITY_OBJ_PERSON) return; @@ -1599,7 +1602,7 @@ function like_puller($a,$item,&$arr,$mode) { $verb = (($mode === 'like') ? ACTIVITY_LIKE : ACTIVITY_DISLIKE); if((activity_match($item['verb'],$verb)) && ($item['id'] != $item['parent'])) { - $url = $item['author-link']; + $url = $item['author']['xchan_url']; if((local_user()) && (local_user() == $item['uid']) && ($item['network'] === 'dfrn') && (! $item['self']) && (link_compare($item['author-link'],$item['url']))) { $url = $a->get_baseurl(true) . '/redir/' . $item['contact-id']; $sparkle = ' class="sparkle" '; @@ -1616,7 +1619,7 @@ function like_puller($a,$item,&$arr,$mode) { $arr[$item['thr_parent']] = 1; else $arr[$item['thr_parent']] ++; - $arr[$item['thr_parent'] . '-l'][] = '' . $item['author-name'] . ''; + $arr[$item['thr_parent'] . '-l'][] = '' . $item['author']['xchan_name'] . ''; } return; }} diff --git a/mod/like.php b/mod/like.php index 973dc45f8..6a58d67bd 100755 --- a/mod/like.php +++ b/mod/like.php @@ -44,7 +44,7 @@ function like_content(&$a) { if(! $item_id || (! $r)) { logger('like: no item ' . $item_id); - return; + killme(); } $item = $r[0]; @@ -53,10 +53,16 @@ function like_content(&$a) { if(! perm_is_allowed($owner_uid,$observer['xchan_hash'],'post_comments')) { notice( t('Permission denied') . EOL); - return; + killme(); } - $remote_owner = $item['owner_xchan']; + $r = q("select * from xchan where xchan_hash = '%s' limit 1", + dbesc($item['owner_xchan']) + ); + if($r) + $remote_owner = $r[0]; + else + killme(); @@ -110,11 +116,10 @@ function like_content(&$a) { // } - $r = q("SELECT * FROM item WHERE verb = '%s' AND ( item_restrict & %d ) + $r = q("SELECT * FROM item WHERE verb = '%s' AND item_restrict = 0 AND owner_xchan = '%s' AND ( parent = %d OR thr_parent = '%s') LIMIT 1", dbesc($activity), - intval(ITEM_DELETED), - dbesc($remote_owner), + dbesc($remote_owner['xchan_hash']), intval($item_id), dbesc($item['uri']) ); @@ -174,7 +179,7 @@ function like_content(&$a) { $arr['parent'] = $item['id']; $arr['parent_uri'] = $item['uri']; $arr['thr_parent'] = $item['uri']; - $arr['owner_xchan'] = $remote_owner; + $arr['owner_xchan'] = $remote_owner['xchan_hash']; $arr['author_xchan'] = $observer['xchan_hash']; -- cgit v1.2.3