public function homeAction() { $this->_helper->layout->setLayout('topmenu'); $topicService = new Service_Topic(); $results = $topicService->fetchAll(); for ($i = 0; $i < count($results); $i++) { $following = false; if (count($results[$i]['Followers'])) { foreach ($results[$i]['Followers'] as $follower) { if ($this->_user->id == $follower['id']) { $following = true; break; } } } $results[$i]['following'] = $following; } $result['root'] = $results; $this->view->townhalls = $result; return $this->render(); }
public function followtownhallAction() { $topicService = new Service_Topic(); if ($this->getRequest()->isPost() && $this->_ajaxRequest) { if ($topic = $this->getRequest()->getParam('townhall', FALSE)) { if ($topicService->followTopic($this->_user->id, $topic)) { $this->_response->appendBody('1'); return; } else { $this->_response->appendBody('0'); return; } } else { $this->_response->appendBody('0'); return; } } else { return $this->_redirect('/profile'); } }
public function indexAction() { //Load Townhall Resource Page if ($topicName = $this->getRequest()->getParam('topic', FALSE)) { $topicName = strtolower($topicName); $topicService = new Service_Topic(); if (is_array($topics = $topicService->fetchUrlList())) { if ($topic = array_search($topicName, $topics)) { $this->_helper->layout->setLayout('topmenu'); $resourceService = new Service_Resource(); if (is_array($resources = $resourceService->fetchByTopic($topic))) { for ($i = 0; $i < $resources['total']; $i++) { $bookmarked = false; if (count($resources['resources'][$i]['Bookmarkers'])) { foreach ($resources['resources'][$i]['Bookmarkers'] as $bookmarker) { if ($this->_user->id == $bookmarker['id']) { $bookmarked = true; break; } } } $resources['resources'][$i]['bookmarked'] = $bookmarked; } $this->view->title = ucfirst($topicName); $this->view->resources = $resources['resources']; $this->view->resourceCount = $resources['total']; return $this->render('topicResources'); } else { return $this->_redirect("/resources/error"); } } else { $this->view->error = $topics; return $this->render(); return $this->_redirect("/resources/error"); } } else { return $this->_redirect("/error"); } //Modify for Error Response Page } else { $this->_helper->layout->setLayout('topmenu'); $resourceService = new Service_Resource(); $newestResources = $resourceService->fetchNewest(); for ($i = 0; $i < count($newestResources); $i++) { $bookmarked = false; if (count($newestResources[$i]['Bookmarkers'])) { foreach ($newestResources[$i]['Bookmarkers'] as $bookmarker) { if ($this->_user->id == $bookmarker['id']) { $bookmarked = true; break; } } } $newestResources[$i]['bookmarked'] = $bookmarked; } $this->view->newestResources = $newestResources; $locationResources = $resourceService->fetchByState($this->_user->stateprovid); for ($i = 0; $i < $locationResources['total']; $i++) { $bookmarked = false; if (count($locationResources['resources'][$i]['Bookmarkers'])) { foreach ($locationResources['resources'][$i]['Bookmarkers'] as $bookmarker) { if ($this->_user->id == $bookmarker['id']) { $bookmarked = true; break; } } } $locationResources['resources'][$i]['bookmarked'] = $bookmarked; } $this->view->localResources = $locationResources; return $this->render(); } }
public function listresourcesAction() { if ($topicName = $this->getRequest()->getParam('topic', FALSE)) { $topicService = new Service_Topic(); if (is_array($topics = $topicService->fetchUrlList())) { if ($topic = array_search($topicName, $topics)) { //$this->_helper->layout->setLayout('topmenu'); $resourceService = new Service_Resource(); if (is_array($resources = $resourceService->fetchByTopic($topic))) { for ($i = 0; $i < $resources['total']; $i++) { $bookmarked = false; if (count($resources['resources'][$i]['Bookmarkers'])) { foreach ($resources['resources'][$i]['Bookmarkers'] as $bookmarker) { if ($this->_user->id = $bookmarker['id']) { $bookmarked = true; break; } } } $resources['resources'][$i]['bookmarked'] = $bookmarked; $resources['resources'][$i]['userid'] = $this->_user->id; } //$this->view->title = ucfirst($topicName); $this->view->result = $resources['resources']; //$this->view->resourceCount = $resources['total']; return $this->render('friend'); } else { return $this->_redirect("/resources/error"); } } else { return $this->_redirect("/resources/error"); } } else { return $this->_redirect("/error"); } //Modify for Error Response Page } }