]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Fixes for Event plugin:
authorBrion Vibber <brion@pobox.com>
Wed, 9 Mar 2011 22:10:26 +0000 (14:10 -0800)
committerBrion Vibber <brion@pobox.com>
Wed, 9 Mar 2011 22:10:26 +0000 (14:10 -0800)
* RSVP cancel/delete now works
* caching fix for RSVP insert and delete (compound unique keys aren't properly handled for pkeyGet's caching right now; hacked it for this class for the moment)
* div nesting fix
* missing name/avatar on RSVP responses

plugins/Event/EventPlugin.php
plugins/Event/Happening.php
plugins/Event/RSVP.php
plugins/Event/cancelrsvp.php
plugins/Event/newrsvp.php

index bd9c10b3e4354a286fd0d153f6242cd5bea9d44c..5c2fd35d74532e5a671fb6ad550b5bb19ab44037 100644 (file)
@@ -295,6 +295,31 @@ class EventPlugin extends MicroappPlugin
             $this->showRSVPNotice($notice, $out);
             break;
         }
+
+        // @fixme we have to start the name/avatar and open this div
+        $out->elementStart('div', array('class' => 'event-info entry-content')); // EVENT-INFO.ENTRY-CONTENT IN
+
+        $profile = $notice->getProfile();
+        $avatar = $profile->getAvatar(AVATAR_MINI_SIZE);
+
+        $out->element('img',
+                      array('src' => ($avatar) ?
+                            $avatar->displayUrl() :
+                            Avatar::defaultImage(AVATAR_MINI_SIZE),
+                            'class' => 'avatar photo bookmark-avatar',
+                            'width' => AVATAR_MINI_SIZE,
+                            'height' => AVATAR_MINI_SIZE,
+                            'alt' => $profile->getBestName()));
+
+        $out->raw('&#160;'); // avoid &nbsp; for AJAX XML compatibility
+
+        $out->elementStart('span', 'vcard author'); // hack for belongsOnTimeline; JS needs to be able to find the author
+        $out->element('a',
+                      array('class' => 'url',
+                            'href' => $profile->profileurl,
+                            'title' => $profile->getBestName()),
+                      $profile->nickname);
+        $out->elementEnd('span');
     }
 
     function showRSVPNotice($notice, $out)
@@ -311,9 +336,9 @@ class EventPlugin extends MicroappPlugin
         assert(!empty($event));
         assert(!empty($profile));
 
-        $out->elementStart('div', 'vevent');
+        $out->elementStart('div', 'vevent'); // VEVENT IN
 
-        $out->elementStart('h3');
+        $out->elementStart('h3');  // VEVENT/H3 IN
 
         if (!empty($event->url)) {
             $out->element('a',
@@ -324,11 +349,11 @@ class EventPlugin extends MicroappPlugin
             $out->text($event->title);
         }
 
-        $out->elementEnd('h3');
+        $out->elementEnd('h3'); // VEVENT/H3 OUT
 
         // FIXME: better dates
 
-        $out->elementStart('div', 'event-times');
+        $out->elementStart('div', 'event-times'); // VEVENT/EVENT-TIMES IN
         $out->element('abbr', array('class' => 'dtstart',
                                     'title' => common_date_iso8601($event->start_time)),
                       common_exact_date($event->start_time));
@@ -336,7 +361,7 @@ class EventPlugin extends MicroappPlugin
         $out->element('span', array('class' => 'dtend',
                                     'title' => common_date_iso8601($event->end_time)),
                       common_exact_date($event->end_time));
-        $out->elementEnd('div');
+        $out->elementEnd('div'); // VEVENT/EVENT-TIMES OUT
 
         if (!empty($event->description)) {
             $out->element('div', 'description', $event->description);
@@ -358,6 +383,7 @@ class EventPlugin extends MicroappPlugin
 
         if (!empty($user)) {
             $rsvp = $event->getRSVP($user->getProfile());
+            common_log(LOG_DEBUG, "RSVP is: " . ($rsvp ? $rsvp->id : 'none'));
 
             if (empty($rsvp)) {
                 $form = new RSVPForm($event, $out);
@@ -368,31 +394,7 @@ class EventPlugin extends MicroappPlugin
             $form->show();
         }
 
-        $out->elementStart('div', array('class' => 'event-info entry-content'));
-
-        $avatar = $profile->getAvatar(AVATAR_MINI_SIZE);
-
-        $out->element('img', 
-                      array('src' => ($avatar) ?
-                            $avatar->displayUrl() :
-                            Avatar::defaultImage(AVATAR_MINI_SIZE),
-                            'class' => 'avatar photo bookmark-avatar',
-                            'width' => AVATAR_MINI_SIZE,
-                            'height' => AVATAR_MINI_SIZE,
-                            'alt' => $profile->getBestName()));
-
-        $out->raw('&#160;'); // avoid &nbsp; for AJAX XML compatibility
-
-        $out->elementStart('span', 'vcard author'); // hack for belongsOnTimeline; JS needs to be able to find the author
-        $out->element('a', 
-                      array('class' => 'url',
-                            'href' => $profile->profileurl,
-                            'title' => $profile->getBestName()),
-                      $profile->nickname);
-        $out->elementEnd('span');
-
-        // @fixme right now we have to leave this div open
-        //$out->elementEnd('div');
+        $out->elementEnd('div'); // vevent out
     }
 
     /**
@@ -417,15 +419,20 @@ class EventPlugin extends MicroappPlugin
     {
         switch ($notice->object_type) {
         case Happening::OBJECT_TYPE:
+            common_log(LOG_DEBUG, "Deleting event from notice...");
             $happening = Happening::fromNotice($notice);
             $happening->delete();
             break;
         case RSVP::POSITIVE:
         case RSVP::NEGATIVE:
         case RSVP::POSSIBLE:
+            common_log(LOG_DEBUG, "Deleting rsvp from notice...");
             $rsvp = RSVP::fromNotice($notice);
+            common_log(LOG_DEBUG, "to delete: $rsvp->id");
             $rsvp->delete();
             break;
+        default:
+            common_log(LOG_DEBUG, "Not deleting related, wtf...");
         }
     }
 }
index 1a6a028dca3c9012d41c815a58d007dac808ad18..376f27c6989b8c16ebdbfdaa617d2b6a339772ba 100644 (file)
@@ -213,6 +213,7 @@ class Happening extends Managed_DataObject
 
     function getRSVP($profile)
     {
+        common_log(LOG_DEBUG, "Finding RSVP for " . $profile->id . ', ' . $this->id);
         return RSVP::pkeyGet(array('profile_id' => $profile->id,
                                    'event_id' => $this->id));
     }
index 22bd239a684d7eb1e8dffebcc56c6e472b758092..c61ff3dbf0619b46df01542a5146f4e1e36d6144 100644 (file)
@@ -85,6 +85,20 @@ class RSVP extends Managed_DataObject
         return Memcached_DataObject::pkeyGet('RSVP', $kv);
     }
 
+    /**
+     * Add the compound profile_id/event_id index to our cache keys
+     * since the DB_DataObject stuff doesn't understand compound keys
+     * except for the primary.
+     *
+     * @return array
+     */
+    function _allCacheKeys() {
+        $keys = parent::_allCacheKeys();
+        $keys[] = self::multicacheKey('RSVP', array('profile_id' => $this->profile_id,
+                                                    'event_id' => $this->event_id));
+        return $keys;
+    }
+
     /**
      * The One True Thingy that must be defined and declared.
      */
@@ -232,8 +246,4 @@ class RSVP extends Managed_DataObject
 
         return $rsvps;
     }
-
-    function delete()
-    {
-    }
 }
index 21ed41a4512d6bdbbe03cb4bd3240541c60d2f27..83dabe2de5e084bba93b2d41af404526daf81482 100644 (file)
@@ -72,6 +72,9 @@ class CancelrsvpAction extends Action
     function prepare($argarray)
     {
         parent::prepare($argarray);
+        if ($this->boolean('ajax')) {
+            StatusNet::setApi(true); // short error results!
+        }
 
         $rsvpId = $this->trimmed('rsvp');
 
@@ -133,8 +136,10 @@ class CancelrsvpAction extends Action
             $notice = $this->rsvp->getNotice();
             // NB: this will delete the rsvp, too
             if (!empty($notice)) {
+                common_log(LOG_DEBUG, "Deleting notice...");
                 $notice->delete();
             } else {
+                common_log(LOG_DEBUG, "Deleting RSVP alone...");
                 $this->rsvp->delete();
             }
         } catch (ClientException $ce) {
index da613ec6c78c1ec2dae5b2dac2f95006b3f18025..4bacd129f4412c497e20599dfe91fae9b75dd647 100644 (file)
@@ -72,6 +72,9 @@ class NewrsvpAction extends Action
     function prepare($argarray)
     {
         parent::prepare($argarray);
+        if ($this->boolean('ajax')) {
+            StatusNet::setApi(true); // short error results!
+        }
 
         $eventId = $this->trimmed('event');