public function postInfoJson($slug, Request $request, Application $app) { if (!$this->build($slug, $request, $app)) { $app->abort(404, "Does not exist."); } $ourRequest = new \Request($request); $edits = false; if ($ourRequest->hasGetOrPost('title') && $this->venue->setTitleIfDifferent($ourRequest->getGetOrPostString('title', ''))) { $edits = true; } if ($ourRequest->hasGetOrPost('description') && $this->venue->setDescriptionIfDifferent($ourRequest->getGetOrPostString('description', ''))) { $edits = true; } if ($ourRequest->hasGetOrPost('address') && $this->venue->setAddressIfDifferent($ourRequest->getGetOrPostString('address', ''))) { $edits = true; } if ($ourRequest->hasGetOrPost('address_code') && $this->venue->setAddressCodeIfdifferent($ourRequest->getGetOrPostString('address_code', ''))) { $edits = true; } if ($ourRequest->hasGetOrPost('lat') && $ourRequest->hasGetOrPost('lng')) { if ($this->venue->setLatIfDifferent($ourRequest->getGetOrPostString('lat', ''))) { $edits = true; } if ($this->venue->setLngIfDifferent($ourRequest->getGetOrPostString('lng', ''))) { $edits = true; } } if ($edits) { $repo = new VenueRepository(); $repo->edit($this->venue, $app['apiUser']); $out = array('edited' => true); } else { $out = array('edited' => false); } return json_encode($out); }
function moveToArea($slug, Request $request, Application $app) { if (!$this->build($slug, $request, $app)) { $app->abort(404, "Venue does not exist."); } if ($request->request->get('area') && $request->request->get('CSFRToken') == $app['websession']->getCSFRToken()) { if (intval($request->request->get('area'))) { $areaRepository = new AreaRepository(); $area = $areaRepository->loadBySlug($app['currentSite'], $request->request->get('area')); if ($area && (!$this->parameters['area'] || $area->getId() != $this->parameters['area']->getId())) { $this->parameters['venue']->setAreaId($area->getId()); $venueRepository = new VenueRepository(); $venueRepository->edit($this->parameters['venue'], $app['currentUser']); $app['flashmessages']->addMessage('Thank you; venue updated!'); } } } return $app->redirect("/venue/" . $this->parameters['venue']->getSlugForURL() . '/'); }
function testIntegration2() { $this->addCountriesToTestDB(); \TimeSource::mock(2014, 1, 1, 12, 0, 0); $user = new UserAccountModel(); $user->setEmail("*****@*****.**"); $user->setUsername("test"); $user->setPassword("password"); $userRepo = new UserAccountRepository(); $userRepo->create($user); $site = new SiteModel(); $site->setTitle("Test"); $site->setSlug("test"); $siteRepo = new SiteRepository(); $siteRepo->create($site, $user, array(), $this->getSiteQuotaUsedForTesting()); $countryRepo = new CountryRepository(); $gb = $countryRepo->loadByTwoCharCode('GB'); ## Create venue \TimeSource::mock(2014, 1, 1, 13, 0, 0); $venue = new VenueModel(); $venue->setTitle("test"); $venue->setDescription("test test"); $venue->setCountryId($gb->getId()); $venueRepo = new VenueRepository(); $venueRepo->create($venue, $site, $user); ## Edit venue \TimeSource::mock(2014, 1, 1, 14, 0, 0); $venue = $venueRepo->loadById($venue->getId()); $venue->setDescription("testy"); $venue->setLat(3.6); $venue->setLng(3.7); $venueRepo->edit($venue, $user); ## Delete venue \TimeSource::mock(2014, 1, 1, 15, 0, 0); $venueRepo->delete($venue, $user); ## Now save changed flags on these ..... $venueHistoryRepo = new VenueHistoryRepository(); $stat = $this->app['db']->prepare("SELECT * FROM venue_history"); $stat->execute(); while ($data = $stat->fetch()) { $venueHistory = new VenueHistoryModel(); $venueHistory->setFromDataBaseRow($data); $venueHistoryRepo->ensureChangedFlagsAreSet($venueHistory); } ## Now load and check $historyRepo = new HistoryRepositoryBuilder(); $historyRepo->setVenue($venue); $historyRepo->setIncludeEventHistory(false); $historyRepo->setIncludeGroupHistory(false); $historyRepo->setIncludeVenueHistory(true); $histories = $historyRepo->fetchAll(); $this->assertEquals(3, count($histories)); #the delete $this->assertEquals(FALSE, $histories[0]->getTitleChanged()); $this->assertEquals(false, $histories[0]->getDescriptionChanged()); $this->assertEquals(false, $histories[0]->getCountryIdChanged()); $this->assertEquals(true, $histories[0]->getIsDeletedChanged()); $this->assertEquals(false, $histories[0]->getLatChanged()); $this->assertEquals(false, $histories[0]->getLngChanged()); #the edit $this->assertEquals(FALSE, $histories[1]->getTitleChanged()); $this->assertEquals(true, $histories[1]->getDescriptionChanged()); $this->assertEquals(false, $histories[1]->getCountryIdChanged()); $this->assertEquals(false, $histories[1]->getIsDeletedChanged()); $this->assertEquals(true, $histories[1]->getLatChanged()); $this->assertEquals(true, $histories[1]->getLngChanged()); #the create $this->assertEquals(true, $histories[2]->getTitleChanged()); $this->assertEquals(true, $histories[2]->getDescriptionChanged()); $this->assertEquals(true, $histories[2]->getCountryIdChanged()); $this->assertEquals(false, $histories[2]->getIsDeletedChanged()); $this->assertEquals(false, $histories[2]->getLatChanged()); $this->assertEquals(false, $histories[2]->getLngChanged()); }
function moveToArea($slug, Request $request, Application $app) { if (!$this->build($slug, $request, $app)) { $app->abort(404, "Event does not exist."); } $gotResultEditedVenue = false; $gotResultEditedEvent = false; if ($request->request->get('area') && $request->request->get('CSFRToken') == $app['websession']->getCSFRToken()) { if (intval($request->request->get('area'))) { $areaRepository = new AreaRepository(); $area = $areaRepository->loadBySlug($app['currentSite'], $request->request->get('area')); if ($area && (!$this->parameters['area'] || $area->getId() != $this->parameters['area']->getId())) { if ($this->parameters['venue']) { $this->parameters['venue']->setAreaId($area->getId()); $venueRepository = new VenueRepository(); $venueRepository->edit($this->parameters['venue'], $app['currentUser']); $gotResultEditedVenue = true; } else { $this->parameters['event']->setAreaId($area->getId()); $eventRepository = new EventRepository(); $eventRepository->edit($this->parameters['event'], $app['currentUser']); $gotResultEditedEvent = true; } $app['flashmessages']->addMessage('Thank you; event updated!'); } } } if ($gotResultEditedEvent) { $repo = new EventRecurSetRepository(); if ($repo->isEventInSetWithNotDeletedFutureEvents($this->parameters['event'])) { return $app->redirect("/event/" . $this->parameters['event']->getSlugForUrl() . '/edit/future'); } else { return $app->redirect("/event/" . $this->parameters['event']->getSlugForUrl()); } } else { return $app->redirect("/event/" . $this->parameters['event']->getSlugForUrl() . '/'); } }