Beispiel #1
0
 public function indexAction()
 {
     WAuthUtil::whetherLogout($this);
     $routeID = $this->params()->fromRoute('id');
     $auth = WAuthUtil::get_auth();
     $userID = $auth == null ? 0 : $auth->userID;
     $mode = $routeID == $userID ? self::User_EDIT : self::USER_CHECK;
     //处理上传头像请求
     $request = $this->getRequest();
     $user = $this->getservice()->getUser($routeID);
     if ($request->isPost() && $_FILES["faceimgpath"]["error"] == 0) {
         $upfilepath = $_FILES["faceimgpath"]["tmp_name"];
         //             Debug::dump($_FILES["faceimgpath"]["tmp_name"]);
         //http://framework.zend.com/manual/current/en/modules/zend.filter.file.html
         $basepath = WBasePath::getBasePath();
         //public
         $filter = new Rename(array("target" => $basepath . '/' . "data/face/face.jpg", "randomize" => true));
         $filepath = $filter->filter($upfilepath);
         // public/,,,
         $filepath = substr($filepath, strlen($basepath));
         // File has been renamed to "./data/uploads/newfile_4b3403665fea6.txt"
         $user->setFaceimgpath($filepath);
         //             Debug::dump($filepath);
         $this->getservice()->updateUser($user);
     }
     WAuthUtil::addUserpanelToLayout($this, '/account/' . $routeID);
     return new ViewModel(array('mode' => $mode, 'user' => $user, 'friends' => $this->getservice()->getSimi()));
 }
 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));
 }
Beispiel #3
0
 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));
 }
Beispiel #7
0
 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 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;
     }
 }