/** * @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 ''; }
/** * Event handler to re-parse request URI. * * @return void */ public function onAfterRoute() { // Get installed Joomla version $JVersion = new JVersion(); $JVersion = $JVersion->getShortVersion(); $option = trim((string) $this->option); if (self::$_app->isAdmin() && version_compare($JVersion, '3.0', '>=') && in_array($option, JSNVersion::$products)) { $manifestFile = JPATH_ADMINISTRATOR . '/components/' . $option . '/' . str_replace('com_', '', $option) . '.xml'; if (file_exists($manifestFile)) { $xml = JSNUtilsXml::load($manifestFile); $attr = $xml->attributes(); if (count($attr)) { if (isset($attr['version']) && (string) $attr['version'] != '') { $version = (string) $attr['version']; if ($option == 'com_imageshow') { $version = str_replace('.x', '.0', $version); } if (version_compare($version, '3.0', '<')) { // Check if all JSN Extensions are compatible with Joomla 3.x, if not, redirect to index.php and show a warning message self::$_app->enqueueMessage(JText::sprintf('You are running a Joomla 2.5 version of %1$s on Joomla 3.x. Please download %1$s for Joomla 3.x and reinstall via Joomla! Installer to fix the problem.', 'JSN ' . ucfirst(str_replace('com_', '', $option))), 'warning'); self::$_app->redirect('index.php'); return false; } } } } } // Make sure our onAfterRender event handler is the last one executed self::$_app->registerEvent('onAfterRender', 'jsnExtFrameworkFinalize'); }
/** * @return bool */ protected function verifyCaptcha() { $captcha = KunenaSpamRecaptcha::getInstance(); $result = $captcha->verify(); if (!$result) { $this->app->enqueueMessage($captcha->getError()); } return $result; }
/** * Enqueues into the session a message to display on next displayed page * * @param string $message HTML message to display * @param string $messageType Message type ('message' or 'error') */ function enqueueMessage($message = null, $messageType = 'message') { if (trim($message) != '') { if (method_exists($this->_baseFramework, 'enqueueMessage')) { $this->_baseFramework->enqueueMessage($message, $messageType); } else { echo '<div class="' . htmlspecialchars($messageType) . '">' . $message . '</div>'; } } }
/** * Sends message if possible * * @param type $context * @param type $article * @param type $isNew * @return type */ public function onContentAfterSave($context, &$article, $isNew) { if (0 !== strpos($context, 'com_content')) { return; } $message = $this->session->get('asar.message'); if (!empty($message)) { $this->app->enqueueMessage($message); $this->session->clear('asar.message'); } }