]> git.mxchange.org Git - friendica.git/blobdiff - mod/network.php
Mentions are now displayed much faster. Attention: The related database update can...
[friendica.git] / mod / network.php
index b5582b5fadbce892c059b8ece3c6b6b7ccbb5029..ecef7c1dfbb85c60a78d799d8f27534d41167343 100644 (file)
@@ -142,7 +142,7 @@ function network_init(&$a) {
        if(x($_GET['nets']) && $_GET['nets'] === 'all')
                unset($_GET['nets']);
        
-       $group_id = (($a->argc > 1 && intval($a->argv[1])) ? intval($a->argv[1]) : 0);
+       $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);
                  
@@ -181,7 +181,7 @@ function network_init(&$a) {
                $a->page['content'] .= '<h2>' . t('Search Results For:') . ' '  . $search . '</h2>';
        }
 
-       $a->page['aside'] .= group_side('network/0','network',true,$group_id);
+       $a->page['aside'] .= (feature_enabled(local_user(),'groups') ? group_side('network/0','network',true,$group_id) : '');
        $a->page['aside'] .= posted_date_widget($a->get_baseurl() . '/network',local_user(),false);     
        $a->page['aside'] .= networks_widget($a->get_baseurl(true) . '/network',(x($_GET, 'nets') ? $_GET['nets'] : ''));
        $a->page['aside'] .= saved_searches($search);
@@ -191,6 +191,9 @@ function network_init(&$a) {
 
 function saved_searches($search) {
 
+       if(! feature_enabled(local_user(),'savedsearch'))
+               return '';
+
        $a = get_app();
 
        $srchurl = '/network?f=' 
@@ -403,30 +406,30 @@ function network_content(&$a, $update = 0) {
                        'title' => t('Sort by Post Date'),
                ),
 
-               array(
+/*             array(
                        'label' => t('Personal'),
                        'url' => $a->get_baseurl(true) . '/' . str_replace('/new', '', $cmd) . ((x($_GET,'cid')) ? '/?f=&cid=' . $_GET['cid'] : '') . '&conv=1',
                        'sel' => $conv_active,
                        'title' => t('Posts that mention or involve you'),
-               ),
-               array(
+               ),*/
+/*             array(
                        'label' => t('New'),
                        'url' => $a->get_baseurl(true) . '/' . str_replace('/new', '', $cmd) . ($len_naked_cmd ? '/' : '') . 'new' . ((x($_GET,'cid')) ? '/?f=&cid=' . $_GET['cid'] : ''),
                        'sel' => $new_active,
                        'title' => t('Activity Stream - by date'),
-               ),
-               array(
+               ),*/
+/*             array(
                        'label' => t('Starred'),
                        'url'=>$a->get_baseurl(true) . '/' . str_replace('/new', '', $cmd) . ((x($_GET,'cid')) ? '/?f=&cid=' . $_GET['cid'] : '') . '&star=1',
                        'sel'=>$starred_active,
                        'title' => t('Favourite Posts'),
-               ),
-               array(
+               ),*/
+/*             array(
                        'label' => t('Shared Links'),
                        'url'=>$a->get_baseurl(true) . '/' . str_replace('/new', '', $cmd) . ((x($_GET,'cid')) ? '/?f=&cid=' . $_GET['cid'] : '') . '&bmark=1',
                        'sel'=>$bookmarked_active,
                        'title'=> t('Interesting Links'),
-               ),      
+               ),      */
 //             array(
 //                     'label' => t('Spam'),
 //                     'url'=>$a->get_baseurl(true) . '/network?f=&spam=1'
@@ -436,6 +439,53 @@ function network_content(&$a, $update = 0) {
 
        );
        
+       if(feature_enabled(local_user(),'personal_tab')) {
+               $tabs[] = array(
+                       'label' => t('Personal'),
+                       'url' => $a->get_baseurl(true) . '/' . str_replace('/new', '', $cmd) . ((x($_GET,'cid')) ? '/?f=&cid=' . $_GET['cid'] : '') . '&conv=1',
+                       'sel' => $conv_active,
+                       'title' => t('Posts that mention or involve you'),
+               );
+       }
+
+       if(feature_enabled(local_user(),'new_tab')) {
+               $tabs[] = array(
+                       'label' => t('New'),
+                       'url' => $a->get_baseurl(true) . '/' . str_replace('/new', '', $cmd) . ($len_naked_cmd ? '/' : '') . 'new' . ((x($_GET,'cid')) ? '/?f=&cid=' . $_GET['cid'] : ''),
+                       'sel' => $new_active,
+                       'title' => t('Activity Stream - by date'),
+               );
+       }
+
+       if(feature_enabled(local_user(),'link_tab')) {
+               $tabs[] = array(
+                       'label' => t('Shared Links'),
+                       'url'=>$a->get_baseurl(true) . '/' . str_replace('/new', '', $cmd) . ((x($_GET,'cid')) ? '/?f=&cid=' . $_GET['cid'] : '') . '&bmark=1',
+                       'sel'=>$bookmarked_active,
+                       'title'=> t('Interesting Links'),
+               );
+       }
+
+       if(feature_enabled(local_user(),'star_posts')) {
+               $tabs[] = array(
+                       'label' => t('Starred'),
+                       'url'=>$a->get_baseurl(true) . '/' . str_replace('/new', '', $cmd) . ((x($_GET,'cid')) ? '/?f=&cid=' . $_GET['cid'] : '') . '&star=1',
+                       'sel'=>$starred_active,
+                       'title' => t('Favourite Posts'),
+               );
+       }
+
+       // Not yet implemented
+
+/*     if(feature_enabled(local_user(),'spam_filter'))  {
+               $tabs[] = array(
+                       'label' => t('Spam'),
+                       'url'=>$a->get_baseurl(true) . '/network?f=&spam=1',
+                       'sel'=> $spam_active,
+                       'title' => t('Posts flagged as SPAM'),
+               );
+       }*/
+
        // save selected tab, but only if not in search or file mode
        if(!x($_GET,'search') && !x($_GET,'file')) {
                set_pconfig( local_user(), 'network.view','tab.selected',array($all_active, $postord_active, $conv_active, $new_active, $starred_active, $bookmarked_active, $spam_active) );
@@ -584,31 +634,6 @@ function network_content(&$a, $update = 0) {
                $o .= get_events();
        }
 
-       if(! $update) {
-               // The special div is needed for liveUpdate to kick in for this page.
-               // We only launch liveUpdate if you aren't filtering in some incompatible 
-               // way and also you aren't writing a comment (discovered in javascript).
-
-               $o .= '<div id="live-network"></div>' . "\r\n";
-               $o .= "<script> var profile_uid = " . $_SESSION['uid'] 
-                       . "; var netargs = '" . substr($a->cmd,8)
-                       . '?f='
-                       . ((x($_GET,'cid'))    ? '&cid='    . $_GET['cid']    : '')
-                       . ((x($_GET,'search')) ? '&search=' . $_GET['search'] : '') 
-                       . ((x($_GET,'star'))   ? '&star='   . $_GET['star']   : '') 
-                       . ((x($_GET,'order'))  ? '&order='  . $_GET['order']  : '') 
-                       . ((x($_GET,'bmark'))  ? '&bmark='  . $_GET['bmark']  : '') 
-                       . ((x($_GET,'liked'))  ? '&liked='  . $_GET['liked']  : '') 
-                       . ((x($_GET,'conv'))   ? '&conv='   . $_GET['conv']   : '') 
-                       . ((x($_GET,'spam'))   ? '&spam='   . $_GET['spam']   : '') 
-                       . ((x($_GET,'nets'))   ? '&nets='   . $_GET['nets']   : '') 
-                       . ((x($_GET,'cmin'))   ? '&cmin='   . $_GET['cmin']   : '') 
-                       . ((x($_GET,'cmax'))   ? '&cmax='   . $_GET['cmax']   : '') 
-                       . ((x($_GET,'file'))   ? '&file='   . $_GET['file']   : '') 
-
-                       . "'; var profile_page = " . $a->pager['page'] . "; </script>\r\n";
-       }
-
        $sql_extra3 = '';
 
        if($datequery) {
@@ -649,8 +674,10 @@ function network_content(&$a, $update = 0) {
                $myurl = substr($myurl,strpos($myurl,'://')+3);
                $myurl = str_replace('www.','',$myurl);
                $diasp_url = str_replace('/profile/','/u/',$myurl);
-               if (get_config('system','use_fulltext_engine'))
+               /*if (get_config('system','use_fulltext_engine'))
                        $sql_extra .= sprintf(" AND `item`.`parent` IN (SELECT distinct(`parent`) from item where (MATCH(`author-link`) AGAINST ('".'"%s"'."' in boolean mode) or MATCH(`tag`) AGAINST ('".'"%s"'."' in boolean mode) or MATCH(tag) AGAINST ('".'"%s"'."' in boolean mode))) ",
+                       //$sql_extra .= sprintf(" AND `item`.`parent` IN (SELECT distinct(`parent`) from item where (`author-link` IN ('https://%s', 'http://%s') OR MATCH(`tag`) AGAINST ('".'"%s"'."' in boolean mode) or MATCH(tag) AGAINST ('".'"%s"'."' in boolean mode))) ",
+                       //$sql_extra .= sprintf(" AND `item`.`parent` IN (SELECT distinct(`parent`) from item where `author-link` IN ('https://%s', 'http://%s') OR `mention`)",
                                dbesc(protect_sprintf($myurl)),
                                dbesc(protect_sprintf($myurl)),
                                dbesc(protect_sprintf($diasp_url))
@@ -660,8 +687,12 @@ function network_content(&$a, $update = 0) {
                                dbesc(protect_sprintf('%' . $myurl)),
                                dbesc(protect_sprintf('%' . $myurl . ']%')),
                                dbesc(protect_sprintf('%' . $diasp_url . ']%'))
-                       );
+                       );*/
 
+               $sql_extra .= sprintf(" AND `item`.`parent` IN (SELECT distinct(`parent`) from item where `author-link` IN ('https://%s', 'http://%s') OR `mention`)",
+                       dbesc(protect_sprintf($myurl)),
+                       dbesc(protect_sprintf($myurl))
+               );
        }
 
        if($update) {
@@ -671,7 +702,7 @@ function network_content(&$a, $update = 0) {
 
        }
        else {
-               if(! get_pconfig(local_user(),'system','alt_pager')) {
+               if( (! get_config('alt_pager', 'global')) && (! get_pconfig(local_user(),'system','alt_pager')) ) {
                        $r = q("SELECT COUNT(*) AS `total`
                                FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
                                WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0
@@ -792,15 +823,25 @@ function network_content(&$a, $update = 0) {
        // level which items you've seen and which you haven't. If you're looking
        // at the top level network page just mark everything seen. 
        
-/*     if((! $group) && (! $cid) && (! $star)) {
+
+// The $update_unseen is a bit unreliable if you have stuff coming into your stream from a new contact - 
+// and other feeds that bring in stuff from the past. One can't find it all. 
+// I'm reviving this block to mark everything seen on page 1 of the network as a temporary measure.
+// The correct solution is to implement a network notifications box just like the system notifications popup
+// with the ability in the popup to "mark all seen".
+// Several people are complaining because there are unseen messages they can't find and as time goes
+// on they just get buried deeper. It has happened to me a couple of times also.
+
+       if((! $group) && (! $cid) && (! $star)) {
                $r = q("UPDATE `item` SET `unseen` = 0 
                        WHERE `unseen` = 1 AND `uid` = %d",
                        intval(local_user())
                );
-       }*/
-
-       if($update_unseen)
-               $r = q("UPDATE `item` SET `unseen` = 0 $update_unseen");
+       }
+       else {
+               if($update_unseen)
+                       $r = q("UPDATE `item` SET `unseen` = 0 $update_unseen");
+       }
 
        // Set this so that the conversation function can find out contact info for our wall-wall items
        $a->page_contact = $a->contact;
@@ -810,11 +851,11 @@ function network_content(&$a, $update = 0) {
        $o .= conversation($a,$items,$mode,$update);
 
        if(! $update) {
-               if(! get_pconfig(local_user(),'system','alt_pager')) {
-                       $o .= paginate($a);
+               if( get_config('alt_pager', 'global') || get_pconfig(local_user(),'system','alt_pager') ) {
+                       $o .= alt_pager($a,count($items));
                }
                else {
-                       $o .= alt_pager($a,count($items));
+                       $o .= paginate($a);
                }
        }