5 function network_init(App $a) {
7 notice( t('Permission denied.') . EOL);
11 $is_a_date_query = false;
12 if (x($_GET, 'cid') && intval($_GET['cid']) != 0) {
17 for ($x = 1; $x < $a->argc; $x ++) {
18 if (is_a_date_arg($a->argv[$x])) {
19 $is_a_date_query = true;
25 // convert query string to array. remove friendica args
26 $query_array = array();
27 $query_string = str_replace($a->cmd."?", "", $a->query_string);
28 parse_str($query_string, $query_array);
29 array_shift($query_array);
31 // fetch last used network view and redirect if needed
32 if (! $is_a_date_query) {
33 $sel_tabs = network_query_get_sel_tab($a);
34 $sel_nets = network_query_get_sel_net();
35 $sel_groups = network_query_get_sel_group($a);
36 $last_sel_tabs = get_pconfig(local_user(), 'network.view','tab.selected');
37 $last_sel_nets = get_pconfig(local_user(), 'network.view', 'net.selected');
38 $last_sel_groups = get_pconfig(local_user(), 'network.view', 'group.selected');
40 $remember_tab = ($sel_tabs[0] === 'active' && is_array($last_sel_tabs) && $last_sel_tabs[0] !== 'active');
41 $remember_net = ($sel_nets === false && $last_sel_nets && $last_sel_nets !== 'all');
42 $remember_group = ($sel_groups === false && $last_sel_groups && $last_sel_groups != 0);
44 $net_baseurl = '/network';
47 if ($remember_group) {
48 $net_baseurl .= '/' . $last_sel_groups; // Note that the group number must come before the "/new" tab selection
49 } elseif($sel_groups !== false) {
50 $net_baseurl .= '/' . $sel_groups;
54 // redirect if current selected tab is '/network' and
55 // last selected tab is _not_ '/network?f=&order=comment'.
56 // and this isn't a date query
58 $tab_baseurls = array(
68 'f=&order=comment', //all
69 'f=&order=post', //postord
72 'f=&star=1', //starred
73 'f=&bmark=1', //bookmarked
77 $k = array_search('active', $last_sel_tabs);
80 $net_baseurl .= $tab_baseurls[$k];
82 // parse out tab queries
84 $dest_qs = $tab_args[$k];
85 parse_str($dest_qs, $dest_qa);
86 $net_args = array_merge($net_args, $dest_qa);
88 $remember_tab = false;
90 } elseif ($sel_tabs[4] === 'active') {
91 // The '/new' tab is selected
92 $remember_group = false;
96 $net_args['nets'] = $last_sel_nets;
98 else if($sel_nets!==false) {
99 $net_args['nets'] = $sel_nets;
102 if($remember_tab || $remember_net || $remember_group) {
103 $net_args = array_merge($query_array, $net_args);
104 $net_queries = build_querystring($net_args);
106 $redir_url = ($net_queries ? $net_baseurl."?".$net_queries : $net_baseurl);
108 goaway(App::get_baseurl() . $redir_url);
112 // If nets is set to all, unset it
113 if (x($_GET, 'nets') && $_GET['nets'] === 'all') {
114 unset($_GET['nets']);
117 $group_id = (($a->argc > 1 && is_numeric($a->argv[1])) ? intval($a->argv[1]) : 0);
119 set_pconfig(local_user(), 'network.view', 'group.selected', $group_id);
121 require_once 'include/group.php';
122 require_once 'include/contact_widgets.php';
123 require_once 'include/items.php';
124 require_once 'include/ForumManager.php';
126 if (! x($a->page, 'aside')) {
127 $a->page['aside'] = '';
130 $search = ((x($_GET, 'search')) ? escape_tags($_GET['search']) : '');
132 if (x($_GET, 'save')) {
133 $r = qu("SELECT * FROM `search` WHERE `uid` = %d AND `term` = '%s' LIMIT 1",
134 intval(local_user()),
137 if (! dbm::is_result($r)) {
138 q("INSERT INTO `search` ( `uid`,`term` ) VALUES ( %d, '%s') ",
139 intval(local_user()),
144 if (x($_GET, 'remove')) {
145 q("DELETE FROM `search` WHERE `uid` = %d AND `term` = '%s'",
146 intval(local_user()),
151 // search terms header
152 if (x($_GET, 'search')) {
153 $a->page['content'] .= replace_macros(get_markup_template("section_title.tpl"),array(
154 '$title' => sprintf( t('Results for: %s'), $search)
158 $a->page['aside'] .= (feature_enabled(local_user(),'groups') ? group_side('network/0','network','standard',$group_id) : '');
159 $a->page['aside'] .= (feature_enabled(local_user(),'forumlist_widget') ? ForumManager::widget(local_user(),$cid) : '');
160 $a->page['aside'] .= posted_date_widget('network',local_user(),false);
161 $a->page['aside'] .= networks_widget('network',(x($_GET, 'nets') ? $_GET['nets'] : ''));
162 $a->page['aside'] .= saved_searches($search);
163 $a->page['aside'] .= fileas_widget('network',(x($_GET, 'file') ? $_GET['file'] : ''));
167 function saved_searches($search) {
169 if (! feature_enabled(local_user(),'savedsearch')) {
175 $srchurl = '/network?f='
176 . ((x($_GET,'cid')) ? '&cid=' . $_GET['cid'] : '')
177 . ((x($_GET,'star')) ? '&star=' . $_GET['star'] : '')
178 . ((x($_GET,'bmark')) ? '&bmark=' . $_GET['bmark'] : '')
179 . ((x($_GET,'conv')) ? '&conv=' . $_GET['conv'] : '')
180 . ((x($_GET,'nets')) ? '&nets=' . $_GET['nets'] : '')
181 . ((x($_GET,'cmin')) ? '&cmin=' . $_GET['cmin'] : '')
182 . ((x($_GET,'cmax')) ? '&cmax=' . $_GET['cmax'] : '')
183 . ((x($_GET,'file')) ? '&file=' . $_GET['file'] : '');
188 $r = qu("SELECT `id`,`term` FROM `search` WHERE `uid` = %d",
194 if (dbm::is_result($r)) {
195 foreach ($r as $rr) {
198 'term' => $rr['term'],
199 'encodedterm' => urlencode($rr['term']),
200 'delete' => t('Remove term'),
201 'selected' => ($search==$rr['term']),
207 $tpl = get_markup_template("saved_searches_aside.tpl");
208 $o = replace_macros($tpl, array(
209 '$title' => t('Saved Searches'),
211 '$searchbox' => search($search,'netsearch-box',$srchurl,true),
220 * Return selected tab from query
223 * '/network' => $no_active = 'active'
224 * '/network?f=&order=comment' => $comment_active = 'active'
225 * '/network?f=&order=post' => $postord_active = 'active'
226 * '/network?f=&conv=1', => $conv_active = 'active'
227 * '/network/new', => $new_active = 'active'
228 * '/network?f=&star=1', => $starred_active = 'active'
229 * '/network?f=&bmark=1', => $bookmarked_active = 'active'
230 * '/network?f=&spam=1', => $spam_active = 'active'
232 * @return Array ( $no_active, $comment_active, $postord_active, $conv_active, $new_active, $starred_active, $bookmarked_active, $spam_active );
234 function network_query_get_sel_tab(App $a) {
236 $starred_active = '';
238 $bookmarked_active = '';
243 $postord_active = '';
245 if(($a->argc > 1 && $a->argv[1] === 'new')
246 || ($a->argc > 2 && $a->argv[2] === 'new')) {
247 $new_active = 'active';
250 if(x($_GET,'search')) {
251 $search_active = 'active';
254 if(x($_GET,'star')) {
255 $starred_active = 'active';
258 if(x($_GET,'bmark')) {
259 $bookmarked_active = 'active';
262 if(x($_GET,'conv')) {
263 $conv_active = 'active';
266 if(x($_GET,'spam')) {
267 $spam_active = 'active';
272 if (($new_active == '')
273 && ($starred_active == '')
274 && ($bookmarked_active == '')
275 && ($conv_active == '')
276 && ($search_active == '')
277 && ($spam_active == '')) {
278 $no_active = 'active';
281 if ($no_active=='active' && x($_GET,'order')) {
282 switch($_GET['order']){
283 case 'post': $postord_active = 'active'; $no_active=''; break;
284 case 'comment' : $all_active = 'active'; $no_active=''; break;
288 return array($no_active, $all_active, $postord_active, $conv_active, $new_active, $starred_active, $bookmarked_active, $spam_active);
292 * @brief Return selected network from query
293 * @return string Name of the selected network
295 function network_query_get_sel_net() {
298 if(x($_GET,'nets')) {
299 $network = $_GET['nets'];
305 function network_query_get_sel_group(App $a) {
308 if($a->argc >= 2 && is_numeric($a->argv[1])) {
309 $group = $a->argv[1];
316 function network_content(App $a, $update = 0) {
318 require_once('include/conversation.php');
320 if (! local_user()) {
321 $_SESSION['return_url'] = $a->query_string;
325 // Rawmode is used for fetching new content at the end of the page
326 $rawmode = (isset($_GET["mode"]) AND ($_GET["mode"] == "raw"));
328 /// @TODO Is this really necessary? $a is already available to hooks
329 $arr = array('query' => $a->query_string);
330 call_hooks('network_content_init', $arr);
333 $datequery = $datequery2 = '';
340 for($x = 1; $x < $a->argc; $x ++) {
341 if(is_a_date_arg($a->argv[$x])) {
343 $datequery2 = escape_tags($a->argv[$x]);
345 $datequery = escape_tags($a->argv[$x]);
346 $_GET['order'] = 'post';
349 elseif($a->argv[$x] === 'new') {
352 elseif(intval($a->argv[$x])) {
353 $group = intval($a->argv[$x]);
354 $def_acl = array('allow_gid' => '<' . $group . '>');
363 $contact_id = $a->cid;
365 require_once('include/acl_selectors.php');
367 $cid = ((x($_GET,'cid')) ? intval($_GET['cid']) : 0);
368 $star = ((x($_GET,'star')) ? intval($_GET['star']) : 0);
369 $bmark = ((x($_GET,'bmark')) ? intval($_GET['bmark']) : 0);
370 $order = ((x($_GET,'order')) ? notags($_GET['order']) : 'comment');
371 $liked = ((x($_GET,'liked')) ? intval($_GET['liked']) : 0);
372 $conv = ((x($_GET,'conv')) ? intval($_GET['conv']) : 0);
373 $spam = ((x($_GET,'spam')) ? intval($_GET['spam']) : 0);
374 $nets = ((x($_GET,'nets')) ? $_GET['nets'] : '');
375 $cmin = ((x($_GET,'cmin')) ? intval($_GET['cmin']) : 0);
376 $cmax = ((x($_GET,'cmax')) ? intval($_GET['cmax']) : 99);
377 $file = ((x($_GET,'file')) ? $_GET['file'] : '');
381 if(x($_GET,'search') || x($_GET,'file'))
384 $def_acl = array('allow_cid' => '<' . intval($cid) . '>');
387 $r = qu("SELECT `id` FROM `contact` WHERE `uid` = %d AND network = '%s' AND `self` = 0",
388 intval(local_user()),
393 if (dbm::is_result($r))
395 $str .= '<' . $rr['id'] . '>';
397 $def_acl = array('allow_cid' => $str);
399 set_pconfig(local_user(), 'network.view', 'net.selected', ($nets ? $nets : 'all'));
401 if(!$update AND !$rawmode) {
402 $tabs = network_tabs($a);
406 if(($t = group_public_members($group)) && (! get_pconfig(local_user(),'system','nowarn_insecure'))) {
407 notice(sprintf(tt("Warning: This group contains %s member from a network that doesn't allow non public messages.",
408 "Warning: This group contains %s members from a network that doesn't allow non public messages.",
410 notice(t("Messages in this group won't be send to these receivers.").EOL);
414 nav_set_selected('network');
419 // If $cid belongs to a communitity forum or a privat goup,.add a mention to the status editor
420 $contact = qu("SELECT `nick` FROM `contact` WHERE `id` = %d AND `uid` = %d AND (`forum` OR `prv`) ",
425 $content = "@".$contact[0]["nick"]."+".$cid;
430 'allow_location' => $a->user['allow_location'],
431 'default_location' => $a->user['default-location'],
432 'nickname' => $a->user['nickname'],
433 'lockstate'=> ((($group) || ($cid) || ($nets) || (is_array($a->user) &&
434 ((strlen($a->user['allow_cid'])) || (strlen($a->user['allow_gid'])) ||
435 (strlen($a->user['deny_cid'])) || (strlen($a->user['deny_gid']))))) ? 'lock' : 'unlock'),
436 'default_perms' => get_acl_permissions($a->user),
437 'acl' => populate_acl((($group || $cid || $nets) ? $def_acl : $a->user), true),
438 'bang' => (($group || $cid || $nets) ? '!' : ''),
439 'visitor' => 'block',
440 'profile_uid' => local_user(),
441 'acl_data' => construct_acl_data($a, $a->user), // For non-Javascript ACL selector
442 'content' => $content,
445 $o .= status_editor($a,$x);
449 // We don't have to deal with ACLs on this page. You're looking at everything
450 // that belongs to you, hence you can see all of it. We will filter by group if
453 $sql_post_table = "";
454 $sql_options = (($star) ? " AND `thread`.`starred` " : '');
455 $sql_options .= (($bmark) ? " AND `thread`.`bookmark` " : '');
456 $sql_extra = $sql_options;
459 $sql_table = "`thread`";
460 $sql_parent = "`iid`";
462 if ($nouveau OR strlen($file) OR $update) {
463 $sql_table = "`item`";
464 $sql_parent = "`parent`";
465 $sql_post_table = " INNER JOIN `thread` ON `thread`.`iid` = `item`.`parent`";
468 $sql_nets = (($nets) ? sprintf(" and $sql_table.`network` = '%s' ", dbesc($nets)) : '');
471 $r = qu("SELECT `name`, `id` FROM `group` WHERE `id` = %d AND `uid` = %d LIMIT 1",
473 intval($_SESSION['uid'])
475 if (! dbm::is_result($r)) {
478 notice( t('No such group') . EOL );
483 $contacts = expand_groups(array($group));
484 $gcontacts = expand_groups(array($group), false, true);
486 if((is_array($contacts)) && count($contacts)) {
487 $contact_str_self = "";
488 $gcontact_str_self = "";
490 $contact_str = implode(',',$contacts);
491 $gcontact_str = implode(',',$gcontacts);
492 $self = qu("SELECT `contact`.`id`, `gcontact`.`id` AS `gid` FROM `contact`
493 INNER JOIN `gcontact` ON `gcontact`.`nurl` = `contact`.`nurl`
494 WHERE `uid` = %d AND `self`", intval($_SESSION['uid']));
496 $contact_str_self = $self[0]["id"];
497 $gcontact_str_self = $self[0]["gid"];
500 $sql_post_table .= " INNER JOIN `item` AS `temp1` ON `temp1`.`id` = ".$sql_table.".".$sql_parent;
501 $sql_extra3 .= " AND (`thread`.`contact-id` IN ($contact_str) ";
502 $sql_extra3 .= " OR (`thread`.`contact-id` = '$contact_str_self' AND `temp1`.`allow_gid` LIKE '".protect_sprintf('%<'.intval($group).'>%')."' AND `temp1`.`private`))";
504 $sql_extra3 .= " AND false ";
505 info( t('Group is empty'));
508 $o = replace_macros(get_markup_template("section_title.tpl"),array(
509 '$title' => sprintf( t('Group: %s'), $r[0]['name'])
515 $r = qu("SELECT `id`,`name`,`network`,`writable`,`nurl`, `forum`, `prv`, `contact-type`, `addr`, `thumb`, `location` FROM `contact` WHERE `id` = %d
516 AND (NOT `blocked` OR `pending`) LIMIT 1",
519 if (dbm::is_result($r)) {
520 $sql_extra = " AND ".$sql_table.".`contact-id` = ".intval($cid);
524 'name' => htmlentities($r[0]['name']),
525 'itemurl' => (($r[0]['addr']) ? ($r[0]['addr']) : ($r[0]['nurl'])),
526 'thumb' => proxy_url($r[0]['thumb'], false, PROXY_SIZE_THUMB),
527 'details' => $r[0]['location'],
530 $entries[0]["account_type"] = account_type($r[0]);
532 $o = replace_macros(get_markup_template("viewcontact_template.tpl"),array(
533 'contacts' => $entries,
537 if($r[0]['network'] === NETWORK_OSTATUS && $r[0]['writable'] && (! get_pconfig(local_user(),'system','nowarn_insecure'))) {
538 notice( t('Private messages to this person are at risk of public disclosure.') . EOL);
543 notice( t('Invalid contact.') . EOL);
549 if((! $group) && (! $cid) && (! $update) && (! get_config('theme','hide_eventlist'))) {
550 $o .= get_birthdays();
555 $sql_extra3 .= protect_sprintf(sprintf(" AND $sql_table.created <= '%s' ", dbesc(datetime_convert(date_default_timezone_get(),'',$datequery))));
558 $sql_extra3 .= protect_sprintf(sprintf(" AND $sql_table.created >= '%s' ", dbesc(datetime_convert(date_default_timezone_get(),'',$datequery2))));
561 //$sql_extra2 = (($nouveau) ? '' : " AND `item`.`parent` = `item`.`id` ");
562 $sql_extra2 = (($nouveau) ? '' : $sql_extra2);
563 $sql_extra3 = (($nouveau) ? '' : $sql_extra3);
565 $order_mode = "received";
568 if(x($_GET,'search')) {
569 $search = escape_tags($_GET['search']);
571 if(strpos($search,'#') === 0) {
573 $search = substr($search,1);
576 if (get_config('system','only_tag_search'))
582 $sql_post_table .= sprintf("INNER JOIN (SELECT `oid` FROM `term` WHERE `term` = '%s' AND `otype` = %d AND `type` = %d AND `uid` = %d ORDER BY `tid` DESC) AS `term` ON `item`.`id` = `term`.`oid` ",
583 dbesc(protect_sprintf($search)), intval(TERM_OBJ_POST), intval(TERM_HASHTAG), intval(local_user()));
584 $sql_order = "`item`.`id`";
587 $sql_extra = sprintf(" AND `item`.`body` REGEXP '%s' ", dbesc(protect_sprintf(preg_quote($search))));
588 $sql_order = "`item`.`id`";
593 $sql_post_table .= sprintf("INNER JOIN (SELECT `oid` FROM `term` WHERE `term` = '%s' AND `otype` = %d AND `type` = %d AND `uid` = %d ORDER BY `tid` DESC) AS `term` ON `item`.`id` = `term`.`oid` ",
594 dbesc(protect_sprintf($file)), intval(TERM_OBJ_POST), intval(TERM_FILE), intval(local_user()));
595 $sql_order = "`item`.`id`";
600 $sql_extra3 .= " AND $sql_table.`mention`";
604 // only setup pagination on initial page view
608 // check if we serve a mobile device and get the user settings
611 $itemspage_network = get_pconfig(local_user(),'system','itemspage_mobile_network');
612 $itemspage_network = ((intval($itemspage_network)) ? $itemspage_network : 20);
614 $itemspage_network = get_pconfig(local_user(),'system','itemspage_network');
615 $itemspage_network = ((intval($itemspage_network)) ? $itemspage_network : 40);
618 // now that we have the user settings, see if the theme forces
619 // a maximum item number which is lower then the user choice
620 if(($a->force_max_items > 0) && ($a->force_max_items < $itemspage_network))
621 $itemspage_network = $a->force_max_items;
623 $a->set_pager_itemspage($itemspage_network);
624 $pager_sql = sprintf(" LIMIT %d, %d ",intval($a->pager['start']), intval($a->pager['itemspage']));
628 $simple_update = (($update) ? " AND `item`.`unseen` " : '');
630 if ($sql_order == "")
631 $sql_order = "`item`.`id`";
633 // "New Item View" - show all items unthreaded in reverse created date order
634 $items = qu("SELECT %s FROM $sql_table $sql_post_table %s
635 WHERE %s AND `item`.`uid` = %d
638 ORDER BY $sql_order DESC $pager_sql ",
639 item_fieldlists(), item_joins(), item_condition(),
640 intval($_SESSION['uid'])
643 $update_unseen = ' WHERE uid = ' . intval($_SESSION['uid']) . " AND unseen = 1 $sql_extra $sql_nets";
646 // Normal conversation view
649 if($order === 'post') {
650 $ordering = "`created`";
651 if ($sql_order == "")
652 $order_mode = "created";
654 $ordering = "`commented`";
655 if ($sql_order == "")
656 $order_mode = "commented";
659 if ($sql_order == "")
660 $sql_order = "$sql_table.$ordering";
662 if (($_GET["offset"] != ""))
663 $sql_extra3 .= sprintf(" AND $sql_order <= '%s'", dbesc($_GET["offset"]));
665 // Fetch a page full of parent items for this page
667 if (get_config("system", "like_no_comment"))
668 $sql_extra4 = " AND `item`.`verb` = '".ACTIVITY_POST."'";
672 $r = qu("SELECT `item`.`parent` AS `item_id`, `item`.`network` AS `item_network`, `contact`.`uid` AS `contact_uid`
673 FROM $sql_table $sql_post_table INNER JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
674 AND (NOT `contact`.`blocked` OR `contact`.`pending`)
675 WHERE `item`.`uid` = %d AND `item`.`visible` AND NOT `item`.`deleted` $sql_extra4
676 AND NOT `item`.`moderated` AND `item`.`unseen`
677 $sql_extra3 $sql_extra $sql_nets
678 ORDER BY `item_id` DESC LIMIT 100",
682 $r = qu("SELECT `thread`.`iid` AS `item_id`, `thread`.`network` AS `item_network`, `contact`.`uid` AS `contact_uid`
683 FROM $sql_table $sql_post_table STRAIGHT_JOIN `contact` ON `contact`.`id` = `thread`.`contact-id`
684 AND (NOT `contact`.`blocked` OR `contact`.`pending`)
685 WHERE `thread`.`uid` = %d AND `thread`.`visible` AND NOT `thread`.`deleted`
686 AND NOT `thread`.`moderated`
687 $sql_extra2 $sql_extra3 $sql_extra $sql_nets
688 ORDER BY $sql_order DESC $pager_sql ",
693 // Then fetch all the children of the parents that are on this page
695 $parents_arr = array();
699 if (dbm::is_result($r)) {
701 if(! in_array($rr['item_id'],$parents_arr))
702 $parents_arr[] = $rr['item_id'];
704 $parents_str = implode(", ", $parents_arr);
706 // splitted into separate queries to avoid the problem with very long threads
707 // so always the last X comments are loaded
708 // This problem can occur expecially with imported facebook posts
709 $max_comments = get_config("system", "max_comments");
710 if ($max_comments == 0)
715 foreach ($parents_arr AS $parents) {
716 $thread_items = qu(item_query()." AND `item`.`uid` = %d
717 AND `item`.`parent` = %d
718 ORDER BY `item`.`commented` DESC LIMIT %d",
719 intval(local_user()),
721 intval($max_comments + 1)
724 if (dbm::is_result($thread_items))
725 $items = array_merge($items, $thread_items);
727 $items = conv_sort($items,$ordering);
732 if ($_GET["offset"] == "")
733 $date_offset = $items[0][$order_mode];
735 $date_offset = $_GET["offset"];
737 $a->page_offset = $date_offset;
740 $update_unseen = ' WHERE uid = ' . intval(local_user()) . ' AND unseen = 1 AND parent IN ( ' . dbesc($parents_str) . ' )';
743 // We aren't going to try and figure out at the item, group, and page
744 // level which items you've seen and which you haven't. If you're looking
745 // at the top level network page just mark everything seen.
748 // The $update_unseen is a bit unreliable if you have stuff coming into your stream from a new contact -
749 // and other feeds that bring in stuff from the past. One can't find it all.
750 // I'm reviving this block to mark everything seen on page 1 of the network as a temporary measure.
751 // The correct solution is to implement a network notifications box just like the system notifications popup
752 // with the ability in the popup to "mark all seen".
753 // Several people are complaining because there are unseen messages they can't find and as time goes
754 // on they just get buried deeper. It has happened to me a couple of times also.
757 if (!$group && !$cid && !$star) {
759 $unseen = q("SELECT `id` FROM `item` WHERE `unseen` AND `uid` = %d LIMIT 1",
760 intval(local_user()));
762 if (dbm::is_result($unseen)) {
763 $r = q("UPDATE `item` SET `unseen` = 0
764 WHERE `unseen` = 1 AND `uid` = %d",
768 } elseif ($update_unseen) {
770 $unseen = q("SELECT `id` FROM `item` ".$update_unseen. " LIMIT 1");
772 if (dbm::is_result($unseen)) {
773 $r = q("UPDATE `item` SET `unseen` = 0 $update_unseen");
777 // Set this so that the conversation function can find out contact info for our wall-wall items
778 $a->page_contact = $a->contact;
780 $mode = (($nouveau) ? 'network-new' : 'network');
782 $o .= conversation($a, $items, $mode, $update);
785 if (get_pconfig(local_user(), 'system', 'infinite_scroll')) {
786 $o .= scroll_loader();
788 $o .= alt_pager($a, count($items));
796 * @brief Get the network tabs menu
798 * @param App $a The global App
799 * @return string Html of the networktab
801 function network_tabs(App $a) {
803 /// @TODO fix this logic, reduce duplication
804 /// $a->page['content'] .= '<div class="tabs-wrapper">';
806 list($no_active, $all_active, $postord_active, $conv_active, $new_active, $starred_active, $bookmarked_active, $spam_active) = network_query_get_sel_tab($a);
807 // if no tabs are selected, defaults to comments
808 if ($no_active=='active') $all_active='active';
810 $cmd = (($datequery) ? '' : $a->cmd);
811 $len_naked_cmd = strlen(str_replace('/new','',$cmd));
816 'label' => t('Commented Order'),
817 'url' => str_replace('/new', '', $cmd) . '?f=&order=comment' . ((x($_GET,'cid')) ? '&cid=' . $_GET['cid'] : ''),
818 'sel' => $all_active,
819 'title' => t('Sort by Comment Date'),
820 'id' => 'commented-order-tab',
824 'label' => t('Posted Order'),
825 'url' => str_replace('/new', '', $cmd) . '?f=&order=post' . ((x($_GET,'cid')) ? '&cid=' . $_GET['cid'] : ''),
826 'sel' => $postord_active,
827 'title' => t('Sort by Post Date'),
828 'id' => 'posted-order-tab',
833 if(feature_enabled(local_user(),'personal_tab')) {
835 'label' => t('Personal'),
836 'url' => str_replace('/new', '', $cmd) . ((x($_GET,'cid')) ? '/?f=&cid=' . $_GET['cid'] : '/?f=') . '&conv=1',
837 'sel' => $conv_active,
838 'title' => t('Posts that mention or involve you'),
839 'id' => 'personal-tab',
844 if (feature_enabled(local_user(),'new_tab')) {
847 'url' => 'network/new' . ((x($_GET,'cid')) ? '/?f=&cid=' . $_GET['cid'] : ''),
848 'sel' => $new_active,
849 'title' => t('Activity Stream - by date'),
850 'id' => 'activitiy-by-date-tab',
855 if(feature_enabled(local_user(),'link_tab')) {
857 'label' => t('Shared Links'),
858 'url' => str_replace('/new', '', $cmd) . ((x($_GET,'cid')) ? '/?f=&cid=' . $_GET['cid'] : '/?f=') . '&bmark=1',
859 'sel' => $bookmarked_active,
860 'title' => t('Interesting Links'),
861 'id' => 'shared-links-tab',
866 if(feature_enabled(local_user(),'star_posts')) {
868 'label' => t('Starred'),
869 'url' => str_replace('/new', '', $cmd) . ((x($_GET,'cid')) ? '/?f=&cid=' . $_GET['cid'] : '/?f=') . '&star=1',
870 'sel' => $starred_active,
871 'title' => t('Favourite Posts'),
872 'id' => 'starred-posts-tab',
877 // save selected tab, but only if not in search or file mode
878 if(!x($_GET,'search') && !x($_GET,'file')) {
879 set_pconfig( local_user(), 'network.view','tab.selected',array($all_active, $postord_active, $conv_active, $new_active, $starred_active, $bookmarked_active, $spam_active) );
882 $arr = array('tabs' => $tabs);
883 call_hooks('network_tabs', $arr);
885 $tpl = get_markup_template('common_tabs.tpl');
887 return replace_macros($tpl, array('$tabs' => $arr['tabs']));
889 // --- end item filter tabs