function show($slug, Request $request, Application $app) { if (!$this->build($slug, $request, $app)) { $app->abort(404, "Event does not exist."); } if ($app['currentUser'] && !$this->parameters['event']->isInPast()) { $uaer = new UserAtEventRepository(); $this->parameters['userAtEvent'] = $uaer->loadByUserAndEventOrInstanciate($app['currentUser'], $this->parameters['event']); } $this->parameters['mediasForGroup'] = array(); $this->parameters['mediasForVenue'] = array(); $this->parameters['mediasForEvent'] = array(); $this->parameters['medias'] = array(); if ($app['config']->isFileStore()) { foreach ($this->parameters['groups'] as $group) { $mrb = new MediaRepositoryBuilder(); $mrb->setIncludeDeleted(false); $mrb->setSite($app['currentSite']); $mrb->setGroup($group); $this->parameters['mediasForGroup'][$group->getSlug()] = $mrb->fetchAll(); $this->parameters['medias'] = array_merge($this->parameters['medias'], $this->parameters['mediasForGroup'][$group->getSlug()]); } if ($this->parameters['venue']) { $mrb = new MediaRepositoryBuilder(); $mrb->setIncludeDeleted(false); $mrb->setSite($app['currentSite']); $mrb->setVenue($this->parameters['venue']); $this->parameters['mediasForVenue'] = $mrb->fetchAll(); $this->parameters['medias'] = array_merge($this->parameters['medias'], $this->parameters['mediasForVenue']); } $mrb = new MediaRepositoryBuilder(); $mrb->setIncludeDeleted(false); $mrb->setSite($app['currentSite']); $mrb->setEvent($this->parameters['event']); $this->parameters['mediasForEvent'] = $mrb->fetchAll(); $this->parameters['medias'] = array_merge($this->parameters['medias'], $this->parameters['mediasForEvent']); } $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; } $this->addTagsToParameters($app); if ($this->parameters['country']) { $areaRepoBuilder = new AreaRepositoryBuilder(); $areaRepoBuilder->setSite($app['currentSite']); $areaRepoBuilder->setCountry($this->parameters['country']); $areaRepoBuilder->setIncludeDeleted(false); if ($this->parameters['area']) { $areaRepoBuilder->setParentArea($this->parameters['area']); } else { $areaRepoBuilder->setNoParentArea(true); } $this->parameters['childAreas'] = $areaRepoBuilder->fetchAll(); $app['currentUserActions']->set("org.openacalendar", "eventEditPushToChildAreas", $this->parameters['childAreas'] && $app['currentUserPermissions']->hasPermission("org.openacalendar", "CALENDAR_CHANGE") && $app['currentSite']->getIsFeaturePhysicalEvents() && $this->parameters['event']->getIsPhysical() && !$this->parameters['event']->getIsCancelled() && !$this->parameters['event']->getIsDeleted()); } $this->parameters['isGroupRunningOutOfFutureEvents'] = 0; if ($this->parameters['group'] && !$this->parameters['group']->getIsDeleted() && $app['currentSite']->getIsFeatureGroup() && $app['currentUserPermissions']->hasPermission("org.openacalendar", "CALENDAR_CHANGE")) { $groupRepo = new GroupRepository(); $this->parameters['isGroupRunningOutOfFutureEvents'] = $groupRepo->isGroupRunningOutOfFutureEvents($this->parameters['group'], $app['currentSite']); } $this->parameters['templatesAfterDetails'] = array(); $this->parameters['templatesAtEnd'] = array(); foreach ($app['extensions']->getExtensions() as $extension) { foreach ($extension->getAddContentToEventShowPages($this->parameters) as $addContent) { $this->parameters = array_merge($this->parameters, $addContent->getParameters()); $this->parameters['templatesAfterDetails'] = array_merge($this->parameters['templatesAfterDetails'], $addContent->getTemplatesAfterDetails()); $this->parameters['templatesAtEnd'] = array_merge($this->parameters['templatesAtEnd'], $addContent->getTemplatesAtEnd()); } } return $app['twig']->render('site/event/show.html.twig', $this->parameters); }
function editMedia($slug, Request $request, Application $app) { if (!$this->build($slug, $request, $app)) { $app->abort(404, "Group does not exist."); } if ($app['currentUserPermissions']->hasPermission("org.openacalendar", "CALENDAR_CHANGE") && $app['currentSite']->getIsFeatureGroup()) { $form = $app['form.factory']->create(new UploadNewMediaForm($this->parameters['group']->getTitle())); if ('POST' == $request->getMethod()) { $form->bind($request); if ($form->isValid() && $form['media']->getData()) { $mediaRepository = new MediaRepository(); $media = $mediaRepository->createFromFile($form['media']->getData(), $app['currentSite'], $app['currentUser'], $form['title']->getData(), $form['source_text']->getData(), $form['source_url']->getData()); if ($media) { $mediaInGroupRepo = new MediaInGroupRepository(); $mediaInGroupRepo->add($media, $this->parameters['group'], $app['currentUser']); $app['flashmessages']->addMessage('Picture added!'); return $app->redirect("/group/" . $this->parameters['group']->getSlugForURL()); } } } $this->parameters['uploadNewMediaForm'] = $form->createView(); } $mrb = new MediaRepositoryBuilder(); $mrb->setIncludeDeleted(false); $mrb->setSite($app['currentSite']); $mrb->setGroup($this->parameters['group']); $this->parameters['medias'] = $mrb->fetchAll(); return $app['twig']->render('site/group/edit.media.html.twig', $this->parameters); }