]> git.mxchange.org Git - friendica.git/commitdiff
gcontact update script, rebuilt follow page, query speedup for community and network...
authorMichael Vogel <icarus@dabo.de>
Sun, 10 Jan 2016 08:19:00 +0000 (09:19 +0100)
committerMichael Vogel <icarus@dabo.de>
Sun, 10 Jan 2016 08:19:00 +0000 (09:19 +0100)
13 files changed:
include/Contact.php
include/acl_selectors.php
include/cron.php
include/dbstructure.php
include/group.php
include/identity.php
include/threads.php
mod/community.php
mod/contacts.php
mod/display.php
mod/follow.php
mod/network.php
view/global.css

index 3185e8734829d39b14d6c1492fde63916a90d9ee..5aaaa11bffa601183ad33bef33ed80c913b1ebf0 100644 (file)
@@ -500,3 +500,165 @@ function get_contact($url, $uid = 0) {
 
        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;
+}
+?>
index 4ef3d05ea3959fb9ba46070436f7c33e2b034612..d5730a93a9f7fee45ab63aef5080b4e1b0402614 100644 (file)
@@ -407,7 +407,7 @@ function acl_lookup(&$a, $out_type = 'json') {
                $search = $_REQUEST['query'];
        }
 
-//     logger("Searching for ".$search." - type ".$type, LOGGER_DEBUG);
+       logger("Searching for ".$search." - type ".$type, LOGGER_DEBUG);
 
        if ($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`
                        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)
                );
        }
+       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') {
                $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
index a6e81f6bfd2710b2ecbedd8fff3751071697c74a..b1db9278af9f8a2974293094110117cf55ef8f0d 100644 (file)
@@ -133,9 +133,8 @@ function cron_run(&$argv, &$argc){
        // Check every conversation
        check_conversations(false);
 
-       // Follow your friends from your legacy OStatus account
-       // Doesn't work
-       // ostatus_check_follow_friends();
+       // Set the gcontact-id in the item table if missing
+       item_set_gcontact();
 
        // update nodeinfo data
        nodeinfo_cron();
index 4b2cdb251c46dfb6a6367f5cd76d8766b31cba4e..7fed50e741c9192577201eee6370943295750200 100644 (file)
@@ -877,7 +877,7 @@ function db_definition() {
                                        "uid_thrparent" => array("uid","thr-parent"),
                                        "uid_parenturi" => array("uid","parent-uri"),
                                        "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)"),
                                        "uid_visible_moderated_created" => array("uid","visible","moderated","created"),
                                        "uid_uri" => array("uid","uri"),
@@ -1324,6 +1324,8 @@ function db_definition() {
                                        "uid_network_created" => array("uid","network","created"),
                                        "uid_contactid_commented" => array("uid","contact-id","commented"),
                                        "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"),
                                        "uid_created" => array("uid","created"),
                                        "uid_commented" => array("uid","commented"),
index fd1c97dfde47d1af8c665b03eac51370428a7940..a1375e00dfa678f18368a407583d9d96e0625916 100644 (file)
@@ -297,17 +297,26 @@ function group_side($every="contacts",$each="group",$editmode = "standard", $gro
        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)))
                return array();
        $groups = implode(',', $a);
        $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();
        if(count($r))
                foreach($r as $rr)
                        $ret[] = $rr['contact-id'];
-       if($check_dead) {
+       if($check_dead AND !$use_gcontact) {
                require_once('include/acl_selectors.php');
                $ret = prune_deadguys($ret);
        }
@@ -366,4 +375,4 @@ function groups_count_unseen() {
        );
 
        return $r;
-}
\ No newline at end of file
+}
index fb405b90f17b278ea035cf11f0cb4846f7504d65..fdd28f81ce40f4f3f2bee76b5a9f826ef54113d8 100644 (file)
@@ -300,6 +300,7 @@ function profile_sidebar($profile, $block = 0) {
                $account_type = "";
 
        if((x($profile,'address') == 1)
+                       || (x($profile,'location') == 1)
                        || (x($profile,'locality') == 1)
                        || (x($profile,'region') == 1)
                        || (x($profile,'postal-code') == 1)
@@ -368,6 +369,8 @@ function profile_sidebar($profile, $block = 0) {
 
        if (isset($p["address"]))
                $p["address"] = bbcode($p["address"]);
+       else
+               $p["address"] = bbcode($p["location"]);
 
        if (isset($p["photo"]))
                $p["photo"] = proxy_url($p["photo"], false, PROXY_SIZE_SMALL);
index a6718465942dc8dcfc215323208697519a1612c3..44a7e6538447fc55baa41cdd53f5b92f857b5c7c 100644 (file)
@@ -111,7 +111,7 @@ function update_thread_uri($itemuri, $uid) {
 }
 
 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));
 
        if (!$items)
index d6f87762bdefefda35ecdb15ec387c7711a439a9..86bd18c869aab5fd238a842264d1eb5f921e5c30 100644 (file)
@@ -143,14 +143,13 @@ function community_getpublicitems($start, $itemspage) {
        $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 `item`.`uid` = 0 AND `item`.`id` = `item`.`parent`
-               AND `item`.`allow_cid` = '' AND `item`.`allow_gid` = ''
-               AND `item`.`deny_cid` = '' AND `item`.`deny_gid` = ''
-               ORDER BY `item`.`received` DESC LIMIT %d, %d",
+               FROM `thread`
+               INNER JOIN `item` ON `item`.`id` = `thread`.`iid`
+               WHERE `thread`.`uid` = 0
+               ORDER BY `thread`.`created` DESC LIMIT %d, %d",
                intval($start),
                intval($itemspage)
        );
 
        return($r);
-
 }
index 0a8aad9d722137493003a0b3cded94f5b450a473..ac7c7d85a1f1e0e85b5ba8d606ba22cbfc13fd08 100644 (file)
@@ -345,7 +345,6 @@ function _contact_archive($contact_id, $orig_record) {
        return $r;
 }
 function _contact_drop($contact_id, $orig_record) {
-       require_once('include/Contact.php');
        $a = get_app();
 
        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) {
 
-       require_once('include/conversation.php');
-
-       $r = q("SELECT * FROM `contact` WHERE `id` = %d", intval($contact_id));
+       $r = q("SELECT `url` FROM `contact` WHERE `id` = %d", intval($contact_id));
        if ($r) {
                $contact = $r[0];
                $a->page['aside'] = "";
                profile_load($a, "", 0, get_contact_details_by_url($contact["url"]));
-       }
-
-       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'])
-       );
+       } else
+               $profile = "";
 
        $tab_str = contacts_tab($a, $contact_id, 1);
 
        $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')) {
-               $o .= alt_pager($a,count($r));
-       } else {
-               $o .= paginate($a);
+               if ($r[0]["id"] <> 0)
+                       $o .= posts_from_gcontact($a, $r[0]["id"]);
        }
 
        return $o;
index 3a4674c323eb08210920b9dd290d39d5da7a787a..41cad5c6a92c81bd107b84d3a85f4df4500922bc 100644 (file)
@@ -154,49 +154,48 @@ function display_fetchauthor($a, $item) {
                $profiledata["about"] = "";
        }
 
-       // 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'",
-               dbesc(normalise_link($profiledata["url"])), intval($item["uid"]), dbesc($item["network"]));
-
-       if (!count($r))
-               $r = q("SELECT `uid`, `network`, `photo`, `nick`, `location`, `about` FROM `contact` WHERE `nurl` = '%s' AND `uid` = %d",
-                       dbesc(normalise_link($profiledata["url"])), intval($item["uid"]));
+       // 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
+       $r = q("SELECT `uid`, `network`, `photo`, `nick`, `addr`, `location`, `about`, `gender`, `keywords`
+               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))
-               $r = q("SELECT `uid`, `network`, `photo`, `nick`, `location`, `about` FROM `contact` WHERE `nurl` = '%s' AND `uid` = 0",
-                       dbesc(normalise_link($profiledata["url"])));
+               $r = q("SELECT `uid`, `network`, `photo`, `nick`, `addr`, `location`, `about`, `gender`, `keywords`
+                       FROM `contact` WHERE `nurl` = '%s' AND `uid` = %d AND `rel` IN (%d, %d)",
+                       dbesc(normalise_link($profiledata["url"])), intval($item["uid"]),
+                       intval(CONTACT_IS_SHARING), intval(CONTACT_IS_FRIEND));
 
        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["address"] = $r[0]["location"];
-               $profiledata["about"] = $r[0]["about"];
-               if ($r[0]["nick"] != "")
-                       $profiledata["nickname"] = $r[0]["nick"];
+               $profiledata["nickname"] = $r[0]["nick"];
+               $profiledata["addr"] = $r[0]["addr"];
+               $profiledata["keywords"] = $r[0]["keywords"];
+
+               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
        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 ($r[0]["avatar"] != "")
-                               $profiledata["photo"] = $r[0]["avatar"];
-                       if (($r[0]["location"] != "") AND ($profiledata["network"] != NETWORK_DIASPORA))
+                       $profiledata["photo"] = $r[0]["photo"];
+                       $profiledata["nickname"] = $r[0]["nick"];
+                       $profiledata["addr"] = $r[0]["addr"];
+                       $profiledata["keywords"] = $r[0]["keywords"];
+
+                       if ($showdetails) {
                                $profiledata["address"] = $r[0]["location"];
-                       if (($r[0]["about"] != "") AND ($profiledata["network"] != NETWORK_DIASPORA))
                                $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"];
-                       if ($r[0]["addr"] != "")
-                               $profiledata["addr"] = $r[0]["addr"];
-                       if ($r[0]["keywords"] != "")
-                               $profiledata["keywords"] = $r[0]["keywords"];
+                       }
                }
        }
 
index cc08831285e74fb69ed6aef54deafce7c5f67543..b92a0d980fb57e1150214c07aee7e5b590277c05 100644 (file)
@@ -2,6 +2,7 @@
 
 require_once('include/Scrape.php');
 require_once('include/follow.php');
+require_once('include/Contact.php');
 require_once('include/contact_selectors.php');
 
 function follow_content(&$a) {
@@ -75,15 +76,18 @@ function follow_content(&$a) {
        }
 
        $myaddr = $r[0]["url"];
+       $gcontact_id = 0;
 
        // Makes the connection request for friendica contacts easier
        $_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"]));
 
        if (!$r)
                $r = array(array("location" => "", "about" => "", "keywords" => ""));
+       else
+               $gcontact_id = $r[0]["id"];
 
        if($ret['network'] === NETWORK_DIASPORA) {
                $r[0]["location"] = "";
@@ -95,11 +99,12 @@ function follow_content(&$a) {
        if ($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(
                        '$header' => htmlentities($header),
-                       '$photo' => proxy_url($ret["photo"], false, PROXY_SIZE_SMALL),
+                       //'$photo' => proxy_url($ret["photo"], false, PROXY_SIZE_SMALL),
                        '$desc' => "",
                        '$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'))),
@@ -121,13 +126,26 @@ function follow_content(&$a) {
                        '$url_label' => t("Profile URL"),
                        '$myaddr' => $myaddr,
                        '$request' => $request,
-                       '$location' => bbcode($r[0]["location"]),
+                       /*'$location' => bbcode($r[0]["location"]),
                        '$location_label' => t("Location:"),
                        '$about' => bbcode($r[0]["about"], false, false),
-                       '$about_label' => t("About:"),
+                       '$about_label' => t("About:"), */
                        '$keywords' => $r[0]["keywords"],
                        '$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;
 }
 
index 4b9493bc613b29664255ad0467796c7619eebeb9..a12fa4ec36b95f1b733d479e4b65f70dc8315925 100644 (file)
@@ -312,6 +312,9 @@ function network_content(&$a, $update = 0) {
                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
        $arr = array('query' => $a->query_string);
        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'));
 
-       if(! $update) {
+       if(!$update AND !$rawmode) {
                if($group) {
                        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.',
@@ -549,27 +552,30 @@ function network_content(&$a, $update = 0) {
                }
 
                $contacts = expand_groups(array($group));
-
-               $contact_str_self = "";
+               $gcontacts = expand_groups(array($group), false, true);
 
                if((is_array($contacts)) && count($contacts)) {
+                       $contact_str_self = "";
+                       $gcontact_str_self = "";
+
                        $contact_str = implode(',',$contacts);
-                       $self = q("SELECT `id` FROM `contact` WHERE `uid` = %d AND `self`", intval($_SESSION['uid']));
-                       if (count($self))
-                               $contact_str_self = ",".$self[0]["id"];
-               }
-               else {
-                       $contact_str = ' 0 ';
+                       $gcontact_str = implode(',',$gcontacts);
+                       $self = q("SELECT `contact`.`id`, `gcontact`.`id` AS `gid` FROM `contact`
+                                       INNER JOIN `gcontact` ON `gcontact`.`nurl` = `contact`.`nurl`
+                                       WHERE `uid` = %d AND `self`", intval($_SESSION['uid']));
+                       if (count($self)) {
+                               $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'));
                }
 
-               //$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(
                        '$title' => sprintf( t('Group: %s'), $r[0]['name'])
                )) . $o;
index 05940508ca49c5609a68d0f8071c646b18112daf..900df531467fbdbd4fcf34040635ee23ba1aa57a 100644 (file)
@@ -321,3 +321,7 @@ ul.credits li {
 .p-addr {
        clear: both;    
 }
+
+#live-community {
+       clear: both;
+}