Ejemplo n.º 1
1
 /**
  * @param                     $row
  * @param KunenaForumCategory $category
  * @param KunenaForumTopic    $topic
  * @param                     $subject
  *
  * @return bool|string
  */
 protected function replyTopic($row, KunenaForumCategory $category, KunenaForumTopic $topic, $subject)
 {
     $uri = JFactory::getURI();
     if (JSession::checkToken() == false) {
         $this->app->enqueueMessage(JText::_('COM_KUNENA_ERROR_TOKEN'), 'error');
         return false;
     }
     /*if ($this->hasCaptcha() && !$this->verifyCaptcha()) {
     			return $this->showForm ( $row, $category, $topic, $subject );
     		}*/
     // Create topic if it doesn't exist
     if (!$topic->exists()) {
         $topic = $this->createTopic($row, $category, $subject);
     }
     $params = array('name' => JRequest::getString('name', $this->user->getName(), 'POST'), 'email' => JRequest::getString('email', null, 'POST'), 'subject' => $subject, 'message' => JRequest::getString('message', null, 'POST'));
     if ($this->hasCaptcha() && !$this->verifyCaptcha()) {
         $this->app->redirect($uri->toString(), $result);
     }
     $message = $topic->newReply($params);
     $success = $message->save();
     if (!$success) {
         $this->app->enqueueMessage($message->getError(), 'error');
         return false;
     }
     $message->sendNotification();
     if ($message->hold) {
         $result = JText::_('PLG_KUNENADISCUSS_PENDING_MODERATOR_APPROVAL');
     } else {
         $result = JText::_('PLG_KUNENADISCUSS_MESSAGE_POSTED');
     }
     // Redirect
     $app = JFactory::getApplication('site');
     $app->redirect($uri->toString(), $result);
     return '';
 }