function index(Application $app)
 {
     $trb = new TagRepositoryBuilder();
     $trb->setSite($app['currentSite']);
     $trb->setIncludeDeleted(false);
     $tags = $trb->fetchAll();
     return $app['twig']->render('site/taglist/index.html.twig', array('tags' => $tags));
 }
 function index($siteid, Request $request, Application $app)
 {
     $sr = new SiteRepository();
     $site = $sr->loadById($siteid);
     if (!$site) {
         die("404");
     }
     $trb = new TagRepositoryBuilder();
     $trb->setSite($site);
     $tags = $trb->fetchAll();
     return $app['twig']->render('sysadmin/taglist/index.html.twig', array('site' => $site, 'tags' => $tags));
 }
 function testAddOnCreate()
 {
     TimeSource::mock(2013, 7, 1, 7, 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());
     $tag = new TagModel();
     $tag->setTitle("test");
     $tagRepo = new TagRepository();
     $tagRepo->create($tag, $site, $user);
     $event = new EventModel();
     $event->setSummary("test");
     $event->setDescription("test test");
     $event->setStartAt(getUTCDateTime(2013, 8, 1, 19, 0, 0));
     $event->setEndAt(getUTCDateTime(2013, 8, 1, 21, 0, 0));
     $eventRepository = new EventRepository();
     $eventRepository->create($event, $site, $user, null, null, null, array($tag));
     ## test
     $tagRepoBuilder = new TagRepositoryBuilder();
     $tagRepoBuilder->setSite($site);
     $tagRepoBuilder->setTagsForEvent($event);
     $this->assertEquals(1, count($tagRepoBuilder->fetchAll()));
     $tagRepoBuilder = new TagRepositoryBuilder();
     $tagRepoBuilder->setSite($site);
     $tagRepoBuilder->setTagsNotForEvent($event);
     $this->assertEquals(0, count($tagRepoBuilder->fetchAll()));
     $eventRepoBuilder = new EventRepositoryBuilder();
     $eventRepoBuilder->setSite($site);
     $eventRepoBuilder->setTag($tag);
     $this->assertEquals(1, count($eventRepoBuilder->fetchAll()));
 }
 function editTags($slug, Request $request, Application $app)
 {
     if (!$this->build($slug, $request, $app)) {
         $app->abort(404, "Event does not exist.");
     }
     $tagRepo = new TagRepository();
     if ('POST' == $request->getMethod() && $request->request->get('CSFRToken') == $app['websession']->getCSFRToken()) {
         if ($request->request->get('addTag')) {
             $tag = $tagRepo->loadBySlug($app['currentSite'], $request->request->get('addTag'));
             if ($tag) {
                 $tagRepo->addTagToEvent($tag, $this->parameters['event'], $app['currentUser']);
             }
         } elseif ($request->request->get('removeTag')) {
             $tag = $tagRepo->loadBySlug($app['currentSite'], $request->request->get('removeTag'));
             if ($tag) {
                 $tagRepo->removeTagFromEvent($tag, $this->parameters['event'], $app['currentUser']);
             }
         }
     }
     $trb = new TagRepositoryBuilder();
     $trb->setSite($app['currentSite']);
     $trb->setIncludeDeleted(false);
     $trb->setTagsForEvent($this->parameters['event']);
     $this->parameters['tags'] = $trb->fetchAll();
     $trb = new TagRepositoryBuilder();
     $trb->setSite($app['currentSite']);
     $trb->setIncludeDeleted(false);
     $trb->setTagsNotForEvent($this->parameters['event']);
     $this->parameters['tagsToAdd'] = $trb->fetchAll();
     return $app['twig']->render('site/event/edit.tags.html.twig', $this->parameters);
 }
 function listTags(Application $app)
 {
     $trb = new TagRepositoryBuilder();
     $trb->setSite($app['currentSite']);
     $trb->setIncludeDeleted(true);
     $tags = $trb->fetchAll();
     return $app['twig']->render('site/admin/listTags.html.twig', array('tags' => $tags));
 }