Esempio n. 1
0
 public function addcommentAction()
 {
     if ($this->getRequest()->isPost()) {
         $user = iconv("UTF-8", "Windows-1251", $this->_getParam('name'));
         $text = iconv("UTF-8", "Windows-1251", $this->_getParam('text'));
         $id = $this->_getParam('id');
         $dt = time() + TIME_DIFFER;
         $dt = date('Y-m-d H:i:s', $dt);
         $db = new Application_Model_DbTable_Comments();
         $params = array('user' => $user, 'comment' => $text, 'dt' => $dt, 'productId' => $id);
         $last = $db->addComment($params);
         $last_comment = $db->getCommentById($last);
         $last_comment = $last_comment[0];
         $this->view->user = $last_comment['user'];
         $this->view->comment = $last_comment['comment'];
         $this->view->dt = $last_comment['dt'];
         $out = $this->view->render('commentsloop.phtml');
         echo iconv("Windows-1251", "UTF-8", $out);
         exit;
     }
 }
 public function replyAction()
 {
     $this->view->form = $form = new Application_Form_Comment();
     // id post
     $id = $this->_request->getParam('id', 0);
     $post = $this->_request->getParam('post', 0);
     if ($this->_request->isPost() && $id > 0) {
         $formData = $this->_request->getPost();
         if ($form->isValid($formData)) {
             $c = new Application_Model_DbTable_Comments();
             $c->addComment($form->getValues());
             $this->_redirect('/post/index');
         } else {
             $form->populate($formData);
         }
     } else {
         if ($id > 0) {
             $form->parent->setValue($id);
             $form->post->setValue($post);
         }
     }
 }
Esempio n. 3
0
 public function groupAction()
 {
     $group_DB = new Application_Model_DbTable_Group();
     $group_id = $this->_request->getParam('g');
     $target_id = $this->_request->getParam('t');
     $game_id = $this->_request->getParam('gm');
     //Return After Planining
     if ($group_id && $target_id) {
         $group = $group_DB->get($group_id);
         $this->view->group = $group;
         $this->view->group_id = $group_id;
         $this->view->target_id = $target_id;
         $this->view->game_id = $game_id;
     } else {
         if ($group_id) {
             $group = $group_DB->get($group_id);
             $this->view->group_id = $group_id;
             $this->view->group = $group;
         }
     }
     $comments_DB = new Application_Model_DbTable_Comments();
     if (!isset($_SESSION['Default']['field'])) {
         $this->view->comments = "";
         $this->view->field_error = true;
     } else {
         $last_comment = $comments_DB->getLast($group_id, $_SESSION['Default']['field']);
         $this->view->comments = $last_comment['text'];
     }
 }
 public function studentsAction()
 {
     $group_id = $this->_request->getParam('g');
     $target_id = $this->_request->getParam('t');
     $game_id = $this->_request->getParam('gm');
     $is_recommend = $this->_request->getParam('recommend');
     //Return After Planining
     if ($group_id && $target_id) {
         $student_DB = new Application_Model_DbTable_StudentsInField();
         $grade_DB = new Application_Model_DbTable_Grade();
         $students = $student_DB->getAll($group_id);
         $grades = $grade_DB->getAll($target_id);
         $_students = array();
         foreach ($students as $s) {
             $s['grades'] = $grades;
             $_students[] = $s;
         }
         $this->view->students = $_students;
         $this->view->group_id = $group_id;
         $this->view->target_id = $target_id;
         $this->view->game_id = $game_id;
         $groups_DB = new Application_Model_DbTable_Group();
         $this->view->groupName = $groups_DB->getName($group_id);
     } else {
         $plans_DB = new Application_Model_DbTable_Planing();
         $last_plan = $plans_DB->getLastPlan($group_id, $_SESSION['Default']['field']);
         if ($last_plan) {
             $group_id = $last_plan['groupID'];
             $target_id = $last_plan['goal_id'];
             $game_id = $last_plan['game_id'];
             $student_DB = new Application_Model_DbTable_StudentsInField();
             $grade_DB = new Application_Model_DbTable_Grade();
             $students = $student_DB->getAll($group_id);
             $grades = $grade_DB->getAll($target_id);
             $_students = array();
             foreach ($students as $s) {
                 $s['grades'] = $grades;
                 $_students[] = $s;
             }
             $this->view->students = $_students;
             $this->view->group_id = $group_id;
             $this->view->target_id = $target_id;
             $this->view->game_id = $game_id;
             $groups_DB = new Application_Model_DbTable_Group();
             $this->view->groupName = $groups_DB->getName($group_id);
         } else {
             $this->view->group_id = $group_id;
             $groups_DB = new Application_Model_DbTable_Group();
             $this->view->groupName = $groups_DB->getName($group_id);
         }
     }
     $games_DB = new Application_Model_DbTable_Game();
     $this->view->gameName = $games_DB->getGameName($game_id);
     $notes = $this->getRequest()->getPost('notes');
     if ($notes) {
         $comments_DB = new Application_Model_DbTable_Comments();
         $new_comment = array('groupID' => $group_id, 'gameID' => $game_id, 'date' => date('Y-m-d H:i:s'), 'text' => $notes, 'fieldID' => $_SESSION['Default']['field']);
         try {
             $comment_id = $comments_DB->insert($new_comment);
         } catch (Exception $ex) {
             die(json_encode(array('status' => 'danger', 'msg' => $this->lang->_('FAILED_DOC'))));
         }
     }
     if ($is_recommend) {
         $this->recommend();
     }
 }
Esempio n. 5
0
 /**
  * Specifically for Comments actions.
  *
  * @return mixed
  * @throws Exception
  */
 public function commentAction()
 {
     if ($this->getRequest()->isPost()) {
         $comment = $this->getRequest()->getPost('pcomment');
         if ($comment == "Post Comment") {
             $id = (int) $this->getRequest()->getPost('id');
             $user_name = $this->getRequest()->getPost('user_name');
             $description = $this->getRequest()->getPost('description');
             $comments = new Application_Model_DbTable_Comments();
             $comments->addComment($id, $user_name, $description);
             return $this->_helper->redirector('index');
         } else {
             $id = $this->_getParam('id', 0);
             if ($id > 0) {
                 $comments = new Application_Model_DbTable_Comments();
                 $this->view->comment = $comments->getComments($id);
             }
         }
     }
 }