From 602960460a6206f20ec9cb69b3f5214391b8ddc4 Mon Sep 17 00:00:00 2001
From: friendica <info@friendica.com>
Date: Mon, 8 Oct 2012 18:40:30 -0700
Subject: abook structure

---
 boot.php        |  2 +-
 database.sql    | 18 ++++++++++++++++++
 mod/network.php | 25 ++++++++++---------------
 version.inc     |  2 +-
 4 files changed, 30 insertions(+), 17 deletions(-)

diff --git a/boot.php b/boot.php
index 7d4310413..7f5dd06df 100644
--- a/boot.php
+++ b/boot.php
@@ -338,7 +338,7 @@ define ( 'ITEM_UPLINK',          0x0008);
 define ( 'ITEM_UPLINK_PRV',      0x0010);
 define ( 'ITEM_WALL',            0x0020);
 define ( 'ITEM_THREAD_TOP',      0x0040);
-
+define ( 'ITEM_NOTSHOWN',        0x0080);  // technically visible but not normally shown (e.g. like/dislike)
 
 
 
diff --git a/database.sql b/database.sql
index 8cb634eaa..248502859 100644
--- a/database.sql
+++ b/database.sql
@@ -6,6 +6,21 @@ SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
 /*!40101 SET NAMES utf8 */;
 
 
+CREATE TABLE IF NOT EXISTS `abook` (
+  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
+  `account` int(10) unsigned NOT NULL,
+  `channel` int(10) unsigned NOT NULL,
+  `xchan` char(255) NOT NULL DEFAULT '',
+  `my_perms` int(11) NOT NULL DEFAULT '0',
+  `their_perms` int(11) NOT NULL DEFAULT '0',
+  `closeness` tinyint(3) unsigned NOT NULL DEFAULT '255',
+  `created` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
+  `updated` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
+  `connnected` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
+  `abook_flags` int(11) NOT NULL DEFAULT '0',
+  PRIMARY KEY (`id`)
+) ENGINE=MyISAM DEFAULT CHARSET=utf8;
+
 CREATE TABLE IF NOT EXISTS `account` (
   `account_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
   `account_parent` int(10) unsigned NOT NULL DEFAULT '0',
@@ -849,11 +864,14 @@ CREATE TABLE IF NOT EXISTS `xchan` (
   `xchan_hash` char(255) NOT NULL,
   `xchan_guid` char(255) NOT NULL DEFAULT '',
   `xchan_guid_sig` char(255) NOT NULL DEFAULT '',
+  `xchan_pubkey` text NOT NULL,
   `xchan_photo` char(255) NOT NULL DEFAULT '',
   `xchan_addr` char(255) NOT NULL DEFAULT '',
   `xchan_profile` char(255) NOT NULL DEFAULT '',
   `xchan_name` char(255) NOT NULL DEFAULT '',
   `xchan_network` char(255) NOT NULL DEFAULT '',
+  `xchan_photo_date` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
+  `xchan_name_date` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
   PRIMARY KEY (`xchan_hash`),
   KEY `xchan_guid` (`xchan_guid`),
   KEY `xchan_addr` (`xchan_addr`),
diff --git a/mod/network.php b/mod/network.php
index ad3d43102..b5c568b78 100644
--- a/mod/network.php
+++ b/mod/network.php
@@ -602,21 +602,19 @@ function network_content(&$a, $update = 0, $load = false) {
 
 	if($nouveau && $load) {
 		// "New Item View" - show all items unthreaded in reverse created date order
-/*
-		$items = q("SELECT `item`.*, `item`.`id` AS `item_id`, 
-			o.xchan_name as oname, o.xchan_photo as ophoto, o.xchan_profile as ourl, 
-			a.xchan_name as aname, a.xchan_photo as aphoto, a.xchan_profile as aurl,
-			FROM `item` left join xchan as o on xchan_hash = owner_xchan left join xchan as a
-			on xchan_hash = author_xchan
+
+		$items = q("SELECT `item`.*, `item`.`id` AS `item_id` FROM `item` 
 			WHERE `item`.`uid` = %d AND item_restrict = 0 
 			$simple_update
 			$sql_extra $sql_nets
 			ORDER BY `item`.`received` DESC $pager_sql ",
 			intval($_SESSION['uid'])
 		);
-*/
+
 		require_once('include/items.php');
 
+		xchan_query($items);
+
 		$items = fetch_post_tags($items);
 	}
 	elseif($load) {
@@ -632,16 +630,12 @@ function network_content(&$a, $update = 0, $load = false) {
 		// Fetch a page full of parent items for this page
 
 		if($update && (! $load)) {
-/*			$r = q("SELECT `parent` AS `item_id`, `contact`.`uid` AS `contact_uid`
-				FROM `item` 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
-				AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
+			$r = q("SELECT `parent` AS `item_id` FROM `item` 
+				WHERE `item`.`uid` = %d AND `item`.`restrict` = 0 
 				$sql_extra3 $sql_extra $sql_nets ",
 				intval(local_user())
 			);
-*/		}
+		}
 		else {
 
 			$r = q("SELECT `item`.`id` AS `item_id`
@@ -675,7 +669,7 @@ function network_content(&$a, $update = 0, $load = false) {
 
 			$items = conv_sort($items,$ordering);
 
-logger('items: ' . print_r($items,true));
+//logger('items: ' . print_r($items,true));
 
 		} else {
 			$items = array();
@@ -697,6 +691,7 @@ logger('items: ' . print_r($items,true));
 		);
 	}
 
+// fixme
 	// Set this so that the conversation function can find out contact info for our wall-wall items
 	$a->page_contact = $a->contact;
 
diff --git a/version.inc b/version.inc
index 504c93750..0e8c2c404 100644
--- a/version.inc
+++ b/version.inc
@@ -1 +1 @@
-2012-10-07.100
+2012-10-08.101
-- 
cgit v1.2.3