Example #1
0
 public function experthomeAction()
 {
     $id = $this->getRequest()->getParam('expertid', '0');
     $questionid = $this->getRequest()->getParam('questionid', '0');
     $type = $this->getRequest()->getParam('type', '0');
     // $id=$_SESSION["userinfo"][0][id];
     //echo $id;
     //exit();
     $usertable = new UserModel();
     $db1 = $usertable->getAdapter();
     $expertinfo = new expertinfoModel();
     $db2 = $expertinfo->getAdapter();
     $question = new User_QuestionModel();
     $db3 = $question->getAdapter();
     $response = new Expert_ResponseModel();
     $db4 = $response->getAdapter();
     if ($type == 0) {
         $expert = $db2->query('SELECT * FROM expertinfo,User WHERE expertinfo.userid = User.id and User.id =? ', $id)->fetchAll();
         //print_r($expert);
         $questions = $db3->query('SELECT userconquestion.*,User.name FROM userconquestion,User WHERE userconquestion.state=1 and userconquestion.userid=User.id and userconquestion.expertid=? order by time desc ', $id)->fetchAll();
         // print_r($questions);
         // exit();
         $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);
         // exit();
         $this->view->result = $expert;
         $this->view->question = $questions;
         $this->view->responses = $responses;
         $this->view->type = $type;
         $this->view->questionid = $questionid;
     } else {
         if ($type == 1) {
             $expert = $db2->query('SELECT * FROM expertinfo,User WHERE expertinfo.userid = User.id and User.id =? ', $id)->fetchAll();
             $question = $db3->query('SELECT userconquestion.*,User.name FROM userconquestion,User WHERE  userconquestion.userid=User.id and userconquestion.id=? order by time desc ', $questionid)->fetchAll();
             $set = array('expertid' => $id, 'questionid' => $questionid);
             $_SESSION["question"] = $set;
             $this->view->expertid = $id;
             $this->view->result = $expert;
             $this->view->question = $question;
             $this->view->questionid = $questionid;
             $this->view->type = $type;
         }
     }
 }
Example #2
0
 public function expertregisterAction()
 {
     $account = $this->getRequest()->getParam('account');
     $password = $this->getRequest()->getParam('password');
     $name = $this->getRequest()->getParam('name');
     $content = $this->getRequest()->getParam('context');
     $work = $this->getRequest()->getParam('work');
     $code = $this->getRequest()->getParam('surecode');
     if ($code == $_SESSION["validcode"]) {
         $User = new UserModel();
         if ($User->ifRegister($account)) {
             $set = array('account' => $account, 'password' => $password, 'name' => $name, 'email' => $account, 'type' => 2);
             //在注册用户的时候顺带着要建一个用户个人信息
             if ($User->insert($set) > 0) {
                 $where = "email='{$account}'";
                 $result = $User->fetchAll($where)->toArray();
                 $info = array('userid' => $result[0][id], 'sex' => 'M', 'name' => $result[0][name], 'sheng' => '北京市', 'shi' => '北京市', 'xian' => '东城区', 'birth' => '1994-5-29', 'interest' => '跑步');
                 $userinfo = new userinfoModel();
                 $expert = array('info' => $content, 'userid' => $result[0][id], 'work' => $work, 'concern' => 0, 'image' => '/WebOne/public/image/initial.png');
                 $expertinfo = new expertinfoModel();
                 if ($userinfo->insert($info) > 0 && $expertinfo->insert($expert) > 0) {
                     //注册账号成功
                     $this->render('ok');
                 }
             } else {
                 $this->view->info = '1';
                 $this->_forward('error');
             }
         } else {
             $this->view->info = '2';
             //账号已经创建
             $this->_forward('error');
         }
     } else {
         $this->view->info = '3';
         $this->render('error');
         //验证码输入错误
     }
 }
 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;
 }