Ejemplo n.º 1
0
 /**
  * Prepare report message form.
  *
  * @return void
  *
  * @throws KunenaExceptionAuthorise
  */
 protected function before()
 {
     parent::before();
     $id = $this->input->getInt('id');
     $mesid = $this->input->getInt('mesid');
     $me = KunenaUserHelper::getMyself();
     if (!$this->config->reportmsg) {
         // Deny access if report feature has been disabled.
         throw new KunenaExceptionAuthorise(JText::_('COM_KUNENA_NO_ACCESS'), 404);
     }
     if (!$me->exists()) {
         // Deny access if user is guest.
         throw new KunenaExceptionAuthorise(JText::_('COM_KUNENA_NO_ACCESS'), 401);
     }
     if (!$mesid) {
         $this->topic = KunenaForumTopicHelper::get($id);
         $this->topic->tryAuthorise();
     } else {
         $this->message = KunenaForumMessageHelper::get($mesid);
         $this->message->tryAuthorise();
         $this->topic = $this->message->getTopic();
     }
     $this->category = $this->topic->getCategory();
     $this->uri = "index.php?option=com_kunena&view=topic&layout=report&catid={$this->category->id}" . "&id={$this->topic->id}" . ($this->message ? "&mesid={$this->message->id}" : '');
 }
Ejemplo n.º 2
0
 public function getTopic()
 {
     if ($this->topic === false) {
         $mesid = $this->getState('item.mesid');
         if ($mesid) {
             // Find actual topic by fetching current message
             $message = KunenaForumMessageHelper::get($mesid);
             $topic = KunenaForumTopicHelper::get($message->thread);
             $this->setState('list.start', intval($topic->getPostLocation($mesid) / $this->getState('list.limit')) * $this->getState('list.limit'));
         } else {
             $topic = KunenaForumTopicHelper::get($this->getState('item.id'));
             $ids = array();
             // If topic has been moved, find the new topic
             while ($topic->moved_id) {
                 if (isset($ids[$topic->moved_id])) {
                     // Break on loops
                     return false;
                 }
                 $ids[$topic->moved_id] = 1;
                 $topic = KunenaForumTopicHelper::get($topic->moved_id);
             }
             // If topic doesn't exist, check if there's a message with the same id
             /*if (! $topic->exists()) {
             			$message = KunenaForumMessageHelper::get($this->getState ( 'item.id'));
             			if ($message->exists()) {
             				$topic = KunenaForumTopicHelper::get($message->thread);
             			}
             		}*/
         }
         $this->topic = $topic;
     }
     return $this->topic;
 }
Ejemplo n.º 3
0
	public function check() {
		$user = KunenaUserHelper::get($this->userid);
		$message = KunenaForumMessageHelper::get($this->mesid);
		if ($this->userid != 0 && !$user->exists()) {
			$this->setError(JText::sprintf('COM_KUNENA_LIB_TABLE_ATTACHMENTS_ERROR_USER_INVALID', (int) $user->userid));
		}
		if (!$message->exists()) {
			$this->setError(JText::sprintf('COM_KUNENA_LIB_TABLE_ATTACHMENTS_ERROR_MESSAGE_INVALID', (int) $message->id));
		}
		$this->folder = trim($this->folder, '/');
		if (!$this->folder) {
			$this->setError(JText::_('COM_KUNENA_LIB_TABLE_ATTACHMENTS_ERROR_NO_FOLDER'));
		}
		if (!$this->filename) {
			$this->setError(JText::_('COM_KUNENA_LIB_TABLE_ATTACHMENTS_ERROR_NO_FILENAME'));
		}
		$file = JPATH_ROOT . "/{$this->folder}/{$this->filename}";
		if (!file_exists($file)) {
			$this->setError(JText::sprintf('COM_KUNENA_LIB_TABLE_ATTACHMENTS_ERROR_FILE_MISSING', "{$this->folder}/{$this->filename}"));
		} else {
			if (!$this->hash) $this->hash = md5_file ( $file );
			if (!$this->size) $this->size = filesize ( $file );
		}
		return ($this->getError () == '');
	}
Ejemplo n.º 4
0
 /**
  * Prepare topic reply form.
  *
  * @return void
  *
  * @throws RuntimeException
  * @throws KunenaExceptionAuthorise
  */
 protected function before()
 {
     parent::before();
     $catid = $this->input->getInt('catid');
     $id = $this->input->getInt('id');
     $mesid = $this->input->getInt('mesid');
     $quote = $this->input->getBool('quote', false);
     $saved = $this->app->getUserState('com_kunena.postfields');
     $this->me = KunenaUserHelper::getMyself();
     $this->template = KunenaFactory::getTemplate();
     if (!$mesid) {
         $this->topic = KunenaForumTopicHelper::get($id);
         $parent = KunenaForumMessageHelper::get($this->topic->first_post_id);
     } else {
         $parent = KunenaForumMessageHelper::get($mesid);
         $this->topic = $parent->getTopic();
     }
     $this->category = $this->topic->getCategory();
     if ($parent->isAuthorised('reply') && $this->me->canDoCaptcha()) {
         if (JPluginHelper::isEnabled('captcha')) {
             $plugin = JPluginHelper::getPlugin('captcha');
             $params = new JRegistry($plugin[0]->params);
             $captcha_pubkey = $params->get('public_key');
             $catcha_privkey = $params->get('private_key');
             if (!empty($captcha_pubkey) && !empty($catcha_privkey)) {
                 JPluginHelper::importPlugin('captcha');
                 $dispatcher = JDispatcher::getInstance();
                 $result = $dispatcher->trigger('onInit', 'dynamic_recaptcha_1');
                 $this->captchaEnabled = $result[0];
             }
         } else {
             $this->captchaEnabled = false;
         }
     }
     $parent->tryAuthorise('reply');
     // Run event.
     $params = new JRegistry();
     $params->set('ksource', 'kunena');
     $params->set('kunena_view', 'topic');
     $params->set('kunena_layout', 'reply');
     $dispatcher = JDispatcher::getInstance();
     JPluginHelper::importPlugin('kunena');
     $dispatcher->trigger('onKunenaPrepare', array('kunena.topic', &$this->topic, &$params, 0));
     // Can user edit topic icons?
     if ($this->config->topicicons && $this->topic->isAuthorised('edit')) {
         $this->topicIcons = $this->template->getTopicIcons(false, $saved ? $saved['icon_id'] : $this->topic->icon_id);
     }
     list($this->topic, $this->message) = $parent->newReply($saved ? $saved : $quote);
     $this->action = 'post';
     $this->allowedExtensions = KunenaAttachmentHelper::getExtensions($this->category);
     $this->post_anonymous = $saved ? $saved['anonymous'] : !empty($this->category->post_anonymous);
     $this->subscriptionschecked = $saved ? $saved['subscribe'] : $this->config->subscriptionschecked == 1;
     $this->app->setUserState('com_kunena.postfields', null);
     $this->canSubscribe = $this->canSubscribe();
     $this->headerText = JText::_('COM_KUNENA_BUTTON_MESSAGE_REPLY') . ' ' . $this->topic->subject;
 }
Ejemplo n.º 5
0
 /**
  * Redirect unread layout to the page that contains the first unread message.
  *
  * @return void
  *
  * @throws KunenaExceptionAuthorise
  */
 protected function before()
 {
     $catid = $this->input->getInt('catid', 0);
     $id = $this->input->getInt('id', 0);
     $category = KunenaForumCategoryHelper::get($catid);
     $category->tryAuthorise();
     $topic = KunenaForumTopicHelper::get($id);
     $topic->tryAuthorise();
     KunenaForumTopicHelper::fetchNewStatus(array($topic->id => $topic));
     $message = KunenaForumMessageHelper::get($topic->lastread ? $topic->lastread : $topic->last_post_id);
     $message->tryAuthorise();
     while (@ob_end_clean()) {
     }
     $this->app->redirect($topic->getUrl($category, false, $message));
 }
Ejemplo n.º 6
0
 /**
  * Prepare topic moderate display.
  *
  * @return void
  *
  * @throws KunenaExceptionAuthorise
  */
 protected function before()
 {
     parent::before();
     $catid = $this->input->getInt('catid');
     $id = $this->input->getInt('id');
     $mesid = $this->input->getInt('mesid');
     if (!$mesid) {
         $this->topic = KunenaForumTopicHelper::get($id);
         $this->topic->tryAuthorise('move');
     } else {
         $this->message = KunenaForumMessageHelper::get($mesid);
         $this->message->tryAuthorise('move');
         $this->topic = $this->message->getTopic();
     }
     $this->category = $this->topic->getCategory();
     $this->uri = "index.php?option=com_kunena&view=topic&layout=moderate" . "&catid={$this->category->id}&id={$this->topic->id}" . ($this->message ? "&mesid={$this->message->id}" : '');
     $this->title = !$this->message ? JText::_('COM_KUNENA_TITLE_MODERATE_TOPIC') : JText::_('COM_KUNENA_TITLE_MODERATE_MESSAGE');
     // Load topic icons if available.
     if ($this->config->topicicons) {
         $this->template = KunenaTemplate::getInstance();
         $this->template->setCategoryIconset();
         $this->topicIcons = $this->template->getTopicIcons(false);
     }
     // Have a link to moderate user as well.
     if (isset($this->message)) {
         $user = $this->message->getAuthor();
         if ($user->exists()) {
             $username = $user->getName();
             $this->userLink = $this->message->userid ? JHtml::_('kunenaforum.link', 'index.php?option=com_kunena&view=user&layout=moderate&userid=' . $this->message->userid, $username . ' (' . $this->message->userid . ')', $username . ' (' . $this->message->userid . ')') : null;
         }
     }
     if ($this->message) {
         $this->banHistory = KunenaUserBan::getUserHistory($this->message->userid);
         $this->me = KunenaFactory::getUser();
         // Get thread and reply count from current message:
         $db = JFactory::getDbo();
         $query = "SELECT COUNT(mm.id) AS replies FROM #__kunena_messages AS m\r\n\t\t\t\tINNER JOIN #__kunena_messages AS t ON m.thread=t.id\r\n\t\t\t\tLEFT JOIN #__kunena_messages AS mm ON mm.thread=m.thread AND mm.time > m.time\r\n\t\t\t\tWHERE m.id={$db->Quote($this->message->id)}";
         $db->setQuery($query, 0, 1);
         $this->replies = $db->loadResult();
         if (KunenaError::checkDatabaseError()) {
             return;
         }
     }
     $this->banInfo = KunenaUserBan::getInstanceByUserid(JFactory::getUser()->id, true);
 }
Ejemplo n.º 7
0
 /**
  * Prepare topic edit form.
  *
  * @return void
  *
  * @throws KunenaExceptionAuthorise
  */
 protected function before()
 {
     parent::before();
     $this->catid = $this->input->getInt('catid');
     $mesid = $this->input->getInt('mesid');
     $saved = $this->app->getUserState('com_kunena.postfields');
     $this->me = KunenaUserHelper::getMyself();
     $this->template = KunenaFactory::getTemplate();
     $this->message = KunenaForumMessageHelper::get($mesid);
     $this->message->tryAuthorise('edit');
     $this->topic = $this->message->getTopic();
     $this->category = $this->topic->getCategory();
     $this->template->setCategoryIconset($this->topic->getCategory()->iconset);
     if ($this->config->topicicons && $this->topic->isAuthorised('edit')) {
         $this->topicIcons = $this->template->getTopicIcons(false, $saved ? $saved['icon_id'] : $this->topic->icon_id);
     }
     // Run onKunenaPrepare event.
     $params = new JRegistry();
     $params->set('ksource', 'kunena');
     $params->set('kunena_view', 'topic');
     $params->set('kunena_layout', 'reply');
     $dispatcher = JEventDispatcher::getInstance();
     JPluginHelper::importPlugin('kunena');
     $dispatcher->trigger('onKunenaPrepare', array('kunena.topic', &$this->topic, &$params, 0));
     $this->action = 'edit';
     // Get attachments.
     $this->attachments = $this->message->getAttachments();
     // Get poll.
     if ($this->message->parent == 0 && $this->topic->isAuthorised(!$this->topic->poll_id ? 'poll.create' : 'poll.edit')) {
         $this->poll = $this->topic->getPoll();
     }
     $this->allowedExtensions = KunenaAttachmentHelper::getExtensions($this->category);
     if ($saved) {
         // Update message contents.
         $this->message->edit($saved);
     }
     $this->post_anonymous = isset($saved['anonymous']) ? $saved['anonymous'] : !empty($this->category->post_anonymous);
     $this->subscriptionschecked = isset($saved['subscribe']) ? $saved['subscribe'] : $this->config->subscriptionschecked == 1;
     $this->modified_reason = isset($saved['modified_reason']) ? $saved['modified_reason'] : '';
     $this->app->setUserState('com_kunena.postfields', null);
     $this->canSubscribe = $this->canSubscribe();
     $this->headerText = JText::_('COM_KUNENA_POST_EDIT') . ' ' . $this->topic->subject;
 }
Ejemplo n.º 8
0
 /**
  * @return KunenaForumMessage
  */
 public function getParent()
 {
     return KunenaForumMessageHelper::get($this->parent);
 }
Ejemplo n.º 9
0
	public function getTopic() {
		$topic = KunenaForumTopicHelper::get($this->getState ( 'item.id'));
		$ids = array();
		// If topic has been moved, find the new topic
		while ($topic->moved_id) {
			if (isset($ids[$topic->moved_id])) {
				// Break on loops
				return false;
			}
			$ids[$topic->moved_id] = 1;
			$topic = KunenaForumTopicHelper::get($topic->moved_id);
		}
		// If topic doesn't exist, check if there's a message with the same id
		if (! $topic->exists()) {
			$message = KunenaForumMessageHelper::get($this->getState ( 'item.id'));
			if ($message->exists()) {
				$topic = KunenaForumTopicHelper::get($message->thread);
			}
		}
		$this->topic = $topic;
		return $topic;
	}
Ejemplo n.º 10
0
 public static function convert($uri, $showstart = 1)
 {
     // Make sure that input is JUri to legacy Kunena func=xxx
     if (!$uri instanceof JUri) {
         return;
     }
     if ($uri->getVar('option') != 'com_kunena') {
         return;
     }
     KUNENA_PROFILER ? KunenaProfiler::instance()->start('function ' . __CLASS__ . '::' . __FUNCTION__ . '()') : null;
     if ($uri->getVar('func')) {
         $uri->setVar('view', $uri->getVar('func'));
         $uri->delVar('func');
     }
     if (!isset(self::$functions[$uri->getVar('view')])) {
         KUNENA_PROFILER ? KunenaProfiler::instance()->stop('function ' . __CLASS__ . '::' . __FUNCTION__ . '()') : null;
         return;
     }
     $legacy = clone $uri;
     // Turn &do=xxx into &layout=xxx
     if ($uri->getVar('do')) {
         $uri->setVar('layout', $uri->getVar('do'));
         $uri->delVar('do');
     }
     $app = JFactory::getApplication();
     $config = KunenaFactory::getConfig();
     $changed = false;
     switch ($uri->getVar('view')) {
         case 'entrypage':
             $changed = true;
             $uri->setVar('view', 'home');
             break;
         case 'listcat':
             $changed = true;
             $uri->setVar('view', 'category');
             $uri->setVar('layout', 'list');
             break;
         case 'showcat':
             $changed = true;
             $uri->setVar('view', 'category');
             $page = (int) $uri->getVar('page', $showstart);
             if ($page > 0) {
                 $uri->setVar('limitstart', (int) $config->messages_per_page * ($page - 1));
                 $uri->setVar('limit', (int) $config->messages_per_page);
             }
             $uri->delVar('page');
             break;
         case 'latest':
         case 'mylatest':
         case 'noreplies':
         case 'subscriptions':
         case 'favorites':
         case 'userposts':
         case 'unapproved':
         case 'deleted':
             $changed = true;
             $uri->setVar('view', 'topics');
             // Handle both &func=noreplies and &func=latest&do=noreplies
             $mode = $uri->getVar('layout') ? $uri->getVar('layout') : $uri->getVar('view');
             switch ($mode) {
                 case 'latest':
                     $uri->setVar('layout', 'default');
                     $uri->setVar('mode', 'replies');
                     break;
                 case 'unapproved':
                     $uri->setVar('layout', 'default');
                     $uri->setVar('mode', 'unapproved');
                     break;
                 case 'deleted':
                     $uri->setVar('layout', 'default');
                     $uri->setVar('mode', 'deleted');
                     break;
                 case 'noreplies':
                     $uri->setVar('layout', 'default');
                     $uri->setVar('mode', 'noreplies');
                     break;
                 case 'latesttopics':
                     $uri->setVar('layout', 'default');
                     $uri->setVar('mode', 'topics');
                     break;
                 case 'mylatest':
                     $uri->setVar('layout', 'user');
                     $uri->setVar('mode', 'default');
                     break;
                 case 'subscriptions':
                     $uri->setVar('layout', 'user');
                     $uri->setVar('mode', 'subscriptions');
                     break;
                 case 'favorites':
                     $uri->setVar('layout', 'user');
                     $uri->setVar('mode', 'favorites');
                     break;
                 case 'owntopics':
                     $uri->setVar('layout', 'user');
                     $uri->setVar('mode', 'started');
                     break;
                 case 'userposts':
                     $uri->setVar('userid', '0');
                     // Continue in latestposts
                 // Continue in latestposts
                 case 'latestposts':
                     $uri->setVar('layout', 'posts');
                     $uri->setVar('mode', 'recent');
                     break;
                 case 'saidthankyouposts':
                     $uri->setVar('layout', 'posts');
                     $uri->setVar('mode', 'mythanks');
                     break;
                 case 'gotthankyouposts':
                     $uri->setVar('layout', 'posts');
                     $uri->setVar('mode', 'thankyou');
                     break;
                 case 'catsubscriptions':
                     $uri->setVar('view', 'category');
                     $uri->setVar('layout', 'user');
                     break;
                 default:
                     $uri->setVar('layout', 'default');
                     $uri->setVar('mode', 'replies');
             }
             $page = (int) $uri->getVar('page', $showstart);
             if ($page > 0) {
                 $uri->setVar('limitstart', (int) $config->threads_per_page * ($page - 1));
                 $uri->setVar('limit', (int) $config->threads_per_page);
             }
             $uri->delVar('page');
             break;
         case 'view':
             $changed = true;
             $uri->setVar('view', 'topic');
             // Convert URI to have both id and mesid
             $id = $uri->getVar('id');
             $message = KunenaForumMessageHelper::get($id);
             $mesid = $uri->getVar('mesid');
             if ($message->exists()) {
                 $id = $message->thread;
                 if ($id != $message->id) {
                     $mesid = $message->id;
                 }
             }
             if ($id) {
                 $uri->setVar('id', $id);
             }
             if ($mesid) {
                 $uri->setVar('mesid', $mesid);
             }
             break;
         case 'moderateuser':
             if ($uri->getVar('view') == 'moderateuser') {
                 $uri->setVar('layout', 'moderate');
             }
             // Continue to user profile
         // Continue to user profile
         case 'myprofile':
         case 'userprofile':
         case 'fbprofile':
         case 'profile':
             $changed = true;
             $uri->setVar('view', 'user');
             if ($uri->getVar('task')) {
                 $app->enqueueMessage(JText::_('COM_KUNENA_DEPRECATED_ACTION'), 'error');
                 $uri->delVar('task');
             }
             // Handle &do=xxx
             switch ($uri->getVar('layout')) {
                 case 'edit':
                     $uri->setVar('layout', 'edit');
                     break;
                 case 'moderate':
                     $uri->setVar('layout', 'moderate');
                     break;
                 default:
                     $uri->delVar('layout');
                     break;
             }
             break;
         case 'report':
             $changed = true;
             $uri->setVar('view', 'topic');
             $uri->setVar('layout', 'report');
             // Convert URI to have both id and mesid
             $id = $uri->getVar('id');
             $message = KunenaForumMessageHelper::get($id);
             $mesid = null;
             if ($message->exists()) {
                 $id = $message->thread;
                 if ($id != $message->id) {
                     $mesid = $message->id;
                 }
             }
             if ($id) {
                 $uri->setVar('id', $id);
             }
             if ($mesid) {
                 $uri->setVar('mesid', $mesid);
             }
             break;
         case 'userlist':
             $changed = true;
             $uri->setVar('view', 'user');
             $uri->setVar('layout', 'list');
             break;
         case 'rss':
             $changed = true;
             $uri->setVar('view', 'topics');
             $mode = $config->rss_type;
             switch ($mode) {
                 case 'topic':
                     $uri->setVar('layout', 'default');
                     $uri->setVar('mode', 'topics');
                     break;
                 case 'recent':
                     $uri->setVar('layout', 'default');
                     $uri->setVar('mode', 'replies');
                     break;
                 case 'post':
                 default:
                     $uri->setVar('layout', 'posts');
                     $uri->setVar('mode', 'latest');
                     break;
             }
             switch ($config->rss_timelimit) {
                 case 'week':
                     $uri->setVar('sel', 168);
                     break;
                 case 'year':
                     $uri->setVar('sel', 8760);
                     break;
                 case 'month':
                 default:
                     $uri->setVar('sel', 720);
                     break;
             }
             $uri->setVar('type', 'rss');
             $uri->setVar('format', 'feed');
             break;
         case 'post':
             $changed = true;
             $uri->setVar('view', 'topic');
             // Support old &parentid=123 and &replyto=123 variables
             $id = $uri->getVar('id');
             if (!$id) {
                 $id = $uri->getVar('parentid');
                 $uri->delVar('parentid');
             }
             if (!$id) {
                 $id = $uri->getVar('replyto');
                 $uri->delVar('replyto');
             }
             // Convert URI to have both id and mesid
             $message = KunenaForumMessageHelper::get($id);
             $mesid = null;
             if ($message->exists()) {
                 $id = $message->thread;
                 if ($id != $message->id) {
                     $mesid = $message->id;
                 }
             }
             if ($id) {
                 $uri->setVar('id', $id);
             }
             if ($mesid) {
                 $uri->setVar('mesid', $mesid);
             }
             if ($uri->getVar('action')) {
                 $app->enqueueMessage(JText::_('COM_KUNENA_DEPRECATED_ACTION'), 'error');
                 $uri->delVar('action');
             } else {
                 // Handle &do=xxx
                 $layout = $uri->getVar('layout');
                 $uri->delVar('layout');
                 switch ($layout) {
                     // Create, reply, quote and edit:
                     case 'new':
                         $uri->setVar('layout', 'create');
                         $uri->delVar('id');
                         $uri->delVar('mesid');
                         break;
                     case 'quote':
                         $uri->setVar('layout', 'reply');
                         $uri->setVar('quote', 1);
                         break;
                     case 'reply':
                         $uri->setVar('layout', 'reply');
                         break;
                     case 'edit':
                         $uri->setVar('layout', 'edit');
                         // Always add &mesid=x
                         if (!$mesid) {
                             $uri->setVar('mesid', $id);
                         }
                         break;
                         // Topic moderation:
                     // Topic moderation:
                     case 'moderatethread':
                         $uri->setVar('layout', 'moderate');
                         // Always remove &mesid=x
                         $uri->delVar('mesid');
                         break;
                     case 'deletethread':
                         $uri->setVar('task', 'delete');
                         // Always remove &mesid=x
                         $uri->delVar('mesid');
                         break;
                     case 'sticky':
                         $uri->setVar('task', 'sticky');
                         // Always remove &mesid=x
                         $uri->delVar('mesid');
                         break;
                     case 'unsticky':
                         $uri->setVar('task', 'unsticky');
                         // Always remove &mesid=x
                         $uri->delVar('mesid');
                         break;
                     case 'lock':
                         $uri->setVar('task', 'lock');
                         // Always remove &mesid=x
                         $uri->delVar('mesid');
                         break;
                     case 'unlock':
                         $uri->setVar('task', 'unlock');
                         // Always remove &mesid=x
                         $uri->delVar('mesid');
                         break;
                         // Message moderator actions:
                     // Message moderator actions:
                     case 'moderate':
                         $uri->setVar('layout', 'moderate');
                         // Always add &mesid=x
                         if (!$mesid) {
                             $uri->setVar('mesid', $id);
                         }
                         break;
                     case 'approve':
                         $uri->setVar('task', 'approve');
                         // Always add &mesid=x
                         if (!$mesid) {
                             $uri->setVar('mesid', $id);
                         }
                         break;
                     case 'delete':
                         $uri->setVar('task', 'delete');
                         // Always add &mesid=x
                         if (!$mesid) {
                             $uri->setVar('mesid', $id);
                         }
                         break;
                     case 'undelete':
                         $uri->setVar('task', 'undelete');
                         // Always add &mesid=x
                         if (!$mesid) {
                             $uri->setVar('mesid', $id);
                         }
                         break;
                     case 'permdelete':
                         $uri->setVar('task', 'permdelete');
                         // Always add &mesid=x
                         if (!$mesid) {
                             $uri->setVar('mesid', $id);
                         }
                         break;
                         // Topic user actions:
                     // Topic user actions:
                     case 'subscribe':
                         $uri->setVar('task', 'subscribe');
                         // Always remove &mesid=x
                         $uri->delVar('mesid');
                         break;
                     case 'unsubscribe':
                         $uri->setVar('task', 'unsubscribe');
                         // Always remove &mesid=x
                         $uri->delVar('mesid');
                         break;
                     case 'favorite':
                         $uri->setVar('task', 'favorite');
                         // Always remove &mesid=x
                         $uri->delVar('mesid');
                         break;
                     case 'unfavorite':
                         $uri->setVar('task', 'unfavorite');
                         // Always remove &mesid=x
                         $uri->delVar('mesid');
                         break;
                     default:
                         $app->enqueueMessage(JText::_('COM_KUNENA_DEPRECATED_ACTION'), 'error');
                 }
             }
             break;
         case 'stats':
             $changed = true;
             $uri->setVar('view', 'statistics');
             break;
         case 'search':
         case 'advsearch':
             $changed = true;
             $uri->setVar('view', 'search');
             break;
         case 'poll':
             $changed = true;
             $uri->setVar('view', 'topic');
             // Handle &do=xxx
             switch ($uri->getVar('layout')) {
                 case 'changevote':
                     $uri->setVar('layout', 'vote');
                     break;
             }
             break;
         case 'review':
             $changed = true;
             $uri->setVar('view', 'topics');
             $uri->setVar('layout', 'posts');
             $uri->setVar('mode', 'unapproved');
             $uri->setVar('userid', 0);
             $uri->delVar('action');
             break;
         case 'announcement':
             switch ($uri->getVar('layout')) {
                 case 'read':
                     $changed = true;
                     $uri->delVar('layout');
                     break;
                 case 'show':
                     $changed = true;
                     $uri->setVar('layout', 'list');
                     break;
                 case 'add':
                     $changed = true;
                     $uri->setVar('layout', 'create');
                     break;
                 case 'edit':
                     $changed = false;
                     break;
                 case 'doedit':
                     $changed = true;
                     $uri->delVar('layout');
                     $uri->setVar('task', 'edit');
                     break;
                 case 'delete':
                     $changed = true;
                     $uri->delVar('layout');
                     $uri->setVar('task', 'delete');
                     break;
             }
             break;
         case 'thankyou':
             // Convert URI to have both id and mesid
             $id = $uri->getVar('pid');
             if ($id) {
                 $changed = true;
                 $uri->setVar('view', 'topic');
                 $uri->setVar('task', 'thankyou');
                 $uri->delVar('pid');
                 $message = KunenaForumMessageHelper::get($id);
                 if ($message->exists()) {
                     $id = $message->thread;
                     $uri->setVar('mesid', $message->id);
                 }
                 $uri->setVar('id', $id);
             }
             break;
         case 'karma':
             $changed = true;
             $uri->setVar('view', 'user');
             switch ($uri->getVar('layout')) {
                 case 'increase':
                     $uri->setVar('task', 'karmaup');
                     break;
                 case 'decrease':
                     $uri->setVar('task', 'karmadown');
                     break;
             }
             $uri->delVar('layout');
             $uri->delVar('pid');
             break;
         case 'template':
             $changed = true;
             $uri->setVar('view', 'misc');
             $uri->setVar('task', 'template');
             break;
         case 'rules':
         case 'help':
             $changed = true;
             $uri->setVar('view', 'misc');
             $uri->delVar('layout');
             break;
     }
     if ($changed) {
         JLog::add("Legacy URI {$legacy->toString(array('path', 'query'))} was converted to {$uri->toString(array('path', 'query'))}", JLog::DEBUG, 'kunena');
     }
     KUNENA_PROFILER ? KunenaProfiler::instance()->stop('function ' . __CLASS__ . '::' . __FUNCTION__ . '()') : null;
     return $changed;
 }
Ejemplo n.º 11
0
	/**
	 * Returns KunenaForumMessage object
	 *
	 * @access	public
	 * @param	identifier		The message to load - Can be only an integer.
	 * @return	KunenaForumMessage		The message object.
	 * @since	1.7
	 */
	static public function getInstance($identifier = null, $reload = false) {
		return KunenaForumMessageHelper::get($identifier, $reload);
	}
Ejemplo n.º 12
0
 /**
  * Method to get a content item to index.
  *
  * @param   integer  $id  The id of the content item.
  *
  * @return  FinderIndexerResult  A FinderIndexerResult object.
  *
  * @since   2.5
  * @throws  Exception on database error.
  */
 protected function getItem($id)
 {
     JLog::add('FinderIndexerAdapter::getItem', JLog::INFO);
     $message = KunenaForumMessageHelper::get($id);
     // Convert the item to a result object.
     $item = $this->{$this}->createIndexerResult($message);
     unset($message);
     KunenaForumMessageHelper::clean();
     return $item;
 }
Ejemplo n.º 13
0
 /**
  * Prepare displaying message.
  *
  * @return void
  *
  * @throws KunenaExceptionAuthorise
  */
 protected function before()
 {
     parent::before();
     $mesid = $this->input->getInt('mesid', 0);
     $this->me = KunenaUserHelper::getMyself();
     $this->location = $this->input->getInt('location', 0);
     $this->detail = $this->input->get('detail', false);
     $this->message = KunenaForumMessageHelper::get($mesid);
     $this->message->tryAuthorise();
     $this->topic = $this->message->getTopic();
     $this->category = $this->topic->getCategory();
     $this->profile = $this->message->getAuthor();
     $this->ktemplate = KunenaFactory::getTemplate();
     $this->captchaEnabled = false;
     if ($this->message->isAuthorised('reply') && $this->me->canDoCaptcha()) {
         if (JPluginHelper::isEnabled('captcha')) {
             $plugin = JPluginHelper::getPlugin('captcha');
             $params = new JRegistry($plugin[0]->params);
             $captcha_pubkey = $params->get('public_key');
             $catcha_privkey = $params->get('private_key');
             if (!empty($captcha_pubkey) && !empty($catcha_privkey)) {
                 JPluginHelper::importPlugin('captcha');
                 $dispatcher = JDispatcher::getInstance();
                 $result = $dispatcher->trigger('onInit', "dynamic_recaptcha_{$this->message->id}");
                 $this->captchaEnabled = $result[0];
             }
         }
     }
     // Thank you info and buttons.
     $this->thankyou = array();
     $this->total_thankyou = 0;
     $this->more_thankyou = 0;
     $this->thankyou_delete = array();
     if (isset($this->message->thankyou)) {
         if ($this->config->showthankyou && $this->profile->exists()) {
             $task = "index.php?option=com_kunena&view=topic&task=%s&catid={$this->category->id}" . "&id={$this->topic->id}&mesid={$this->message->id}&" . JSession::getFormToken() . '=1';
             // Ror normal users, show only limited number of thankyou (config->thankyou_max).
             if (!$this->me->isAdmin() && !$this->me->isModerator()) {
                 if (count($this->message->thankyou) > $this->config->thankyou_max) {
                     $this->more_thankyou = count($this->message->thankyou) - $this->config->thankyou_max;
                 }
                 $this->total_thankyou = count($this->message->thankyou);
                 $thankyous = array_slice($this->message->thankyou, 0, $this->config->thankyou_max, true);
             } else {
                 $thankyous = $this->message->thankyou;
             }
             $userids_thankyous = array();
             foreach ($thankyous as $userid => $time) {
                 $userids_thankyous[] = $userid;
             }
             $loaded_users = KunenaUserHelper::loadUsers($userids_thankyous);
             foreach ($loaded_users as $userid => $user) {
                 if ($this->message->authorise('unthankyou') && $this->me->isModerator($this->message->getCategory())) {
                     $this->thankyou_delete[$userid] = KunenaRoute::_(sprintf($task, "unthankyou&userid={$userid}"));
                 }
                 $this->thankyou[$userid] = $loaded_users[$userid]->getLink();
             }
         }
     }
     if ($this->config->reportmsg && $this->me->exists()) {
         if ($this->config->user_report && $this->me->userid == $this->message->userid && !$this->me->isModerator()) {
             $this->reportMessageLink = JHTML::_('kunenaforum.link', 'index.php?option=com_kunena&view=topic&layout=report&catid=' . intval($this->category->id) . '&id=' . intval($this->message->thread) . '&mesid=' . intval($this->message->id), JText::_('COM_KUNENA_REPORT'), JText::_('COM_KUNENA_REPORT'));
         }
     }
     // Show admins the IP address of the user.
     if ($this->category->isAuthorised('admin') || $this->category->isAuthorised('moderate') && !$this->config->hide_ip) {
         if (!empty($this->message->ip)) {
             $this->ipLink = '<a href="http://whois.domaintools.com/' . $this->message->ip . '" target="_blank"> IP: ' . $this->message->ip . '</a>';
         } else {
             $this->ipLink = '&nbsp;';
         }
     }
 }
Ejemplo n.º 14
0
 /**
  * Prepare topic display.
  *
  * @return void
  *
  * @throws KunenaExceptionAuthorise
  */
 protected function before()
 {
     parent::before();
     $catid = $this->input->getInt('catid', 0);
     $id = $this->input->getInt('id', 0);
     $mesid = $this->input->getInt('mesid', 0);
     $start = $this->input->getInt('limitstart', 0);
     $limit = $this->input->getInt('limit', 0);
     if ($limit < 1 || $limit > 100) {
         $limit = $this->config->messages_per_page;
     }
     $this->me = KunenaUserHelper::getMyself();
     // Load topic and message.
     if ($mesid) {
         // If message was set, use it to find the current topic.
         $this->message = KunenaForumMessageHelper::get($mesid);
         $this->topic = $this->message->getTopic();
     } else {
         // Note that redirect loops throw RuntimeException because of we added KunenaForumTopic::getTopic() call!
         $this->topic = KunenaForumTopicHelper::get($id)->getTopic();
         $this->message = KunenaForumMessageHelper::get($this->topic->first_post_id);
     }
     // Load also category (prefer the URI variable if available).
     if ($catid && $catid != $this->topic->category_id) {
         $this->category = KunenaForumCategoryHelper::get($catid);
         $this->category->tryAuthorise();
     } else {
         $this->category = $this->topic->getCategory();
     }
     // Access check.
     $this->message->tryAuthorise();
     // Check if we need to redirect (category or topic mismatch, or resolve permanent URL).
     if ($this->primary) {
         $channels = $this->category->getChannels();
         if ($this->message->thread != $this->topic->id || $this->topic->category_id != $this->category->id && !isset($channels[$this->topic->category_id]) || $mesid && $this->layout != 'threaded') {
             while (@ob_end_clean()) {
             }
             $this->app->redirect($this->message->getUrl(null, false));
         }
     }
     // Load messages from the current page and set the pagination.
     $hold = KunenaAccess::getInstance()->getAllowedHold($this->me, $this->category->id, false);
     $finder = new KunenaForumMessageFinder();
     $finder->where('thread', '=', $this->topic->id)->filterByHold($hold);
     $start = $mesid ? $this->topic->getPostLocation($mesid) : $start;
     $this->pagination = new KunenaPagination($finder->count(), $start, $limit);
     $this->messages = $finder->order('time', $this->me->getMessageOrdering() == 'asc' ? 1 : -1)->start($this->pagination->limitstart)->limit($this->pagination->limit)->find();
     $this->prepareMessages($mesid);
     // Run events.
     $params = new JRegistry();
     $params->set('ksource', 'kunena');
     $params->set('kunena_view', 'topic');
     $params->set('kunena_layout', 'default');
     $dispatcher = JEventDispatcher::getInstance();
     JPluginHelper::importPlugin('kunena');
     $dispatcher->trigger('onKunenaPrepare', array('kunena.topic', &$this->topic, &$params, 0));
     $dispatcher->trigger('onKunenaPrepare', array('kunena.messages', &$this->messages, &$params, 0));
     // Get user data, captcha & quick reply.
     $this->userTopic = $this->topic->getUserTopic();
     $this->quickReply = $this->topic->isAuthorised('reply') && $this->me->exists();
     $this->headerText = JText::_('COM_KUNENA_TOPIC') . ' ' . html_entity_decode($this->topic->displayField('subject'));
 }
Ejemplo n.º 15
0
 function report()
 {
     if (!JSession::checkToken('post')) {
         $this->app->enqueueMessage(JText::_('COM_KUNENA_ERROR_TOKEN'), 'error');
         $this->setRedirectBack();
         return;
     }
     if (!$this->me->exists() || $this->config->reportmsg == 0) {
         // Deny access if report feature has been disabled or user is guest
         $this->app->enqueueMessage(JText::_('COM_KUNENA_NO_ACCESS'), 'notice');
         $this->setRedirectBack();
         return;
     }
     if (!$this->config->get('send_emails')) {
         // Emails have been disabled
         $this->app->enqueueMessage(JText::_('COM_KUNENA_EMAIL_DISABLED'), 'notice');
         $this->setRedirectBack();
         return;
     }
     if (!$this->config->getEmail() || !JMailHelper::isEmailAddress($this->config->getEmail())) {
         // Error: email address is invalid
         $this->app->enqueueMessage(JText::_('COM_KUNENA_EMAIL_INVALID'), 'error');
         $this->setRedirectBack();
         return;
     }
     // Get target object for the report
     if ($this->mesid) {
         $message = $target = KunenaForumMessageHelper::get($this->mesid);
         $topic = $target->getTopic();
     } else {
         $topic = $target = KunenaForumTopicHelper::get($this->id);
         $message = KunenaForumMessageHelper::get($topic->first_post_id);
     }
     $messagetext = $message->message;
     $baduser = KunenaFactory::getUser($message->userid);
     if (!$target->authorise('read')) {
         // Deny access if user cannot read target
         $this->app->enqueueMessage($target->getError(), 'notice');
         $this->setRedirectBack();
         return;
     }
     $reason = JRequest::getString('reason');
     $text = JRequest::getString('text');
     $template = KunenaTemplate::getInstance();
     if (method_exists($template, 'reportMessage')) {
         $template->reportMessage($message, $reason, $text);
     }
     // Load language file from the template.
     KunenaFactory::getTemplate()->loadLanguage();
     if (empty($reason) && empty($text)) {
         // Do nothing: empty subject or reason is empty
         $this->app->enqueueMessage(JText::_('COM_KUNENA_REPORT_FORG0T_SUB_MES'));
         $this->setRedirectBack();
         return;
     } else {
         $acl = KunenaAccess::getInstance();
         $emailToList = $acl->getSubscribers($topic->category_id, $topic->id, false, true, false);
         if (!empty($emailToList)) {
             $mailsender = JMailHelper::cleanAddress($this->config->board_title . ' ' . JText::_('COM_KUNENA_FORUM') . ': ' . $this->me->getName());
             $mailsubject = "[" . $this->config->board_title . " " . JText::_('COM_KUNENA_FORUM') . "] " . JText::_('COM_KUNENA_REPORT_MSG') . ": ";
             if ($reason) {
                 $mailsubject .= $reason;
             } else {
                 $mailsubject .= $topic->subject;
             }
             jimport('joomla.environment.uri');
             $msglink = JUri::getInstance()->toString(array('scheme', 'host', 'port')) . $target->getPermaUrl(null, false);
             $mail = JFactory::getMailer();
             $mail->setSender(array($this->me->username, $this->me->email));
             $mail->setSubject($mailsubject);
             // Render the email.
             $layout = KunenaLayout::factory('Email/Report')->debug(false)->set('mail', $mail)->set('message', $message)->set('me', $this->me)->set('title', $reason)->set('content', $text)->set('messageLink', $msglink);
             try {
                 $body = trim($layout->render());
                 $mail->setBody($body);
             } catch (Exception $e) {
                 // TODO: Deprecated in K4.0, remove in K5.0
                 $mailmessage = "" . JText::_('COM_KUNENA_REPORT_RSENDER') . " {$this->me->username} ({$this->me->name})";
                 $mailmessage .= "\n";
                 $mailmessage .= "" . JText::_('COM_KUNENA_REPORT_RREASON') . " " . $reason;
                 $mailmessage .= "\n";
                 $mailmessage .= "" . JText::_('COM_KUNENA_REPORT_RMESSAGE') . " " . $text;
                 $mailmessage .= "\n\n";
                 $mailmessage .= "" . JText::_('COM_KUNENA_REPORT_POST_POSTER') . " {$baduser->username} ({$baduser->name})";
                 $mailmessage .= "\n";
                 $mailmessage .= "" . JText::_('COM_KUNENA_REPORT_POST_SUBJECT') . ": " . $topic->subject;
                 $mailmessage .= "\n";
                 $mailmessage .= "" . JText::_('COM_KUNENA_REPORT_POST_MESSAGE') . "\n-----\n" . KunenaHtmlParser::stripBBCode($messagetext, 0, false);
                 $mailmessage .= "\n-----\n\n";
                 $mailmessage .= "" . JText::_('COM_KUNENA_REPORT_POST_LINK') . " " . $msglink;
                 $mailmessage = JMailHelper::cleanBody(strtr($mailmessage, array('&#32;' => '')));
                 $mail->setBody($mailmessage);
             }
             $receivers = array();
             foreach ($emailToList as $emailTo) {
                 if (!$emailTo->email || !JMailHelper::isEmailAddress($emailTo->email)) {
                     continue;
                 }
                 $receivers[] = $emailTo->email;
             }
             KunenaEmail::send($mail, $receivers);
             $this->app->enqueueMessage(JText::_('COM_KUNENA_REPORT_SUCCESS'));
         } else {
             $this->app->enqueueMessage(JText::_('COM_KUNENA_REPORT_NOT_SEND'));
         }
     }
     $this->setRedirect($target->getUrl($this->return, false));
 }
Ejemplo n.º 16
0
 /**
  * Prepares the activity log item
  *
  * @since	1.2
  * @access	public
  * @param	SocialStreamItem	The stream object.
  * @param	bool				Determines if we should respect the privacy
  */
 public function onPrepareActivityLog(SocialStreamItem &$item, $includePrivacy = true)
 {
     if ($item->context != 'kunena') {
         return;
     }
     // Test if Kunena exists;
     if (!$this->exists()) {
         return;
     }
     // Get the context id.
     $actor = $item->actor;
     $topic = KunenaForumTopicHelper::get($item->contextId);
     if ($item->verb == 'thanked') {
         $message = KunenaForumMessageHelper::get($item->contextId);
         $topic = $message->getTopic();
         $target = $item->targets[0];
         $this->set('target', $target);
         $this->set('message', $message);
     } else {
         if ($item->verb == 'reply') {
             $message = KunenaForumMessageHelper::get($item->contextId);
             $topic = $message->getTopic();
             $this->set('message', $message);
         }
     }
     $this->set('topic', $topic);
     $this->set('actor', $actor);
     // Load up the contents now.
     $item->title = parent::display('streams/' . $item->verb . '.title');
     $item->content = '';
 }
Ejemplo n.º 17
0
 /**
  * Method to get the URL for the item. The URL is how we look up the link
  * in the Finder index.
  *
  * @param	mixed		$id	The id of the item.
  * @param	mixed		$extension Unused.
  * @param   string		$view View name.
  * @return	string		The URL of the item.
  */
 protected function getUrl($id, $extension, $view)
 {
     $item = KunenaForumMessageHelper::get($id);
     return "index.php?option=com_kunena&view={$view}&catid={$item->catid}&id={$item->thread}&mesid={$item->id}";
 }
Ejemplo n.º 18
0
 function report()
 {
     if (!JRequest::checkToken()) {
         $this->app->enqueueMessage(JText::_('COM_KUNENA_ERROR_TOKEN'), 'error');
         $this->redirectBack();
     }
     if (!$this->me->exists() || $this->config->reportmsg == 0) {
         // Deny access if report feature has been disabled or user is guest
         $this->app->enqueueMessage(JText::_('COM_KUNENA_NO_ACCESS'), 'notice');
         $this->redirectBack();
     }
     if (!$this->config->get('send_emails')) {
         // Emails have been disabled
         $this->app->enqueueMessage(JText::_('COM_KUNENA_EMAIL_DISABLED'), 'notice');
         $this->redirectBack();
     }
     jimport('joomla.mail.helper');
     if (!$this->config->getEmail() || !JMailHelper::isEmailAddress($this->config->getEmail())) {
         // Error: email address is invalid
         $this->app->enqueueMessage(JText::_('COM_KUNENA_EMAIL_INVALID'), 'error');
         $this->redirectBack();
     }
     // Get target object for the report
     if ($this->mesid) {
         $message = $target = KunenaForumMessageHelper::get($this->mesid);
         $topic = $target->getTopic();
     } else {
         $topic = $target = KunenaForumTopicHelper::get($this->id);
         $message = KunenaForumMessageHelper::get($topic->first_post_id);
     }
     $messagetext = $message->message;
     $baduser = KunenaFactory::getUser($message->userid);
     if (!$target->authorise('read')) {
         // Deny access if user cannot read target
         $this->app->enqueueMessage($target->getError(), 'notice');
         $this->redirectBack();
     }
     $category = $topic->getCategory();
     $reason = JRequest::getString('reason');
     $text = JRequest::getString('text');
     if (empty($reason) && empty($text)) {
         // Do nothing: empty subject or reason is empty
         $this->app->enqueueMessage(JText::_('COM_KUNENA_REPORT_FORG0T_SUB_MES'));
         $this->redirectBack();
     } else {
         $acl = KunenaAccess::getInstance();
         $emailToList = $acl->getSubscribers($topic->category_id, $topic->id, false, true, false, $this->me->userid);
         if (!empty($emailToList)) {
             $mailsender = JMailHelper::cleanAddress($this->config->board_title . ' ' . JText::_('COM_KUNENA_FORUM') . ': ' . $this->me->getName());
             $mailsubject = "[" . $this->config->board_title . " " . JText::_('COM_KUNENA_FORUM') . "] " . JText::_('COM_KUNENA_REPORT_MSG') . ": ";
             if ($reason) {
                 $mailsubject .= $reason;
             } else {
                 $mailsubject .= $topic->subject;
             }
             jimport('joomla.environment.uri');
             $uri = JURI::getInstance(JURI::base());
             $msglink = $uri->toString(array('scheme', 'host', 'port')) . $target->getPermaUrl(null, false);
             $mailmessage = "" . JText::_('COM_KUNENA_REPORT_RSENDER') . " {$this->me->username} ({$this->me->name})";
             $mailmessage .= "\n";
             $mailmessage .= "" . JText::_('COM_KUNENA_REPORT_RREASON') . " " . $reason;
             $mailmessage .= "\n";
             $mailmessage .= "" . JText::_('COM_KUNENA_REPORT_RMESSAGE') . " " . $text;
             $mailmessage .= "\n\n";
             $mailmessage .= "" . JText::_('COM_KUNENA_REPORT_POST_POSTER') . " {$baduser->username} ({$baduser->name})";
             $mailmessage .= "\n";
             $mailmessage .= "" . JText::_('COM_KUNENA_REPORT_POST_SUBJECT') . ": " . $topic->subject;
             $mailmessage .= "\n";
             $mailmessage .= "" . JText::_('COM_KUNENA_REPORT_POST_MESSAGE') . "\n-----\n" . KunenaHtmlParser::stripBBCode($messagetext, 0, false);
             $mailmessage .= "\n-----\n\n";
             $mailmessage .= "" . JText::_('COM_KUNENA_REPORT_POST_LINK') . " " . $msglink;
             $mailmessage = JMailHelper::cleanBody(strtr($mailmessage, array('&#32;' => '')));
             foreach ($emailToList as $emailTo) {
                 if (!$emailTo->email || !JMailHelper::isEmailAddress($emailTo->email)) {
                     continue;
                 }
                 JUtility::sendMail($this->config->getEmail(), $mailsender, $emailTo->email, $mailsubject, $mailmessage);
             }
             $this->app->enqueueMessage(JText::_('COM_KUNENA_REPORT_SUCCESS'));
         } else {
             $this->app->enqueueMessage(JText::_('COM_KUNENA_REPORT_NOT_SEND'));
         }
     }
     $this->app->redirect($target->getUrl($this->return, false));
 }
Ejemplo n.º 19
0
	/**
	 * @param cbautoactionsActionTable $trigger
	 * @param UserTable $user
	 */
	public function execute( $trigger, $user )
	{
		global $_CB_database;

		if ( ! $this->installed() ) {
			if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) {
				var_dump( CBTxt::T( 'AUTO_ACTION_KUNENA_NOT_INSTALLED', ':: Action [action] :: Kunena is not installed', array( '[action]' => (int) $trigger->get( 'id' ) ) ) );
			}

			return;
		}

		foreach ( $trigger->getParams()->subTree( 'kunena' ) as $row ) {
			/** @var ParamsInterface $row */
			$owner								=	$row->get( 'owner', null, GetterInterface::STRING );

			if ( ! $owner ) {
				$owner							=	(int) $user->get( 'id' );
			} else {
				$owner							=	(int) $trigger->getSubstituteString( $owner );
			}

			switch ( $row->get( 'mode', 'category', GetterInterface::STRING ) ) {
				case 'sync':
					if ( ! $user->get( 'id' ) ) {
						if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) {
							var_dump( CBTxt::T( 'AUTO_ACTION_KUNENA_NO_USER', ':: Action [action] :: Kunena skipped due to no user', array( '[action]' => (int) $trigger->get( 'id' ) ) ) );
						}

						continue;
					}

					$kunenaUser					=	KunenaUserHelper::get( (int) $user->get( 'id' ) );

					$kunenaUser->set( 'name', $user->get( 'name' ) );
					$kunenaUser->set( 'username', $user->get( 'username' ) );
					$kunenaUser->set( 'email', $user->get( 'email' ) );

					foreach ( $row->subTree( 'fields' ) as $r ) {
						/** @var ParamsInterface $r */
						$field					=	$r->get( 'field', null, GetterInterface::STRING );

						if ( $field ) {
							$kunenaUser->set( $field, $trigger->getSubstituteString( $r->get( 'value', null, GetterInterface::RAW ), false, $r->get( 'translate', false, GetterInterface::BOOLEAN ) ) );
						}
					}

					$kunenaUser->save();
					break;
				case 'reply':
					if ( ! $owner ) {
						if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) {
							var_dump( CBTxt::T( 'AUTO_ACTION_KUNENA_NO_OWNER', ':: Action [action] :: Kunena skipped due to missing owner', array( '[action]' => (int) $trigger->get( 'id' ) ) ) );
						}

						continue;
					}

					$message					=	$trigger->getSubstituteString( $row->get( 'message', null, GetterInterface::RAW ), false );

					if ( ! $message ) {
						if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) {
							var_dump( CBTxt::T( 'AUTO_ACTION_KUNENA_NO_MSG', ':: Action [action] :: Kunena skipped due to missing message', array( '[action]' => (int) $trigger->get( 'id' ) ) ) );
						}

						continue;
					}

					$topicId					=	(int) $row->get( 'topic', 0, GetterInterface::INT );

					if ( ! $topicId ) {
						if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) {
							var_dump( CBTxt::T( 'AUTO_ACTION_KUNENA_NO_TOPIC', ':: Action [action] :: Kunena skipped due to missing topic', array( '[action]' => (int) $trigger->get( 'id' ) ) ) );
						}

						continue;
					}

					$subject					=	$trigger->getSubstituteString( $row->get( 'subject', null, GetterInterface::STRING ) );

					$topic						=	KunenaForumMessageHelper::get( $topicId );

					$fields						=	array( 'message' => $message );

					if ( $subject ) {
						$fields['subject']		=	$subject;
					}

					$topic->newReply( $fields, $owner );
					break;
				case 'topic':
					if ( ! $owner ) {
						if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) {
							var_dump( CBTxt::T( 'AUTO_ACTION_KUNENA_NO_OWNER', ':: Action [action] :: Kunena skipped due to missing owner', array( '[action]' => (int) $trigger->get( 'id' ) ) ) );
						}

						continue;
					}

					$subject					=	$trigger->getSubstituteString( $row->get( 'subject', null, GetterInterface::STRING ) );

					if ( ! $subject ) {
						if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) {
							var_dump( CBTxt::T( 'AUTO_ACTION_KUNENA_NO_SUBJ', ':: Action [action] :: Kunena skipped due to missing subject', array( '[action]' => (int) $trigger->get( 'id' ) ) ) );
						}

						continue;
					}

					$message					=	$trigger->getSubstituteString( $row->get( 'message', null, GetterInterface::RAW ), false );

					if ( ! $message ) {
						if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) {
							var_dump( CBTxt::T( 'AUTO_ACTION_KUNENA_NO_MSG', ':: Action [action] :: Kunena skipped due to missing message', array( '[action]' => (int) $trigger->get( 'id' ) ) ) );
						}

						continue;
					}

					$categoryId					=	(int) $row->get( 'category', 0, GetterInterface::INT );

					if ( ! $categoryId ) {
						if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) {
							var_dump( CBTxt::T( 'AUTO_ACTION_KUNENA_NO_CAT', ':: Action [action] :: Kunena skipped due to missing category', array( '[action]' => (int) $trigger->get( 'id' ) ) ) );
						}

						continue;
					}

					$category					=	KunenaForumCategoryHelper::get( $categoryId );

					$fields						=	array(	'catid' => $categoryId,
															'subject' => $subject,
															'message' => $message
														);

					$category->newTopic( $fields, $owner );
					break;
				case 'category':
				default:
					$name						=	$trigger->getSubstituteString( $row->get( 'name', null, GetterInterface::STRING ) );

					if ( ! $name ) {
						if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) {
							var_dump( CBTxt::T( 'AUTO_ACTION_KUNENA_NO_NAME', ':: Action [action] :: Kunena skipped due to missing name', array( '[action]' => (int) $trigger->get( 'id' ) ) ) );
						}

						continue;
					}

					$query						=	'SELECT ' . $_CB_database->NameQuote( 'id' )
												.	"\n FROM " . $_CB_database->NameQuote( '#__kunena_categories' )
												.	"\n WHERE " . $_CB_database->NameQuote( 'name' ) . " = " . $_CB_database->Quote( $name );
					$_CB_database->setQuery( $query );
					if ( ! $_CB_database->loadResult() ) {
						$category				=	KunenaForumCategoryHelper::get();

						$category->set( 'parent_id', (int) $row->get( 'parent', 0, GetterInterface::INT ) );
						$category->set( 'name', $name );
						$category->set( 'alias', KunenaRoute::stringURLSafe( $name ) );
						$category->set( 'accesstype', 'joomla.group' );
						$category->set( 'access', (int) $row->get( 'access', 1, GetterInterface::INT ) );
						$category->set( 'published', (int) $row->get( 'published', 1, GetterInterface::INT ) );
						$category->set( 'description', $trigger->getSubstituteString( $row->get( 'description', null, GetterInterface::STRING ) ) );

						if ( $category->save() && $owner ) {
							$category->addModerator( (int) $owner );
						}
					}
					break;
			}
		}
	}
Ejemplo n.º 20
0
 /**
  * Send email notifications from the first post in the topic.
  *
  * @param null|string $url
  */
 public function sendNotification($url = null)
 {
     // Reload message just in case if it was published by bulk update.
     KunenaForumMessageHelper::get($this->first_post_id, true)->sendNotification($url);
 }
Ejemplo n.º 21
0
 protected function displayModerate($tpl = null)
 {
     $this->mesid = JRequest::getInt('mesid', 0);
     $this->id = $this->state->get('item.id');
     $this->catid = $this->state->get('item.catid');
     if ($this->config->topicicons) {
         $this->topicIcons = $this->ktemplate->getTopicIcons(false);
     }
     if (!$this->mesid) {
         $this->topic = KunenaForumTopicHelper::get($this->id);
         if (!$this->topic->authorise('move')) {
             $this->app->enqueueMessage($this->topic->getError(), 'notice');
             return;
         }
     } else {
         $this->message = KunenaForumMessageHelper::get($this->mesid);
         if (!$this->message->authorise('move')) {
             $this->app->enqueueMessage($this->message->getError(), 'notice');
             return;
         }
         $this->topic = $this->message->getTopic();
     }
     $this->category = $this->topic->getCategory();
     $options = array();
     if (!$this->mesid) {
         $options[] = JHtml::_('select.option', 0, JText::_('COM_KUNENA_MODERATION_MOVE_TOPIC'));
     } else {
         $options[] = JHtml::_('select.option', 0, JText::_('COM_KUNENA_MODERATION_CREATE_TOPIC'));
     }
     $options[] = JHtml::_('select.option', -1, JText::_('COM_KUNENA_MODERATION_ENTER_TOPIC'));
     $db = JFactory::getDBO();
     $params = array('orderby' => 'tt.last_post_time DESC', 'where' => " AND tt.id != {$db->Quote($this->topic->id)} ");
     list($total, $topics) = KunenaForumTopicHelper::getLatestTopics($this->catid, 0, 30, $params);
     foreach ($topics as $cur) {
         $options[] = JHtml::_('select.option', $cur->id, $this->escape($cur->subject));
     }
     $this->topiclist = JHtml::_('select.genericlist', $options, 'targettopic', 'class="inputbox"', 'value', 'text', 0, 'kmod_topics');
     $options = array();
     $cat_params = array('sections' => 0, 'catid' => 0);
     $this->categorylist = JHtml::_('kunenaforum.categorylist', 'targetcategory', 0, $options, $cat_params, 'class="inputbox kmove_selectbox"', 'value', 'text', $this->catid, 'kmod_categories');
     if (isset($this->message)) {
         $this->user = KunenaFactory::getUser($this->message->userid);
         $username = $this->message->getAuthor()->getName();
         $this->userLink = $this->message->userid ? JHtml::_('kunenaforum.link', 'index.php?option=com_kunena&view=user&layout=moderate&userid=' . $this->message->userid, $username . ' (' . $this->message->userid . ')', $username . ' (' . $this->message->userid . ')') : null;
     }
     if ($this->mesid) {
         // Get thread and reply count from current message:
         $query = "SELECT COUNT(mm.id) AS replies FROM #__kunena_messages AS m\r\n\t\t\t\tINNER JOIN #__kunena_messages AS t ON m.thread=t.id\r\n\t\t\t\tLEFT JOIN #__kunena_messages AS mm ON mm.thread=m.thread AND mm.time > m.time\r\n\t\t\t\tWHERE m.id={$db->Quote($this->mesid)}";
         $db->setQuery($query, 0, 1);
         $this->replies = $db->loadResult();
         if (KunenaError::checkDatabaseError()) {
             return;
         }
     }
     $this->render('Topic/Moderate', $tpl);
 }
Ejemplo n.º 22
0
 /**
  * Get message to which attachment has been attached into.
  *
  * NOTE: Returns message object even if there isn't one. Please call $message->exists() to check if it exists.
  *
  * @return KunenaForumMessage
  *
  * @since  K4.0
  */
 public function getMessage()
 {
     return KunenaForumMessageHelper::get($this->mesid);
 }
Ejemplo n.º 23
0
 /**
  * @param int $mesid
  * @param null|string $direction
  * @param null|array $hold
  *
  * @return int
  */
 public static function getLocation($mesid, $direction = null, $hold = null)
 {
     if (is_null($direction)) {
         $direction = KunenaUserHelper::getMyself()->getMessageOrdering();
     }
     if (!$hold) {
         $me = KunenaUserHelper::getMyself();
         $mes_instance = KunenaForumMessageHelper::get($mesid);
         $hold = KunenaAccess::getInstance()->getAllowedHold($me->userid, $mes_instance->catid, false);
     }
     if (!isset(self::$_location[$mesid])) {
         self::loadLocation(array($mesid));
     }
     $location = self::$_location[$mesid];
     $count = 0;
     foreach ($location->hold as $meshold => $values) {
         if (isset($hold[$meshold])) {
             $count += $values[$direction == 'asc' ? 'before' : 'after'];
             if ($direction == 'both') {
                 $count += $values['before'];
             }
         }
     }
     return $count;
 }
Ejemplo n.º 24
0
 /**
  * Send email notifications from the first post in the topic.
  *
  * @param string $url
  *
  * @since 2.0.0-BETA2
  */
 public function sendNotification($url = null)
 {
     KunenaForumMessageHelper::get($this->first_post_id)->sendNotification($url);
 }
Ejemplo n.º 25
0
	static function GetReportMessageLink($catid, $id, $name, $rel = 'nofollow', $class = '', $title = '') {
		$message = KunenaForumMessageHelper::get($id);
		return self::GetSefHrefLink ( "index.php?option=com_kunena&view=topic&layout=report&catid={$catid}&id={$message->thread}&mesid={$message->id}", $name, $title, $rel, $class );
	}
Ejemplo n.º 26
0
						onclick="isChecked(this.checked);" /></td>
					<td >
						<?php
						echo $this->escape($row->id);
						?>
						</td>
					<td ><?php
						echo $this->escape($row->subject);
						?></td>
					<td ><?php $cat = KunenaForumCategoryHelper::get($row->category_id);
						echo $this->escape($cat->name);
						?></td>
					<td ><?php
						echo $this->escape($row->last_post_message);
						?></td>
					<td><?php $message = KunenaForumMessageHelper::get($row->id);
						echo $message->ip; ?></td>
					<td ><?php
						echo $this->escape($row->last_post_userid);
						?></td>
					<td ><?php
						if(empty($row->last_post_userid)){
							echo JText::_('COM_KUNENA_VIEW_VISITOR');
						} else {
							echo $this->escape($row->last_post_guest_name);
						}
						?></td>
					<td ><?php
						echo strftime('%Y-%m-%d %H:%M:%S',$row->last_post_time);
						?></td>
				</tr>
Ejemplo n.º 27
0
 /**
  * Detele thank you from the database.
  *
  * @param mixed $user
  *
  * @return bool
  */
 public function delete($user)
 {
     $user = KunenaFactory::getUser($user);
     $message = KunenaForumMessageHelper::get($this->id);
     if (!$user->exists()) {
         $this->setError(JText::_('COM_KUNENA_THANKYOU_LOGIN'));
         return false;
     }
     if (!$this->exists($user->userid)) {
         $this->setError(JText::_('COM_KUNENA_THANKYOU_NOT_PRESENT'));
         return false;
     }
     $db = JFactory::getDBO();
     $query = "DELETE FROM #__kunena_thankyou WHERE postid={$db->quote($this->id)} AND userid={$db->quote($user->userid)}";
     $db->setQuery($query);
     $db->query();
     $query = "UPDATE #__kunena_users SET thankyou=thankyou-1 WHERE userid={$db->quote($message->userid)}";
     $db->setQuery($query);
     $db->query();
     // Check for an error message.
     if ($db->getErrorNum()) {
         $this->setError($db->getErrorMsg());
         return false;
     }
     return true;
 }
Ejemplo n.º 28
0
	protected function displayModerate($tpl = null) {
		$this->mesid = JRequest::getInt('mesid', 0);
		$this->id = $this->state->get('item.id');
		$this->catid = $this->state->get('item.catid');
		$this->config = KunenaFactory::getConfig();
		$app = JFactory::getApplication();

		if (!$this->mesid) {
			$this->topic = KunenaForumTopicHelper::get($this->id);
			if (!$this->topic->authorise('move')) {
				$app->enqueueMessage ( $this->topic->getError(), 'notice' );
				return;
			}
		} else {
			$this->message = KunenaForumMessageHelper::get($this->mesid);
			if (!$this->message->authorise('move')) {
				$app->enqueueMessage ( $this->message->getError(), 'notice' );
				return;
			}
			$this->topic = $this->message->getTopic();
		}
		$this->category = $this->topic->getCategory();

		$options =array ();
		if (!$this->mesid) {
			$options [] = JHTML::_ ( 'select.option', 0, JText::_ ( 'COM_KUNENA_MODERATION_MOVE_TOPIC' ) );
		} else {
			$options [] = JHTML::_ ( 'select.option', 0, JText::_ ( 'COM_KUNENA_MODERATION_CREATE_TOPIC' ) );
		}
		$options [] = JHTML::_ ( 'select.option', -1, JText::_ ( 'COM_KUNENA_MODERATION_ENTER_TOPIC' ) );

		$db = JFactory::getDBO();
		$params = array(
			'orderby'=>'tt.last_post_time DESC',
			'where'=>" AND tt.id != {$db->Quote($this->topic->id)} ");
		list ($total, $topics) = KunenaForumTopicHelper::getLatestTopics($this->catid, 0, 30, $params);
		foreach ( $topics as $cur ) {
			$options [] = JHTML::_ ( 'select.option', $cur->id, $this->escape ( $cur->subject ) );
		}
		$this->topiclist = JHTML::_ ( 'select.genericlist', $options, 'targettopic', 'class="inputbox"', 'value', 'text', 0, 'kmod_topics' );

		$options = array ();
		$cat_params = array ('sections'=>0, 'catid'=>0);
		$this->assignRef ( 'categorylist', JHTML::_('kunenaforum.categorylist', 'targetcategory', 0, $options, $cat_params, 'class="inputbox kmove_selectbox"', 'value', 'text', $this->catid, 'kmod_categories'));
		if (isset($this->message)) $this->user = KunenaFactory::getUser($this->message->userid);

		if ($this->mesid) {
			// Get thread and reply count from current message:
			$query = "SELECT COUNT(mm.id) AS replies FROM #__kunena_messages AS m
				INNER JOIN #__kunena_messages AS t ON m.thread=t.id
				LEFT JOIN #__kunena_messages AS mm ON mm.thread=m.thread AND mm.id > m.id
				WHERE m.id={$db->Quote($this->mesid)}";
			$db->setQuery ( $query, 0, 1 );
			$this->replies = $db->loadResult ();
			if (KunenaError::checkDatabaseError()) return;
		}

		$this->display($tpl);
	}