123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143 |
- <?php
- if (!defined('GNUSOCIAL')) { exit(1); }
- class RSVPForm extends Form
- {
- protected $event = null;
- function __construct($out=null, array $formOpts=array())
- {
- parent::__construct($out);
- 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'];
- }
-
- function id()
- {
- return 'form_event_rsvp';
- }
-
- function formClass()
- {
- return 'ajax';
- }
-
- function action()
- {
- return common_local_url('rsvp');
- }
-
- function formData()
- {
- $this->out->elementStart('fieldset', array('id' => 'new_rsvp_data'));
-
- $this->out->text(_m('RSVP:'));
- $this->out->hidden('notice', $this->event->getStored()->getID(), 'event');
- $this->out->hidden('event', $this->event->getUri(), 'event');
- $this->out->hidden('rsvp', '');
- $this->out->elementEnd('fieldset');
- }
-
- function formActions()
- {
- try {
- $rsvp = RSVP::byEventAndActor($this->event, $this->scoped);
- $this->submitButton('cancel', _m('BUTTON', 'Cancel'));
- } catch (NoResultException $e) {
-
- $this->submitButton('yes', _m('BUTTON', 'Yes'));
-
- $this->submitButton('no', _m('BUTTON', 'No'));
-
- $this->submitButton('maybe', _m('BUTTON', 'Maybe'));
- }
- }
- function submitButton($answer, $label)
- {
- $this->out->element(
- 'input',
- array(
- 'type' => 'submit',
- 'id' => 'rsvp-submit-'.$answer,
- 'name' => $answer,
- 'class' => 'submit',
- 'value' => $label,
- 'title' => $label,
- 'onClick' => 'this.form.rsvp.value = this.name; return true;'
- )
- );
- }
- }
|