Exemplo n.º 1
0
 public function beforeCreate()
 {
     $user = new LoginModel();
     if ($userinfo = $user->isUserLoggedIn()) {
         $this->userId = $userinfo['id'];
         $this->username = $userinfo['username'];
     }
 }
Exemplo n.º 2
0
 public function beforeUpdate()
 {
     $user = new LoginModel();
     if ($userinfo = $user->isUserLoggedIn()) {
         $this->editorId = $userinfo['id'];
         $this->editorName = $userinfo['username'];
     }
     $this->updatedAt = time();
 }
Exemplo n.º 3
0
 public function beforeCreate()
 {
     $this->createdAt = $this->updatedAt = time();
     $user = new LoginModel();
     if ($userinfo = $user->isUserLoggedIn()) {
         $this->userId = $this->userId ? $this->userId : $userinfo['id'];
         $this->username = $this->username ? $this->username : $userinfo['username'];
     }
 }
Exemplo n.º 4
0
 private function getUserInfo()
 {
     $user = new LoginModel();
     if ($user->isUserLoggedIn()) {
         $userinfo = $user->getCurrentUser();
         return $userinfo;
     } else {
         return false;
     }
 }
Exemplo n.º 5
0
 public function beforeUpdate()
 {
     $this->updatedAt = $this->updatedAt ?: time();
     $user = new LoginModel();
     if ($user->isUserLoggedIn()) {
         $userinfo = LoginModel::getCurrentUser();
         $this->userId = $this->userId ? $this->userId : $userinfo['id'];
         $this->username = $this->username ? $this->username : $userinfo['username'];
     }
 }
Exemplo n.º 6
0
 /**
  * Creates a new Comment for the Thread from the submitted data.
  *
  * @param string $uniqueKey The id of the thread
  * @throws \Exception
  */
 public function postThreadCommentsAction($uniqueKey)
 {
     $threadManager = new ThreadManager();
     $thread = $threadManager->findThreadByUniqueKey($uniqueKey);
     if (!$thread) {
         throw new \Exception(sprintf('Thread with identifier of "%s" does not exist', $uniqueKey));
     }
     //        if (!$thread->isCommentable()) {
     //            throw new \Exception(sprintf('Thread "%s" is not commentable', $uniqueKey));
     //        }
     $parentId = $this->request->getPost('parentId');
     $parent = $this->getValidCommentParent($thread, $parentId);
     $content = $this->request->getPost('content');
     $username = $this->request->getPost('username');
     $commentManager = new CommentManager();
     $comment = $commentManager->createComment($thread, $parent);
     //        if ($form->isValid()) {
     $comment->content = $content;
     //        if(!empty($username)) $comment->username = $username;
     $user = new LoginModel();
     if ($user->isUserLoggedIn()) {
         $userinfo = $user->getCurrentUser();
         $comment->userId = $userinfo['id'];
         $comment->username = $userinfo['username'];
     }
     $commentManager->filterContent($comment);
     //政治敏感词过滤
     if ($commentManager->saveComment($comment) !== false) {
         $errors = $comment->getMessages();
         p($errors);
         //                return $this->getViewHandler()->handle($this->onCreateCommentSuccess($form, $id, $parent));
     }
     $this->view->pick('thread/comment');
     $this->view->setVars(array('comment' => $comment, 'thread' => $thread));
 }