* @link http://status.net/
*/
-if (!defined('STATUSNET')) {
- // This check helps protect against security problems;
- // your code file can't be executed directly from the web.
- exit(1);
-}
+if (!defined('GNUSOCIAL')) { exit(1); }
/**
* Event plugin
return true;
}
+ public function onBeforePluginCheckSchema()
+ {
+ RSVP::beforeSchemaUpdate();
+ return true;
+ }
+
/**
* Map URLs to actions
*
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;
}
}
function types() {
- return array(Happening::OBJECT_TYPE,
+ return array(Happening::OBJECT_TYPE);
+ }
+
+ function verbs() {
+ return array(ActivityVerb::POST,
RSVP::POSITIVE,
RSVP::NEGATIVE,
RSVP::POSSIBLE);
$url = $url_object->item(0)->nodeValue;
}
- $notice = null;
-
switch ($activity->verb) {
case ActivityVerb::POST:
// FIXME: get startTime, endTime, location and URL
break;
case RSVP::POSITIVE:
case RSVP::NEGATIVE:
+ case RSVP::POSSIBLE:
+ return Notice::saveActivity($activity, $actor, $options);
+ break;
+ default:
+ // TRANS: Exception thrown when event plugin comes across a undefined verb.
+ throw new Exception(_m('Unknown verb for events.'));
+ }
+ }
+
+ protected function saveObjectFromActivity(Activity $activity, Notice $stored, array $options=array())
+ {
+ $happeningObj = $activity->objects[0];
+
+ switch ($activity->verb) {
+ case RSVP::POSITIVE:
+ case RSVP::NEGATIVE:
case RSVP::POSSIBLE:
$happening = Happening::getKV('uri', $happeningObj->id);
if (empty($happening)) {
// TRANS: Exception thrown when trying to RSVP for an unknown event.
throw new Exception(_m('RSVP for unknown event.'));
}
- $notice = RSVP::saveNew($actor, $happening, $activity->verb, $options);
+ $object = RSVP::saveNewFromNotice($stored, $happening, $activity->verb);
+ // Our data model expects this
+ $stored->object_type = $activity->verb;
+ return $object;
break;
default:
- // TRANS: Exception thrown when event plugin comes across a undefined verb.
- throw new Exception(_m('Unknown verb for events.'));
+ common_log(LOG_ERR, 'Unknown verb for events.');
+ return NULL;
}
-
- return $notice;
}
/**
{
switch ($notice->object_type) {
case Happening::OBJECT_TYPE:
- common_log(LOG_DEBUG, "Deleting event from notice...");
+ common_debug("Deleting event from notice...");
$happening = Happening::fromNotice($notice);
$happening->delete();
break;
case RSVP::POSITIVE:
case RSVP::NEGATIVE:
case RSVP::POSSIBLE:
- common_log(LOG_DEBUG, "Deleting rsvp from notice...");
+ common_debug("Deleting rsvp from notice...");
$rsvp = RSVP::fromNotice($notice);
- common_log(LOG_DEBUG, "to delete: $rsvp->id");
+ common_debug("to delete: $rsvp->id");
$rsvp->delete();
break;
default:
- common_log(LOG_DEBUG, "Not deleting related, wtf...");
+ common_debug("Not deleting related, wtf...");
}
}
- function onEndShowScripts($action)
+ function onEndShowScripts(Action $action)
{
$action->script($this->path('js/event.js'));
}
- function onEndShowStyles($action)
+ function onEndShowStyles(Action $action)
{
$action->cssLink($this->path('css/event.css'));
return true;
$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;
+ }
}