]> git.mxchange.org Git - friendica.git/commitdiff
Events are now shared with Diaspora.
authorMichael <heluecht@pirati.ca>
Fri, 30 Dec 2016 03:31:38 +0000 (03:31 +0000)
committerMichael <heluecht@pirati.ca>
Fri, 30 Dec 2016 03:31:38 +0000 (03:31 +0000)
boot.php
database.sql
include/dbstructure.php
include/diaspora.php
include/event.php
update.php

index e480f8e3ac1f8f99887cc1c307a52039fe5726e9..aad8813766002d0cd265b0eeabb6f5f580ae43c3 100644 (file)
--- 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.
index 3eb70b4511d8a4b29b8634bc122580e6e10eff86..2e83c33a643dea97b59026a69929df8d2727903f 100644 (file)
@@ -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 '',
index 3ff9efee7942b483938a148dd3c5ab0049fc558c..4a8bac198211afa493f81ca9cd96009c81b3a6a5 100644 (file)
@@ -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" => ""),
index 1e31bae8e5d155ccb69e0800d0c5a5983a851160..eda1b090d5fd387225443b53db37371f4deed19d 100644 (file)
@@ -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'] = '';
                                }
                        }
 
index 4abe3ffef54a73a8b4e2264fbfdb74f405b390c9..791c331bbbe7295544f871101053203cd96f7904 100644 (file)
@@ -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']),
index 948e10f27e7deba640c5fa9e90b7d10cf862e5d3..3bd9cbe610efa77aae3f5b045f510c79069bf3fd 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 
-define('UPDATE_VERSION' , 1210);
+define('UPDATE_VERSION' , 1211);
 
 /**
  *