]> git.mxchange.org Git - friendica.git/blobdiff - include/conversation.php
Merge pull request #8670 from MrPetovan/bug/8626-attach-empty-data
[friendica.git] / include / conversation.php
index a4fe9c00e397a7f6053990ed2997a589b5248330..0eb94181f019fa5ad5c69d313a9b57291ac0f1f8 100644 (file)
@@ -376,17 +376,17 @@ function conversation(App $a, array $items, $mode, $update, $preview = false, $o
                                . "<script> var profile_uid = " . $_SESSION['uid']
                                . "; var netargs = '" . substr(DI::args()->getCommand(), 8)
                                . '?f='
-                               . (!empty($_GET['cid'])    ? '&cid='    . rawurlencode($_GET['cid'])    : '')
-                               . (!empty($_GET['search']) ? '&search=' . rawurlencode($_GET['search']) : '')
-                               . (!empty($_GET['star'])   ? '&star='   . rawurlencode($_GET['star'])   : '')
-                               . (!empty($_GET['order'])  ? '&order='  . rawurlencode($_GET['order'])  : '')
-                               . (!empty($_GET['bmark'])  ? '&bmark='  . rawurlencode($_GET['bmark'])  : '')
-                               . (!empty($_GET['liked'])  ? '&liked='  . rawurlencode($_GET['liked'])  : '')
-                               . (!empty($_GET['conv'])   ? '&conv='   . rawurlencode($_GET['conv'])   : '')
-                               . (!empty($_GET['nets'])   ? '&nets='   . rawurlencode($_GET['nets'])   : '')
-                               . (!empty($_GET['cmin'])   ? '&cmin='   . rawurlencode($_GET['cmin'])   : '')
-                               . (!empty($_GET['cmax'])   ? '&cmax='   . rawurlencode($_GET['cmax'])   : '')
-                               . (!empty($_GET['file'])   ? '&file='   . rawurlencode($_GET['file'])   : '')
+                               . (!empty($_GET['contactid']) ? '&contactid=' . rawurlencode($_GET['contactid']) : '')
+                               . (!empty($_GET['search'])    ? '&search='    . rawurlencode($_GET['search'])    : '')
+                               . (!empty($_GET['star'])      ? '&star='      . rawurlencode($_GET['star'])      : '')
+                               . (!empty($_GET['order'])     ? '&order='     . rawurlencode($_GET['order'])     : '')
+                               . (!empty($_GET['bmark'])     ? '&bmark='     . rawurlencode($_GET['bmark'])     : '')
+                               . (!empty($_GET['liked'])     ? '&liked='     . rawurlencode($_GET['liked'])     : '')
+                               . (!empty($_GET['conv'])      ? '&conv='      . rawurlencode($_GET['conv'])      : '')
+                               . (!empty($_GET['nets'])      ? '&nets='      . rawurlencode($_GET['nets'])      : '')
+                               . (!empty($_GET['cmin'])      ? '&cmin='      . rawurlencode($_GET['cmin'])      : '')
+                               . (!empty($_GET['cmax'])      ? '&cmax='      . rawurlencode($_GET['cmax'])      : '')
+                               . (!empty($_GET['file'])      ? '&file='      . rawurlencode($_GET['file'])      : '')
 
                                . "'; </script>\r\n";
                }
@@ -769,20 +769,12 @@ function conversation_add_children(array $parents, $block_authors, $order, $uid)
 
        $items = [];
 
-       foreach ($parents AS $parent) {
-               $condition = ["`item`.`parent-uri` = ? AND `item`.`uid` IN (0, ?) ",
-                       $parent['uri'], $uid];
-               if ($block_authors) {
-                       $condition[0] .= "AND NOT `author`.`hidden`";
-               }
-
-               $thread_items = Item::selectForUser(local_user(), array_merge(Item::DISPLAY_FIELDLIST, ['contact-uid', 'gravity']), $condition, $params);
+       $follow = Item::activityToIndex(Activity::FOLLOW);
 
-               $comments = conversation_fetch_comments($thread_items, $parent['pinned'] ?? false);
-
-               if (count($comments) != 0) {
-                       $items = array_merge($items, $comments);
-               }
+       foreach ($parents AS $parent) {
+               $condition = ["`item`.`parent-uri` = ? AND `item`.`uid` IN (0, ?) AND (`activity` != ? OR `activity` IS NULL)",
+                       $parent['uri'], $uid, $follow];
+               $items = conversation_fetch_items($parent, $items, $condition, $block_authors, $params);
        }
 
        foreach ($items as $index => $item) {
@@ -796,6 +788,31 @@ function conversation_add_children(array $parents, $block_authors, $order, $uid)
        return $items;
 }
 
+/**
+ * Fetch conversation items
+ *
+ * @param array $parent
+ * @param array $items
+ * @param array $condition
+ * @param boolean $block_authors
+ * @param array $params
+ * @return array
+ */
+function conversation_fetch_items(array $parent, array $items, array $condition, bool $block_authors, array $params) {
+       if ($block_authors) {
+               $condition[0] .= "AND NOT `author`.`hidden`";
+       }
+
+       $thread_items = Item::selectForUser(local_user(), array_merge(Item::DISPLAY_FIELDLIST, ['contact-uid', 'gravity']), $condition, $params);
+
+       $comments = conversation_fetch_comments($thread_items, $parent['pinned'] ?? false);
+
+       if (count($comments) != 0) {
+               $items = array_merge($items, $comments);
+       }
+       return $items;
+}
+
 function item_photo_menu($item) {
        $sub_link = '';
        $poke_link = '';