gcontact update script, rebuilt follow page, query speedup for community and network groups

This commit is contained in:
Michael Vogel 2016-01-10 09:19:00 +01:00
parent 6703ba468a
commit 885dc1df81
13 changed files with 287 additions and 102 deletions

View file

@ -500,3 +500,165 @@ function get_contact($url, $uid = 0) {
return $contactid; return $contactid;
} }
/**
* @brief Returns posts from a given gcontact
*
* @param App $a argv application class
* @param int $gcontact_id Global contact
*
* @return string posts in HTML
*/
function posts_from_gcontact($a, $gcontact_id) {
require_once('include/conversation.php');
// There are no posts with "uid = 0" with connector networks
// This speeds up the query a lot
$r = q("SELECT `network` FROM `gcontact` WHERE `id` = %d", dbesc($gcontact_id));
if (in_array($r[0]["network"], array(NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS, "")))
$sql = "(`item`.`uid` = 0 OR (`item`.`uid` = %d AND `item`.`private`))";
else
$sql = "`item`.`uid` = %d";
if(get_config('system', 'old_pager')) {
$r = q("SELECT COUNT(*) AS `total` FROM `item`
WHERE `gcontact-id` = %d and $sql",
intval($gcontact_id),
intval(local_user()));
$a->set_pager_total($r[0]['total']);
}
$r = q("SELECT `item`.`uri`, `item`.*, `item`.`id` AS `item_id`,
`author-name` AS `name`, `owner-avatar` AS `photo`,
`owner-link` AS `url`, `owner-avatar` AS `thumb`
FROM `item`
WHERE `gcontact-id` = %d AND $sql AND
NOT `deleted` AND NOT `moderated` AND `visible`
ORDER BY `item`.`created` DESC LIMIT %d, %d",
intval($gcontact_id),
intval(local_user()),
intval($a->pager['start']),
intval($a->pager['itemspage'])
);
$o = conversation($a,$r,'community',false);
if(!get_config('system', 'old_pager')) {
$o .= alt_pager($a,count($r));
} else {
$o .= paginate($a);
}
return $o;
}
/**
* @brief set the gcontact-id in all item entries
*
* This job has to be started multiple times until all entries are set.
* It isn't started in the update function since it would consume too much time and can be done in the background.
*/
function item_set_gcontact() {
define ('POST_UPDATE_VERSION', 1192);
// Was the script completed?
if (get_config("system", "post_update_version") >= POST_UPDATE_VERSION)
return;
// Check if the first step is done (Setting "gcontact-id" in the item table)
$r = q("SELECT `author-link`, `author-name`, `author-avatar`, `uid`, `network` FROM `item` WHERE `gcontact-id` = 0 LIMIT 1000");
if (!$r) {
// Are there unfinished entries in the thread table?
$r = q("SELECT COUNT(*) AS `total` FROM `thread`
INNER JOIN `item` ON `item`.`id` =`thread`.`iid`
WHERE `thread`.`gcontact-id` = 0 AND
(`thread`.`uid` IN (SELECT `uid` from `user`) OR `thread`.`uid` = 0)");
if ($r AND ($r[0]["total"] == 0)) {
set_config("system", "post_update_version", POST_UPDATE_VERSION);
return false;
}
// Update the thread table from the item table
q("UPDATE `thread` INNER JOIN `item` ON `item`.`id`=`thread`.`iid`
SET `thread`.`gcontact-id` = `item`.`gcontact-id`
WHERE `thread`.`gcontact-id` = 0 AND
(`thread`.`uid` IN (SELECT `uid` from `user`) OR `thread`.`uid` = 0)");
return false;
}
$item_arr = array();
foreach ($r AS $item) {
$index = $item["author-link"]."-".$item["uid"];
$item_arr[$index] = array("author-link" => $item["author-link"],
"uid" => $item["uid"],
"network" => $item["network"]);
}
// Set the "gcontact-id" in the item table and add a new gcontact entry if needed
foreach($item_arr AS $item) {
$gcontact_id = get_gcontact_id(array("url" => $item['author-link'], "network" => $item['network'],
"photo" => $item['author-avatar'], "name" => $item['author-name']));
q("UPDATE `item` SET `gcontact-id` = %d WHERE `uid` = %d AND `author-link` = '%s' AND `gcontact-id` = 0",
intval($gcontact_id), intval($item["uid"]), dbesc($item["author-link"]));
}
return true;
}
/**
* @brief Returns posts from a given contact
*
* @param App $a argv application class
* @param int $contact_id contact
*
* @return string posts in HTML
*/
function posts_from_contact($a, $contact_id) {
require_once('include/conversation.php');
$r = q("SELECT `url` FROM `contact` WHERE `id` = %d", intval($contact_id));
if (!$r)
return false;
$contact = $r[0];
if(get_config('system', 'old_pager')) {
$r = q("SELECT COUNT(*) AS `total` FROM `item`
WHERE `item`.`uid` = %d AND `author-link` IN ('%s', '%s')",
intval(local_user()),
dbesc(str_replace("https://", "http://", $contact["url"])),
dbesc(str_replace("http://", "https://", $contact["url"])));
$a->set_pager_total($r[0]['total']);
}
$r = q("SELECT `item`.`uri`, `item`.*, `item`.`id` AS `item_id`,
`author-name` AS `name`, `owner-avatar` AS `photo`,
`owner-link` AS `url`, `owner-avatar` AS `thumb`
FROM `item` FORCE INDEX (uid_contactid_created)
WHERE `item`.`uid` = %d AND `contact-id` = %d
AND `author-link` IN ('%s', '%s')
AND NOT `deleted` AND NOT `moderated` AND `visible`
ORDER BY `item`.`created` DESC LIMIT %d, %d",
intval(local_user()),
intval($contact_id),
dbesc(str_replace("https://", "http://", $contact["url"])),
dbesc(str_replace("http://", "https://", $contact["url"])),
intval($a->pager['start']),
intval($a->pager['itemspage'])
);
$o .= conversation($a,$r,'community',false);
if(!get_config('system', 'old_pager'))
$o .= alt_pager($a,count($r));
else
$o .= paginate($a);
return $o;
}
?>

View file

@ -407,7 +407,7 @@ function acl_lookup(&$a, $out_type = 'json') {
$search = $_REQUEST['query']; $search = $_REQUEST['query'];
} }
// logger("Searching for ".$search." - type ".$type, LOGGER_DEBUG); logger("Searching for ".$search." - type ".$type, LOGGER_DEBUG);
if ($search!=""){ if ($search!=""){
$sql_extra = "AND `name` LIKE '%%".dbesc($search)."%%'"; $sql_extra = "AND `name` LIKE '%%".dbesc($search)."%%'";
@ -503,7 +503,7 @@ function acl_lookup(&$a, $out_type = 'json') {
} }
} }
if ($type=='' || $type=='c'){ if ($type==''){
$r = q("SELECT `id`, `name`, `nick`, `micro`, `network`, `url`, `attag`, forum FROM `contact` $r = q("SELECT `id`, `name`, `nick`, `micro`, `network`, `url`, `attag`, forum FROM `contact`
WHERE `uid` = %d AND `self` = 0 AND `blocked` = 0 AND `pending` = 0 AND `archive` = 0 AND `notify` != '' WHERE `uid` = %d AND `self` = 0 AND `blocked` = 0 AND `pending` = 0 AND `archive` = 0 AND `notify` != ''
@ -514,6 +514,17 @@ function acl_lookup(&$a, $out_type = 'json') {
dbesc(NETWORK_OSTATUS), dbesc(NETWORK_STATUSNET) dbesc(NETWORK_OSTATUS), dbesc(NETWORK_STATUSNET)
); );
} }
elseif ($type=='c'){
$r = q("SELECT `id`, `name`, `nick`, `micro`, `network`, `url`, `attag`, forum FROM `contact`
WHERE `uid` = %d AND `self` = 0 AND `blocked` = 0 AND `pending` = 0 AND `archive` = 0 AND `notify` != ''
AND NOT (`network` IN ('%s'))
$sql_extra2
ORDER BY `name` ASC ",
intval(local_user()),
dbesc(NETWORK_STATUSNET)
);
}
elseif($type == 'm') { elseif($type == 'm') {
$r = q("SELECT `id`, `name`, `nick`, `micro`, `network`, `url`, `attag` FROM `contact` $r = q("SELECT `id`, `name`, `nick`, `micro`, `network`, `url`, `attag` FROM `contact`
WHERE `uid` = %d AND `self` = 0 AND `blocked` = 0 AND `pending` = 0 AND `archive` = 0 WHERE `uid` = %d AND `self` = 0 AND `blocked` = 0 AND `pending` = 0 AND `archive` = 0

View file

@ -133,9 +133,8 @@ function cron_run(&$argv, &$argc){
// Check every conversation // Check every conversation
check_conversations(false); check_conversations(false);
// Follow your friends from your legacy OStatus account // Set the gcontact-id in the item table if missing
// Doesn't work item_set_gcontact();
// ostatus_check_follow_friends();
// update nodeinfo data // update nodeinfo data
nodeinfo_cron(); nodeinfo_cron();

View file

@ -877,7 +877,7 @@ function db_definition() {
"uid_thrparent" => array("uid","thr-parent"), "uid_thrparent" => array("uid","thr-parent"),
"uid_parenturi" => array("uid","parent-uri"), "uid_parenturi" => array("uid","parent-uri"),
"uid_contactid_created" => array("uid","contact-id","created"), "uid_contactid_created" => array("uid","contact-id","created"),
"uid_gcontactid_created" => array("uid","gcontact-id","created"), "gcontactid_uid_created" => array("gcontact-id","uid","created"),
"wall_body" => array("wall","body(6)"), "wall_body" => array("wall","body(6)"),
"uid_visible_moderated_created" => array("uid","visible","moderated","created"), "uid_visible_moderated_created" => array("uid","visible","moderated","created"),
"uid_uri" => array("uid","uri"), "uid_uri" => array("uid","uri"),
@ -1324,6 +1324,8 @@ function db_definition() {
"uid_network_created" => array("uid","network","created"), "uid_network_created" => array("uid","network","created"),
"uid_contactid_commented" => array("uid","contact-id","commented"), "uid_contactid_commented" => array("uid","contact-id","commented"),
"uid_contactid_created" => array("uid","contact-id","created"), "uid_contactid_created" => array("uid","contact-id","created"),
"uid_gcontactid_commented" => array("uid","gcontact-id","commented"),
"uid_gcontactid_created" => array("uid","gcontact-id","created"),
"wall_private_received" => array("wall","private","received"), "wall_private_received" => array("wall","private","received"),
"uid_created" => array("uid","created"), "uid_created" => array("uid","created"),
"uid_commented" => array("uid","commented"), "uid_commented" => array("uid","commented"),

View file

@ -297,17 +297,26 @@ function group_side($every="contacts",$each="group",$editmode = "standard", $gro
return $o; return $o;
} }
function expand_groups($a,$check_dead = false) { function expand_groups($a,$check_dead = false, $use_gcontact = false) {
if(! (is_array($a) && count($a))) if(! (is_array($a) && count($a)))
return array(); return array();
$groups = implode(',', $a); $groups = implode(',', $a);
$groups = dbesc($groups); $groups = dbesc($groups);
$r = q("SELECT `contact-id` FROM `group_member` WHERE `gid` IN ( $groups )");
if ($use_gcontact)
$r = q("SELECT `gcontact`.`id` AS `contact-id` FROM `group_member`
INNER JOIN `contact` ON `contact`.`id` = `group_member`.`contact-id`
INNER JOIN `gcontact` ON `gcontact`.`nurl` = `contact`.`nurl`
WHERE `gid` IN ($groups)");
else
$r = q("SELECT `contact-id` FROM `group_member` WHERE `gid` IN ( $groups )");
$ret = array(); $ret = array();
if(count($r)) if(count($r))
foreach($r as $rr) foreach($r as $rr)
$ret[] = $rr['contact-id']; $ret[] = $rr['contact-id'];
if($check_dead) { if($check_dead AND !$use_gcontact) {
require_once('include/acl_selectors.php'); require_once('include/acl_selectors.php');
$ret = prune_deadguys($ret); $ret = prune_deadguys($ret);
} }
@ -366,4 +375,4 @@ function groups_count_unseen() {
); );
return $r; return $r;
} }

View file

@ -300,6 +300,7 @@ function profile_sidebar($profile, $block = 0) {
$account_type = ""; $account_type = "";
if((x($profile,'address') == 1) if((x($profile,'address') == 1)
|| (x($profile,'location') == 1)
|| (x($profile,'locality') == 1) || (x($profile,'locality') == 1)
|| (x($profile,'region') == 1) || (x($profile,'region') == 1)
|| (x($profile,'postal-code') == 1) || (x($profile,'postal-code') == 1)
@ -368,6 +369,8 @@ function profile_sidebar($profile, $block = 0) {
if (isset($p["address"])) if (isset($p["address"]))
$p["address"] = bbcode($p["address"]); $p["address"] = bbcode($p["address"]);
else
$p["address"] = bbcode($p["location"]);
if (isset($p["photo"])) if (isset($p["photo"]))
$p["photo"] = proxy_url($p["photo"], false, PROXY_SIZE_SMALL); $p["photo"] = proxy_url($p["photo"], false, PROXY_SIZE_SMALL);

View file

@ -111,7 +111,7 @@ function update_thread_uri($itemuri, $uid) {
} }
function update_thread($itemid, $setmention = false) { function update_thread($itemid, $setmention = false) {
$items = q("SELECT `uid`, `guid`, `title`, `body`, `created`, `edited`, `commented`, `received`, `changed`, `wall`, `private`, `pubmail`, `moderated`, `visible`, `spam`, `starred`, `bookmark`, `contact-id`, $items = q("SELECT `uid`, `guid`, `title`, `body`, `created`, `edited`, `commented`, `received`, `changed`, `wall`, `private`, `pubmail`, `moderated`, `visible`, `spam`, `starred`, `bookmark`, `contact-id`, 'gcontact-id`,
`deleted`, `origin`, `forum_mode`, `network` FROM `item` WHERE `id` = %d AND (`parent` = %d OR `parent` = 0) LIMIT 1", intval($itemid), intval($itemid)); `deleted`, `origin`, `forum_mode`, `network` FROM `item` WHERE `id` = %d AND (`parent` = %d OR `parent` = 0) LIMIT 1", intval($itemid), intval($itemid));
if (!$items) if (!$items)

View file

@ -143,14 +143,13 @@ function community_getpublicitems($start, $itemspage) {
$r = q("SELECT `item`.`uri`, `item`.*, `item`.`id` AS `item_id`, $r = q("SELECT `item`.`uri`, `item`.*, `item`.`id` AS `item_id`,
`author-name` AS `name`, `owner-avatar` AS `photo`, `author-name` AS `name`, `owner-avatar` AS `photo`,
`owner-link` AS `url`, `owner-avatar` AS `thumb` `owner-link` AS `url`, `owner-avatar` AS `thumb`
FROM `item` WHERE `item`.`uid` = 0 AND `item`.`id` = `item`.`parent` FROM `thread`
AND `item`.`allow_cid` = '' AND `item`.`allow_gid` = '' INNER JOIN `item` ON `item`.`id` = `thread`.`iid`
AND `item`.`deny_cid` = '' AND `item`.`deny_gid` = '' WHERE `thread`.`uid` = 0
ORDER BY `item`.`received` DESC LIMIT %d, %d", ORDER BY `thread`.`created` DESC LIMIT %d, %d",
intval($start), intval($start),
intval($itemspage) intval($itemspage)
); );
return($r); return($r);
} }

View file

@ -345,7 +345,6 @@ function _contact_archive($contact_id, $orig_record) {
return $r; return $r;
} }
function _contact_drop($contact_id, $orig_record) { function _contact_drop($contact_id, $orig_record) {
require_once('include/Contact.php');
$a = get_app(); $a = get_app();
terminate_friendship($a->user,$a->contact,$orig_record); terminate_friendship($a->user,$a->contact,$orig_record);
@ -890,50 +889,24 @@ function contacts_tab($a, $contact_id, $active_tab) {
function contact_posts($a, $contact_id) { function contact_posts($a, $contact_id) {
require_once('include/conversation.php'); $r = q("SELECT `url` FROM `contact` WHERE `id` = %d", intval($contact_id));
$r = q("SELECT * FROM `contact` WHERE `id` = %d", intval($contact_id));
if ($r) { if ($r) {
$contact = $r[0]; $contact = $r[0];
$a->page['aside'] = ""; $a->page['aside'] = "";
profile_load($a, "", 0, get_contact_details_by_url($contact["url"])); profile_load($a, "", 0, get_contact_details_by_url($contact["url"]));
} } else
$profile = "";
if(get_config('system', 'old_pager')) {
$r = q("SELECT COUNT(*) AS `total` FROM `item`
WHERE `item`.`uid` = %d AND `author-link` IN ('%s', '%s')",
intval(local_user()),
dbesc(str_replace("https://", "http://", $contact["url"])),
dbesc(str_replace("http://", "https://", $contact["url"])));
$a->set_pager_total($r[0]['total']);
}
$r = q("SELECT `item`.`uri`, `item`.*, `item`.`id` AS `item_id`,
`author-name` AS `name`, `owner-avatar` AS `photo`,
`owner-link` AS `url`, `owner-avatar` AS `thumb`
FROM `item` FORCE INDEX (uid_contactid_created)
WHERE `item`.`uid` = %d AND `contact-id` = %d
AND `author-link` IN ('%s', '%s')
ORDER BY `item`.`created` DESC LIMIT %d, %d",
intval(local_user()),
intval($contact_id),
dbesc(str_replace("https://", "http://", $contact["url"])),
dbesc(str_replace("http://", "https://", $contact["url"])),
intval($a->pager['start']),
intval($a->pager['itemspage'])
);
$tab_str = contacts_tab($a, $contact_id, 1); $tab_str = contacts_tab($a, $contact_id, 1);
$o .= $tab_str; $o .= $tab_str;
$o .= conversation($a,$r,'community',false); if ($contact["url"]) {
$r = q("SELECT `id` FROM `gcontact` WHERE `nurl` = '%s' LIMIT 1",
dbesc(normalise_link($contact["url"])));
if(!get_config('system', 'old_pager')) { if ($r[0]["id"] <> 0)
$o .= alt_pager($a,count($r)); $o .= posts_from_gcontact($a, $r[0]["id"]);
} else {
$o .= paginate($a);
} }
return $o; return $o;

View file

@ -154,49 +154,48 @@ function display_fetchauthor($a, $item) {
$profiledata["about"] = ""; $profiledata["about"] = "";
} }
// Don't show details from Diaspora contacts if you don't follow the contact
$showdetails = ($profiledata["network"] != NETWORK_DIASPORA);
// Fetching further contact data from the contact table // Fetching further contact data from the contact table
$r = q("SELECT `uid`, `network`, `photo`, `nick`, `location`, `about` FROM `contact` WHERE `nurl` = '%s' AND `uid` = %d AND `network` = '%s'", $r = q("SELECT `uid`, `network`, `photo`, `nick`, `addr`, `location`, `about`, `gender`, `keywords`
dbesc(normalise_link($profiledata["url"])), intval($item["uid"]), dbesc($item["network"])); FROM `contact` WHERE `nurl` = '%s' AND `uid` = %d AND `network` = '%s' AND `rel` IN (%d, %d)",
dbesc(normalise_link($profiledata["url"])), intval($item["uid"]), dbesc($item["network"]),
intval(CONTACT_IS_SHARING), intval(CONTACT_IS_FRIEND));
if (!count($r)) if (!count($r))
$r = q("SELECT `uid`, `network`, `photo`, `nick`, `location`, `about` FROM `contact` WHERE `nurl` = '%s' AND `uid` = %d", $r = q("SELECT `uid`, `network`, `photo`, `nick`, `addr`, `location`, `about`, `gender`, `keywords`
dbesc(normalise_link($profiledata["url"])), intval($item["uid"])); FROM `contact` WHERE `nurl` = '%s' AND `uid` = %d AND `rel` IN (%d, %d)",
dbesc(normalise_link($profiledata["url"])), intval($item["uid"]),
if (!count($r)) intval(CONTACT_IS_SHARING), intval(CONTACT_IS_FRIEND));
$r = q("SELECT `uid`, `network`, `photo`, `nick`, `location`, `about` FROM `contact` WHERE `nurl` = '%s' AND `uid` = 0",
dbesc(normalise_link($profiledata["url"])));
if (count($r)) { if (count($r)) {
if ((($r[0]["uid"] != local_user()) OR !local_user()) AND ($profiledata["network"] == NETWORK_DIASPORA)) {
$r[0]["location"] = "";
$r[0]["about"] = "";
}
$profiledata["photo"] = $r[0]["photo"]; $profiledata["photo"] = $r[0]["photo"];
$profiledata["address"] = $r[0]["location"]; $profiledata["nickname"] = $r[0]["nick"];
$profiledata["about"] = $r[0]["about"]; $profiledata["addr"] = $r[0]["addr"];
if ($r[0]["nick"] != "") $profiledata["keywords"] = $r[0]["keywords"];
$profiledata["nickname"] = $r[0]["nick"];
if (($r[0]["uid"] != 0) OR $showdetails) {
$showdetails = true;
$profiledata["address"] = $r[0]["location"];
$profiledata["about"] = $r[0]["about"];
$profiledata["gender"] = $r[0]["gender"];
}
} }
// Fetching profile data from global contacts // Fetching profile data from global contacts
if ($profiledata["network"] != NETWORK_FEED) { if ($profiledata["network"] != NETWORK_FEED) {
$r = q("SELECT `photo`, `nick`, `addr`, `location`, `about`, `gender` FROM `gcontact` WHERE `nurl` = '%s'", dbesc(normalise_link($profiledata["url"]))); $r = q("SELECT `photo`, `nick`, `addr`, `location`, `about`, `gender`, `keywords` FROM `gcontact` WHERE `nurl` = '%s'", dbesc(normalise_link($profiledata["url"])));
if (count($r)) { if (count($r)) {
if ($r[0]["avatar"] != "") $profiledata["photo"] = $r[0]["photo"];
$profiledata["photo"] = $r[0]["avatar"]; $profiledata["nickname"] = $r[0]["nick"];
if (($r[0]["location"] != "") AND ($profiledata["network"] != NETWORK_DIASPORA)) $profiledata["addr"] = $r[0]["addr"];
$profiledata["keywords"] = $r[0]["keywords"];
if ($showdetails) {
$profiledata["address"] = $r[0]["location"]; $profiledata["address"] = $r[0]["location"];
if (($r[0]["about"] != "") AND ($profiledata["network"] != NETWORK_DIASPORA))
$profiledata["about"] = $r[0]["about"]; $profiledata["about"] = $r[0]["about"];
if (($r[0]["nick"] != "") AND ($r[0]["nick"] != ""))
$profiledata["nickname"] = $r[0]["nick"];
if ($r[0]["gender"] != "")
$profiledata["gender"] = $r[0]["gender"]; $profiledata["gender"] = $r[0]["gender"];
if ($r[0]["addr"] != "") }
$profiledata["addr"] = $r[0]["addr"];
if ($r[0]["keywords"] != "")
$profiledata["keywords"] = $r[0]["keywords"];
} }
} }

View file

@ -2,6 +2,7 @@
require_once('include/Scrape.php'); require_once('include/Scrape.php');
require_once('include/follow.php'); require_once('include/follow.php');
require_once('include/Contact.php');
require_once('include/contact_selectors.php'); require_once('include/contact_selectors.php');
function follow_content(&$a) { function follow_content(&$a) {
@ -75,15 +76,18 @@ function follow_content(&$a) {
} }
$myaddr = $r[0]["url"]; $myaddr = $r[0]["url"];
$gcontact_id = 0;
// Makes the connection request for friendica contacts easier // Makes the connection request for friendica contacts easier
$_SESSION["fastlane"] = $ret["url"]; $_SESSION["fastlane"] = $ret["url"];
$r = q("SELECT `location`, `about`, `keywords` FROM `gcontact` WHERE `nurl` = '%s'", $r = q("SELECT `id`, `location`, `about`, `keywords` FROM `gcontact` WHERE `nurl` = '%s'",
normalise_link($ret["url"])); normalise_link($ret["url"]));
if (!$r) if (!$r)
$r = array(array("location" => "", "about" => "", "keywords" => "")); $r = array(array("location" => "", "about" => "", "keywords" => ""));
else
$gcontact_id = $r[0]["id"];
if($ret['network'] === NETWORK_DIASPORA) { if($ret['network'] === NETWORK_DIASPORA) {
$r[0]["location"] = ""; $r[0]["location"] = "";
@ -95,11 +99,12 @@ function follow_content(&$a) {
if ($ret["addr"] != "") if ($ret["addr"] != "")
$header .= " <".$ret["addr"].">"; $header .= " <".$ret["addr"].">";
$header .= " (".network_to_name($ret['network'], $ret['url']).")"; //$header .= " (".network_to_name($ret['network'], $ret['url']).")";
$header = t("Connect/Follow");
$o = replace_macros($tpl,array( $o = replace_macros($tpl,array(
'$header' => htmlentities($header), '$header' => htmlentities($header),
'$photo' => proxy_url($ret["photo"], false, PROXY_SIZE_SMALL), //'$photo' => proxy_url($ret["photo"], false, PROXY_SIZE_SMALL),
'$desc' => "", '$desc' => "",
'$pls_answer' => t('Please answer the following:'), '$pls_answer' => t('Please answer the following:'),
'$does_know_you' => array('knowyou', sprintf(t('Does %s know you?'),$ret["name"]), false, '', array(t('No'),t('Yes'))), '$does_know_you' => array('knowyou', sprintf(t('Does %s know you?'),$ret["name"]), false, '', array(t('No'),t('Yes'))),
@ -121,13 +126,26 @@ function follow_content(&$a) {
'$url_label' => t("Profile URL"), '$url_label' => t("Profile URL"),
'$myaddr' => $myaddr, '$myaddr' => $myaddr,
'$request' => $request, '$request' => $request,
'$location' => bbcode($r[0]["location"]), /*'$location' => bbcode($r[0]["location"]),
'$location_label' => t("Location:"), '$location_label' => t("Location:"),
'$about' => bbcode($r[0]["about"], false, false), '$about' => bbcode($r[0]["about"], false, false),
'$about_label' => t("About:"), '$about_label' => t("About:"), */
'$keywords' => $r[0]["keywords"], '$keywords' => $r[0]["keywords"],
'$keywords_label' => t("Tags:") '$keywords_label' => t("Tags:")
)); ));
$a->page['aside'] = "";
profile_load($a, "", 0, get_contact_details_by_url($ret["url"]));
// Show last public posts
if ($gcontact_id <> 0) {
$o .= replace_macros(get_markup_template('section_title.tpl'),
array('$title' => t('Status Messages and Posts')
));
$o .= posts_from_gcontact($a, $gcontact_id);
}
return $o; return $o;
} }

View file

@ -312,6 +312,9 @@ function network_content(&$a, $update = 0) {
return login(false); return login(false);
} }
// Rawmode is used for fetching new content at the end of the page
$rawmode = (isset($_GET["mode"]) AND ($_GET["mode"] == "raw"));
/// @TODO Is this really necessary? $a is already available to hooks /// @TODO Is this really necessary? $a is already available to hooks
$arr = array('query' => $a->query_string); $arr = array('query' => $a->query_string);
call_hooks('network_content_init', $arr); call_hooks('network_content_init', $arr);
@ -470,7 +473,7 @@ function network_content(&$a, $update = 0) {
} }
set_pconfig(local_user(), 'network.view', 'net.selected', ($nets ? $nets : 'all')); set_pconfig(local_user(), 'network.view', 'net.selected', ($nets ? $nets : 'all'));
if(! $update) { if(!$update AND !$rawmode) {
if($group) { if($group) {
if(($t = group_public_members($group)) && (! get_pconfig(local_user(),'system','nowarn_insecure'))) { if(($t = group_public_members($group)) && (! get_pconfig(local_user(),'system','nowarn_insecure'))) {
notice( sprintf( tt('Warning: This group contains %s member from an insecure network.', notice( sprintf( tt('Warning: This group contains %s member from an insecure network.',
@ -549,27 +552,30 @@ function network_content(&$a, $update = 0) {
} }
$contacts = expand_groups(array($group)); $contacts = expand_groups(array($group));
$gcontacts = expand_groups(array($group), false, true);
$contact_str_self = "";
if((is_array($contacts)) && count($contacts)) { if((is_array($contacts)) && count($contacts)) {
$contact_str_self = "";
$gcontact_str_self = "";
$contact_str = implode(',',$contacts); $contact_str = implode(',',$contacts);
$self = q("SELECT `id` FROM `contact` WHERE `uid` = %d AND `self`", intval($_SESSION['uid'])); $gcontact_str = implode(',',$gcontacts);
if (count($self)) $self = q("SELECT `contact`.`id`, `gcontact`.`id` AS `gid` FROM `contact`
$contact_str_self = ",".$self[0]["id"]; INNER JOIN `gcontact` ON `gcontact`.`nurl` = `contact`.`nurl`
} WHERE `uid` = %d AND `self`", intval($_SESSION['uid']));
else { if (count($self)) {
$contact_str = ' 0 '; $contact_str_self = $self[0]["id"];
$gcontact_str_self = $self[0]["gid"];
}
$sql_post_table = " INNER JOIN `item` AS `temp1` ON `temp1`.`id` = ".$sql_table.".".$sql_parent;
$sql_extra3 .= " AND ($sql_table.`contact-id` IN ($contact_str) ";
$sql_extra3 .= " OR ($sql_table.`contact-id` = '$contact_str_self' AND `temp1`.`allow_gid` LIKE '".protect_sprintf('%<'.intval($group).'>%')."' AND `temp1`.`private`))";
} else {
$sql_extra3 .= " AND false ";
info( t('Group is empty')); info( t('Group is empty'));
} }
//$sql_post_table = " INNER JOIN (SELECT DISTINCT(`parent`) FROM `item` WHERE (`contact-id` IN ($contact_str) OR `allow_gid` like '".protect_sprintf('%<'.intval($group).'>%')."') and deleted = 0 ORDER BY `created` DESC) AS `temp1` ON $sql_table.$sql_parent = `temp1`.`parent` ";
$sql_extra3 .= " AND $sql_table.`contact-id` IN ($contact_str$contact_str_self) ";
$sql_extra3 .= " AND EXISTS (SELECT `id` FROM `item` WHERE (`contact-id` IN ($contact_str)
OR `allow_gid` LIKE '".protect_sprintf('%<'.intval($group).'>%')."') AND `deleted` = 0
AND `id` = $sql_table.$sql_parent) ";
$o = replace_macros(get_markup_template("section_title.tpl"),array( $o = replace_macros(get_markup_template("section_title.tpl"),array(
'$title' => sprintf( t('Group: %s'), $r[0]['name']) '$title' => sprintf( t('Group: %s'), $r[0]['name'])
)) . $o; )) . $o;

View file

@ -321,3 +321,7 @@ ul.credits li {
.p-addr { .p-addr {
clear: both; clear: both;
} }
#live-community {
clear: both;
}