public function write()
 {
     $thread = Thread::getById(Param::get('thread_id'));
     $comment = new Comment();
     $page = Param::get('page_next', 'write');
     switch ($page) {
         case self::CURRENT_PAGE_WRITE:
             break;
         case self::RENDER_PAGE_AFTER_WRITE:
             $comment->id = $thread->id;
             $comment->user_id = get_authenticated_user_id($_SESSION['userid']);
             $comment->body = Param::get('body');
             try {
                 $comment->write();
             } catch (ValidationException $e) {
                 $page = self::CURRENT_PAGE_WRITE;
             }
             break;
         default:
             throw new NotFoundException("{$page} is not found");
     }
     $this->set(get_defined_vars());
     $this->render($page);
 }
Example #2
0
 public function getFollowedThreads($session_user)
 {
     $this->threads_followed = array();
     $followed_ids = Follow::getFollowedThreadIds($this->id);
     foreach ($followed_ids as $thread) {
         $this->threads_followed[] = Thread::getById($thread['thread_id']);
     }
     Thread::getAttributes($this->threads_followed, $session_user);
 }