aboutsummaryrefslogtreecommitdiffstats
path: root/mod/network.php
diff options
context:
space:
mode:
Diffstat (limited to 'mod/network.php')
-rw-r--r--mod/network.php101
1 files changed, 48 insertions, 53 deletions
diff --git a/mod/network.php b/mod/network.php
index dae9fa6be..9b108aef8 100644
--- a/mod/network.php
+++ b/mod/network.php
@@ -7,6 +7,10 @@ function network_init(&$a) {
notice( t('Permission denied.') . EOL);
return;
}
+
+ $channel = $a->get_channel();
+ $a->profile_uid = local_user();
+ head_set_icon($channel['xchan_photo_s']);
$is_a_date_query = false;
@@ -100,23 +104,6 @@ function network_init(&$a) {
$a->page['aside'] .= saved_searches($search);
$a->page['aside'] .= fileas_widget($a->get_baseurl(true) . '/network',(x($_GET, 'file') ? $_GET['file'] : ''));
- $base = $a->get_baseurl();
-
- $a->page['htmlhead'] .= <<< EOT
-
-<script>$(document).ready(function() {
- var a;
- a = $("#search-text").autocomplete({
- serviceUrl: '$base/search_ac',
- minChars: 2,
- width: 350,
- });
-});
-</script>
-EOT;
-
-
-
}
function saved_searches($search) {
@@ -338,9 +325,9 @@ function network_content(&$a, $update = 0, $load = false) {
// 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) );
- }
+// 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) );
+// }
$contact_id = $a->cid;
@@ -369,7 +356,7 @@ function network_content(&$a, $update = 0, $load = false) {
if(feature_enabled(local_user(),'affinity')) {
$tpl = get_markup_template('main_slider.tpl');
- $o .= replace_macros($tpl,array(
+ $x = replace_macros($tpl,array(
'$val' => intval($cmin) . ';' . intval($cmax),
'$refresh' => t('Refresh'),
'$me' => t('Me'),
@@ -380,6 +367,9 @@ function network_content(&$a, $update = 0, $load = false) {
'$acquaintances' => t('Acquaintances'),
'$world' => t('Everybody')
));
+ $arr = array('html' => $x);
+ call_hooks('main_slider',$arr);
+ $o .= $arr['html'];
}
$arr = array('tabs' => $tabs);
@@ -389,18 +379,18 @@ function network_content(&$a, $update = 0, $load = false) {
// --- end item filter tabs
-
+ $search = (($_GET['search']) ? $_GET['search'] : '');
// search terms header
if($search)
$o .= '<h2>' . t('Search Results For:') . ' ' . htmlspecialchars($search) . '</h2>';
nav_set_selected('network');
- $celeb = ((($a->user['page-flags'] == PAGE_SOAPBOX) || ($a->user['page-flags'] == PAGE_COMMUNITY)) ? true : false);
+ $celeb = false;
$x = array(
'is_owner' => true,
- 'allow_location' => $a->user['allow_location'], // FIXME
+ 'allow_location' => ((intval(get_pconfig($channel['channel_id'],'system','use_browser_location'))) ? '1' : ''),
'default_location' => $channel['channel_location'],
'nickname' => $channel['channel_address'],
'lockstate' => (($group || $cid || $channel['channel_allow_cid'] || $channel['channel_allow_gid'] || $channel['channel_deny_cid'] || $channel['channel_deny_gid']) ? 'lock' : 'unlock'),
@@ -430,11 +420,11 @@ function network_content(&$a, $update = 0, $load = false) {
$sql_extra = " AND `item`.`parent` IN ( SELECT `parent` FROM `item` WHERE (item_flags & " . intval(ITEM_THREAD_TOP) . ") $sql_options ) ";
if($group) {
- $r = q("SELECT `name`, `id` FROM `group` WHERE `id` = %d AND `uid` = %d LIMIT 1",
- intval($group),
- intval($_SESSION['uid'])
- );
- if(! count($r)) {
+ $r = q("SELECT * FROM `group` WHERE id = %d AND uid = %d LIMIT 1",
+ intval($group),
+ intval(local_user())
+ );
+ if(! $r) {
if($update)
killme();
notice( t('No such group') . EOL );
@@ -442,33 +432,33 @@ function network_content(&$a, $update = 0, $load = false) {
// NOTREACHED
}
- $contacts = expand_groups(array($group));
- if((is_array($contacts)) && count($contacts)) {
- $contact_str = implode(',',$contacts);
- }
- else {
- $contact_str = ' 0 ';
- info( t('Group is empty'));
- }
+ $contacts = expand_groups(array($arr['group']));
+ if((is_array($contacts)) && count($contacts)) {
+ $contact_str = implode(',',$contacts);
+ }
+ else {
+ $contact_str = ' 0 ';
+ info( t('Group is empty'));
+ }
+
+ $sql_extra = " AND item.parent IN ( SELECT DISTINCT parent FROM item WHERE true $sql_options AND ( author_xchan IN ( $contact_str ) OR owner_xchan in ( $contact_str) or allow_gid like '" . protect_sprintf('%<' . dbesc($r[0]['hash']) . '>%') . "' ) and item_restrict = 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) {
- $r = q("SELECT `id`,`name`,`network`,`writable`,`nurl` FROM `contact` WHERE `id` = %d
- AND `blocked` = 0 AND `pending` = 0 LIMIT 1",
- intval($cid)
- );
- if(count($r)) {
- $sql_extra = " AND `item`.`parent` IN ( SELECT DISTINCT(`parent`) FROM `item` WHERE 1 $sql_options AND `contact-id` = " . intval($cid) . " and deleted = 0 ) ";
+ $r = q("SELECT * from abook where abook_id = %d and abook_channel = %d and not ( abook_flags & " . intval(ABOOK_FLAG_BLOCKED) . ") limit 1",
+ intval($cid),
+ intval(local_user())
+ );
+ if($r) {
+ $sql_extra = " AND item.parent IN ( SELECT DISTINCT parent FROM item WHERE true $sql_options AND uid = " . intval(local_user()) . " AND ( author_xchan = '" . dbesc($r[0]['abook_xchan']) . "' or owner_xchan = '" . dbesc($r[0]['abook_xchan']) . "' ) and item_restrict = 0 ) ";
$o = '<h2>' . t('Contact: ') . $r[0]['name'] . '</h2>' . $o;
- }
- else {
+ }
+ else {
notice( t('Invalid contact.') . EOL);
goaway($a->get_baseurl(true) . '/network');
- // NOTREACHED
- }
+ }
}
@@ -494,6 +484,7 @@ function network_content(&$a, $update = 0, $load = false) {
. "'; var profile_page = " . $a->pager['page'] . ";</script>";
+logger('Search: ' . $search);
$a->page['htmlhead'] .= replace_macros(get_markup_template("build_query.tpl"),array(
'$baseurl' => z_root(),
@@ -510,12 +501,12 @@ function network_content(&$a, $update = 0, $load = false) {
'$nouveau' => (($nouveau) ? $nouveau : '0'),
'$wall' => '0',
'$page' => (($a->pager['page'] != 1) ? $a->pager['page'] : 1),
- '$search' => $search,
+ '$search' => (($search) ? $search : ''),
'$order' => $order,
'$file' => $file,
'$cats' => '',
'$dend' => $datequery,
- '$uri' => '',
+ '$mid' => '',
'$dbegin' => $datequery2
));
}
@@ -651,6 +642,8 @@ function network_content(&$a, $update = 0, $load = false) {
$first = dba_timer();
// Then fetch all the children of the parents that are on this page
+ $parents_str = '';
+ $update_unseen = '';
if($r) {
@@ -709,10 +702,12 @@ function network_content(&$a, $update = 0, $load = false) {
$sixth = dba_timer();
- if(! $update)
+ if(($items) && (! $update))
$o .= alt_pager($a,count($items));
if($load) {
+ logger('mod_network: load: ' . count($items) . ' items', LOGGER_DATA);
+
profiler($start,$first,'network parents');
profiler($first,$second,'network children');
profiler($second,$third,'network authors');