From: Evan Prodromou Date: Wed, 9 Mar 2011 15:40:49 +0000 (-0500) Subject: show RSVPs for an event X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=728869e3110d3246dc1943a5d6ca14e88a2cc821;p=quix0rs-gnu-social.git show RSVPs for an event --- diff --git a/plugins/Event/EventPlugin.php b/plugins/Event/EventPlugin.php index 896ecaf5c8..d8d9b572ed 100644 --- a/plugins/Event/EventPlugin.php +++ b/plugins/Event/EventPlugin.php @@ -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); diff --git a/plugins/Event/Happening.php b/plugins/Event/Happening.php index 503cd8af14..b2adb4d9b5 100644 --- a/plugins/Event/Happening.php +++ b/plugins/Event/Happening.php @@ -205,4 +205,9 @@ class Happening extends Managed_DataObject { return Happening::staticGet('uri', $notice->uri); } + + function getRSVPs() + { + return RSVP::forEvent($this); + } } diff --git a/plugins/Event/RSVP.php b/plugins/Event/RSVP.php index 851978e819..36c6b32ec7 100644 --- a/plugins/Event/RSVP.php +++ b/plugins/Event/RSVP.php @@ -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; + } }