We are no longer offering accounts on this server. Consider https://gitlab.freedesktop.org/ as a place to host projects.

Commit 728869e3 authored by Evan Prodromou's avatar Evan Prodromou

show RSVPs for an event

parent 1e4e9a84
......@@ -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);
......
......@@ -205,4 +205,9 @@ class Happening extends Managed_DataObject
{
return Happening::staticGet('uri', $notice->uri);
}
function getRSVPs()
{
return RSVP::forEvent($this);
}
}
......@@ -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;
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment