public function addAction()
 {
     WAuthUtil::whetherLogout($this);
     $request = $this->getRequest();
     $form = new PageForm();
     //start
     if ($request->isPost() && isset($request->getPost()['pcontent'])) {
         $page = new Page();
         $user = new User();
         $form->bind($page);
         $form->setData($request->getPost());
         if ($form->isValid()) {
             $auth = WAuthUtil::get_auth();
             $schID = $auth->schoolID;
             $userID = $auth->userID;
             $page->setSchID($schID);
             $user->setUserID($userID);
             $page->setUser($user);
             $pageID = $this->getservice()->getNewPageIDandMakedir();
             $page->setPageID($pageID);
             $file = $request->getFiles();
             $this->getservice()->savePage($page, $file);
             //                 Redirect to list of albums如果想要dump就不要转业
             return $this->redirect()->toRoute('page');
         } else {
             $messages = $form->getMessages();
             Debug::dump($messages);
         }
     }
     WAuthUtil::addUserpanelToLayout($this, '/add');
     return new ViewModel(array('pageform' => $form));
 }
 public function getPageCount($secID, $ptype)
 {
     if (isset(WAuthUtil::get_auth()->schoolID)) {
         $schID = WAuthUtil::get_auth()->schoolID;
     } else {
         $schID = 0;
     }
     return $this->pageMapper->getAllCount($secID, $ptype, $schID);
 }
 public function getPages($secID, $ptype)
 {
     // TODO: Implement findAllPosts() method.
     if (isset(WAuthUtil::get_auth()->schoolID)) {
         $schID = WAuthUtil::get_auth()->schoolID;
     } else {
         $schID = 0;
     }
     return $this->pageMapper->findAll($secID, $ptype, $schID);
 }
 public function getRecruits($tag, $type)
 {
     // TODO: Implement findAllPosts() method.
     if (isset(WAuthUtil::get_auth()->schoolID)) {
         $schID = WAuthUtil::get_auth()->schoolID;
     } else {
         $schID = 0;
     }
     return $this->recruitMapper->findAll($schID, $tag, $type);
 }
 public function detailAction()
 {
     WAuthUtil::whetherLogout($this);
     //form
     $form = new FollowForm();
     $id = $this->params()->fromRoute('id');
     //增加点击次数
     $this->getFollowService()->updateClicktime($id);
     //查看是否评论,进行request处理
     $request = $this->getRequest();
     $whetherlogin = false;
     $userID = 0;
     $auth = WAuthUtil::get_auth();
     $star = null;
     if ($auth) {
         $whetherlogin = true;
         $userID = $auth->userID;
         $star = $this->getFollowService()->getStar($userID, $id);
     }
     if ($request->isPost() && isset($request->getPost()['fcontent'])) {
         if ($auth) {
             $followObject = new Follow();
             $user = new User();
             //!之所以要用一个对象,是因为follow对象里面没有userID这个属性,要在mapper里手工加上
             $form->bind($followObject);
             //通过Hydrator\ArraySerializable 通过model的exchangeArray
             $form->setData($request->getPost());
             if ($form->isValid()) {
                 $user->setUserID($userID);
                 $followObject->setUser($user);
                 $followObject->setPageID($id);
                 $this->getFollowService()->saveFollow($followObject);
                 //                 Redirect to list of albums如果想要dump就不要转业
                 //                 return $this->redirect()->toRoute('page');
             } else {
                 $messages = $form->getMessages();
                 Debug::dump($messages);
             }
         }
     }
     //读取page信息
     try {
         $page = $this->getPageService()->getPage($id);
     } catch (\InvalidArgumentException $ex) {
         return $this->redirect()->toRoute('blog');
     }
     //读取follow信息
     $follows = $this->getFollowService()->getFollows($id);
     //         //         Debug::dump($page);
     WAuthUtil::addUserpanelToLayout($this, '/detail/' . $id);
     return new ViewModel(array('userID' => $userID, 'page' => $page, 'follows' => $follows, 'form' => $form, 'whetherLogin' => $whetherlogin, 'simi' => $this->getFollowService()->getSimi($id), 'star' => $star));
 }
 public function getSimi()
 {
     $userId = WAuthUtil::get_auth() === null ? null : WAuthUtil::get_auth()->userID;
     $users = array();
     if ($userId !== null) {
         $sql = "select recfris.friendId userID,simi ,user.* from recfris join user on\n            recfris.friendId = user.userID where recfris.userId = {$userId} and simi <> 0\n            order by simi desc";
         $stmt = $this->dbAdapter->query($sql);
         $result = $stmt->execute();
         foreach ($result as $s) {
             $userObject = new User();
             $userObject->exchangeArray($s);
             $users[] = $userObject;
         }
     }
     return $users;
 }
 public function indexAction()
 {
     WAuthUtil::whetherLogout($this);
     $request = $this->getRequest();
     if ($request->isGet() && isset($request->getQuery()['userId']) && $request->getQuery()['userId'] != null) {
         $userId = $request->getQuery()['userId'];
         $this->adminService->deleteUser($userId);
         echo "删除用户{$userId}成功!";
     }
     if ($request->isGet() && isset($request->getQuery()['pageId']) && $request->getQuery()['pageId'] != null) {
         $pageId = $request->getQuery()['pageId'];
         $this->adminService->deletePage($request->getQuery()['pageId']);
         echo "删除帖子{$pageId}成功";
     }
     WAuthUtil::addUserpanelToLayout($this, '/admin');
     $type = WAuthUtil::get_auth() == null ? 0 : WAuthUtil::get_auth()->type;
     return new ViewModel(array('type' => $type));
 }
 public function detailAction()
 {
     WAuthUtil::whetherLogout($this);
     //form
     $form = new RFollowForm();
     $id = $this->params()->fromRoute('id');
     //查看是否评论,进行request处理
     $request = $this->getRequest();
     if ($request->isPost() && isset($request->getPost()['rfcontent'])) {
         $followObject = new RFollow();
         $user = new User();
         //!之所以要用一个对象,是因为follow对象里面没有userID这个属性,要在mapper里手工加上
         $form->bind($followObject);
         //通过Hydrator\ArraySerializable 通过model的exchangeArray
         $form->setData($request->getPost());
         if ($form->isValid()) {
             $auth = WAuthUtil::get_auth();
             $userID = $auth->userID;
             $user->setUserID($userID);
             $followObject->setUser($user);
             $followObject->setRecruitID($id);
             $this->getRFollowService()->saveRFollow($followObject);
             //                 Redirect to list of albums如果想要dump就不要转业
             //                 return $this->redirect()->toRoute('page');
         } else {
             $messages = $form->getMessages();
             Debug::dump($messages);
         }
     }
     //读取page信息
     try {
         $recruit = $this->getRecruitService()->getRecruit($id);
     } catch (\InvalidArgumentException $ex) {
         return $this->redirect()->toRoute('blog');
     }
     //读取follow信息
     $follows = $this->getRFollowService()->getRFollows($id);
     //         //         Debug::dump($page);
     WAuthUtil::addUserpanelToLayout($this, '/detail/' . $id);
     return new ViewModel(array('recruit' => $recruit, 'follows' => $follows, 'form' => $form));
 }
 public function indexAction()
 {
     $auth = WAuthUtil::get_auth();
     WAuthUtil::addUserpanelToLayout($this, '/');
     return new ViewModel();
 }
 public function loginAction()
 {
     WAuthUtil::whetherLogout($this);
     $errormessage = null;
     $form = new UserForm();
     //         $username2=$form->get('username');
     //         $username2->setAttribute('class', 'username');
     $form->remove('schoolID');
     $form->get('submit')->setValue('login');
     $request = $this->getRequest();
     if ($request->isPost()) {
         $user = new User();
         $form->setInputFilter($user->getInputFilter());
         //就算没有输入id也可以通过检验。
         $form->bind($user);
         $form->setData($request->getPost());
         if ($form->isValid()) {
             if ($this->getservice()->auth($user)) {
                 return $this->redirect()->toRoute('add');
             } else {
                 $errormessage = "用户名不存在或者密码错误";
             }
         } else {
             $messages = $form->getMessages();
             //                 Debug::dump($messages);
         }
     }
     //         WAuthUtil::addUserpanelToLayout($this, '/login');
     return new ViewModel(array('userform' => $form, 'errormessage' => $errormessage));
 }
 public function findRec()
 {
     if (WAuthUtil::get_auth() !== null) {
         $userId = WAuthUtil::get_auth()->userID;
         $sql = "select page.*,predictRating,user.* from (recs join page  on recs.pageId = page.pageID)join user on recs.userId = user.userId where \n                recs.userId = {$userId} and predictRating <> 0 order by predictRating desc";
         $statement = $this->dbAdapter->query($sql);
         $result = $statement->execute();
         if ($result instanceof ResultInterface && $result->isQueryResult()) {
             $resultSet = new WHydrateResultset($this->hydrator, $this->pagePrototype, $this->prototypeArr);
             $tmp = $resultSet->initialize($result);
             //              foreach ($resultSet as $row){
             //                  Debug::dump($row);
             //              }
             return $tmp;
         }
         throw new \InvalidArgumentException("Forum with given ID:{$id} not found.");
     } else {
         return null;
     }
 }