]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
RSVP stuff, mostly forms.
authorMikael Nordfeldth <mmn@hethane.se>
Tue, 19 Jan 2016 00:33:09 +0000 (01:33 +0100)
committerMikael Nordfeldth <mmn@hethane.se>
Tue, 19 Jan 2016 00:33:09 +0000 (01:33 +0100)
Now fix CancelRSVP stuff so it gets by event_uri and can cancel existing RSVP.

plugins/Event/actions/cancelrsvp.php
plugins/Event/actions/newrsvp.php
plugins/Event/forms/cancelrsvp.php
plugins/Event/forms/rsvp.php

index 662a1de0b36694a3ab9ff8816779e16af326c641..0db422c8c682addd9fbcacd23c757a40550198df 100644 (file)
  * @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
index 0e0810cd78a25195eec46088df8772491a4dd265..df58f5b62f1225b8c0e6575ae027ae9b1e8457d1 100644 (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;
     }
index 3047c57beeeb1e0148a60af7d7b9316dfbb79481..5c0399135dc12d296d7ac5093cfad0cb060a3dea 100644 (file)
  * @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:
index 9d5cea744438fb4c5a3668f39cd9c6d8c196998c..81cd335f873fb216b3be8ce4105f833ae3ae8312 100644 (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');