X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=mod%2Fitem.php;h=1c7a970c2da2eda04026e624bbdc35494ab826ad;hb=a7ce601580b07e9b3e7653cbdb0a9b6bbb5c474e;hp=b902f1e354ad2646aee22526892af9e2b31f1111;hpb=ca734f168caaa3a9fb66fd7ada6ecc26e1299ae6;p=friendica.git diff --git a/mod/item.php b/mod/item.php index b902f1e354..1c7a970c2d 100644 --- a/mod/item.php +++ b/mod/item.php @@ -27,7 +27,7 @@ require_once('include/Scrape.php'); require_once('include/diaspora.php'); require_once('include/Contact.php'); -function item_post(&$a) { +function item_post(App &$a) { if((! local_user()) && (! remote_user()) && (! x($_REQUEST,'commenter'))) return; @@ -95,8 +95,7 @@ function item_post(&$a) { $r = q("SELECT * FROM `item` WHERE `id` = %d LIMIT 1", intval($parent) ); - } - elseif ($parent_uri && local_user()) { + } elseif ($parent_uri && local_user()) { // This is coming from an API source, and we are logged in $r = q("SELECT * FROM `item` WHERE `uri` = '%s' AND `uid` = %d LIMIT 1", dbesc($parent_uri), @@ -139,18 +138,9 @@ function item_post(&$a) { // If the contact id doesn't fit with the contact, then set the contact to null $thrparent = q("SELECT `author-link`, `network` FROM `item` WHERE `uri` = '%s' LIMIT 1", dbesc($thr_parent)); - if (count($thrparent) AND ($thrparent[0]["network"] === NETWORK_OSTATUS) + if (dbm::is_result($thrparent) AND ($thrparent[0]["network"] === NETWORK_OSTATUS) AND (normalise_link($parent_contact["url"]) != normalise_link($thrparent[0]["author-link"]))) { - $parent_contact = null; - - $r = q("SELECT * FROM `gcontact` WHERE `nurl` = '%s' LIMIT 1", - dbesc(normalise_link($thrparent[0]["author-link"]))); - if (dbm::is_result($r)) { - $parent_contact = $r[0]; - $parent_contact["thumb"] = $parent_contact["photo"]; - $parent_contact["micro"] = $parent_contact["photo"]; - unset($parent_contact["id"]); - } + $parent_contact = get_contact_details_by_url($thrparent[0]["author-link"]); if (!isset($parent_contact["nick"])) { require_once("include/Scrape.php"); @@ -228,8 +218,9 @@ function item_post(&$a) { intval($profile_uid), intval($post_id) ); - if(! count($i)) + if (! dbm::is_result($i)) { killme(); + } $orig_post = $i[0]; } @@ -568,12 +559,8 @@ function item_post(&$a) { * add a statusnet style reply tag if the original post was from there * and we are replying, and there isn't one already */ - - if($parent AND ($parent_contact['network'] === NETWORK_OSTATUS)) { - if ($parent_contact['id'] != "") - $contact = '@'.$parent_contact['nick'].'+'.$parent_contact['id']; - else - $contact = '@[url='.$parent_contact['url'].']'.$parent_contact['nick'].'[/url]'; + if ($parent AND ($parent_contact['network'] == NETWORK_OSTATUS)) { + $contact = '@[url='.$parent_contact['url'].']'.$parent_contact['nick'].'[/url]'; if (!in_array($contact,$tags)) { $body = $contact.' '.$body; @@ -619,16 +606,17 @@ function item_post(&$a) { continue; $success = handle_tag($a, $body, $inform, $str_tags, (local_user()) ? local_user() : $profile_uid , $tag, $network); - if($success['replaced']) + if ($success['replaced']) { $tagged[] = $tag; - if(is_array($success['contact']) && intval($success['contact']['prv'])) { + } + if (is_array($success['contact']) && intval($success['contact']['prv'])) { $private_forum = true; $private_id = $success['contact']['id']; } } } - if(($private_forum) && (! $parent) && (! $private)) { + if (($private_forum) && (! $parent) && (! $private)) { // we tagged a private forum in a top level post and the message was public. // Restrict it. $private = 1; @@ -638,8 +626,8 @@ function item_post(&$a) { $attachments = ''; $match = false; - if(preg_match_all('/(\[attachment\]([0-9]+)\[\/attachment\])/',$body,$match)) { - foreach($match[2] as $mtch) { + if (preg_match_all('/(\[attachment\]([0-9]+)\[\/attachment\])/',$body,$match)) { + foreach ($match[2] as $mtch) { $r = q("SELECT `id`,`filename`,`filesize`,`filetype` FROM `attach` WHERE `uid` = %d AND `id` = %d LIMIT 1", intval($profile_uid), intval($mtch) @@ -1078,7 +1066,7 @@ function item_post_return($baseurl, $api_source, $return_path) { -function item_content(&$a) { +function item_content(App &$a) { if ((! local_user()) && (! remote_user())) { return;