From: Roland Haeder Date: Tue, 5 Jan 2016 13:27:33 +0000 (+0100) Subject: Merge remote-tracking branch 'upstream/master' into social-master X-Git-Url: https://git.mxchange.org/?p=quix0rs-gnu-social.git;a=commitdiff_plain;h=d6b28c64830f632bb2f4b6f3c9369b9e56ad217a Merge remote-tracking branch 'upstream/master' into social-master Signed-off-by: Roland Haeder --- d6b28c64830f632bb2f4b6f3c9369b9e56ad217a diff --cc plugins/Event/classes/RSVP.php index c4ffc3ee34,5c74bfee4f..0c39022b14 --- a/plugins/Event/classes/RSVP.php +++ b/plugins/Event/classes/RSVP.php @@@ -124,16 -124,39 +124,39 @@@ class RSVP extends Managed_DataObjec print "Resuming core schema upgrade..."; } - function saveNew($profile, $event, $verb, $options=array()) + function saveNew(Profile $profile, $event, $verb, array $options = array()) { - if (array_key_exists('uri', $options)) { - $other = RSVP::getKV('uri', $options['uri']); - if (!empty($other)) { - // TRANS: Client exception thrown when trying to save an already existing RSVP ("please respond"). - throw new ClientException(_m('RSVP already exists.')); - } + $eventNotice = $event->getNotice(); + $options = array_merge(array('source' => 'web'), $options); + + $act = new Activity(); + $act->type = ActivityObject::ACTIVITY; + $act->verb = $verb; + $act->time = $options['created'] ? strtotime($options['created']) : time(); + $act->title = _m("RSVP"); + $act->actor = $profile->asActivityObject(); + $act->target = $eventNotice->asActivityObject(); + $act->objects = array(clone($act->target)); + $act->content = RSVP::toHTML($profile, $event, self::codeFor($verb)); + + $act->id = common_local_url('showrsvp', array('id' => UUID::gen())); + $act->link = $act->id; + + $saved = Notice::saveActivity($act, $profile, $options); + + return $saved; + } + + function saveNewFromNotice($notice, $event, $verb) + { + $other = RSVP::getKV('uri', $notice->uri); + if (!empty($other)) { + // TRANS: Client exception thrown when trying to save an already existing RSVP ("please respond"). + throw new ClientException(_m('RSVP already exists.')); } + $profile = $notice->getProfile(); + try { $other = RSVP::getByKeys( [ 'profile_id' => $profile->getID(), 'event_uri' => $event->getUri(),