]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - plugins/Event/EventPlugin.php
Don't check Link header if not set
[quix0rs-gnu-social.git] / plugins / Event / EventPlugin.php
index 75bdfd2ec38990cd19afc502965e08ca056513b4..0c520ddb7a7a916df87f6c33276ad18112cdae3f 100644 (file)
@@ -90,6 +90,10 @@ class EventPlugin extends MicroAppPlugin
                     array('id' => '[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}'));
         $m->connect('main/event/updatetimes',
                     array('action' => 'timelist'));
+
+        $m->connect(':nickname/events',
+                    array('action' => 'events'),
+                    array('nickname' => Nickname::DISPLAY_FMT));
         return true;
     }
 
@@ -157,6 +161,14 @@ class EventPlugin extends MicroAppPlugin
             throw new Exception(_m('No end date for event.'));
         }
 
+        // convert RFC3339 dates delivered in Activity Stream to MySQL DATETIME date format
+        $start_time = new DateTime($dtstart->item(0)->nodeValue);
+        $start_time->setTimezone(new DateTimeZone('UTC'));
+        $start_time = $start_time->format('Y-m-d H:i:s');
+        $end_time = new DateTime($dtend->item(0)->nodeValue);
+        $end_time->setTimezone(new DateTimeZone('UTC'));
+        $end_time = $end_time->format('Y-m-d H:i:s');
+
         // location is optional
         $location = null;
         $location_object = $happeningObj->element->getElementsByTagName('location');
@@ -164,18 +176,25 @@ 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) {
         case ActivityVerb::POST:
                // FIXME: get startTime, endTime, location and URL
             $notice = Happening::saveNew($actor,
-                                         $dtstart->item(0)->nodeValue,
-                                         $dtend->item(0)->nodeValue,
+                                         $start_time,
+                                         $end_time,
                                          $happeningObj->title,
                                          $location,
                                          $happeningObj->summary,
-                                         null,
+                                         $url,
                                          $options);
             break;
         case RSVP::POSITIVE:
@@ -251,8 +270,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;
@@ -501,4 +520,14 @@ class EventPlugin extends MicroAppPlugin
         $out->raw($rsvp->asHTML());
         $out->elementEnd('div');
     }
+
+    function onEndPersonalGroupNav(Menu $menu, Profile $target, Profile $scoped=null)
+    {
+        $menu->menuItem(common_local_url('events', array('nickname' => $target->getNickname())),
+                          // TRANS: Menu item in sample plugin.
+                          _m('Happenings'),
+                          // TRANS: Menu item title in sample plugin.
+                          _m('A list of your events'), false, 'nav_timeline_events');
+        return true;
+    }
 }