From 827dffb94cd29ef914772c803b9e6500b26485b3 Mon Sep 17 00:00:00 2001 From: Hannes Mannerheim Date: Fri, 9 Oct 2015 16:00:33 +0200 Subject: [PATCH] make event dates federate --- plugins/Event/EventPlugin.php | 18 +++++++++++++++--- plugins/Event/actions/newevent.php | 4 ++-- plugins/Event/classes/Happening.php | 4 ++-- 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/plugins/Event/EventPlugin.php b/plugins/Event/EventPlugin.php index 110f928a4c..5f20031693 100644 --- a/plugins/Event/EventPlugin.php +++ b/plugins/Event/EventPlugin.php @@ -145,14 +145,26 @@ class EventPlugin extends MicroAppPlugin throw new Exception(_m('Wrong type for object.')); } + $dtstart = $happeningObj->element->getElementsByTagName('dtstart'); + if($dtstart->length == 0) { + // TRANS: Exception thrown when has no start date + throw new Exception(_m('No start date for event.')); + } + + $dtend = $happeningObj->element->getElementsByTagName('dtend'); + if($dtend->length == 0) { + // TRANS: Exception thrown when has no end date + throw new Exception(_m('No end date for event.')); + } + $notice = null; switch ($activity->verb) { case ActivityVerb::POST: // FIXME: get startTime, endTime, location and URL $notice = Happening::saveNew($actor, - $start_time, - $end_time, + $dtstart->item(0)->nodeValue, + $dtend->item(0)->nodeValue, $happeningObj->title, null, $happeningObj->summary, @@ -233,7 +245,7 @@ class EventPlugin extends MicroAppPlugin // FIXME: add location // FIXME: add URL - + // XXX: probably need other stuff here return $obj; diff --git a/plugins/Event/actions/newevent.php b/plugins/Event/actions/newevent.php index 9483db7b4e..57cd1bb37e 100644 --- a/plugins/Event/actions/newevent.php +++ b/plugins/Event/actions/newevent.php @@ -220,8 +220,8 @@ class NeweventAction extends Action $profile = $this->user->getProfile(); $saved = Happening::saveNew($profile, - $this->startTime, - $this->endTime, + common_sql_date($this->startTime), + common_sql_date($this->endTime), $this->title, $this->location, $this->description, diff --git a/plugins/Event/classes/Happening.php b/plugins/Event/classes/Happening.php index 733235655c..8c713bacbd 100644 --- a/plugins/Event/classes/Happening.php +++ b/plugins/Event/classes/Happening.php @@ -116,8 +116,8 @@ class Happening extends Managed_DataObject $ev->id = UUID::gen(); $ev->profile_id = $profile->id; - $ev->start_time = common_sql_date($start_time); - $ev->end_time = common_sql_date($end_time); + $ev->start_time = $start_time; + $ev->end_time = $end_time; $ev->title = $title; $ev->location = $location; $ev->description = $description;