]> git.mxchange.org Git - friendica.git/blobdiff - include/conversation.php
Degrade priority step by step
[friendica.git] / include / conversation.php
index 09fc682b846bb691af3e066511583659e92ea3b0..e58df19f16cc03908d0c71174fc569750b4530ff 100644 (file)
@@ -1,9 +1,10 @@
 <?php
 
+use Friendica\App;
+
 require_once "include/bbcode.php";
 require_once "include/acl_selectors.php";
 
-
 /*
  * Note: the code in 'item_extract_images' and 'item_redir_and_replace_images'
  * is identical to the code in mod/message.php for 'item_extract_images' and
@@ -374,8 +375,9 @@ function count_descendants($item) {
 
        if ($total > 0) {
                foreach ($item['children'] as $child) {
-                       if (! visible_activity($child))
+                       if (! visible_activity($child)) {
                                $total --;
+                       }
                        $total += count_descendants($child);
                }
        }
@@ -389,10 +391,9 @@ function visible_activity($item) {
         * likes (etc.) can apply to other things besides posts. Check if they are post children,
         * in which case we handle them specially
         */
-
        $hidden_activities = array(ACTIVITY_LIKE, ACTIVITY_DISLIKE, ACTIVITY_ATTEND, ACTIVITY_ATTENDNO, ACTIVITY_ATTENDMAYBE);
        foreach ($hidden_activities as $act) {
-               if (activity_match($item['verb'],$act)) {
+               if (activity_match($item['verb'], $act)) {
                        return false;
                }
        }
@@ -410,8 +411,8 @@ function visible_activity($item) {
  * @brief SQL query for items
  */
 function item_query() {
-       return "SELECT ".item_fieldlists()." FROM `item` ".
-               item_joins()." WHERE ".item_condition();
+       return "SELECT " . item_fieldlists() . " FROM `item` " .
+               item_joins() . " WHERE " . item_condition();
 }
 
 /**
@@ -508,9 +509,9 @@ function conversation(App $a, $items, $mode, $update, $preview = false) {
        $arr_blocked = null;
 
        if (local_user()) {
-               $str_blocked = get_pconfig(local_user(),'system','blocked');
+               $str_blocked = get_pconfig(local_user(), 'system', 'blocked');
                if ($str_blocked) {
-                       $arr_blocked = explode(',',$str_blocked);
+                       $arr_blocked = explode(',', $str_blocked);
                        for ($x = 0; $x < count($arr_blocked); $x ++) {
                                $arr_blocked[$x] = trim($arr_blocked[$x]);
                        }
@@ -639,7 +640,7 @@ function conversation(App $a, $items, $mode, $update, $preview = false) {
                                if ($arr_blocked) {
                                        $blocked = false;
                                        foreach ($arr_blocked as $b) {
-                                               if ($b && link_compare($item['author-link'],$b)) {
+                                               if ($b && link_compare($item['author-link'], $b)) {
                                                        $blocked = true;
                                                        break;
                                                }
@@ -711,7 +712,7 @@ function conversation(App $a, $items, $mode, $update, $preview = false) {
                                        $profile_link = zrl($profile_link);
                                }
 
-                               if (!x($item, 'author-thumb') OR ($item['author-thumb'] == "")) {
+                               if (!x($item, 'author-thumb') || ($item['author-thumb'] == "")) {
                                        $author_contact = get_contact_details_by_url($item['author-link'], $profile_owner);
                                        if ($author_contact["thumb"]) {
                                                $item['author-thumb'] = $author_contact["thumb"];
@@ -720,7 +721,7 @@ function conversation(App $a, $items, $mode, $update, $preview = false) {
                                        }
                                }
 
-                               if (!isset($item['owner-thumb']) OR ($item['owner-thumb'] == "")) {
+                               if (!isset($item['owner-thumb']) || ($item['owner-thumb'] == "")) {
                                        $owner_contact = get_contact_details_by_url($item['owner-link'], $profile_owner);
                                        if ($owner_contact["thumb"]) {
                                                $item['owner-thumb'] = $owner_contact["thumb"];
@@ -858,7 +859,7 @@ function conversation(App $a, $items, $mode, $update, $preview = false) {
                                if ($arr_blocked) {
                                        $blocked = false;
                                        foreach ($arr_blocked as $b) {
-                                               if ($b && link_compare($item['author-link'],$b)) {
+                                               if ($b && link_compare($item['author-link'], $b)) {
                                                        $blocked = true;
                                                        break;
                                                }
@@ -907,7 +908,7 @@ function conversation(App $a, $items, $mode, $update, $preview = false) {
                '$mode' => $mode,
                '$user' => $a->user,
                '$threads' => $threads,
-               '$dropping' => ($page_dropping && feature_enabled(local_user(),'multi_delete') ? t('Delete Selected Items') : False),
+               '$dropping' => ($page_dropping && feature_enabled(local_user(), 'multi_delete') ? t('Delete Selected Items') : False),
        ));
 
        return $o;
@@ -1012,7 +1013,7 @@ function item_photo_menu($item) {
                        $menu[t("Poke")] = $poke_link;
                }
 
-               if ((($cid == 0) OR ($rel == CONTACT_IS_FOLLOWER)) AND
+               if ((($cid == 0) || ($rel == CONTACT_IS_FOLLOWER)) &&
                        in_array($item['network'], array(NETWORK_DFRN, NETWORK_OSTATUS, NETWORK_DIASPORA))) {
                        $menu[t('Connect/Follow')] = 'follow?url=' . urlencode($item['author-link']);
                }
@@ -1075,7 +1076,7 @@ function builtin_activity_puller($item, &$conv_responses) {
 
                if ((activity_match($item['verb'], $verb)) && ($item['id'] != $item['parent'])) {
                        $url = $item['author-link'];
-                       if ((local_user()) && (local_user() == $item['uid']) && ($item['network'] === NETWORK_DFRN) && (! $item['self']) && (link_compare($item['author-link'],$item['url']))) {
+                       if ((local_user()) && (local_user() == $item['uid']) && ($item['network'] === NETWORK_DFRN) && (! $item['self']) && (link_compare($item['author-link'], $item['url']))) {
                                $url = 'redir/' . $item['contact-id'];
                                $sparkle = ' class="sparkle" ';
                        } else {
@@ -1155,8 +1156,9 @@ function format_like($cnt, array $arr, $type, $id) {
 
        if ($cnt > 1) {
                $total = count($arr);
-               if ($total >= MAX_LIKERS)
+               if ($total >= MAX_LIKERS) {
                        $arr = array_slice($arr, 0, MAX_LIKERS - 1);
+               }
                if ($total < MAX_LIKERS) {
                        $last = t('and') . ' ' . $arr[count($arr)-1];
                        $arr2 = array_slice($arr, 0, -1);
@@ -1208,7 +1210,7 @@ function format_like($cnt, array $arr, $type, $id) {
        return $o;
 }}
 
-function status_editor($a,$x, $notes_cid = 0, $popup = false) {
+function status_editor(App $a, $x, $notes_cid = 0, $popup = false) {
        $o = '';
 
        $geotag = (x($x, 'allow_location') ? replace_macros(get_markup_template('jot_geotag.tpl'), array()) : '');
@@ -1249,7 +1251,7 @@ function status_editor($a,$x, $notes_cid = 0, $popup = false) {
 
        // Private/public post links for the non-JS ACL form
        $private_post = 1;
-       if ($_REQUEST['public']) {
+       if (x($_REQUEST, 'public')) {
                $private_post = 0;
        }
 
@@ -1293,7 +1295,7 @@ function status_editor($a,$x, $notes_cid = 0, $popup = false) {
                '$title' => $x['title'],
                '$placeholdertitle' => t('Set title'),
                '$category' => $x['category'],
-               '$placeholdercategory' => (feature_enabled(local_user(),'categories') ? t('Categories (comma-separated list)') : ''),
+               '$placeholdercategory' => (feature_enabled(local_user(), 'categories') ? t('Categories (comma-separated list)') : ''),
                '$wait' => t('Please wait'),
                '$permset' => t('Permission settings'),
                '$shortpermset' => t('permissions'),
@@ -1414,14 +1416,14 @@ function conv_sort($arr, $order) {
                }
        }
 
-       if (stristr($order,'created')) {
-               usort($parents,'sort_thr_created');
-       } elseif (stristr($order,'commented')) {
-               usort($parents,'sort_thr_commented');
+       if (stristr($order, 'created')) {
+               usort($parents, 'sort_thr_created');
+       } elseif (stristr($order, 'commented')) {
+               usort($parents, 'sort_thr_commented');
        }
 
        if (count($parents)) {
-               foreach ($parents as $i=>$_x) {
+               foreach ($parents as $i => $_x) {
                        $parents[$i]['children'] = get_item_children($arr, $_x);
                }
        }
@@ -1531,19 +1533,19 @@ function get_responses($conv_responses, $response_verbs, $ob, $item) {
 function get_response_button_text($v, $count) {
        switch ($v) {
                case 'like':
-                       return tt('Like','Likes', $count,'noun');
+                       return tt('Like', 'Likes', $count, 'noun');
                        break;
                case 'dislike':
-                       return tt('Dislike','Dislikes', $count,'noun');
+                       return tt('Dislike', 'Dislikes', $count, 'noun');
                        break;
                case 'attendyes':
-                       return tt('Attending','Attending', $count,'noun');
+                       return tt('Attending', 'Attending', $count, 'noun');
                        break;
                case 'attendno':
-                       return tt('Not Attending','Not Attending', $count,'noun');
+                       return tt('Not Attending', 'Not Attending', $count, 'noun');
                        break;
                case 'attendmaybe':
-                       return tt('Undecided','Undecided', $count,'noun');
+                       return tt('Undecided', 'Undecided', $count, 'noun');
                        break;
        }
 }