Example #1
0
 public function replyAction()
 {
     $content = $this->getRequest()->getParam('context');
     // echo $content;
     //得到expertid
     $expertid = $_SESSION["userinfo"][0][id];
     $questionid = $_SESSION["question"][questionid];
     $usertable = new UserModel();
     $db1 = $usertable->getAdapter();
     $response = new Expert_ResponseModel();
     $db2 = $response->getAdapter();
     $question = new User_QuestionModel();
     $db3 = $question->getAdapter();
     //  exit();
     $questions = $db3->query('SELECT userconquestion.* FROM userconquestion WHERE id=? ', $questionid)->fetchAll();
     $userid = $questions[0][userid];
     //   print_r($questions);
     //获取当前时间
     $t = time();
     $time = date("Y-m-d H:i:s", $t);
     $set = array('expertid' => $expertid, 'userid' => $userid, 'questionid' => $questionid, 'response' => $content, 'time' => $time);
     //   print_r($insertset);
     $flag1 = $response->insert($set);
     $state = 0;
     $updateset = array('state' => $state);
     $question->update($updateset, $db3->quoteInto('id = ?', $questionid));
     $this->view->info = '回复成功';
     $this->view->expertid = $expertid;
     $this->_forward('result7', 'globals');
 }
 public function expertdetailAction()
 {
     $replypage = $this->getRequest()->getParam('replypage', '0');
     $questionpage = $this->getRequest()->getParam('questionpage', '0');
     $id = $this->getRequest()->getParam('expertid', '0');
     $type = $this->getRequest()->getParam('type', '0');
     $userid = $_SESSION["userinfo"][0][id];
     $usertable = new UserModel();
     $db1 = $usertable->getAdapter();
     $expertinfo = new expertinfoModel();
     $db2 = $expertinfo->getAdapter();
     $expert = $db2->query('SELECT * FROM expertinfo,User WHERE expertinfo.userid = User.id and User.id =? ', $id)->fetchAll();
     //print_r($expert);
     $question = new User_QuestionModel();
     $db3 = $question->getAdapter();
     $response = new Expert_ResponseModel();
     $db4 = $response->getAdapter();
     $questions = $db3->query('SELECT * FROM userconquestion,User WHERE userconquestion.state=1 and userconquestion.userid=User.id and userconquestion.expertid=? order by time desc ', $id)->fetchAll();
     //  exit();
     //print_r($questions);
     $questionnum = count($questions);
     $responses = $db4->query('select * from expertconresponse,userconquestion,User where expertconresponse.expertid=? and expertconresponse.questionid=userconquestion.id and userconquestion.userid=User.id order by time desc', $id)->fetchAll();
     //print_r($responses);
     $replynum = count($responses);
     $Isconcern = $db3->query('SELECT COUNT(*) as num FROM userconexpert where expertid=? and userid=? ', array($id, $userid))->fetchAll()[0][num];
     $replypages = ceil($replynum / 3);
     //确定页面显示的规范  处理分页的逻辑  这是reply的
     if ($replypage < 3) {
         if ($replypages > 3) {
             $set = array(1, 2, 3, 4);
         } else {
             $set = array();
             for ($i = 1; $i <= $replypages; $i++) {
                 $set[] = $i;
             }
         }
     } else {
         if ($replypage >= 3) {
             if ($replypage + 3 <= $replypages) {
                 $set = array($replypage, $replypage + 1, $replypage + 2, $replypage + 3);
             } else {
                 $set = array();
                 for ($i = $replypage; $i <= $replypages; $i++) {
                     $set[] = $i;
                 }
             }
         }
     }
     $questionpages = ceil($questionnum / 6);
     if ($questionpage < 3) {
         if ($questionpages > 3) {
             $questionset = array(1, 2, 3, 4);
         } else {
             $questionset = array();
             for ($i = 1; $i <= $questionpages; $i++) {
                 $questionset[] = $i;
             }
         }
     } else {
         if ($questionpage >= 3) {
             if ($questionpage + 3 <= $questionpages) {
                 $questionset = array($questionpage, $questionpage + 1, $questionpage + 2, $questionpage + 3);
             } else {
                 $questionset = array();
                 for ($i = $questionpage; $i <= $questionpages; $i++) {
                     $questionset[] = $i;
                 }
             }
         }
     }
     $this->view->replypage = $replypage;
     $this->view->replynums = $replynum;
     $this->view->questionpage = $questionpage;
     $this->view->questionnums = $questionnum;
     $this->view->replys = $set;
     $this->view->questions = $questionset;
     $this->view->expertid = $id;
     $this->view->result = $expert;
     $this->view->question = $questions;
     $this->view->responses = $responses;
     $this->view->type = $type;
     $this->view->userid = $userid;
     $this->view->Isconcern = $Isconcern;
 }