function userAttendanceHtml($slug, Request $request, Application $app) { if (!$this->build($slug, $request, $app)) { $app->abort(404, "Event does not exist."); } $uaerb = new UserAtEventRepositoryBuilder(); $uaerb->setEventOnly($this->parameters['event']); $uaerb->setPlanAttendingYesOnly(true); $uaerb->setPlanPublicOnly(true); $this->parameters['userAtEventYesPublic'] = $uaerb->fetchAll(); $uaerb = new UserAtEventRepositoryBuilder(); $uaerb->setEventOnly($this->parameters['event']); $uaerb->setPlanAttendingYesOnly(true); $uaerb->setPlanPrivateOnly(true); $this->parameters['userAtEventYesPrivate'] = $uaerb->fetchAll(); $uaerb = new UserAtEventRepositoryBuilder(); $uaerb->setEventOnly($this->parameters['event']); $uaerb->setPlanAttendingMaybeOnly(true); $uaerb->setPlanPublicOnly(true); $this->parameters['userAtEventMaybePublic'] = $uaerb->fetchAll(); $uaerb = new UserAtEventRepositoryBuilder(); $uaerb->setEventOnly($this->parameters['event']); $uaerb->setPlanAttendingMaybeOnly(true); $uaerb->setPlanPrivateOnly(true); $this->parameters['userAtEventMaybePrivate'] = $uaerb->fetchAll(); if ($app['currentUser']) { $uaer = new UserAtEventRepository(); $uae = $uaer->loadByUserAndEvent($app['currentUser'], $this->parameters['event']); $this->parameters['userAtEventIsCurrentUser'] = $uae && ($uae->getIsPlanAttending() || $uae->getIsPlanMaybeAttending()); } else { $this->parameters['userAtEventIsCurrentUser'] = false; } return $app['twig']->render('/site/event/usersAttending.html.twig', $this->parameters); }
public function markDuplicateWithMetaData(EventModel $duplicateEvent, EventModel $originalEvent, EventEditMetaDataModel $eventEditMetaDataModel) { global $DB; if ($duplicateEvent->getId() == $originalEvent->getId()) { return; } try { $DB->beginTransaction(); $duplicateEvent->setIsDeleted(true); $duplicateEvent->setIsDuplicateOfId($originalEvent->getId()); $this->eventDBAccess->update($duplicateEvent, array('is_deleted', 'is_duplicate_of_id'), $eventEditMetaDataModel); $uaeRepo = new UserAtEventRepository(); $uaerb = new UserAtEventRepositoryBuilder(); $uaerb->setEventOnly($duplicateEvent); foreach ($uaerb->fetchAll() as $uaeDuplicate) { if ($uaeDuplicate->getIsPlanAttending() || $uaeDuplicate->getIsPlanMaybeAttending()) { $uaeOriginal = $uaeRepo->loadByUserIDAndEventOrInstanciate($uaeDuplicate->getUserAccountId(), $originalEvent); // does user already have plans for this event? If so leave them. if (!$uaeOriginal->getIsPlanAttending() && !$uaeOriginal->getIsPlanMaybeAttending()) { $uaeOriginal->setIsPlanAttending($uaeDuplicate->getIsPlanAttending()); $uaeOriginal->setIsPlanMaybeAttending($uaeDuplicate->getIsPlanMaybeAttending()); $uaeOriginal->setIsPlanPublic($uaeDuplicate->getIsPlanPublic()); $uaeRepo->save($uaeOriginal); } } } $DB->commit(); } catch (Exception $e) { $DB->rollBack(); } }