Exemplo n.º 1
0
 public function add_new_commentAction()
 {
     $request = $this->getRequest();
     $link = $request->getServer('HTTP_REFERER');
     if (!JO_Session::get('user_id')) {
         JO_Session::set('msg_error', $this->translate('You must be logged to change your profile'));
         $this->redirect(WM_Router::create($request->getBaseUrl() . '?controller=users&action=login'));
     }
     if ($request->issetPost('thread_id') && $request->issetPost('comment') && $request->issetPost('topic_id')) {
         $thread_id = trim($request->getPost('thread_id'));
         $comment = trim($request->getPost('comment'));
         $error = array();
         if (empty($comment)) {
             $error['comment'] = $this->translate('Comment cannot be empty');
         }
         if (!empty($comment)) {
             $id = Model_Forum::setThread($thread_id, array('user_id' => JO_Session::get('user_id'), 'name' => '', 'comment' => strip_tags(html_entity_decode($comment), '<br><p><span><h1><h2><h3><a><img><big><small><ul><ol><li><quote>'), 'notify' => $request->getPost('reply_notification') == 1 ? 'true' : 'false', 'reply_to' => $request->getPost('topic_id')));
             JO_Session::set('msg_success', $this->translate('The reply has been successfully posted'));
             $this->redirect($link . '#c_' . $id);
         } else {
             $error['msg_error'] = $this->translate('There was an error posting your comment');
             JO_Session::set('msg_error', $error);
         }
     }
     $this->redirect($link);
 }