Now fix CancelRSVP stuff so it gets by event_uri and can cancel existing RSVP.
* @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); }
/**
* RSVP for an event
protected function doPreparation()
{
- $eventId = $this->trimmed('event');
- if (empty($eventId)) {
- // TRANS: Client exception thrown when referring to a non-existing event.
- throw new ClientException(_m('No such event.'));
- }
- $this->event = Happening::getKV('id', $eventId);
- if (empty($this->event)) {
- // TRANS: Client exception thrown when referring to a non-existing event.
- throw new ClientException(_m('No such event.'));
- }
+ $this->event = Happening::getByKeys(['uri'=>$this->trimmed('event')]);
$this->formOpts['event'] = $this->event;
}
* @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('STATUSNET')) { exit(1); }
/**
* A form to RSVP for an event
{
protected $rsvp = null;
- function __construct($rsvp, $out=null)
+ function __construct($out=null, array $formOpts=array())
{
parent::__construct($out);
- $this->rsvp = $rsvp;
+ if (!isset($formOpts['rsvp'])) {
+ throw new ServerException('You must set the "rsvp" form option for RSVPForm.');
+ } elseif (!$formOpts['rsvp'] instanceof Happening) {
+ throw new ServerException('The "rsvp" form option for RSVPForm must be an RSVP object.');
+ }
+ $this->rsvp = $formOpts['rsvp'];
}
/**
{
$this->out->elementStart('fieldset', array('id' => 'new_rsvp_data'));
- $this->out->hidden('rsvp-id', $this->rsvp->id, 'rsvp');
+ $this->out->hidden('rsvp-id', $this->rsvp->getUri(), 'rsvp');
switch (RSVP::verbFor($this->rsvp->response)) {
case RSVP::POSITIVE:
{
protected $event = null;
- function __construct(Happening $event, $out=null)
+ function __construct($out=null, array $formOpts=array())
{
parent::__construct($out);
- $this->event = $event;
+ if (!isset($formOpts['event'])) {
+ throw new ServerException('You must set the "event" form option for RSVPForm.');
+ } elseif (!$formOpts['event'] instanceof Happening) {
+ throw new ServerException('The "event" form option for RSVPForm must be a Happening object.');
+ }
+ $this->event = $formOpts['event'];
}
/**
// TRANS: Field label on form to RSVP ("please respond") for an event.
$this->out->text(_m('RSVP:'));
- $this->out->hidden('event-id', $this->event->id, 'event');
+ $this->out->hidden('event-id', $this->event->getUri(), 'event');
$this->out->hidden('submitvalue', '');
$this->out->elementEnd('fieldset');