RSVP stuff, mostly forms.

Now fix CancelRSVP stuff so it gets by event_uri and can cancel existing RSVP.
This commit is contained in:
Mikael Nordfeldth 2016-01-19 01:33:09 +01:00
parent 84dda697d6
commit 477d71c0bf
4 changed files with 19 additions and 26 deletions

View File

@ -28,11 +28,7 @@
* @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

View File

@ -54,16 +54,7 @@ class NewrsvpAction extends FormAction
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;
}

View File

@ -28,11 +28,7 @@
* @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
@ -48,10 +44,15 @@ class CancelRSVPForm extends Form
{
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'];
}
/**
@ -93,7 +94,7 @@ class CancelRSVPForm extends Form
{
$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:

View File

@ -44,10 +44,15 @@ class RSVPForm extends Form
{
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'];
}
/**
@ -92,7 +97,7 @@ class RSVPForm extends Form
// 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');