public function portraitAction() { $type = $this->getRequest()->getParam('type'); $imgpath = $_SERVER['DOCUMENT_ROOT'] . "/WebOne/public/image/head/"; $id = $_SESSION["userinfo"][0][id]; $expertinfo = new expertinfoModel(); $db2 = $expertinfo->getAdapter(); if (file_exists($imgpath . $id . ".jpg")) { $this->view->path = $baseUrl . "/WebOne/public/image/head/" . $id . ".jpg"; $path = "/WebOne/public/image/head/" . $id . ".jpg"; //更新专家的头像 if ($type == 'success' && $_SESSION["userinfo"][0][type] == 2) { $updateset = array('image' => $path); $expertinfo->update($updateset, $db2->quoteInto('userid = ?', $id)); } $this->view->type = $type; } else { $this->view->path = $baseUrl . "/WebOne/public/image/initial.jpg"; $this->view->type = $type; } }
public function concernAction() { $expertid = $this->getRequest()->getParam('expertid', '0'); $location = $this->getRequest()->getParam('location'); $uid = $_SESSION["userinfo"][0][id]; if ($uid == 'null') { $this->view->info = '未登录'; $this->_forward('result3', 'globals'); return; } /* echo $expertid; echo $uid; exit(); */ $usertable = new UserModel(); $db1 = $usertable->getAdapter(); $concerntable = new User_ExpertModel(); $db2 = $concerntable->getAdapter(); $expertinfo = new expertinfoModel(); $db3 = $expertinfo->getAdapter(); $isAgreed = $db2->query('SELECT COUNT(*) as num FROM userconexpert WHERE expertid = ? AND userid = ?', array($expertid, $uid))->fetchAll()[0][num]; /* echo $isAgreed; exit();*/ if ($isAgreed != 0) { //取消关注 $where = $db2->quoteInto('expertid = ? AND ', $expertid) . $db2->quoteInto('userid = ?', $uid); $concerntable->delete($where); $agrees = $db3->query('SELECT concern FROM expertinfo WHERE userid = ?', $expertid)->fetchAll()[0]['concern']; --$agrees; $updateset = array('concern' => $agrees); $expertinfo->update($updateset, $db3->quoteInto('userid = ?', $expertid)); $this->view->info = '取消关注成功'; $this->view->location = $location; $this->view->expertid = $expertid; $this->_forward('result6', 'globals'); } else { //关注 $set = array('userid' => $uid, 'expertid' => $expertid); // print_r($set); // exit(); $flag1 = $concerntable->insert($set); //exit(); $agrees = $db3->query('SELECT concern FROM expertinfo WHERE userid = ?', $expertid)->fetchAll()[0]['concern']; ++$agrees; $updateset = array('concern' => $agrees); $expertinfo->update($updateset, $db3->quoteInto('userid = ?', $expertid)); $this->view->info = '关注成功'; $this->view->location = $location; $this->view->expertid = $expertid; $this->_forward('result6', 'globals'); } }