- protected function saveObjectFromActivity(Activity $activity, Notice $stored, array $options=array())
- {
- if (count($act->objects) !== 1) {
- // TRANS: Exception thrown when there are too many activity objects.
- throw new Exception(_m('Too many activity objects.'));
- }
- $actobj = $activity->objects[0];
-
- switch ($activity->verb) {
- case ActivityVerb::POST:
- $actobj = $activity->objects[0];
- if (!ActivityUtils::compareTypes($actobj->type, array(Happening::OBJECT_TYPE))) {
- // TRANS: Exception thrown when event plugin comes across a non-event type object.
- throw new Exception(_m('Wrong type for object.'));
- }
- return Happening::saveActivityObject($actobj, $stored->getProfile());
- break;
- case RSVP::POSITIVE:
- case RSVP::NEGATIVE:
- case RSVP::POSSIBLE:
- $happening = Happening::getKV('uri', $actobj->id);
- if (empty($happening)) {
- // FIXME: save the event
- // TRANS: Exception thrown when trying to RSVP for an unknown event.
- throw new Exception(_m('RSVP for unknown event.'));
- }
- $object = RSVP::saveNewFromNotice($stored, $happening, $activity->verb);
- // Our data model expects this
- $stored->object_type = $activity->verb;
- return $object;
- break;
- default:
- common_log(LOG_ERR, 'Unknown verb for events.');
- return NULL;