/** * Store ThankYou into the table * * @since 1.6 */ function setThankyou() { if (JRequest::checkToken('get') == false) { $this->_app->enqueueMessage(JText::_('COM_KUNENA_ERROR_TOKEN'), 'error'); while (@ob_end_clean()) { } $this->_app->redirect(CKunenaLink::GetMessageURL($this->pid, $this->catid, 0, false)); return; } if (!$this->my->id) { $this->_app->enqueueMessage(JText::_('COM_KUNENA_THANKYOU_LOGIN')); while (@ob_end_clean()) { } $this->_app->redirect(CKunenaLink::GetMessageURL($this->pid, $this->catid, 0, false)); } if (!$this->config->showthankyou) { $this->_app->enqueueMessage(JText::_('COM_KUNENA_THANKYOU_DISABLED')); $this->_app->redirect(CKunenaLink::GetMessageURL($this->pid, $this->catid, 0, false)); while (@ob_end_clean()) { } } require_once KPATH_SITE . '/lib/kunena.posting.class.php'; $post = new CKunenaPosting(); if (!$post->action($this->pid)) { $errors = $post->getErrors(); $this->_app->enqueueMessage(reset($post->getErrors())); while (@ob_end_clean()) { } $this->_app->redirect(CKunenaLink::GetMessageURL($this->pid, $this->catid, 0, false)); } $this->targetuserid = $post->get('userid'); //Check if the user already said thank you to this post if ($this->my->id == $this->targetuserid) { $this->_app->enqueueMessage(JText::_('COM_KUNENA_THANKYOU_NOT_YOURSELF')); while (@ob_end_clean()) { } $this->_app->redirect(CKunenaLink::GetMessageURL($this->pid, $this->catid, 0, false)); return; } $saidit = KunenaThankYou::checkIfThankYouAllready($this->pid, $this->my->id); if (!empty($saidit)) { $this->_app->enqueueMessage(JText::_('COM_KUNENA_THANKYOU_ALLREADY')); while (@ob_end_clean()) { } $this->_app->redirect(CKunenaLink::GetMessageURL($this->pid, $this->catid, 0, false)); return; } //Perform the insert if (KunenaThankYou::storeThankYou($this->pid, $this->my->id, $this->targetuserid) !== true) { KunenaError::checkDatabaseError(); } $activityIntegration = KunenaFactory::getActivityIntegration(); $activityIntegration->onAfterThankyou($this->targetuserid, $this->my->id, $post); $this->_app->enqueueMessage(JText::_('COM_KUNENA_THANKYOU_SUCCESS')); while (@ob_end_clean()) { } $this->_app->redirect(CKunenaLink::GetMessageURL($this->pid, $this->catid, 0, false)); }
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 post() { if ($this->isUserBanned()) { return false; } if ($this->isIPBanned()) { return false; } $this->fields['name'] = JRequest::getString('authorname', $this->getAuthorName()); $this->fields['email'] = JRequest::getString('email', null); $this->fields['subject'] = JRequest::getVar('subject', null, 'POST', 'string', JREQUEST_ALLOWRAW); $this->fields['message'] = JRequest::getVar('message', null, 'POST', 'string', JREQUEST_ALLOWRAW); $this->fields['topic_emoticon'] = JRequest::getInt('topic_emoticon', null); $this->options['attachments'] = 1; $this->options['anonymous'] = JRequest::getInt('anonymous', 0); $this->options['subscribe'] = JRequest::getVar('subscribeMe', ''); $contentURL = JRequest::getVar('contentURL', ''); // These store above data into session if ($this->tokenProtection()) { return false; } if ($this->floodProtection()) { return false; } $this->verifyCaptcha(); require_once KUNENA_PATH_LIB . '/kunena.posting.class.php'; $message = new CKunenaPosting(); if (!$this->id) { $success = $message->post($this->catid, $this->fields, $this->options); } else { $success = $message->reply($this->id, $this->fields, $this->options); } if ($success) { $success = $message->save(); } // Handle errors if (!$success) { $errors = $message->getErrors(); foreach ($errors as $field => $error) { $this->_app->enqueueMessage($field . ': ' . $error, 'error'); } $this->_app->setUserState('com_kunena.postfields', array('catid' => $this->catid, 'fields' => $this->fields, 'options' => $this->options)); $this->redirectBack(); } $catinfo = $message->parent; $userid = $message->get('userid'); $id = $message->get('id'); $thread = $message->get('thread'); $subject = $message->get('subject'); $holdPost = $message->get('hold'); $polltitle = JRequest::getString('poll_title', 0); $optionsnumbers = JRequest::getInt('number_total_options', ''); $polltimetolive = JRequest::getString('poll_time_to_live', 0); //Insert in the database the informations for the poll and the options for the poll $poll_exist = null; if (!empty($optionsnumbers) && !empty($polltitle)) { $poll_exist = "1"; //Begin Poll management options $poll_optionsID = JRequest::getVar('polloptionsID', array(), 'post', 'array'); $optvalue = array(); foreach ($poll_optionsID as $opt) { if (!empty($opt)) { $optvalue[] = $opt; } } if (!empty($optvalue)) { $this->poll->save_new_poll($polltimetolive, $polltitle, $id, $optvalue); } } // TODO: replace this with better solution $this->_db->setQuery("SELECT COUNT(*) AS totalmessages FROM #__kunena_messages WHERE thread={$this->_db->Quote($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, $thread, $threadPages, $this->config->messages_per_page, $id)); $message->emailToSubscribers($LastPostUrl, $this->config->allowsubscriptions && !$holdPost, $this->config->mailmod || $holdPost, $this->config->mailadmin || $holdPost); $redirectmsg = ''; $subscribeMe = JRequest::getVar('subscribeMe', ''); //now try adding any new subscriptions if asked for by the poster if ($subscribeMe == 1) { $this->_db->setQuery("INSERT INTO #__kunena_subscriptions (thread,userid) VALUES ({$this->_db->Quote($thread)},{$this->_db->Quote($this->my->id)})"); if (@$this->_db->query()) { $redirectmsg .= JText::_('COM_KUNENA_POST_SUBSCRIBED_TOPIC') . '<br />'; } else { $redirectmsg .= JText::_('COM_KUNENA_POST_NO_SUBSCRIBED_TOPIC') . '<br />'; } } if ($holdPost == 1) { $redirectmsg .= JText::_('COM_KUNENA_POST_SUCCES_REVIEW'); } else { $redirectmsg .= JText::_('COM_KUNENA_POST_SUCCESS_POSTED'); } while (@ob_end_clean()) { } $this->_app->redirect(CKunenaLink::GetMessageURL($id, $this->catid, 0, false), $redirectmsg); }