From 76004660e9138b94668263769d4b10cfb1e77955 Mon Sep 17 00:00:00 2001 From: Hannes Mannerheim Date: Tue, 11 Aug 2015 22:18:57 +0200 Subject: [PATCH 1/5] make it possible to erase fields in the profile via the api --- actions/apiaccountupdateprofile.php | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/actions/apiaccountupdateprofile.php b/actions/apiaccountupdateprofile.php index a9842ec5d8..1999248b93 100644 --- a/actions/apiaccountupdateprofile.php +++ b/actions/apiaccountupdateprofile.php @@ -98,15 +98,21 @@ class ApiAccountUpdateProfileAction extends ApiAuthAction if (!empty($this->name)) { $profile->fullname = $this->name; + } else { + $profile->fullname = ''; } if (!empty($this->url)) { $profile->homepage = $this->url; - } + } else { + $profile->homepage = ''; + } if (!empty($this->description)) { $profile->bio = $this->description; - } + } else { + $profile->bio = ''; + } if (!empty($this->location)) { $profile->location = $this->location; @@ -119,7 +125,9 @@ class ApiAccountUpdateProfileAction extends ApiAuthAction $profile->location_id = $loc->location_id; $profile->location_ns = $loc->location_ns; } - } + } else { + $profile->location = ''; + } $result = $profile->update($original); From 499d4aadbcf48683767cde2abbd6624cccfe58e2 Mon Sep 17 00:00:00 2001 From: Hannes Mannerheim Date: Fri, 9 Oct 2015 13:10:48 +0200 Subject: [PATCH 2/5] make events federate --- plugins/Event/EventPlugin.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/plugins/Event/EventPlugin.php b/plugins/Event/EventPlugin.php index 9fa6e17fc3..110f928a4c 100644 --- a/plugins/Event/EventPlugin.php +++ b/plugins/Event/EventPlugin.php @@ -46,6 +46,9 @@ if (!defined('STATUSNET')) { */ class EventPlugin extends MicroAppPlugin { + + var $oldSaveNew = true; + /** * Set up our tables (event and rsvp) * From 827dffb94cd29ef914772c803b9e6500b26485b3 Mon Sep 17 00:00:00 2001 From: Hannes Mannerheim Date: Fri, 9 Oct 2015 16:00:33 +0200 Subject: [PATCH 3/5] 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; From 55655ba319d633b19f3fc0c38d57b7d93e9e56b3 Mon Sep 17 00:00:00 2001 From: Hannes Mannerheim Date: Fri, 9 Oct 2015 16:16:13 +0200 Subject: [PATCH 4/5] make event location federate --- plugins/Event/EventPlugin.php | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/plugins/Event/EventPlugin.php b/plugins/Event/EventPlugin.php index 5f20031693..75bdfd2ec3 100644 --- a/plugins/Event/EventPlugin.php +++ b/plugins/Event/EventPlugin.php @@ -157,6 +157,13 @@ class EventPlugin extends MicroAppPlugin throw new Exception(_m('No end date for event.')); } + // location is optional + $location = null; + $location_object = $happeningObj->element->getElementsByTagName('location'); + if($location_object->length > 0) { + $location = $location_object->item(0)->nodeValue; + } + $notice = null; switch ($activity->verb) { @@ -166,7 +173,7 @@ class EventPlugin extends MicroAppPlugin $dtstart->item(0)->nodeValue, $dtend->item(0)->nodeValue, $happeningObj->title, - null, + $location, $happeningObj->summary, null, $options); @@ -243,9 +250,9 @@ class EventPlugin extends MicroAppPlugin array('xmlns' => 'urn:ietf:params:xml:ns:xcal'), common_date_iso8601($happening->end_time)); - // FIXME: add location - // FIXME: add URL + $obj->extra[] = array('location', false, $happening->location); + // FIXME: add URL // XXX: probably need other stuff here return $obj; From 61ed36e446a60e35c12f26555205435ccacf6204 Mon Sep 17 00:00:00 2001 From: Hannes Mannerheim Date: Fri, 9 Oct 2015 16:22:47 +0200 Subject: [PATCH 5/5] make event urls federate --- plugins/Event/EventPlugin.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/plugins/Event/EventPlugin.php b/plugins/Event/EventPlugin.php index 75bdfd2ec3..4e9d153b16 100644 --- a/plugins/Event/EventPlugin.php +++ b/plugins/Event/EventPlugin.php @@ -164,6 +164,13 @@ class EventPlugin extends MicroAppPlugin $location = $location_object->item(0)->nodeValue; } + // url is optional + $url = null; + $url_object = $happeningObj->element->getElementsByTagName('url'); + if($url_object->length > 0) { + $url = $url_object->item(0)->nodeValue; + } + $notice = null; switch ($activity->verb) { @@ -175,7 +182,7 @@ class EventPlugin extends MicroAppPlugin $happeningObj->title, $location, $happeningObj->summary, - null, + $url, $options); break; case RSVP::POSITIVE: @@ -251,8 +258,8 @@ class EventPlugin extends MicroAppPlugin common_date_iso8601($happening->end_time)); $obj->extra[] = array('location', false, $happening->location); + $obj->extra[] = array('url', false, $happening->url); - // FIXME: add URL // XXX: probably need other stuff here return $obj;