Exemple #1
0
 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);
 }
	protected function canPost($catid, $thread) {
		require_once (KPATH_SITE . '/lib/kunena.posting.class.php');
		$message = new CKunenaPosting ( );
		if ($thread) {
			return $message->reply ( $thread );
		} else {
			return $message->post ( $catid );
		}
	}
Exemple #3
0
 /**
  * process the plugin, called when form is submitted
  *
  * @param object $params
  * @param object form
  */
 function onBeforeStore(&$params, &$formModel)
 {
     jimport('joomla.filesystem.file');
     $files[] = COM_FABRIK_BASE . DS . 'components' . DS . 'com_kunena' . DS . 'class.kunena.php';
     $define = COM_FABRIK_BASE . DS . 'components' . DS . 'com_kunena' . DS . 'lib' . DS . 'kunena.defines.php';
     $files[] = COM_FABRIK_BASE . DS . 'components' . DS . 'com_kunena' . DS . 'lib' . DS . 'kunena.defines.php';
     $files[] = COM_FABRIK_BASE . DS . 'components' . DS . 'com_kunena' . DS . 'lib' . DS . 'kunena.link.class.php';
     $files[] = COM_FABRIK_BASE . DS . 'components' . DS . 'com_kunena' . DS . 'lib' . DS . 'kunena.link.class.php';
     if (!JFile::exists($define)) {
         JError::raiseError(500, 'could not find the Kunena component');
         return false;
     }
     require_once $define;
     foreach ($files as $file) {
         if (!JFile::exists($file)) {
             JError::raiseError(500, 'could not find the Kunena file: ' . $file);
             return false;
         }
         require_once $file;
     }
     $postfile = KUNENA_PATH_FUNCS . DS . 'post.php';
     $w = new FabrikWorker();
     if (!JFile::exists($postfile)) {
         JError::raiseError(500, "cant find post file");
         return false;
     }
     //new
     include_once COM_FABRIK_BASE . DS . 'components' . DS . 'com_kunena' . DS . 'lib' . DS . 'kunena.timeformat.class.php';
     if (file_exists(KUNENA_ABSTMPLTPATH . '/initialize.php')) {
         require_once KUNENA_ABSTMPLTPATH . '/initialize.php';
     } else {
         require_once KPATH_SITE . '/template/default/initialize.php';
     }
     // Kunena Current Template Icons Pack
     if (file_exists(KUNENA_ABSTMPLTPATH . '/icons.php')) {
         include KUNENA_ABSTMPLTPATH . '/icons.php';
     } else {
         include KUNENA_PATH_TEMPLATE_DEFAULT . DS . 'icons.php';
     }
     $kunena_session = KunenaFactory::getSession(true);
     //end new
     $catid = $params->get('kunena_category', 0);
     $msg = $w->parseMessageForPlaceHolder($params->get('kunena_content'), $formModel->_fullFormData);
     $subject = $params->get('kunena_title');
     $subject = $w->parseMessageForPlaceHolder($subject, $formModel->_fullFormData);
     include $postfile;
     $page = new CKunenaPost();
     require_once KUNENA_PATH_LIB . DS . 'kunena.posting.class.php';
     $message = new CKunenaPosting();
     $user =& JFactory::getUser();
     $fields['name'] = $user->guest ? 'Annonymous' : $user->get('name');
     $fields['email'] = $user->guest ? '*****@*****.**' : $user->get('email');
     $fields['subject'] = $subject;
     $fields['message'] = $msg;
     $fields['topic_emoticon'] = JRequest::getInt('topic_emoticon', null);
     $options['attachments'] = 1;
     $options['anonymous'] = 0;
     $lang =& JFactory::getLanguage();
     $lang->load('com_kunena');
     $success = $message->post($catid, $fields, $options);
     // Handle errors
     if (!$success) {
         $errors = $message->getErrors();
         foreach ($errors as $field => $error) {
             JError::raiseNotice(500, "{$field}: {$error}");
             return false;
         }
     } else {
         $success = $message->save();
         // Handle errors
         if (!$success) {
             $errors = $message->getErrors();
             foreach ($errors as $field => $error) {
                 JError::raiseNotice(500, "{$field}: {$error}");
                 return false;
             }
         }
     }
 }