]> git.mxchange.org Git - friendica.git/blobdiff - include/conversation.php
Improve expectation for not modified check in theme/vier/style
[friendica.git] / include / conversation.php
index 1e8437f71532753752a354821ad55b7221936c1b..22cd71957b17e2dc00317955fbbe6065f008b312 100644 (file)
@@ -452,8 +452,8 @@ function conversation(App $a, array $items, $mode, $update, $preview = false, $o
                $profile_owner = 0;
 
                if (!$update) {
-                       $live_update_div = '<div id="live-contacts"></div>' . "\r\n"
-                               . "<script> var profile_uid = -1; var netargs = '" . substr(DI::args()->getCommand(), 9)
+                       $live_update_div = '<div id="live-contact"></div>' . "\r\n"
+                               . "<script> var profile_uid = -1; var netargs = '" . substr(DI::args()->getCommand(), 8)
                                ."/?f='; </script>\r\n";
                }
        } elseif ($mode === 'search') {
@@ -501,7 +501,7 @@ function conversation(App $a, array $items, $mode, $update, $preview = false, $o
                        $writable = false;
                }
 
-               if (in_array($mode, ['network-new', 'search', 'contact-posts'])) {
+               if (in_array($mode, ['filed', 'search', 'contact-posts'])) {
 
                        /*
                         * "New Item View" on network page or search page results
@@ -548,7 +548,7 @@ function conversation(App $a, array $items, $mode, $update, $preview = false, $o
                                $location_html = $locate['html'] ?: Strings::escapeHtml($locate['location'] ?: $locate['coord'] ?: '');
 
                                localize_item($item);
-                               if ($mode === 'network-new') {
+                               if ($mode === 'filed') {
                                        $dropping = true;
                                } else {
                                        $dropping = false;
@@ -562,9 +562,10 @@ function conversation(App $a, array $items, $mode, $update, $preview = false, $o
                                ];
 
                                $likebuttons = [
-                                       'like'    => null,
-                                       'dislike' => null,
-                                       'share'   => null,
+                                       'like'     => null,
+                                       'dislike'  => null,
+                                       'share'    => null,
+                                       'announce' => null,
                                ];
 
                                if (DI::pConfig()->get(local_user(), 'system', 'hide_dislike')) {
@@ -696,6 +697,7 @@ function conversation(App $a, array $items, $mode, $update, $preview = false, $o
                '$live_update' => $live_update_div,
                '$remove' => DI::l10n()->t('remove'),
                '$mode' => $mode,
+               '$update' => $update,
                '$user' => $a->user,
                '$threads' => $threads,
                '$dropping' => ($page_dropping ? DI::l10n()->t('Delete Selected Items') : False),
@@ -709,13 +711,28 @@ function conversation(App $a, array $items, $mode, $update, $preview = false, $o
  *
  * @param mixed   $thread_items Database statement with thread posts
  * @param boolean $pinned       Is the item pinned?
+ * @param integer $causer       Contact ID of the resharer
  *
  * @return array items with parents and comments
  */
-function conversation_fetch_comments($thread_items, $pinned) {
+function conversation_fetch_comments($thread_items, $pinned, $causer) {
        $comments = [];
 
        while ($row = Item::fetch($thread_items)) {
+               if (!empty($causer)) {
+                       if (($row['gravity'] == GRAVITY_PARENT)) {
+                               $row['post-type'] = Item::PT_ANNOUNCEMENT;
+                               $row['causer-id'] = $causer;
+                               $contact = Contact::getById($causer, ['url', 'name', 'thumb']);
+                               $row['causer-link'] = $contact['url'];
+                               $row['causer-avatar'] = $contact['thumb'];
+                               $row['causer-name'] = $contact['name'];
+                       } elseif (($row['gravity'] == GRAVITY_ACTIVITY) && ($row['verb'] == Activity::ANNOUNCE) &&
+                               ($row['author-id'] == $causer)) {
+                               continue;
+                       }
+               }
+
                $name = $row['causer-contact-type'] == Contact::TYPE_RELAY ? $row['causer-link'] : $row['causer-name'];
 
                switch ($row['post-type']) {
@@ -739,6 +756,7 @@ function conversation_fetch_comments($thread_items, $pinned) {
                                break;
                        case Item::PT_ANNOUNCEMENT:
                                if (!empty($row['causer-id']) && DI::pConfig()->get(local_user(), 'system', 'display_resharer')) {
+                                       $row['owner-id'] = $row['causer-id'];
                                        $row['owner-link'] = $row['causer-link'];
                                        $row['owner-avatar'] = $row['causer-avatar'];
                                        $row['owner-name'] = $row['causer-name'];
@@ -808,9 +826,16 @@ function conversation_add_children(array $parents, $block_authors, $order, $uid)
        $items = [];
 
        foreach ($parents AS $parent) {
-               $condition = ["`item`.`parent-uri` = ? AND `item`.`uid` IN (0, ?) AND (`vid` != ? OR `vid` IS NULL)",
-                       $parent['uri'], $uid, Verb::getID(Activity::FOLLOW)];
-               $items = conversation_fetch_items($parent, $items, $condition, $block_authors, $params);
+               if (!empty($parent['thr-parent-id']) && !empty($parent['gravity']) && ($parent['gravity'] == GRAVITY_ACTIVITY)) {
+                       $condition = ["`item`.`parent-uri-id` = ? AND `item`.`uid` IN (0, ?) AND (`vid` != ? OR `vid` IS NULL)",
+                               $parent['thr-parent-id'], $uid, Verb::getID(Activity::FOLLOW)];
+                       $causer = $parent['author-id'] ?? 0;
+               } else {
+                       $condition = ["`item`.`parent-uri` = ? AND `item`.`uid` IN (0, ?) AND (`vid` != ? OR `vid` IS NULL)",
+                               $parent['uri'], $uid, Verb::getID(Activity::FOLLOW)];
+                       $causer = 0;
+               }
+               $items = conversation_fetch_items($parent, $items, $condition, $block_authors, $params, $causer);
        }
 
        foreach ($items as $index => $item) {
@@ -827,21 +852,22 @@ function conversation_add_children(array $parents, $block_authors, $order, $uid)
 /**
  * Fetch conversation items
  *
- * @param array $parent
- * @param array $items
- * @param array $condition
- * @param boolean $block_authors
- * @param array $params
+ * @param array   $parent        Parent Item array
+ * @param array   $items         Item array
+ * @param array   $condition     SQL condition
+ * @param boolean $block_authors Don't show posts from contacts that are hidden (used on the community page)
+ * @param array   $params        SQL parameters
+ * @param integer $causer        Contact ID of the resharer
  * @return array
  */
-function conversation_fetch_items(array $parent, array $items, array $condition, bool $block_authors, array $params) {
+function conversation_fetch_items(array $parent, array $items, array $condition, bool $block_authors, array $params, int $causer) {
        if ($block_authors) {
                $condition[0] .= " AND NOT `author`.`hidden`";
        }
 
        $thread_items = Item::selectForUser(local_user(), array_merge(Item::DISPLAY_FIELDLIST, ['contact-uid', 'gravity', 'post-type']), $condition, $params);
 
-       $comments = conversation_fetch_comments($thread_items, $parent['pinned'] ?? false);
+       $comments = conversation_fetch_comments($thread_items, $parent['pinned'] ?? false, $causer);
 
        if (count($comments) != 0) {
                $items = array_merge($items, $comments);
@@ -927,7 +953,7 @@ function item_photo_menu($item) {
 
                if ((($cid == 0) || ($rel == Contact::FOLLOWER)) &&
                        in_array($item['network'], Protocol::FEDERATED)) {
-                       $menu[DI::l10n()->t('Connect/Follow')] = 'follow?url=' . urlencode($item['author-link']);
+                       $menu[DI::l10n()->t('Connect/Follow')] = 'follow?url=' . urlencode($item['author-link']) . '&auto=1';
                }
        } else {
                $menu = [DI::l10n()->t('View Profile') => $item['author-link']];