diff --git a/boot.php b/boot.php index e480f8e3ac..aad8813766 100644 --- a/boot.php +++ b/boot.php @@ -38,7 +38,7 @@ define ( 'FRIENDICA_PLATFORM', 'Friendica'); define ( 'FRIENDICA_CODENAME', 'Asparagus'); define ( 'FRIENDICA_VERSION', '3.5.1-dev' ); define ( 'DFRN_PROTOCOL_VERSION', '2.23' ); -define ( 'DB_UPDATE_VERSION', 1210 ); +define ( 'DB_UPDATE_VERSION', 1211 ); /** * @brief Constant with a HTML line break. diff --git a/database.sql b/database.sql index 3eb70b4511..2e83c33a64 100644 --- a/database.sql +++ b/database.sql @@ -1,6 +1,6 @@ -- ------------------------------------------ -- Friendica 3.5.1-dev (Asparagus) --- DB_UPDATE_VERSION 1210 +-- DB_UPDATE_VERSION 1211 -- ------------------------------------------ @@ -212,6 +212,7 @@ CREATE TABLE IF NOT EXISTS `deliverq` ( -- CREATE TABLE IF NOT EXISTS `event` ( `id` int(11) NOT NULL auto_increment, + `guid` varchar(255) NOT NULL DEFAULT '', `uid` int(11) NOT NULL DEFAULT 0, `cid` int(11) NOT NULL DEFAULT 0, `uri` varchar(255) NOT NULL DEFAULT '', diff --git a/include/dbstructure.php b/include/dbstructure.php index 3ff9efee79..4a8bac1982 100644 --- a/include/dbstructure.php +++ b/include/dbstructure.php @@ -622,6 +622,7 @@ function db_definition($charset) { $database["event"] = array( "fields" => array( "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"), + "guid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"), "cid" => array("type" => "int(11)", "not null" => "1", "default" => "0"), "uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), diff --git a/include/diaspora.php b/include/diaspora.php index 1e31bae8e5..eda1b090d5 100644 --- a/include/diaspora.php +++ b/include/diaspora.php @@ -2949,7 +2949,7 @@ class Diaspora { */ private static function build_event($event_id) { - $r = q("SELECT `uid`, `start`, `finish`, `summary`, `desc`, `location`, `adjust` FROM `event` WHERE `id` = %d", intval($event_id)); + $r = q("SELECT `guid`, `uid`, `start`, `finish`, `nofinish`, `summary`, `desc`, `location`, `adjust` FROM `event` WHERE `id` = %d", intval($event_id)); if (!dbm::is_result($r)) { return array(); } @@ -2965,22 +2965,37 @@ class Diaspora { $user = $r[0]; - if ($event['adjust']) { + $r = q("SELECT `addr`, `nick` FROM `contact` WHERE `uid` = %d AND `self`", intval($event['uid'])); + if (!dbm::is_result($r)) { + return array(); + } + + $owner = $r[0]; + + $eventdata['author'] = self::my_handle($owner); + + if ($event['guid']) { + $eventdata['guid'] = $event['guid']; + } + + $mask = 'Y-m-d\TH:i:s\Z'; + + /// @todo + $eventdata["all_day"] = "false"; + + if (!$event['adjust']) { $eventdata['timezone'] = $user['timezone']; if ($eventdata['timezone'] == "") { $eventdata['timezone'] = 'UTC'; } - $mask = 'Y-m-d\TH:i:s\Z'; - } else { - $mask = 'Y-m-d\TH:i:s'; } if ($event['start']) { - $eventdata['start'] = datetime_convert("UTC", "UTC", $event['start'], $mask); + $eventdata['start'] = datetime_convert($eventdata['timezone'], "UTC", $event['start'], $mask); } - if ($event['finish']) { - $eventdata['end'] = datetime_convert("UTC", "UTC", $event['finish'], $mask); + if ($event['finish'] AND !$event['nofinish']) { + $eventdata['end'] = datetime_convert($eventdata['timezone'], "UTC", $event['finish'], $mask); } if ($event['summary']) { $eventdata['summary'] = html_entity_decode(bb2diaspora($event['summary'])); @@ -3083,6 +3098,9 @@ class Diaspora { $event = self::build_event($item['event-id']); if (count($event)) { $message['event'] = $event; + + /// @todo Once Diaspora supports it, we will remove the body + // $message['raw_message'] = ''; } } diff --git a/include/event.php b/include/event.php index 4abe3ffef5..791c331bbb 100644 --- a/include/event.php +++ b/include/event.php @@ -246,6 +246,7 @@ function event_store($arr) { $arr['cid'] = ((intval($arr['cid'])) ? intval($arr['cid']) : 0); $arr['uri'] = (x($arr,'uri') ? $arr['uri'] : item_new_uri($a->get_hostname(),$arr['uid'])); $arr['private'] = ((x($arr,'private')) ? intval($arr['private']) : 0); + $arr['guid'] = get_guid(32); if($arr['cid']) $c = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1", @@ -333,16 +334,16 @@ function event_store($arr) { call_hooks("event_updated", $arr['id']); return $item_id; - } - else { + } else { // New event. Store it. - $r = q("INSERT INTO `event` ( `uid`,`cid`,`uri`,`created`,`edited`,`start`,`finish`,`summary`, `desc`,`location`,`type`, + $r = q("INSERT INTO `event` (`uid`,`cid`,`guid`,`uri`,`created`,`edited`,`start`,`finish`,`summary`, `desc`,`location`,`type`, `adjust`,`nofinish`,`allow_cid`,`allow_gid`,`deny_cid`,`deny_gid`) - VALUES ( %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['uid']), intval($arr['cid']), + dbesc($arr['guid']), dbesc($arr['uri']), dbesc($arr['created']), dbesc($arr['edited']), diff --git a/update.php b/update.php index 948e10f27e..3bd9cbe610 100644 --- a/update.php +++ b/update.php @@ -1,6 +1,6 @@