]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
show RSVPs for an event
authorEvan Prodromou <evan@status.net>
Wed, 9 Mar 2011 15:40:49 +0000 (10:40 -0500)
committerEvan Prodromou <evan@status.net>
Wed, 9 Mar 2011 15:40:49 +0000 (10:40 -0500)
plugins/Event/EventPlugin.php
plugins/Event/Happening.php
plugins/Event/RSVP.php

index 896ecaf5c85a95a5d5c5c30d362ea2d56bb4a94d..d8d9b572ed1b575fd52124c9e72fced88eaa42fc 100644 (file)
@@ -321,6 +321,8 @@ class EventPlugin extends MicroappPlugin
 
         $out->elementEnd('h3');
 
+        // FIXME: better dates
+
         $out->elementStart('div', 'event-times');
         $out->element('abbr', array('class' => 'dtstart',
                                     'title' => common_date_iso8601($event->start_time)),
@@ -339,6 +341,14 @@ class EventPlugin extends MicroappPlugin
             $out->element('div', 'location', $event->location);
         }
 
+        $rsvps = $event->getRSVPs();
+
+        $out->element('div', 'event-rsvps',
+                      sprintf(_('Yes: %d No: %d Maybe: %d'),
+                              count($rsvps[RSVP::POSITIVE]),
+                              count($rsvps[RSVP::NEGATIVE]),
+                              count($rsvps[RSVP::POSSIBLE])));
+
         $out->elementStart('div', array('class' => 'event-info entry-content'));
 
         $avatar = $profile->getAvatar(AVATAR_MINI_SIZE);
index 503cd8af14623b817e0cb71a50b1d7d705a898ae..b2adb4d9b5cc0268081a016ee613d0c86162ff64 100644 (file)
@@ -205,4 +205,9 @@ class Happening extends Managed_DataObject
     {
         return Happening::staticGet('uri', $notice->uri);
     }
+
+    function getRSVPs()
+    {
+        return RSVP::forEvent($this);
+    }
 }
index 851978e8193a91416a29f6f404b5d6fa433c7b61..36c6b32ec748a8b84b4fd6bceeb9e462d4eddc5f 100644 (file)
@@ -196,4 +196,22 @@ class RSVP extends Managed_DataObject
     {
         return RSVP::staticGet('uri', $notice->uri);
     }
+
+    static function forEvent($event)
+    {
+        $rsvps = array(RSVP::POSITIVE => array(), RSVP::NEGATIVE => array(), RSVP::POSSIBLE => array());
+
+        $rsvp = new RSVP();
+
+        $rsvp->event_id = $event->id;
+
+        if ($rsvp->find()) {
+            while ($rsvp->fetch()) {
+                $verb = $this->verbFor($rsvp->code);
+                $rsvps[$verb][] = clone($rsvp);
+            }
+        }
+
+        return $rsvps;
+    }
 }