]> git.mxchange.org Git - friendica.git/blobdiff - include/conversation.php
removed one line too much
[friendica.git] / include / conversation.php
index 1b5f5a0983d9b1488977e9818928edc8bb1eb65b..324b53b5a880410584f5695a48b15c4798f17188 100644 (file)
@@ -433,7 +433,6 @@ These Fields are not added below (yet). They are here to for bug search.
 `item`.`bookmark`,
 `item`.`unseen`,
 `item`.`deleted`,
-`item`.`origin`,
 `item`.`forum_mode`,
 `item`.`mention`,
 `item`.`global`,
@@ -446,7 +445,7 @@ These Fields are not added below (yet). They are here to for bug search.
                `item`.`uri`, `item`.`thr-parent`, `item`.`parent-uri`, `item`.`content-warning`,
                `item`.`commented`, `item`.`created`, `item`.`edited`, `item`.`received`,
                `item`.`verb`, `item`.`object-type`, `item`.`postopts`, `item`.`plink`,
-               `item`.`guid`, `item`.`wall`, `item`.`private`, `item`.`starred`,
+               `item`.`guid`, `item`.`wall`, `item`.`private`, `item`.`starred`, `item`.`origin`,
                `item`.`title`, `item`.`body`, `item`.`file`, `item`.`event-id`,
                `item`.`location`, `item`.`coord`, `item`.`app`, `item`.`attach`,
                `item`.`rendered-hash`, `item`.`rendered-html`, `item`.`object`,
@@ -470,11 +469,15 @@ These Fields are not added below (yet). They are here to for bug search.
  * @brief SQL join for contacts that are needed for displaying items
  */
 function item_joins() {
-       return "STRAIGHT_JOIN `contact` ON `contact`.`id` = `item`.`contact-id` AND
-               (NOT `contact`.`blocked` OR `contact`.`pending`)
-               LEFT JOIN `contact` AS `author` ON `author`.`id`=`item`.`author-id`
-               LEFT JOIN `contact` AS `owner` ON `owner`.`id`=`item`.`owner-id`
-               LEFT JOIN `event` ON `event-id` = `event`.`id`";
+       return sprintf("STRAIGHT_JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
+               AND NOT `contact`.`blocked`
+               AND ((NOT `contact`.`readonly` AND NOT `contact`.`pending` AND (`contact`.`rel` IN (%s, %s)))
+               OR `contact`.`self` OR (`item`.`id` != `item`.`parent`) OR `contact`.`uid` = 0)
+               INNER JOIN `contact` AS `author` ON `author`.`id`=`item`.`author-id` AND NOT `author`.`blocked`
+               INNER JOIN `contact` AS `owner` ON `owner`.`id`=`item`.`owner-id` AND NOT `owner`.`blocked`
+               LEFT JOIN `event` ON `event-id` = `event`.`id`",
+               CONTACT_IS_SHARING, CONTACT_IS_FRIEND
+       );
 }
 
 /**
@@ -668,33 +671,7 @@ function conversation(App $a, $items, $mode, $update, $preview = false, $order =
                                        $profile_name = $item['author-link'];
                                }
 
-                               $tags = [];
-                               $hashtags = [];
-                               $mentions = [];
-
-                               $searchpath = System::baseUrl()."/search?tag=";
-
-                               $taglist = dba::select('term', ['type', 'term', 'url'],
-                                                       ["`otype` = ? AND `oid` = ? AND `type` IN (?, ?)", TERM_OBJ_POST, $item['id'], TERM_HASHTAG, TERM_MENTION],
-                                                       ['order' => ['tid']]);
-
-                               while ($tag = dba::fetch($taglist)) {
-                                       if ($tag["url"] == "") {
-                                               $tag["url"] = $searchpath . strtolower($tag["term"]);
-                                       }
-
-                                       $tag["url"] = best_link_url($item, $sp, $tag["url"]);
-
-                                       if ($tag["type"] == TERM_HASHTAG) {
-                                               $hashtags[] = "#<a href=\"" . $tag["url"] . "\" target=\"_blank\">" . $tag["term"] . "</a>";
-                                               $prefix = "#";
-                                       } elseif ($tag["type"] == TERM_MENTION) {
-                                               $mentions[] = "@<a href=\"" . $tag["url"] . "\" target=\"_blank\">" . $tag["term"] . "</a>";
-                                               $prefix = "@";
-                                       }
-                                       $tags[] = $prefix."<a href=\"" . $tag["url"] . "\" target=\"_blank\">" . $tag["term"] . "</a>";
-                               }
-                               dba::close($taglist);
+                               $tags = \Friendica\Model\Term::populateTagsFromItem($item);
 
                                $sp = false;
                                $profile_link = best_link_url($item, $sp);
@@ -764,9 +741,9 @@ function conversation(App $a, $items, $mode, $update, $preview = false, $order =
                                }
 
                                $body_e = $body;
-                               $tags_e = $tags;
-                               $hashtags_e = $hashtags;
-                               $mentions_e = $mentions;
+                               $tags_e = $tags['tags'];
+                               $hashtags_e = $tags['hashtags'];
+                               $mentions_e = $tags['mentions'];
                                $location_e = $location;
                                $owner_name_e = $owner_name;
 
@@ -922,37 +899,12 @@ function conversation_add_children($parents, $block_authors, $order) {
        $block_sql = $block_authors ? "AND NOT `author`.`hidden` AND NOT `author`.`blocked`" : "";
 
        foreach ($parents AS $parent) {
-               $thread_items = dba::p(item_query()." AND `item`.`uid` = ?
-                       AND `item`.`parent-uri` = ? $block_sql
-                       ORDER BY `item`.`commented` DESC" . $limit,
-                       local_user(),
-                       $parent['uri']
-               );
-               $comments = dba::inArray($thread_items);
+               $thread_items = dba::p(item_query()."AND `item`.`parent-uri` = ?
+                       AND `item`.`uid` IN (0, ?) $block_sql
+                       ORDER BY `item`.`uid` ASC, `item`.`commented` DESC" . $limit,
+                       $parent['uri'], local_user());
 
-               // Check if the original item is in the result.
-               // When commenting from the community page there can be incomplete threads
-               if (count($comments) > 0) {
-                       $parent_found = false;
-                       foreach ($comments as $comment) {
-                               if ($comment['uri'] == $comment['parent-uri']) {
-                                       $parent_found = true;
-                                       break;
-                               }
-                       }
-                       if (!$parent_found) {
-                               $comments = [];
-                       }
-               }
-
-               if (count($comments) == 0) {
-                       $thread_items = dba::p(item_query()." AND `item`.`uid` = 0
-                               AND `item`.`parent-uri` = ?
-                               ORDER BY `item`.`commented` DESC LIMIT ".intval($max_comments + 1),
-                               $parent['uri']
-                       );
-                       $comments = dba::inArray($thread_items);
-               }
+               $comments = dba::inArray($thread_items);
 
                if (count($comments) != 0) {
                        $items = array_merge($items, $comments);
@@ -1335,6 +1287,7 @@ function status_editor(App $a, $x, $notes_cid = 0, $popup = false)
        $tpl = get_markup_template("jot.tpl");
 
        $o .= replace_macros($tpl,[
+               '$new_post' => L10n::t('New Post'),
                '$return_path'  => $query_str,
                '$action'       => 'item',
                '$share'        => defaults($x, 'button', L10n::t('Share')),