public function indexAction()
 {
     $this->view->data = $this->_getAllParams();
     $topicGroupTbl = new VC_DbTable_Store_TopicGroup();
     $this->view->topicGroup = $topicGroupTbl->fetchAll("user_id = " . $this->userId);
     $message = $this->_helper->flashMessenger->getMessages();
     if ($message) {
         $this->view->message = $message[0];
     }
     $menuObj = new VC_Business_MenuFactory();
     $groupAndTopic = $menuObj->getGroupsAndTopicsOfUser($this->userId);
     //echo "<pre>"; var_dump($groupAndTopic); echo "</pre>"; die;
     $this->view->groupAndTopic = $groupAndTopic;
 }
 public function getGroupsAndTopicsOfUser($userId)
 {
     if ((int) $userId == 0) {
         throw new VC_Exception("Invalid user information");
     }
     //TODO: Cache
     $topicGroupTbl = new VC_DbTable_Store_TopicGroup();
     $topicTbl = new VC_DbTable_Store_Topic();
     $allTopicGroupOfUser = $topicGroupTbl->findByUserId($userId);
     if ($allTopicGroupOfUser) {
         foreach ($allTopicGroupOfUser as $key => $topicGroup) {
             //Get all topic of group topic
             $allTopicGroupOfUser[$key]['topics'] = $topicTbl->findByTopicGroupId($topicGroup['id']);
             //if ($topicGroup['id'] == 2) var_dump($topicGroup['topics'] );
         }
     }
     return $allTopicGroupOfUser;
 }
 public function deleteAction()
 {
     $this->_helper->viewRenderer->setNoRender();
     $this->_helper->getHelper('layout')->disableLayout();
     $topicGroupId = $this->_getParam("id");
     $message = "";
     if ($topicGroupId) {
         //Check belong this user
         $topicGroupTbl = new VC_DbTable_Store_TopicGroup();
         $getTopic = $topicGroupTbl->fetchRow("id = " . $topicGroupId . " AND user_id = " . $this->userId);
         if ($getTopic) {
             $topicGroupTbl->delete("id = " . $topicGroupId);
             //Delete all topic of this
             $topicTbl = new VC_DbTable_Store_Topic();
             $topicTbl->deleteTopicByTopicGroup($topicGroupId);
             $this->_helper->flashMessenger->addMessage(array('manage' => "Bạn đã xóa thành công."));
         } else {
             $this->_helper->flashMessenger->addMessage(array('manage' => "Thông tin nhóm chủ đề không hợp lệ."));
         }
     } else {
         $this->_helper->flashMessenger->addMessage(array('manage' => "Thông tin nhóm chủ đề không hợp lệ."));
     }
     $this->_redirect("topic-group/index");
 }