From ed275cd40d3462c302aa1b06a878630750928992 Mon Sep 17 00:00:00 2001 From: friendica Date: Tue, 15 Jan 2013 16:48:59 -0800 Subject: slow progress on events, one step forward, one step back. --- boot.php | 2 +- include/event.php | 40 ++++++++++++++++++++++++++-------------- install/database.sql | 4 ++-- install/update.php | 9 ++++++++- version.inc | 2 +- 5 files changed, 38 insertions(+), 19 deletions(-) diff --git a/boot.php b/boot.php index cc5a01a4e..fab29db51 100644 --- a/boot.php +++ b/boot.php @@ -16,7 +16,7 @@ require_once('include/features.php'); define ( 'FRIENDICA_PLATFORM', 'Friendica Red'); define ( 'FRIENDICA_VERSION', trim(file_get_contents('version.inc')) . 'R'); define ( 'ZOT_REVISION', 1 ); -define ( 'DB_UPDATE_VERSION', 1017 ); +define ( 'DB_UPDATE_VERSION', 1019 ); define ( 'EOL', '
' . "\r\n" ); define ( 'ATOM_TIME', 'Y-m-d\TH:i:s\Z' ); diff --git a/include/event.php b/include/event.php index 6f9ba779c..bcb7eb395 100644 --- a/include/event.php +++ b/include/event.php @@ -208,12 +208,13 @@ function event_store($arr) { $arr['created'] = (($arr['created']) ? $arr['created'] : datetime_convert()); $arr['edited'] = (($arr['edited']) ? $arr['edited'] : datetime_convert()); $arr['type'] = (($arr['type']) ? $arr['type'] : 'event' ); - $arr['cid'] = ((intval($arr['cid'])) ? intval($arr['cid']) : 0); + $arr['event_xchan'] = (($arr['event_xchan']) ? $arr['event_xchan'] : ''); $arr['message_id'] = (x($arr,'message_id') ? $arr['message_id'] : get_message_id()); $arr['private'] = ((x($arr,'private')) ? intval($arr['private']) : 0); // FIXME +/* if($arr['cid']) $c = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1", intval($arr['cid']), @@ -226,7 +227,7 @@ function event_store($arr) { if(count($c)) $contact = $c[0]; - +*/ // Existing event being modified @@ -283,15 +284,22 @@ function event_store($arr) { intval($arr['id']), intval($arr['uid']) ); - $r = q("SELECT * FROM `item` WHERE `event-id` = %d AND `uid` = %d LIMIT 1", + + $r = q("SELECT * FROM item WHERE resource_id = %d AND resource_type = 'event' and uid = %d LIMIT 1", intval($arr['id']), intval($arr['uid']) ); + +// FIXME + if(count($r)) { + +/* $object = '' . xmlify(ACTIVITY_OBJ_EVENT) . '' . xmlify($arr['message_id']) . ''; $object .= '' . xmlify(format_event_bbcode($arr)) . ''; $object .= '' . "\n"; - +*/ +/* q("UPDATE `item` SET `body` = '%s', `object` = '%s', `allow_cid` = '%s', `allow_gid` = '%s', `deny_cid` = '%s', `deny_gid` = '%s', `edited` = '%s', `private` = %d WHERE `id` = %d AND `uid` = %d LIMIT 1", dbesc(format_event_bbcode($arr)), @@ -305,7 +313,7 @@ function event_store($arr) { intval($r[0]['id']), intval($arr['uid']) ); - +*/ $item_id = $r[0]['id']; } else @@ -319,12 +327,12 @@ function event_store($arr) { // New event. Store it. - $r = q("INSERT INTO `event` ( `uid`,`account`,`cid`,`message_id`,`created`,`edited`,`start`,`finish`,`summary`, `desc`,`location`,`type`, + $r = q("INSERT INTO `event` ( `uid`,`account`,`event_xchan`,`message_id`,`created`,`edited`,`start`,`finish`,`summary`, `desc`,`location`,`type`, `adjust`,`nofinish`,`allow_cid`,`allow_gid`,`deny_cid`,`deny_gid`) - VALUES ( %d, %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, '%s', '%s', '%s', '%s' ) ", + VALUES ( %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, '%s', '%s', '%s', '%s' ) ", intval($arr['account']), intval($arr['uid']), - intval($arr['cid']), + intval($arr['event_xchan']), dbesc($arr['uri']), dbesc($arr['created']), dbesc($arr['edited']), @@ -354,10 +362,10 @@ function event_store($arr) { $item_arr['uid'] = $arr['uid']; - $item_arr['contact-id'] = $arr['cid']; +/* $item_arr['contact-id'] = $arr['cid']; */ $item_arr['uri'] = $arr['message_id']; $item_arr['parent_uri'] = $arr['message_id']; - $item_arr['type'] = 'activity'; +/* $item_arr['type'] = 'activity'; $item_arr['wall'] = (($arr['cid']) ? 0 : 1); $item_arr['contact-id'] = $contact['id']; $item_arr['owner-name'] = $contact['name']; @@ -366,24 +374,28 @@ function event_store($arr) { $item_arr['author-name'] = $contact['name']; $item_arr['author-link'] = $contact['url']; $item_arr['author-avatar'] = $contact['thumb']; +*/ $item_arr['title'] = ''; $item_arr['allow_cid'] = $arr['allow_cid']; $item_arr['allow_gid'] = $arr['allow_gid']; $item_arr['deny_cid'] = $arr['deny_cid']; $item_arr['deny_gid'] = $arr['deny_gid']; - $item_arr['private'] = $arr['private']; + +/* $item_arr['private'] = $arr['private']; $item_arr['last-child'] = 1; $item_arr['visible'] = 1; +*/ $item_arr['verb'] = ACTIVITY_POST; $item_arr['obj_type'] = ACTIVITY_OBJ_EVENT; - $item_arr['origin'] = ((intval($arr['cid']) == 0) ? 1 : 0); - $item_arr['body'] = format_event_bbcode($event); +/* $item_arr['origin'] = ((intval($arr['cid']) == 0) ? 1 : 0); */ + $item_arr['body'] = format_event_bbcode($event); +/* $item_arr['object'] = '' . xmlify(ACTIVITY_OBJ_EVENT) . '' . xmlify($arr['message_id']) . ''; $item_arr['object'] .= '' . xmlify(format_event_bbcode($event)) . ''; $item_arr['object'] .= '' . "\n"; - +*/ $item_id = item_store($item_arr); $r = q("SELECT * FROM `user` WHERE `uid` = %d LIMIT 1", diff --git a/install/database.sql b/install/database.sql index 00eada940..addf797a7 100644 --- a/install/database.sql +++ b/install/database.sql @@ -222,7 +222,7 @@ CREATE TABLE IF NOT EXISTS `event` ( `id` int(11) NOT NULL AUTO_INCREMENT, `aid` int(10) unsigned NOT NULL DEFAULT '0', `uid` int(11) NOT NULL, - `cid` int(11) NOT NULL, + `event_xchan` char(255) NOT NULL DEFAULT '', `message_id` char(255) NOT NULL, `created` datetime NOT NULL, `edited` datetime NOT NULL, @@ -241,7 +241,7 @@ CREATE TABLE IF NOT EXISTS `event` ( `deny_gid` mediumtext NOT NULL, PRIMARY KEY (`id`), KEY `uid` (`uid`), - KEY `cid` (`cid`), + KEY `event_xchan` (`event_xchan`), KEY `uri` (`message_id`), KEY `type` (`type`), KEY `start` (`start`), diff --git a/install/update.php b/install/update.php index c29a5fcea..63d65c89c 100644 --- a/install/update.php +++ b/install/update.php @@ -1,6 +1,6 @@