]> git.mxchange.org Git - friendica.git/blobdiff - include/conversation.php
Merge pull request #4183 from MrPetovan/bug/4173-fix-oembed-iframe-url
[friendica.git] / include / conversation.php
index 97630a65fb22633307b1397010bbce8310aded9d..472896ffec2e45c3d342e8d11cd036bd1c2a8f05 100644 (file)
@@ -589,11 +589,8 @@ function conversation(App $a, $items, $mode, $update, $preview = false) {
 
        $page_dropping = ((local_user() && local_user() == $profile_owner) ? true : false);
 
-
-       if ($update) {
-               $return_url = $_SESSION['return_url'];
-       } else {
-               $return_url = $_SESSION['return_url'] = $a->query_string;
+       if (!$update) {
+               $_SESSION['return_url'] = $a->query_string;
        }
 
        $cb = array('items' => $items, 'mode' => $mode, 'update' => $update, 'preview' => $preview);
@@ -601,9 +598,6 @@ function conversation(App $a, $items, $mode, $update, $preview = false) {
 
        $items = $cb['items'];
 
-       $cmnt_tpl    = get_markup_template('comment_item.tpl');
-       $hide_comments_tpl = get_markup_template('hide_comments.tpl');
-
        $conv_responses = array(
                'like' => array('title' => t('Likes','title')), 'dislike' => array('title' => t('Dislikes','title')),
                'attendyes' => array('title' => t('Attending','title')), 'attendno' => array('title' => t('Not attending','title')), 'attendmaybe' => array('title' => t('Might attend','title'))
@@ -624,7 +618,7 @@ function conversation(App $a, $items, $mode, $update, $preview = false) {
                                $community_readonly = false;
                                $writable = true;
                        } else {
-                               $writable = ($items[0]['uid'] == 0) && in_array($items[0]['network'], array(NETWORK_OSTATUS, NETWORK_DIASPORA));
+                               $writable = ($items[0]['uid'] == 0) && in_array($items[0]['network'], array(NETWORK_OSTATUS, NETWORK_DIASPORA, NETWORK_DFRN));
                        }
                } else {
                        $writable = false;
@@ -634,7 +628,7 @@ function conversation(App $a, $items, $mode, $update, $preview = false) {
                        $writable = false;
                }
 
-               if ($mode === 'network-new' || $mode === 'search' || $community_readonly) {
+               if (in_array($mode, ['network-new', 'search', 'contact-posts']) || $community_readonly) {
 
                        /*
                         * "New Item View" on network page or search page results
@@ -759,7 +753,6 @@ function conversation(App $a, $items, $mode, $update, $preview = false) {
 
                                $lock = false;
                                $likebuttons = false;
-                               $shareable = false;
 
                                $body = prepare_body($item, true, $preview);
 
@@ -844,9 +837,7 @@ function conversation(App $a, $items, $mode, $update, $preview = false) {
                         * this shouldn't be needed, as we should have only them in our array
                         * But for now, this array respects the old style, just in case
                         */
-                       $threads = array();
                        foreach ($items as $item) {
-
                                if ($arr_blocked) {
                                        $blocked = false;
                                        foreach ($arr_blocked as $b) {
@@ -883,7 +874,6 @@ function conversation(App $a, $items, $mode, $update, $preview = false) {
                        }
 
                        $threads = $conv->getTemplateData($conv_responses);
-
                        if (!$threads) {
                                logger('[ERROR] conversation : Failed to get template data.', LOGGER_DEBUG);
                                $threads = array();
@@ -929,6 +919,21 @@ function community_add_items($parents) {
                );
                $comments = dba::inArray($thread_items);
 
+               // 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 = array();
+                       }
+               }
+
                if (count($comments) == 0) {
                        $thread_items = dba::p(item_query()." AND `item`.`uid` = 0
                                AND `item`.`parent-uri` = ?
@@ -945,7 +950,7 @@ function community_add_items($parents) {
 
        foreach ($items as $index => $item) {
                if ($item['uid'] == 0) {
-                       $items[$index]['writable'] = in_array($item['network'], [NETWORK_DIASPORA, NETWORK_OSTATUS]);
+                       $items[$index]['writable'] = in_array($item['network'], [NETWORK_OSTATUS, NETWORK_DIASPORA, NETWORK_DFRN]);
                }
        }
 
@@ -1000,7 +1005,6 @@ function item_photo_menu($item) {
        $status_link = '';
        $photos_link = '';
        $posts_link = '';
-       $network = '';
 
        if ((local_user()) && local_user() == $item['uid'] && $item['parent'] == $item['id'] && (! $item['self'])) {
                $sub_link = 'javascript:dosubthread(' . $item['id'] . '); return false;';
@@ -1026,7 +1030,6 @@ function item_photo_menu($item) {
                $status_link = $profile_link . '?url=status';
                $photos_link = $profile_link . '?url=photos';
                $profile_link = $profile_link . '?url=profile';
-               $zurl = '';
        } else {
                $profile_link = zrl($profile_link);
        }
@@ -1113,7 +1116,6 @@ function builtin_activity_puller($item, &$conv_responses) {
                                break;
                        default:
                                return;
-                               break;
                }
 
                if ((activity_match($item['verb'], $verb)) && ($item['id'] != $item['parent'])) {
@@ -1361,7 +1363,6 @@ function status_editor(App $a, $x, $notes_cid = 0, $popup = false)
 
                // ACL permissions box
                '$acl'           => $x['acl'],
-               '$acl_data'      => $x['acl_data'],
                '$group_perms'   => t('Post to Groups'),
                '$contact_perms' => t('Post to Contacts'),
                '$private'       => t('Private post'),
@@ -1656,22 +1657,25 @@ function get_responses($conv_responses, $response_verbs, $ob, $item) {
        return $ret;
 }
 
-function get_response_button_text($v, $count) {
+function get_response_button_text($v, $count)
+{
        switch ($v) {
                case 'like':
-                       return tt('Like', 'Likes', $count, 'noun');
+                       $return = tt('Like', 'Likes', $count);
                        break;
                case 'dislike':
-                       return tt('Dislike', 'Dislikes', $count, 'noun');
+                       $return = tt('Dislike', 'Dislikes', $count);
                        break;
                case 'attendyes':
-                       return tt('Attending', 'Attending', $count, 'noun');
+                       $return = tt('Attending', 'Attending', $count);
                        break;
                case 'attendno':
-                       return tt('Not Attending', 'Not Attending', $count, 'noun');
+                       $return = tt('Not Attending', 'Not Attending', $count);
                        break;
                case 'attendmaybe':
-                       return tt('Undecided', 'Undecided', $count, 'noun');
+                       $return = tt('Undecided', 'Undecided', $count);
                        break;
        }
+
+       return $return;
 }