X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=mod%2Fnetwork.php;h=db4bb91309d84b874850432c7461104c74ba62b6;hb=2c69d368864f7e23075151a810d7dcf869b128c6;hp=cce511ae19ff66238e2112280effd1274d892d11;hpb=ad20c5504deba9dbb4ea5c5deba598f2c448b344;p=friendica.git diff --git a/mod/network.php b/mod/network.php index cce511ae19..db4bb91309 100644 --- a/mod/network.php +++ b/mod/network.php @@ -1,17 +1,18 @@ argc > 1) { - for($x = 1; $x < $a->argc; $x ++) { - if(is_a_date_arg($a->argv[$x])) { + if ($a->argc > 1) { + for ($x = 1; $x < $a->argc; $x ++) { + if (is_a_date_arg($a->argv[$x])) { $is_a_date_query = true; break; } @@ -24,9 +25,8 @@ function network_init(&$a) { parse_str($query_string, $query_array); array_shift($query_array); - // fetch last used network view and redirect if needed - if(! $is_a_date_query) { + if (! $is_a_date_query) { $sel_tabs = network_query_get_sel_tab($a); $sel_nets = network_query_get_sel_net(); $sel_groups = network_query_get_sel_group($a); @@ -41,14 +41,13 @@ function network_init(&$a) { $net_baseurl = '/network'; $net_args = array(); - if($remember_group) { + if ($remember_group) { $net_baseurl .= '/' . $last_sel_groups; // Note that the group number must come before the "/new" tab selection - } - else if($sel_groups !== false) { + } elseif($sel_groups !== false) { $net_baseurl .= '/' . $sel_groups; } - if($remember_tab) { + if ($remember_tab) { // redirect if current selected tab is '/network' and // last selected tab is _not_ '/network?f=&order=comment'. // and this isn't a date query @@ -74,20 +73,23 @@ function network_init(&$a) { $k = array_search('active', $last_sel_tabs); - $net_baseurl .= $tab_baseurls[$k]; + if ($k != 3) { + $net_baseurl .= $tab_baseurls[$k]; - // parse out tab queries - $dest_qa = array(); - $dest_qs = $tab_args[$k]; - parse_str( $dest_qs, $dest_qa); - $net_args = array_merge($net_args, $dest_qa); - } - else if($sel_tabs[4] === 'active') { + // parse out tab queries + $dest_qa = array(); + $dest_qs = $tab_args[$k]; + parse_str($dest_qs, $dest_qa); + $net_args = array_merge($net_args, $dest_qa); + } else { + $remember_tab = false; + } + } elseif ($sel_tabs[4] === 'active') { // The '/new' tab is selected - $net_baseurl .= '/new'; + $remember_group = false; } - if($remember_net) { + if ($remember_net) { $net_args['nets'] = $last_sel_nets; } else if($sel_nets!==false) { @@ -104,24 +106,27 @@ function network_init(&$a) { } } - if(x($_GET['nets']) && $_GET['nets'] === 'all') + // If nets is set to all, unset it + if (x($_GET, 'nets') && $_GET['nets'] === 'all') { unset($_GET['nets']); + } $group_id = (($a->argc > 1 && is_numeric($a->argv[1])) ? intval($a->argv[1]) : 0); set_pconfig(local_user(), 'network.view', 'group.selected', $group_id); - require_once('include/group.php'); - require_once('include/contact_widgets.php'); - require_once('include/items.php'); - require_once('include/ForumManager.php'); + require_once 'include/group.php'; + require_once 'include/contact_widgets.php'; + require_once 'include/items.php'; + require_once 'include/ForumManager.php'; - if(! x($a->page,'aside')) + if (! x($a->page, 'aside')) { $a->page['aside'] = ''; + } - $search = ((x($_GET,'search')) ? escape_tags($_GET['search']) : ''); + $search = ((x($_GET, 'search')) ? escape_tags($_GET['search']) : ''); - if(x($_GET,'save')) { + if (x($_GET, 'save')) { $r = qu("SELECT * FROM `search` WHERE `uid` = %d AND `term` = '%s' LIMIT 1", intval(local_user()), dbesc($search) @@ -133,7 +138,7 @@ function network_init(&$a) { ); } } - if(x($_GET,'remove')) { + if (x($_GET, 'remove')) { q("DELETE FROM `search` WHERE `uid` = %d AND `term` = '%s'", intval(local_user()), dbesc($search) @@ -141,7 +146,7 @@ function network_init(&$a) { } // search terms header - if(x($_GET,'search')) { + if (x($_GET, 'search')) { $a->page['content'] .= replace_macros(get_markup_template("section_title.tpl"),array( '$title' => sprintf( t('Results for: %s'), $search) )); @@ -158,8 +163,9 @@ function network_init(&$a) { function saved_searches($search) { - if(! feature_enabled(local_user(),'savedsearch')) + if (! feature_enabled(local_user(),'savedsearch')) { return ''; + } $a = get_app(); @@ -222,7 +228,7 @@ function saved_searches($search) { * * @return Array ( $no_active, $comment_active, $postord_active, $conv_active, $new_active, $starred_active, $bookmarked_active, $spam_active ); */ -function network_query_get_sel_tab($a) { +function network_query_get_sel_tab(App $a) { $no_active=''; $starred_active = ''; $new_active = ''; @@ -293,7 +299,7 @@ function network_query_get_sel_net() { return $network; } -function network_query_get_sel_group($a) { +function network_query_get_sel_group(App $a) { $group = false; if($a->argc >= 2 && is_numeric($a->argv[1])) { @@ -304,7 +310,7 @@ function network_query_get_sel_group($a) { } -function network_content(&$a, $update = 0) { +function network_content(App $a, $update = 0) { require_once('include/conversation.php'); @@ -575,10 +581,7 @@ function network_content(&$a, $update = 0) { $sql_order = "`item`.`id`"; $order_mode = "id"; } else { - if (get_config('system','use_fulltext_engine')) - $sql_extra = sprintf(" AND MATCH (`item`.`body`, `item`.`title`) AGAINST ('%s' in boolean mode) ", dbesc(protect_sprintf($search))); - else - $sql_extra = sprintf(" AND `item`.`body` REGEXP '%s' ", dbesc(protect_sprintf(preg_quote($search)))); + $sql_extra = sprintf(" AND `item`.`body` REGEXP '%s' ", dbesc(protect_sprintf(preg_quote($search)))); $sql_order = "`item`.`id`"; $order_mode = "id"; } @@ -599,21 +602,6 @@ function network_content(&$a, $update = 0) { $pager_sql = ''; } else { - if(get_config('system', 'old_pager')) { - $r = qu("SELECT COUNT(*) AS `total` - FROM $sql_table $sql_post_table INNER JOIN `contact` ON `contact`.`id` = $sql_table.`contact-id` - AND (NOT `contact`.`blocked` OR `contact`.`pending`) - WHERE $sql_table.`uid` = %d AND $sql_table.`visible` AND NOT $sql_table.`deleted` - $sql_extra2 $sql_extra3 - $sql_extra $sql_nets ", - intval($_SESSION['uid']) - ); - - if (dbm::is_result($r)) { - $a->set_pager_total($r[0]['total']); - } - } - // check if we serve a mobile device and get the user settings // accordingly if ($a->is_mobile) { @@ -729,7 +717,7 @@ function network_content(&$a, $update = 0) { intval($parents), intval($max_comments + 1) ); - + if (dbm::is_result($thread_items)) $items = array_merge($items, $thread_items); } @@ -763,24 +751,23 @@ function network_content(&$a, $update = 0) { // on they just get buried deeper. It has happened to me a couple of times also. - if((! $group) && (! $cid) && (! $star)) { + if (!$group && !$cid && !$star) { - $unseen = q("SELECT `id` FROM `item` WHERE `unseen` AND `uid` = %d", + $unseen = q("SELECT `id` FROM `item` WHERE `unseen` AND `uid` = %d LIMIT 1", intval(local_user())); - if ($unseen) + if (dbm::is_result($unseen)) { $r = q("UPDATE `item` SET `unseen` = 0 WHERE `unseen` = 1 AND `uid` = %d", intval(local_user()) ); - } - else { - if($update_unseen) { + } + } elseif ($update_unseen) { - $unseen = q("SELECT `id` FROM `item` ".$update_unseen); + $unseen = q("SELECT `id` FROM `item` ".$update_unseen. " LIMIT 1"); - if ($unseen) - $r = q("UPDATE `item` SET `unseen` = 0 $update_unseen"); + if (dbm::is_result($unseen)) { + $r = q("UPDATE `item` SET `unseen` = 0 $update_unseen"); } } @@ -789,15 +776,13 @@ function network_content(&$a, $update = 0) { $mode = (($nouveau) ? 'network-new' : 'network'); - $o .= conversation($a,$items,$mode,$update); + $o .= conversation($a, $items, $mode, $update); - if(!$update) { - if(get_pconfig(local_user(),'system','infinite_scroll')) { + if (!$update) { + if (get_pconfig(local_user(), 'system', 'infinite_scroll')) { $o .= scroll_loader(); - } elseif(!get_config('system', 'old_pager')) { - $o .= alt_pager($a,count($items)); } else { - $o .= paginate($a); + $o .= alt_pager($a, count($items)); } } @@ -806,11 +791,11 @@ function network_content(&$a, $update = 0) { /** * @brief Get the network tabs menu - * + * * @param app $a The global App * @return string Html of the networktab */ -function network_tabs($a) { +function network_tabs(App $a) { // item filter tabs /// @TODO fix this logic, reduce duplication /// $a->page['content'] .= '
'; @@ -853,10 +838,10 @@ function network_tabs($a) { ); } - if(feature_enabled(local_user(),'new_tab')) { + if (feature_enabled(local_user(),'new_tab')) { $tabs[] = array( 'label' => t('New'), - 'url' => str_replace('/new', '', $cmd) . ($len_naked_cmd ? '/' : '') . 'new' . ((x($_GET,'cid')) ? '/?f=&cid=' . $_GET['cid'] : ''), + 'url' => 'network/new' . ((x($_GET,'cid')) ? '/?f=&cid=' . $_GET['cid'] : ''), 'sel' => $new_active, 'title' => t('Activity Stream - by date'), 'id' => 'activitiy-by-date-tab', @@ -893,7 +878,7 @@ function network_tabs($a) { $arr = array('tabs' => $tabs); call_hooks('network_tabs', $arr); - + $tpl = get_markup_template('common_tabs.tpl'); return replace_macros($tpl, array('$tabs' => $arr['tabs']));