]> git.mxchange.org Git - friendica.git/blobdiff - mod/network.php
Merge remote branch 'upstream/master'
[friendica.git] / mod / network.php
old mode 100755 (executable)
new mode 100644 (file)
index 9ec8c23..f43eeb6
@@ -108,6 +108,10 @@ function network_content(&$a, $update = 0) {
        return login(false);
        }
 
+       $arr = array('query' => $a->query_string);
+
+       call_hooks('network_content_init', $arr);
+
        $o = '';
 
        // item filter tabs
@@ -157,7 +161,7 @@ function network_content(&$a, $update = 0) {
                        $all_active = 'active';
        }
 
-
+       
        $postord_active = '';
 
        if($all_active && x($_GET,'order') && $_GET['order'] !== 'comment') {
@@ -171,43 +175,54 @@ function network_content(&$a, $update = 0) {
                        'label' => t('Commented Order'),
                        'url'=>$a->get_baseurl(true) . '/' . str_replace('/new', '', $a->cmd) . ((x($_GET,'cid')) ? '?f=&cid=' . $_GET['cid'] : ''), 
                        'sel'=>$all_active,
+                       'title'=> t('Sort by Comment Date'),
                ),
                array(
                        'label' => t('Posted Order'),
                        'url'=>$a->get_baseurl(true) . '/' . str_replace('/new', '', $a->cmd) . '?f=&order=post' . ((x($_GET,'cid')) ? '&cid=' . $_GET['cid'] : ''), 
                        'sel'=>$postord_active,
+                       'title' => t('Sort by Post Date'),
                ),
 
                array(
                        'label' => t('Personal'),
                        'url' => $a->get_baseurl(true) . '/' . str_replace('/new', '', $a->cmd) . ((x($_GET,'cid')) ? '/?f=&cid=' . $_GET['cid'] : '') . '&conv=1',
                        'sel' => $conv_active,
+                       'title' => t('Posts that mention or involve you'),
                ),
                array(
                        'label' => t('New'),
                        'url' => $a->get_baseurl(true) . '/' . str_replace('/new', '', $a->cmd) . '/new' . ((x($_GET,'cid')) ? '/?f=&cid=' . $_GET['cid'] : ''),
                        'sel' => $new_active,
+                       'title' => t('Activity Stream - by date'),
                ),
                array(
                        'label' => t('Starred'),
                        'url'=>$a->get_baseurl(true) . '/' . str_replace('/new', '', $a->cmd) . ((x($_GET,'cid')) ? '/?f=&cid=' . $_GET['cid'] : '') . '&star=1',
                        'sel'=>$starred_active,
+                       'title' => t('Favourite Posts'),
                ),
                array(
                        'label' => t('Shared Links'),
                        'url'=>$a->get_baseurl(true) . '/' . str_replace('/new', '', $a->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'
 //                     'sel'=> $spam_active,
+//                     'title' => t('Posts flagged as SPAM'),
 //             ),      
 
 
        );
-       $tpl = get_markup_template('common_tabs.tpl');
-       $o .= replace_macros($tpl, array('$tabs'=>$tabs));
+
+       $arr = array('tabs' => $tabs);
+       call_hooks('network_tabs', $arr);
+
+       $o .= replace_macros(get_markup_template('common_tabs.tpl'), array('$tabs'=> $arr['tabs']));
+
        // --- end item filter tabs
 
 
@@ -250,6 +265,20 @@ function network_content(&$a, $update = 0) {
        if($cid)
                $def_acl = array('allow_cid' => '<' . intval($cid) . '>');
 
+       if($nets) {
+               $r = q("select id from contact where uid = %d and network = '%s' and self = 0",
+                       intval(local_user()),
+                       dbesc($nets)
+               );
+
+               $str = '';
+               if(count($r))
+                       foreach($r as $rr)
+                               $str .= '<' . $rr['id'] . '>';
+               if(strlen($str))
+                       $def_acl = array('allow_cid' => $str);
+       }
+
        if(! $update) {
                if($group) {
                        if(($t = group_public_members($group)) && (! get_pconfig(local_user(),'system','nowarn_insecure'))) {
@@ -269,9 +298,9 @@ function network_content(&$a, $update = 0) {
                        'allow_location' => $a->user['allow_location'],
                        'default_location' => $a->user['default-location'],
                        'nickname' => $a->user['nickname'],
-                       'lockstate' => ((($group) || (is_array($a->user) && ((strlen($a->user['allow_cid'])) || (strlen($a->user['allow_gid'])) || (strlen($a->user['deny_cid'])) || (strlen($a->user['deny_gid']))))) ? 'lock' : 'unlock'),
-                       'acl' => populate_acl((($group || $cid) ? $def_acl : $a->user), $celeb),
-                       'bang' => (($group || $cid) ? '!' : ''),
+                       'lockstate' => ((($group) || ($cid) || ($nets) || (is_array($a->user) && ((strlen($a->user['allow_cid'])) || (strlen($a->user['allow_gid'])) || (strlen($a->user['deny_cid'])) || (strlen($a->user['deny_gid']))))) ? 'lock' : 'unlock'),
+                       'acl' => populate_acl((($group || $cid || $nets) ? $def_acl : $a->user), $celeb),
+                       'bang' => (($group || $cid || $nets) ? '!' : ''),
                        'visitor' => 'block',
                        'profile_uid' => local_user()
                );
@@ -315,7 +344,7 @@ function network_content(&$a, $update = 0) {
                                info( t('Group is empty'));
                }
 
-               $sql_extra = " AND `item`.`parent` IN ( SELECT DISTINCT(`parent`) FROM `item` WHERE 1 $sql_options AND ( `contact-id` IN ( $contact_str ) OR `allow_gid` REGEXP '<" . intval($group) . ">' ) and deleted = 0 ) ";
+               $sql_extra = " AND `item`.`parent` IN ( SELECT DISTINCT(`parent`) FROM `item` WHERE 1 $sql_options AND ( `contact-id` IN ( $contact_str ) OR `allow_gid` like '" . protect_sprintf('%<' . intval($group) . '>%') . "' ) and deleted = 0 ) ";
                $o = '<h2>' . t('Group: ') . $r[0]['name'] . '</h2>' . $o;
        }
        elseif($cid) {
@@ -373,13 +402,13 @@ function network_content(&$a, $update = 0) {
 
        if(x($_GET,'search')) {
                $search = escape_tags($_GET['search']);
-               $sql_extra .= sprintf(" AND ( `item`.`body` REGEXP '%s' OR `item`.`tag` REGEXP '%s' ) ",
-                       dbesc(preg_quote($search)),
-                       dbesc('\\]' . preg_quote($search) . '\\[')
+               $sql_extra .= sprintf(" AND ( `item`.`body` like '%s' OR `item`.`tag` like '%s' ) ",
+                       dbesc(protect_sprintf('%' . $search . '%')),
+                       dbesc(protect_sprintf('%]' . $search . '[%'))
                );
        }
        if(strlen($file)) {
-               $sql_extra .= file_tag_file_query('item',$file);
+               $sql_extra .= file_tag_file_query('item',unxmlify($file));
        }
 
        if($conv) {
@@ -387,10 +416,10 @@ function network_content(&$a, $update = 0) {
                $myurl = substr($myurl,strpos($myurl,'://')+3);
                $myurl = str_replace(array('www.','.'),array('','\\.'),$myurl);
                $diasp_url = str_replace('/profile/','/u/',$myurl);
-               $sql_extra .= sprintf(" AND `item`.`parent` IN (SELECT distinct(`parent`) from item where ( `author-link` regexp '%s' or `tag` regexp '%s' or tag regexp '%s' )) ",
-                       dbesc($myurl . '$'),
-                       dbesc($myurl . '\\]'),
-                       dbesc($diasp_url . '\\]')
+               $sql_extra .= sprintf(" AND `item`.`parent` IN (SELECT distinct(`parent`) from item where ( `author-link` like '%s' or `tag` like '%s' or tag like '%s' )) ",
+                       dbesc(protect_sprintf('%s' . $myurl)),
+                       dbesc(protect_sprintf('%' . $myurl . '\\]%')),
+                       dbesc(protect_sprintf('%' . $diasp_url . '\\]%'))
                );
        }