X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=mod%2Fnetwork.php;h=ba7bff791aefb66d9fea45c0fc98dd874bc950a2;hb=6edc52f78f12f366f344eb86723d39b92a77a9ff;hp=4d3603843eb8633856c3524af7df184c128d8389;hpb=3af16ff92a6ee3c56986d4d9f79fff3b2d61ca26;p=friendica.git diff --git a/mod/network.php b/mod/network.php index 4d3603843e..ba7bff791a 100644 --- a/mod/network.php +++ b/mod/network.php @@ -6,7 +6,7 @@ function network_init(&$a) { notice( t('Permission denied.') . EOL); return; } - + $is_a_date_query = false; if($a->argc > 1) { @@ -17,12 +17,12 @@ function network_init(&$a) { } } } - + // convert query string to array and remove first element (which is friendica args) $query_array = array(); parse_str($a->query_string, $query_array); array_shift($query_array); - + // fetch last used network view and redirect if needed if(! $is_a_date_query) { $sel_tabs = network_query_get_sel_tab($a); @@ -141,11 +141,11 @@ function network_init(&$a) { 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'); @@ -181,7 +181,7 @@ function network_init(&$a) { $a->page['content'] .= '

' . t('Search Results For:') . ' ' . $search . '

'; } - $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=' @@ -318,7 +321,7 @@ function network_query_get_sel_net() { if(x($_GET,'nets')) { $network = $_GET['nets']; } - + return $network; } @@ -379,14 +382,14 @@ function network_content(&$a, $update = 0) { // item filter tabs // TODO: fix this logic, reduce duplication //$a->page['content'] .= '
'; - + list($no_active, $all_active, $postord_active, $conv_active, $new_active, $starred_active, $bookmarked_active, $spam_active) = network_query_get_sel_tab($a); // if no tabs are selected, defaults to comments if ($no_active=='active') $all_active='active'; //echo "
"; var_dump($no_active, $all_active, $postord_active, $conv_active, $new_active, $starred_active, $bookmarked_active, $spam_active); killme();
 
 	$cmd = (($datequery) ? '' : $a->cmd);
-	$len_naked_cmd = strlen(str_replace('/new','',$cmd));		
+	$len_naked_cmd = strlen(str_replace('/new','',$cmd));
 
 	// tabs
 	$tabs = array(
@@ -403,39 +406,86 @@ 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'
 //			'sel'=> $spam_active,
 //			'title' => t('Posts flagged as SPAM'),
-//		),	
+//		),
 
 	);
-	
+
+	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) );
@@ -450,7 +500,7 @@ function network_content(&$a, $update = 0) {
 
 
 
-	
+
 
 	$contact_id = $a->cid;
 
@@ -510,10 +560,12 @@ function network_content(&$a, $update = 0) {
 			'default_location' => $a->user['default-location'],
 			'nickname' => $a->user['nickname'],
 			'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'),
+			'default_perms' => get_acl_permissions($a->user),
 			'acl' => populate_acl((($group || $cid || $nets) ? $def_acl : $a->user), $celeb),
 			'bang' => (($group || $cid || $nets) ? '!' : ''),
 			'visitor' => 'block',
-			'profile_uid' => local_user()
+			'profile_uid' => local_user(),
+			'acl_data' => construct_acl_data($a, $a->user), // For non-Javascript ACL selector
 		);
 
 		$o .= status_editor($a,$x);
@@ -521,11 +573,11 @@ function network_content(&$a, $update = 0) {
 	}
 
 
-	// We don't have to deal with ACL's on this page. You're looking at everything
+	// We don't have to deal with ACLs on this page. You're looking at everything
 	// that belongs to you, hence you can see all of it. We will filter by group if
 	// desired. 
 
-	
+
 	$sql_options  = (($star) ? " and starred = 1 " : '');
 	$sql_options .= (($bmark) ? " and bookmark = 1 " : '');
 
@@ -595,16 +647,26 @@ function network_content(&$a, $update = 0) {
 
 	$sql_extra2 = (($nouveau) ? '' : " AND `item`.`parent` = `item`.`id` ");
 	$sql_extra3 = (($nouveau) ? '' : $sql_extra3);
+	$sql_table = "`item`";
 
 	if(x($_GET,'search')) {
 		$search = escape_tags($_GET['search']);
-		if (get_config('system','use_fulltext_engine')) {
+
+		if(strpos($search,'#') === 0) {
+                	$tag = true;
+			$search = substr($search,1);
+		}
+
+		if (get_config('system','only_tag_search'))
+			$tag = true;
+
+		/*if (get_config('system','use_fulltext_engine')) {
 			if(strpos($search,'#') === 0)
 				$sql_extra .= sprintf(" AND (MATCH(tag) AGAINST ('".'"%s"'."' in boolean mode)) ",
 					dbesc(protect_sprintf($search))
 				);
 			else
-				$sql_extra .= sprintf(" AND (MATCH(`item`.`body`) AGAINST ('".'"%s"'."' in boolean mode) or MATCH(tag) AGAINST ('".'"%s"'."' in boolean mode)) ",
+				$sql_extra .= sprintf(" AND (MATCH(`item`.`body`, `item`.`title`) AGAINST ('%s' in boolean mode)) ",
 					dbesc(protect_sprintf($search)),
 					dbesc(protect_sprintf($search))
 				);
@@ -613,6 +675,17 @@ function network_content(&$a, $update = 0) {
 					dbesc(protect_sprintf('%' . $search . '%')),
 					dbesc(protect_sprintf('%]' . $search . '[%'))
 			);
+		}*/
+
+		if($tag) {
+			$sql_extra = sprintf(" AND `term`.`term` = '%s' AND `term`.`otype` = %d AND `term`.`type` = %d ",
+					dbesc(protect_sprintf($search)), intval(TERM_OBJ_POST), intval(TERM_HASHTAG));
+			$sql_table = "`term` LEFT JOIN `item` ON `item`.`id` = `term`.`oid` AND `item`.`uid` = `term`.`uid` ";
+		} 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))));
 		}
 	}
 	if(strlen($file)) {
@@ -624,8 +697,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))
@@ -635,8 +710,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) {
@@ -646,9 +725,9 @@ 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`
+			        FROM $sql_table LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
 			        WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0
 			        AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
 			        $sql_extra2 $sql_extra3
@@ -679,11 +758,10 @@ function network_content(&$a, $update = 0) {
 			`contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`rel`, `contact`.`writable`,
 			`contact`.`network`, `contact`.`thumb`, `contact`.`dfrn-id`, `contact`.`self`,
 			`contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`
-			FROM `item`, `contact`
+			FROM $sql_table LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
 			WHERE `item`.`uid` = %d AND `item`.`visible` = 1 
 			AND `item`.`deleted` = 0 and `item`.`moderated` = 0
 			$simple_update
-			AND `contact`.`id` = `item`.`contact-id`
 			AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
 			$sql_extra $sql_nets
 			ORDER BY `item`.`received` DESC $pager_sql ",
@@ -706,7 +784,7 @@ function network_content(&$a, $update = 0) {
 
 		if($update) {
 			$r = q("SELECT `parent` AS `item_id`, `contact`.`uid` AS `contact_uid`
-				FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
+				FROM $sql_table LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
 				WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND
 				(`item`.`deleted` = 0 OR item.verb = '" . ACTIVITY_LIKE ."' OR item.verb = '" . ACTIVITY_DISLIKE . "')
 				and `item`.`moderated` = 0 and `item`.`unseen` = 1
@@ -717,7 +795,7 @@ function network_content(&$a, $update = 0) {
 		}
 		else {
 			$r = q("SELECT `item`.`id` AS `item_id`, `contact`.`uid` AS `contact_uid`
-				FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
+				FROM $sql_table LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
 				WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0
 				AND `item`.`moderated` = 0 AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
 				AND `item`.`parent` = `item`.`id`
@@ -742,9 +820,9 @@ function network_content(&$a, $update = 0) {
 				`contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`alias`, `contact`.`rel`, `contact`.`writable`,
 				`contact`.`network`, `contact`.`thumb`, `contact`.`dfrn-id`, `contact`.`self`,
 				`contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`
-				FROM `item`, `contact`
+				FROM $sql_table LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
 				WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0
-				AND `item`.`moderated` = 0 AND `contact`.`id` = `item`.`contact-id`
+				AND `item`.`moderated` = 0
 				AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
 				AND `item`.`parent` IN ( %s )
 				$sql_extra ",
@@ -766,16 +844,26 @@ function network_content(&$a, $update = 0) {
 	// We aren't going to try and figure out at the item, group, and page
 	// 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;
@@ -785,11 +873,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);
 		}
 	}