public function ApproveMessage() { if ($this->_checkToken()) { return false; } $array = JRequest::getVar('cb', array(0), 'post', 'array'); $backUrl = JRequest::getVar('HTTP_REFERER', JURI::base(true), 'server'); $success = 0; require_once KUNENA_PATH_LIB . '/kunena.posting.class.php'; foreach ($array as $id => $value) { if (!$value) { continue; } $message = new CKunenaPosting(); $message->action($id); if (!$message->canApprove()) { $errors = $message->getErrors(); foreach ($errors as $field => $error) { $this->_app->enqueueMessage($field . ': ' . $error, 'error'); } continue; } $this->_db->setQuery("UPDATE `#__kunena_messages` SET hold='0' WHERE id={$this->_db->Quote($id)}"); $this->_db->query(); if (KunenaError::checkDatabaseError()) { return; } CKunenaTools::modifyCategoryStats($message->get('id'), $message->get('parent'), $message->get('time'), $message->get('catid')); $message->emailToSubscribers(null, $this->config->allowsubscriptions, false, false); $success++; } //end foreach if ($success) { $this->app->enqueueMessage(JText::_('COM_KUNENA_MODERATE_APPROVE_SUCCESS'), 'notice'); } while (@ob_end_clean()) { } $this->app->redirect($backUrl); }
protected function replyTopic($row, $catid, $thread, $subject) { if (JRequest::checkToken () == false) { $this->_app->enqueueMessage ( JText::_ ( 'COM_KUNENA_ERROR_TOKEN' ), 'error' ); return false; } $this->isBanned(); $this->verifyCaptcha(); $this->checkFlood(); require_once (KPATH_SITE . '/lib/kunena.posting.class.php'); if (intval ( $thread ) == 0) { $thread = $this->createTopic ( $row, $catid, $subject ); } $message = new CKunenaPosting ( ); $myprofile = KunenaFactory::getUser(); $fields ['name'] = JRequest::getString ( 'name', $myprofile->getName (), 'POST' ); $fields ['email'] = JRequest::getString ( 'email', null, 'POST' ); $fields ['subject'] = $subject; $fields ['message'] = JRequest::getString ( 'message', null, 'POST' ); $success = $message->reply ( $thread, $fields ); if ($success) { $newMessageId = $message->save (); } // Handle errors if (! $success || ! $newMessageId) { $errors = $message->getErrors (); foreach ( $errors as $field => $error ) { $this->_app->enqueueMessage ( $field . ': ' . $error, 'error' ); } return false; } $config = KunenaFactory::getConfig(); $holdPost = $message->get ( 'hold' ); require_once (KPATH_SITE . '/lib/kunena.link.class.php'); $message->emailToSubscribers(false, $config->allowsubscriptions && ! $holdPost, $config->mailmod || $holdPost, $config->mailadmin || $holdPost); if ($holdPost) { $result = JText::_ ( 'PLG_KUNENADISCUSS_PENDING_MODERATOR_APPROVAL' ); } else { $result = JText::_ ( 'PLG_KUNENADISCUSS_MESSAGE_POSTED' ); } // Redirect $uri = JFactory::getURI (); $app = JFactory::getApplication ( 'site' ); $app->redirect ( $uri->toString (), $result ); }
protected function approve() { if ($this->tokenProtection('get')) { return false; } if (!$this->load()) { return false; } if ($this->moderatorProtection()) { return false; } if ($this->isUserBanned()) { return false; } if ($this->isIPBanned()) { return false; } require_once KUNENA_PATH_LIB . '/kunena.posting.class.php'; $message = new CKunenaPosting(); $message->action($this->id); if ($message->canApprove()) { $success_msg = JText::_('COM_KUNENA_MODERATE_1APPROVE_FAIL'); $this->_db->setQuery("UPDATE #__kunena_messages SET hold=0 WHERE id={$this->_db->Quote($this->id)}"); if ($this->id && $this->_db->query() && $this->_db->getAffectedRows() == 1) { $success_msg = JText::_('COM_KUNENA_MODERATE_APPROVE_SUCCESS'); $this->_db->setQuery("SELECT COUNT(*) AS totalmessages FROM #__kunena_messages WHERE thread={$this->_db->Quote($this->msg_cat->thread)}"); $result = $this->_db->loadObject(); KunenaError::checkDatabaseError(); $threadPages = ceil($result->totalmessages / $this->config->messages_per_page); //construct a useable URL (for plaintext - so no & encoding!) jimport('joomla.environment.uri'); $uri =& JURI::getInstance(JURI::base()); $LastPostUrl = $uri->toString(array('scheme', 'host', 'port')) . str_replace('&', '&', CKunenaLink::GetThreadPageURL('view', $this->catid, $this->msg_cat->thread, $threadPages, $this->config->messages_per_page, $this->id)); $message->emailToSubscribers($LastPostUrl, $this->config->allowsubscriptions, $this->config->mailmod, $this->config->mailadmin); CKunenaTools::modifyCategoryStats($this->id, $this->msg_cat->parent, $this->msg_cat->time, $this->msg_cat->catid); } } while (@ob_end_clean()) { } $this->_app->redirect(CKunenaLink::GetMessageURL($this->id, $this->catid, 0, false), $success_msg); }