X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=mod%2Fitem.php;h=61de1e096cd8c68d1eb4b5634154b699ad5e188c;hb=4d35e228c41a1fc6a6de9f50b8ec5c5bb45a9c2d;hp=5489964161dcd04ee61bbf367bed77dd3316df35;hpb=b0fe83216d6247511ea9d27cf1d66a3264cb7303;p=friendica.git diff --git a/mod/item.php b/mod/item.php index 5489964161..61de1e096c 100644 --- a/mod/item.php +++ b/mod/item.php @@ -24,7 +24,6 @@ use Friendica\Core\System; use Friendica\Core\Worker; use Friendica\Database\DBM; use Friendica\Model\Contact; -use Friendica\Model\GContact; use Friendica\Model\Item; use Friendica\Protocol\Diaspora; use Friendica\Protocol\Email; @@ -94,9 +93,9 @@ function item_post(App $a) { if ($thr_parent || $thr_parent_uri) { if ($thr_parent) { - $parent_item = dba::selectFirst('item', [], ['id' => $thr_parent]); + $parent_item = Item::selectFirst([], ['id' => $thr_parent]); } elseif ($thr_parent_uri) { - $parent_item = dba::selectFirst('item', [], ['uri' => $thr_parent_uri, 'uid' => $profile_uid]); + $parent_item = Item::selectFirst([], ['uri' => $thr_parent_uri, 'uid' => $profile_uid]); } // if this isn't the real parent of the conversation, find it @@ -107,7 +106,7 @@ function item_post(App $a) { $thr_parent_contact = Contact::getDetailsByURL($parent_item["author-link"]); if ($parent_item['id'] != $parent_item['parent']) { - $parent_item = dba::selectFirst('item', [], ['id' => $parent_item['parent']]); + $parent_item = Item::selectFirst(Item::ITEM_FIELDLIST, ['id' => $parent_item['parent']]); } } @@ -171,7 +170,7 @@ function item_post(App $a) { $orig_post = null; if ($post_id) { - $orig_post = dba::selectFirst('item', [], ['id' => $post_id]); + $orig_post = Item::selectFirst(Item::ITEM_FIELDLIST, ['id' => $post_id]); } $user = dba::selectFirst('user', [], ['uid' => $profile_uid]); @@ -230,7 +229,7 @@ function item_post(App $a) { $verb = notags(trim($_REQUEST['verb'])); $emailcc = notags(trim($_REQUEST['emailcc'])); $body = escape_tags(trim($_REQUEST['body'])); - $network = notags(trim($_REQUEST['network'])); + $network = notags(trim(defaults($_REQUEST, 'network', NETWORK_DFRN))); $guid = get_guid(32); $postopts = defaults($_REQUEST, 'postopts', ''); @@ -568,7 +567,7 @@ function item_post(App $a) { $network = NETWORK_DFRN; } - $gravity = ($parent ? 6 : 0); + $gravity = ($parent ? GRAVITY_COMMENT : GRAVITY_PARENT); // even if the post arrived via API we are considering that it // originated on this site by default for determining relayability. @@ -577,7 +576,7 @@ function item_post(App $a) { $notify_type = ($parent ? 'comment-new' : 'wall-new'); - $uri = ($message_id ? $message_id : item_new_uri($a->get_hostname(), $profile_uid, $guid)); + $uri = ($message_id ? $message_id : Item::newURI($profile_uid, $guid)); // Fallback so that we alway have a parent uri if (!$thr_parent_uri || !$parent) { @@ -594,11 +593,11 @@ function item_post(App $a) { $datarray['owner-name'] = $contact_record['name']; $datarray['owner-link'] = $contact_record['url']; $datarray['owner-avatar'] = $contact_record['thumb']; - $datarray['owner-id'] = Contact::getIdForURL($datarray['owner-link'], 0); + $datarray['owner-id'] = Contact::getIdForURL($datarray['owner-link']); $datarray['author-name'] = $author['name']; $datarray['author-link'] = $author['url']; $datarray['author-avatar'] = $author['thumb']; - $datarray['author-id'] = Contact::getIdForURL($datarray['author-link'], 0); + $datarray['author-id'] = Contact::getIdForURL($datarray['author-link']); $datarray['created'] = DateTimeFormat::utcNow(); $datarray['edited'] = DateTimeFormat::utcNow(); $datarray['commented'] = DateTimeFormat::utcNow(); @@ -632,8 +631,6 @@ function item_post(App $a) { $datarray['postopts'] = $postopts; $datarray['origin'] = $origin; $datarray['moderated'] = false; - $datarray['gcontact-id'] = GContact::getId(["url" => $datarray['author-link'], "network" => $datarray['network'], - "photo" => $datarray['author-avatar'], "name" => $datarray['author-name']]); $datarray['object'] = $object; /* @@ -650,13 +647,13 @@ function item_post(App $a) { // This field is for storing the raw conversation data $datarray['protocol'] = PROTOCOL_DFRN; - $r = dba::fetch_first("SELECT `conversation-uri`, `conversation-href` FROM `conversation` WHERE `item-uri` = ?", $datarray['parent-uri']); - if (DBM::is_result($r)) { + $conversation = dba::selectFirst('conversation', ['conversation-uri', 'conversation-href'], ['item-uri' => $datarray['parent-uri']]); + if (DBM::is_result($conversation)) { if ($r['conversation-uri'] != '') { - $datarray['conversation-uri'] = $r['conversation-uri']; + $datarray['conversation-uri'] = $conversation['conversation-uri']; } if ($r['conversation-href'] != '') { - $datarray['conversation-href'] = $r['conversation-href']; + $datarray['conversation-href'] = $conversation['conversation-href']; } } @@ -664,6 +661,11 @@ function item_post(App $a) { $datarray['edit'] = true; } + // Check for hashtags in the body and repair or add hashtag links + if ($preview || $orig_post) { + Item::setHashtags($datarray); + } + // preview mode - prepare the body for display and send it via json if ($preview) { require_once 'include/conversation.php'; @@ -735,7 +737,7 @@ function item_post(App $a) { goaway($return_path); } - $datarray = dba::selectFirst('item', [], ['id' => $post_id]); + $datarray = Item::selectFirst(Item::ITEM_FIELDLIST, ['id' => $post_id]); if (!DBM::is_result($datarray)) { logger("Item with id ".$post_id." couldn't be fetched."); @@ -811,7 +813,6 @@ function item_post(App $a) { $link = '' . $a->user['username'] . '

'; $html = prepare_body($datarray); $message = '' . $link . $html . $disclaimer . ''; - include_once 'include/html2plain.php'; $params = [ 'fromName' => $a->user['username'], 'fromEmail' => $a->user['email'], @@ -819,7 +820,7 @@ function item_post(App $a) { 'replyTo' => $a->user['email'], 'messageSubject' => $subject, 'htmlVersion' => $message, - 'textVersion' => html2plain($html.$disclaimer) + 'textVersion' => Friendica\Content\Text\HTML::toPlaintext($html.$disclaimer) ]; Emailer::send($params); } @@ -876,7 +877,7 @@ function item_content(App $a) { $o = ''; if (($a->argc == 3) && ($a->argv[1] === 'drop') && intval($a->argv[2])) { if (is_ajax()) { - $o = Item::deleteById($a->argv[2]); + $o = Item::deleteForUser(['id' => $a->argv[2]], local_user()); } else { $o = drop_item($a->argv[2]); }