X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=mod%2Fsubthread.php;h=646a4230c5f486819100624ddf754231b52814d1;hb=325d3afe183a397ea6688480c1b2df8e1be99dc1;hp=6cbaa1d2a744be3b466d6fcfba7adcda1b9e50a8;hpb=0c764684bb32a9432fd161e62db907efb78af1a5;p=friendica.git diff --git a/mod/subthread.php b/mod/subthread.php index 6cbaa1d2a7..646a4230c5 100644 --- a/mod/subthread.php +++ b/mod/subthread.php @@ -4,8 +4,8 @@ require_once('include/security.php'); require_once('include/bbcode.php'); require_once('include/items.php'); -if(! function_exists('subthread_content')) { -function subthread_content(&$a) { + +function subthread_content(App $a) { if(! local_user() && ! remote_user()) { return; @@ -20,7 +20,7 @@ function subthread_content(&$a) { dbesc($item_id) ); - if(! $item_id || (! count($r))) { + if(! $item_id || (! dbm::is_result($r))) { logger('subthread: no item ' . $item_id); return; } @@ -41,10 +41,12 @@ function subthread_content(&$a) { intval($item['contact-id']), intval($item['uid']) ); - if(! count($r)) + if (! dbm::is_result($r)) { return; - if(! $r[0]['self']) + } + if (! $r[0]['self']) { $remote_owner = $r[0]; + } } // this represents the post owner on this system. @@ -53,40 +55,39 @@ function subthread_content(&$a) { WHERE `contact`.`self` = 1 AND `contact`.`uid` = %d LIMIT 1", intval($owner_uid) ); - if(count($r)) + if (dbm::is_result($r)) $owner = $r[0]; - if(! $owner) { + if (! $owner) { logger('like: no owner'); return; } - if(! $remote_owner) + if (! $remote_owner) $remote_owner = $owner; // This represents the person posting - if((local_user()) && (local_user() == $owner_uid)) { + if ((local_user()) && (local_user() == $owner_uid)) { $contact = $owner; - } - else { + } else { $r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1", intval($_SESSION['visitor_id']), intval($owner_uid) ); - if(count($r)) + if (dbm::is_result($r)) $contact = $r[0]; } - if(! $contact) { + if (! $contact) { return; } $uri = item_new_uri($a->get_hostname(),$owner_uid); $post_type = (($item['resource-id']) ? t('photo') : t('status')); - $objtype = (($item['resource-id']) ? ACTIVITY_OBJ_PHOTO : ACTIVITY_OBJ_NOTE ); - $link = xmlify('' . "\n") ; + $objtype = (($item['resource-id']) ? ACTIVITY_OBJ_IMAGE : ACTIVITY_OBJ_NOTE ); + $link = xmlify('' . "\n") ; $body = $item['body']; $obj = <<< EOT @@ -102,11 +103,13 @@ function subthread_content(&$a) { EOT; $bodyverb = t('%1$s is following %2$s\'s %3$s'); - if(! isset($bodyverb)) - return; + if (! isset($bodyverb)) { + return; + } $arr = array(); + $arr['guid'] = get_guid(32); $arr['uri'] = $uri; $arr['uid'] = $owner_uid; $arr['contact-id'] = $contact['id']; @@ -126,7 +129,7 @@ EOT; $ulink = '[url=' . $contact['url'] . ']' . $contact['name'] . '[/url]'; $alink = '[url=' . $item['author-link'] . ']' . $item['author-name'] . '[/url]'; - $plink = '[url=' . $a->get_baseurl() . '/display/' . $owner['nickname'] . '/' . $item['id'] . ']' . $post_type . '[/url]'; + $plink = '[url=' . App::get_baseurl() . '/display/' . $owner['nickname'] . '/' . $item['id'] . ']' . $post_type . '[/url]'; $arr['body'] = sprintf( $bodyverb, $ulink, $alink, $plink ); $arr['verb'] = $activity; @@ -142,7 +145,7 @@ EOT; $post_id = item_store($arr); - if(! $item['visible']) { + if (! $item['visible']) { $r = q("UPDATE `item` SET `visible` = 1 WHERE `id` = %d AND `uid` = %d", intval($item['id']), intval($owner_uid) @@ -154,5 +157,7 @@ EOT; call_hooks('post_local_end', $arr); killme(); + } -} + +