예제 #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}" : '');
 }
예제 #2
0
 /**
  * Prepare reply history display.
  *
  * @return void
  */
 protected function before()
 {
     parent::before();
     $id = $this->input->getInt('id');
     $this->topic = KunenaForumTopicHelper::get($id);
     $this->history = KunenaForumMessageHelper::getMessagesByTopic($this->topic, 0, (int) $this->config->historylimit, 'DESC');
     $this->replycount = $this->topic->getReplies();
     $this->historycount = count($this->history);
     KunenaAttachmentHelper::getByMessage($this->history);
     $userlist = array();
     foreach ($this->history as $message) {
         $userlist[(int) $message->userid] = (int) $message->userid;
     }
     KunenaUserHelper::loadUsers($userlist);
     // Run events
     $params = new JRegistry();
     $params->set('ksource', 'kunena');
     $params->set('kunena_view', 'topic');
     $params->set('kunena_layout', 'history');
     $dispatcher = JEventDispatcher::getInstance();
     JPluginHelper::importPlugin('kunena');
     $dispatcher->trigger('onKunenaPrepare', array('kunena.messages', &$this->history, &$params, 0));
     // FIXME: need to improve BBCode class on this...
     $this->attachments = KunenaAttachmentHelper::getByMessage($this->history);
     $this->inline_attachments = array();
     $this->headerText = JText::_('COM_KUNENA_POST_EDIT') . ' ' . $this->topic->subject;
 }
예제 #3
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;
 }
예제 #4
0
 function displaySubscriptions()
 {
     $id = $this->app->input->get('id', 0, 'int');
     $topic = KunenaForumTopicHelper::get($id);
     $acl = KunenaAccess::getInstance();
     $cat_subscribers = $acl->loadSubscribers($topic, KunenaAccess::CATEGORY_SUBSCRIPTION);
     $this->cat_subscribers_users = KunenaUserHelper::loadUsers($cat_subscribers);
     $topic_subscribers = $acl->loadSubscribers($topic, KunenaAccess::TOPIC_SUBSCRIPTION);
     $this->topic_subscribers_users = KunenaUserHelper::loadUsers($topic_subscribers);
     $this->cat_topic_subscribers = $acl->getSubscribers($topic->getCategory()->id, $id, KunenaAccess::CATEGORY_SUBSCRIPTION | KunenaAccess::TOPIC_SUBSCRIPTION, 1, 1);
     $this->display();
 }
예제 #5
0
 public function check()
 {
     $user = KunenaUserHelper::get($this->user_id);
     $topic = KunenaForumTopicHelper::get($this->topic_id);
     if (!$user->exists()) {
         $this->setError(JText::sprintf('COM_KUNENA_LIB_TABLE_USERTOPICS_ERROR_USER_INVALID', (int) $user->userid));
     }
     if (!$topic->exists()) {
         $this->setError(JText::sprintf('COM_KUNENA_LIB_TABLE_USERTOPICS_ERROR_TOPIC_INVALID', (int) $topic->id));
     }
     $this->category_id = $topic->category_id;
     return $this->getError() == '';
 }
예제 #6
0
파일: read.php 프로젝트: madcsaba/li-de
 /**
  * @param mixed $topic
  * @param mixed $user
  *
  * @internal
  */
 public function __construct($topic = null, $user = null)
 {
     $topic = KunenaForumTopicHelper::get($topic);
     // Always fill empty data
     $this->_db = JFactory::getDBO();
     // Create the table object
     $table = $this->getTable();
     // Lets bind the data
     $this->setProperties($table->getProperties());
     $this->_exists = false;
     $this->topic_id = $topic->exists() ? $topic->id : null;
     $this->category_id = $topic->exists() ? $topic->category_id : null;
     $this->user_id = KunenaUserHelper::get($user)->userid;
 }
예제 #7
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));
 }
예제 #8
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);
 }
예제 #9
0
파일: helper.php 프로젝트: rich20/Kunena
	static public function getMessagesByTopic($topic, $start=0, $limit=0, $ordering='ASC', $hold=0, $orderbyid = false) {
		$topic = KunenaForumTopicHelper::get($topic);
		if (!$topic->exists())
			return array();
		$total = $topic->getTotal();

		if ($start < 0)
			$start = 0;
		if ($limit < 1)
			$limit = KunenaFactory::getConfig()->messages_per_page;
		// If out of range, use last page
		if ($total < $start)
			$start = intval($total / $limit) * $limit;
		$ordering = strtoupper($ordering);
		if ($ordering != 'DESC')
			$ordering = 'ASC';

		return self::loadMessagesByTopic($topic->id, $start, $limit, $ordering, $hold, $orderbyid);
	}
예제 #10
0
 /**
  * Prepare poll display.
  *
  * @return void
  *
  * @throws KunenaExceptionAuthorise
  */
 protected function before()
 {
     parent::before();
     $this->topic = KunenaForumTopicHelper::get($this->input->getInt('id'));
     $this->category = $this->topic->getCategory();
     $this->config = KunenaFactory::getConfig();
     $this->me = KunenaUserHelper::getMyself();
     // Need to check if poll is allowed in this category.
     $this->topic->tryAuthorise('poll.read');
     $this->poll = $this->topic->getPoll();
     $this->usercount = $this->poll->getUserCount();
     $this->usersvoted = $this->poll->getUsers();
     $this->voted = $this->poll->getMyVotes();
     if (!empty($this->alwaysVote)) {
         // Authorise forced vote.
         $this->topic->tryAuthorise('poll.vote');
         $this->name = 'Topic/Poll/Vote';
     } elseif (!$this->voted && $this->topic->isAuthorised('poll.vote')) {
         $this->name = 'Topic/Poll/Vote';
     } else {
         $this->name = 'Topic/Poll/Results';
         $this->show_title = true;
         $this->users_voted_list = array();
         $this->users_voted_morelist = array();
         if ($this->config->pollresultsuserslist && !empty($this->usersvoted)) {
             $userids_votes = array();
             foreach ($this->usersvoted as $userid => $vote) {
                 $userids_votes[] = $userid;
             }
             $loaded_users = KunenaUserHelper::loadUsers($userids_votes);
             $i = 0;
             foreach ($loaded_users as $userid => $user) {
                 if ($i <= '4') {
                     $this->users_voted_list[] = $loaded_users[$userid]->getLink();
                 } else {
                     $this->users_voted_morelist[] = $loaded_users[$userid]->getLink();
                 }
                 $i++;
             }
         }
     }
     $this->uri = "index.php?option=com_kunena&view=topic&layout=poll&catid={$this->category->id}&id={$this->topic->id}";
 }
예제 #11
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);
 }
예제 #12
0
 /**
  * Resolve/get current topic.
  *
  * @return  KunenaForumTopic  Returns this topic or move target if this was moved.
  *
  * @throws  RuntimeException  If there is a redirect loop on moved_id.
  *
  * @since  K4.0
  */
 public function getTopic()
 {
     $ids = array();
     $topic = $this;
     // If topic has been moved, find the new topic
     while ($topic->moved_id) {
         if (isset($ids[$topic->moved_id])) {
             throw new RuntimeException(JText::_('COM_KUNENA_VIEW_TOPIC_ERROR_LOOP'), 500);
         }
         $ids[$topic->moved_id] = 1;
         $topic = KunenaForumTopicHelper::get($topic->moved_id);
     }
     return $topic;
 }
예제 #13
0
파일: topic.php 프로젝트: rich20/Kunena
	/**
	 * Returns KunenaForumTopic object
	 *
	 * @access	public
	 * @param	identifier		The topic to load - Can be only an integer.
	 * @return	KunenaForumTopic		The topic object.
	 * @since	1.7
	 */
	static public function getInstance($identifier = null, $reset = false) {
		return KunenaForumTopicHelper::get($identifier, $reset);
	}
예제 #14
0
파일: router.php 프로젝트: rich20/Kunena
function KunenaParseRoute($segments) {
	$profiler = JProfiler::getInstance('Application');
	KUNENA_PROFILER ? $profiler->mark('kunenaRoute') : null;
	$starttime = $profiler->getmicrotime();

	// Get current menu item and get query variables from it
	$active = JFactory::getApplication()->getMenu ()->getActive ();
	$vars = isset ( $active->query ) ? $active->query : array ('view'=>'home');
	if (empty($vars['view']) || $vars['view']=='home' || $vars['view']=='entrypage') {
		$vars['view'] = '';
	}

	// Fix bug in Joomla 1.5 when using /components/kunena instead /component/kunena
	if (!$active && $segments[0] == 'kunena') array_shift ( $segments );

	// Enable SEF category feature
	$sefcats = KunenaRoute::$config->sefcats && isset(KunenaRouter::$sefviews[$vars['view']]) && empty($vars ['id']);

	// Handle all segments
	while ( ($segment = array_shift ( $segments )) !== null ) {
		$seg = explode ( ':', $segment );
		$var = array_shift ( $seg );
		$value = array_shift ( $seg );

		if (is_numeric ( $var )) {
			$value = (int) $var;
			if ($vars['view'] == 'user') {
				$var = 'userid';
			} else {
				// Numeric variable is always catid or id
				if (empty($vars ['catid'])
					|| (empty($vars ['id']) && KunenaForumCategoryHelper::get($value)->exists() && KunenaForumTopicHelper::get($value)->category_id != $vars ['catid'])) {
					// First numbers are always categories
					// FIXME: what if $topic->catid == catid
					$var = 'catid';
					$vars ['view'] = 'category';
				} elseif (empty($vars ['id'])) {
					// Next number is always topic
					$var = 'id';
					$vars ['view'] = 'topic';
					$sefcats = false;
				} elseif (empty($vars ['mesid'])) {
					// Next number is always message
					$var = 'mesid';
					$vars ['view'] = 'topic';
				} else {
					// Invalid parameter, skip it
					continue;
				}
			}
		} elseif (empty ( $var ) && empty ( $value )) {
			// Empty parameter, skip it
			continue;
		} elseif ($sefcats && (($value !== null && ! isset ( KunenaRouter::$parsevars[$var] ))
		|| ($value === null && ! isset ( KunenaRouter::$views[$var] ) && ! isset ( KunenaRouter::$layouts[$var] ) && ! isset ( KunenaRouter::$functions[$var] )))) {
			// We have SEF category: translate category name into catid=123
			// TODO: cache filtered values to gain some speed -- I would like to start using category names instead of catids if it gets fast enough
			$var = 'catid';
			$value = -1;
			$catname = strtr ( $segment, ':', '-' );
			$categories = empty($vars ['catid']) ? KunenaForumCategoryHelper::getCategories() : KunenaForumCategoryHelper::getChildren($vars ['catid']);
			foreach ( $categories as $category ) {
				if ($catname == KunenaRouter::filterOutput ( $category->name ) || $catname == JFilterOutput::stringURLSafe ( $category->name )) {
					$value = (int) $category->id;
					break;
				}
			}
			$vars ['view'] = 'category';
		} elseif ($value === null) {
			// Variable must be either view or layout
			$sefcats = false;
			$value = $var;
			if (empty($vars ['view']) || ($value=='topic' && $vars ['view'] == 'category')) {
				$var = 'view';
			} elseif (empty($vars ['layout'])) {
				$var = 'layout';
			} else {
				// Unknown parameter: continue
				if (!empty($vars ['view'])) continue;
				// Oops: unknown view or non-existing category
				$var = 'view';
			}
		}
		$vars [$var] = $value;
	}
	if (empty($vars ['layout'])) $vars ['layout'] = 'default';
	KunenaRouter::$time = $profiler->getmicrotime() - $starttime;
	return $vars;
}
예제 #15
0
 protected function update($newTopic = false)
 {
     // If post was published and then moved, we need to update old topic
     if (!$this->_hold && $this->_thread && $this->_thread != $this->thread) {
         $topic = KunenaForumTopicHelper::get($this->_thread);
         if (!$topic->update($this, -1)) {
             $this->setError($topic->getError());
         }
     }
     $postDelta = $this->delta(true);
     $topic = $this->getTopic();
     // New topic
     if ($newTopic) {
         $topic->hold = 0;
     }
     // Update topic
     if (!$this->hold && $topic->hold && $topic->exists()) {
         // We published message -> publish and recount topic
         $topic->hold = 0;
         $topic->recount();
     } elseif (!$topic->update($this, $postDelta)) {
         $this->setError($topic->getError());
     }
     // Activity integration
     $dispatcher = JDispatcher::getInstance();
     JPluginHelper::importPlugin('finder');
     $activity = KunenaFactory::getActivityIntegration();
     if ($postDelta < 0) {
         $dispatcher->trigger('onDeleteKunenaPost', array(array($this->id)));
         $activity->onAfterDelete($this);
     } elseif ($postDelta > 0) {
         $topic->markRead();
         if ($this->parent == 0) {
             $activity->onAfterPost($this);
         } else {
             $activity->onAfterReply($this);
         }
     }
 }
예제 #16
0
 /**
  * @param  int    $catid
  * @param  int    $topic_id
  * @param  object $row
  * @param  bool   $linkOnly
  *
  * @return mixed|string
  */
 protected function showPlugin($catid, $topic_id, &$row, $linkOnly)
 {
     // Show a simple form to allow posting to forum from the plugin
     $plgShowForm = $this->params->get('form', 1);
     // Default is to put QuickPost at the very bottom.
     $formLocation = $this->params->get('form_location', 0);
     // Don't repeat the CSS for each instance of this plugin in a page!
     if (!self::$includedCss) {
         $doc = JFactory::getDocument();
         $doc->addStyleSheet(JUri::root(true) . "/plugins/content/kunenadiscuss/css/discuss.css");
         self::$includedCss = true;
     }
     // Find cross reference and the real topic
     $db = $this->db;
     $query = $db->getQuery(true)->select($db->quoteName('thread_id'))->from('#__kunenadiscuss')->where("content_id = {$db->quote($row->id)}");
     $this->db->setQuery($query);
     $result = $this->db->loadResult();
     KunenaError::checkDatabaseError();
     if ($topic_id) {
         // Custom topic found
         $this->debug("showPlugin: Loading Custom Topic {$topic_id}");
         $id = $topic_id;
     } elseif ($result) {
         // Reference found
         $this->debug("showPlugin: Loading Stored Topic {$result}");
         $id = $result;
     } else {
         // No topic exists
         $this->debug("showPlugin: No topic found");
         $id = 0;
     }
     $topic = KunenaForumTopicHelper::get($id);
     // If topic has been moved, find the real topic
     while ($topic->moved_id) {
         $this->debug("showPlugin: Topic {$topic->id} has been moved to {$topic->moved_id}");
         $topic = KunenaForumTopicHelper::get($topic->moved_id);
     }
     if ($result) {
         if (!$topic->exists()) {
             $this->debug("showPlugin: Topic does not exist, removing reference to {$result}");
             $this->deleteReference($row);
         } elseif ($topic->id != $id) {
             $this->debug("showPlugin: Topic has been moved or changed, updating reference to {$topic->id}");
             $this->updateReference($row, $topic->id);
         }
     } elseif ($topic_id && $topic->exists()) {
         $this->debug("showPlugin: First hit to Custom Topic, created reference to topic {$topic_id}");
         $this->createReference($row, $topic_id);
     }
     // Initialise some variables
     $subject = $row->title;
     if (isset($row->publish_up) && $row->publish_up != '0000-00-00 00:00:00') {
         $published = JFactory::getDate($row->publish_up)->toUnix();
         // take start publishing date
     } else {
         $published = JFactory::getDate($row->created)->toUnix();
         // or created date if publish_up is empty
     }
     $now = JFactory::getDate()->toUnix();
     if ($topic->exists()) {
         // If current user doesn't have authorisation to read existing topic, we are done
         if ($id && !$topic->authorise('read')) {
             $this->debug("showPlugin: Topic said {$topic->getError()}");
             return '';
         }
         $category = $topic->getCategory();
     } else {
         $this->debug("showPlugin: Let's see what we can do..");
         // If current user doesn't have authorisation to read category, we are done
         $category = KunenaForumCategoryHelper::get($catid);
         if (!$category->authorise('read')) {
             $this->debug("showPlugin: Category {$catid} said {$category->getError()}");
             return '';
         }
         $create = $this->params->get('create', 0);
         $createTime = $this->params->get('create_time', 0) * 604800;
         // Weeks in seconds
         if ($createTime && $published + $createTime < $now) {
             $this->debug("showPlugin: Topic creation time expired, cannot start new discussion anymore");
             return '';
         }
         if ($create) {
             $this->debug("showPlugin: First hit, created new topic {$topic_id} into forum");
             $topic = $this->createTopic($row, $category, $subject);
             if ($topic === false) {
                 return '';
             }
         }
     }
     // Do we allow answers into the topic?
     $closeTime = $this->params->get('close_time', 0) * 604800;
     // Weeks in seconds or 0 (forever)
     if ($closeTime && $topic->exists()) {
         $closeReason = $this->params->get('close_reason', 0);
         if ($closeReason) {
             $this->debug("showPlugin: Close time by last post");
             $closeTime += $topic->last_post_time;
         } else {
             $this->debug("showPlugin: Close time by topic creation");
             $closeTime += $topic->first_post_time;
         }
     } else {
         // Topic has not yet been created or will kept open forever
         $closeTime = $now + 1;
     }
     $linktopic = '';
     if ($topic->exists() && $linkOnly) {
         $this->debug("showPlugin: Displaying only link to the topic");
         $linktitle = JText::sprintf('PLG_KUNENADISCUSS_DISCUSS_ON_FORUMS', $topic->getReplies());
         return JHtml::_('kunenaforum.link', $topic->getUri($category), $linktitle, $linktitle);
     } elseif ($topic->exists() && !$plgShowForm) {
         $this->debug("showPlugin: Displaying link to the topic because the form is disabled");
         $linktitle = JText::sprintf('PLG_KUNENADISCUSS_DISCUSS_ON_FORUMS', $topic->getReplies());
         $linktopic = JHtml::_('kunenaforum.link', $topic->getUri($category), $linktitle, $linktitle);
     } elseif (!$topic->exists() && !$plgShowForm) {
         $linktopic = JText::_('PLG_KUNENADISCUSS_NEW_TOPIC_NOT_CREATED');
     }
     // ************************************************************************
     // Process the QuickPost form
     $quickPost = '';
     $canPost = $this->canPost($category, $topic);
     if ($canPost && $plgShowForm && (!$closeTime || $closeTime >= $now)) {
         if (JFactory::getUser()->get('guest')) {
             $this->debug("showPlugin: Guest can post: this feature doesn't work well if Joomla caching or Cache Plugin is enabled!");
         }
         if (JRequest::getInt('kdiscussContentId', -1, 'POST') == $row->id) {
             $this->debug("showPlugin: Reply topic!");
             $quickPost .= $this->replyTopic($row, $category, $topic, $subject);
         } else {
             $this->debug("showPlugin: Displaying form");
             $quickPost .= $this->showForm($row, $category, $topic, $subject);
         }
     }
     // This will be used all the way through to tell users how many posts are in the forum.
     $content = $this->showTopic($category, $topic, $linktopic);
     if (!$content && !$quickPost) {
         return $linktopic;
     }
     if ($formLocation) {
         $content = '<div class="kunenadiscuss">' . $content . '<br />' . $quickPost . '</div>';
     } else {
         $content = '<div class="kunenadiscuss">' . $quickPost . "<br />" . $content . '</div>';
     }
     return $content;
 }
예제 #17
0
파일: poll.php 프로젝트: BillVGN/PortalPRP
	/**
	 * Method to delete the KunenaForumTopicPoll object from the database.
	 *
	 * @return bool	True on success.
	 */
	public function delete()
	{
		if (!$this->exists())
		{
			return true;
		}

		// Create the table object
		$table = $this->getTable ();

		$success = $table->delete ( $this->id );

		if (! $success)
		{
			$this->setError ( $table->getError () );
		}

		$this->_exists = false;

		// Delete options
		$db = JFactory::getDBO ();
		$query = "DELETE FROM #__kunena_polls_options WHERE pollid={$db->Quote($this->id)}";
		$db->setQuery($query);
		$db->query();
		KunenaError::checkDatabaseError();

		// Delete votes
		$query = "DELETE FROM #__kunena_polls_users WHERE pollid={$db->Quote($this->id)}";
		$db->setQuery($query);
		$db->query();
		KunenaError::checkDatabaseError();

		// Remove poll from the topic
		$topic = KunenaForumTopicHelper::get($this->threadid);

		if ($success && $topic->exists() && $topic->poll_id)
		{
			$topic->poll_id = 0;
			$success = $topic->save();

			if (!$success)
			{
				$this->setError ( $topic->getError () );
			}
		}

		return $success;
	}
예제 #18
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;
 }
예제 #19
0
 /**
  * @param int  $catid
  * @param mixed $topic
  * @param mixed $type
  * @param bool $moderators
  * @param bool $admins
  * @param mixed $excludeList
  *
  * @return array
  */
 public function getSubscribers($catid, $topic, $type = false, $moderators = false, $admins = false, $excludeList = null)
 {
     $topic = KunenaForumTopicHelper::get($topic);
     $category = $topic->getCategory();
     if (!$topic->exists()) {
         return array();
     }
     $modlist = array();
     if (!empty($this->moderatorsByCatid[0])) {
         $modlist += $this->moderatorsByCatid[0];
     }
     if (!empty($this->moderatorsByCatid[$catid])) {
         $modlist += $this->moderatorsByCatid[$catid];
     }
     $adminlist = array();
     if (!empty($this->adminsByCatid[0])) {
         $adminlist += $this->adminsByCatid[0];
     }
     if (!empty($this->adminsByCatid[$catid])) {
         $adminlist += $this->adminsByCatid[$catid];
     }
     if ($type) {
         $subscribers = $this->loadSubscribers($topic, $type);
         $allow = $deny = array();
         if (!empty($subscribers)) {
             /** @var KunenaAccess $access */
             foreach ($this->accesstypes[$category->accesstype] as $access) {
                 if (method_exists($access, 'authoriseUsers')) {
                     list($a, $d) = $access->authoriseUsers($topic, $subscribers);
                     if (!empty($a)) {
                         $allow += array_combine($a, $a);
                     }
                     if (!empty($d)) {
                         $deny += array_combine($d, $d);
                     }
                 }
             }
         }
         $subslist = array_diff($allow, $deny);
         // Category administrators and moderators override ACL
         $subslist += array_intersect_key($adminlist, array_flip($subscribers));
         $subslist += array_intersect_key($modlist, array_flip($subscribers));
     }
     if (!$moderators) {
         $modlist = array();
     } else {
         // If category has no moderators, send email to admins instead
         if (empty($modlist)) {
             $admins = true;
         }
     }
     if (!$admins) {
         $adminlist = array();
     }
     $query = new KunenaDatabaseQuery();
     $query->select('u.id, u.name, u.username, u.email');
     $query->from('#__users AS u');
     $query->where("u.block=0");
     $userlist = array();
     if (!empty($subslist)) {
         $userlist += $subslist;
         $subslist = implode(',', array_keys($subslist));
         $query->select("IF( u.id IN ({$subslist}), 1, 0 ) AS subscription");
     } else {
         $query->select("0 AS subscription");
     }
     if (!empty($modlist)) {
         $userlist += $modlist;
         $modlist = implode(',', array_keys($modlist));
         $query->select("IF( u.id IN ({$modlist}), 1, 0 ) AS moderator");
     } else {
         $query->select("0 AS moderator");
     }
     if (!empty($adminlist)) {
         $userlist += $adminlist;
         $adminlist = implode(',', array_keys($adminlist));
         $query->select("IF( u.id IN ({$adminlist}), 1, 0 ) AS admin");
     } else {
         $query->select("0 AS admin");
     }
     if (empty($excludeList)) {
         // false, null, '', 0 and array(): get all subscribers
         $excludeList = array();
     } elseif (is_array($excludeList)) {
         // array() needs to be flipped to get userids into keys
         $excludeList = array_flip($excludeList);
     } else {
         // Others: let's assume that we have comma separated list of values (string)
         $excludeList = array_flip(explode(',', (string) $excludeList));
     }
     $userlist = array_diff_key($userlist, $excludeList);
     $userids = array();
     if (!empty($userlist)) {
         $userlist = implode(',', array_keys($userlist));
         $query->where("u.id IN ({$userlist})");
         $db = JFactory::getDBO();
         $db->setQuery($query);
         $userids = (array) $db->loadObjectList();
         KunenaError::checkDatabaseError();
     }
     return $userids;
 }
예제 #20
0
 /**
  * @return KunenaForumTopic
  */
 public function getLastTopic()
 {
     return KunenaForumTopicHelper::get($this->getLastCategory()->last_topic_id);
 }
예제 #21
0
 public function resetvotes()
 {
     if (!JRequest::checkToken('get')) {
         $this->app->enqueueMessage(JText::_('COM_KUNENA_ERROR_TOKEN'), 'error');
         $this->redirectBack();
     }
     $pollid = JRequest::getInt('pollid', 0);
     $topic = KunenaForumTopicHelper::get($this->id);
     $result = $topic->resetvotes($pollid);
     $this->app->enqueueMessage(JText::_('COM_KUNENA_TOPIC_VOTE_RESET_SUCCESS'));
     $this->app->redirect($topic->getUrl($this->return, false));
 }
예제 #22
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'));
 }
예제 #23
0
파일: router.php 프로젝트: madcsaba/li-de
/**
 * Build SEF URL
 *
 * All SEF URLs are formatted like this:
 *
 * http://site.com/menuitem/1-category-name/10-subject/[view]/[layout]/[param1]-value1/[param2]-value2?param3=value3&param4=value4
 *
 * - If catid exists, category will always be in the first segment
 * - If there is no catid, second segment for message will not be used (param-value: id-10)
 * - [view] and [layout] are the only parameters without value
 * - all other segments (task, id, userid, page, sel) are using param-value format
 *
 * NOTE! Only major variables are using SEF segments
 *
 * @param $query
 * @return array Segments
 */
function KunenaBuildRoute(&$query)
{
    $segments = array();
    // If Kunena Forum isn't installed or SEF is not enabled, do nothing
    if (!class_exists('KunenaForum') || !KunenaForum::isCompatible('3.0') || !KunenaForum::installed() || !KunenaRoute::$config->sef) {
        return $segments;
    }
    KUNENA_PROFILER ? KunenaProfiler::instance()->start('function ' . __FUNCTION__ . '()') : null;
    // Get menu item
    $menuitem = null;
    if (isset($query['Itemid'])) {
        static $menuitems = array();
        $Itemid = $query['Itemid'] = (int) $query['Itemid'];
        if (!isset($menuitems[$Itemid])) {
            $menuitems[$Itemid] = JFactory::getApplication()->getMenu()->getItem($Itemid);
            if (!$menuitems[$Itemid]) {
                // Itemid doesn't exist or is invalid
                unset($query['Itemid']);
            }
        }
        $menuitem = $menuitems[$Itemid];
    }
    // Safety check: we need view in order to create SEF URLs
    if (!isset($menuitem->query['view']) && empty($query['view'])) {
        KUNENA_PROFILER ? KunenaProfiler::instance()->stop('function ' . __FUNCTION__ . '()') : null;
        return $segments;
    }
    // Get view for later use (query wins menu item)
    $view = isset($query['view']) ? (string) preg_replace('/[^a-z]/', '', $query['view']) : $menuitem->query['view'];
    // Get default values for URI variables
    if (isset(KunenaRoute::$views[$view])) {
        $defaults = KunenaRoute::$views[$view];
    }
    // Check all URI variables and remove those which aren't needed
    foreach ($query as $var => $value) {
        if (isset($defaults[$var]) && !isset($menuitem->query[$var]) && $value == $defaults[$var]) {
            // Remove URI variable which has default value
            unset($query[$var]);
        } elseif (isset($menuitem->query[$var]) && $value == $menuitem->query[$var] && $var != 'Itemid' && $var != 'option') {
            // Remove URI variable which has the same value as menu item
            unset($query[$var]);
        }
    }
    // We may have catid also in the menu item (it will not be in URI)
    $numeric = !empty($menuitem->query['catid']);
    // Support URIs like: /forum/12-my_category
    if (!empty($query['catid']) && ($view == 'category' || $view == 'topic' || $view == 'home')) {
        // TODO: ensure that we have view=category/topic
        $catid = (int) $query['catid'];
        if ($catid) {
            $numeric = true;
            $alias = KunenaForumCategoryHelper::get($catid)->alias;
            // If category alias is empty, use category id; otherwise use alias
            $segments[] = empty($alias) ? $catid : $alias;
            // This segment fully defines category view so the variable is no longer needed
            if ($view == 'category') {
                unset($query['view']);
            }
        }
        unset($query['catid']);
    }
    // Support URIs like: /forum/12-category/123-topic
    if (!empty($query['id']) && $numeric) {
        $id = (int) $query['id'];
        if ($id) {
            $subject = KunenaRoute::stringURLSafe(KunenaForumTopicHelper::get($id)->subject);
            if (empty($subject)) {
                $segments[] = $id;
            } else {
                $segments[] = "{$id}-{$subject}";
            }
            // This segment fully defines topic view so the variable is no longer needed
            if ($view == 'topic') {
                unset($query['view']);
            }
        }
        unset($query['id']);
    } else {
        // No id available, do not use numeric variable for mesid
        $numeric = false;
    }
    // View gets added only when we do not use short URI for category/topic
    if (!empty($query['view'])) {
        // Use filtered value
        $segments[] = $view;
    }
    // Support URIs like: /forum/12-category/123-topic/reply
    if (!empty($query['layout'])) {
        // Use filtered value
        $segments[] = (string) preg_replace('/[^a-z]/', '', $query['layout']);
    }
    // Support URIs like: /forum/12-category/123-topic/reply/124
    if (isset($query['mesid']) && $numeric) {
        $segments[] = (int) $query['mesid'];
        unset($query['mesid']);
    }
    // Support URIs like: /forum/user/128-matias
    if (isset($query['userid']) && $view == 'user') {
        $segments[] = (int) $query['userid'] . '-' . KunenaRoute::stringURLSafe(KunenaUserHelper::get((int) $query['userid'])->getName());
        unset($query['userid']);
    }
    unset($query['view'], $query['layout']);
    // Rest of the known parameters are in var-value form
    foreach (KunenaRoute::$parsevars as $var => $dummy) {
        if (isset($query[$var])) {
            $segments[] = "{$var}-{$query[$var]}";
            unset($query[$var]);
        }
    }
    KUNENA_PROFILER ? KunenaProfiler::instance()->stop('function ' . __FUNCTION__ . '()') : null;
    return $segments;
}
예제 #24
0
파일: topic.php 프로젝트: rich20/Kunena
	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;
	}
예제 #25
0
 /**
  * @param int    $topic_id
  * @param int    $start
  * @param int    $limit
  * @param string $ordering
  * @param int    $hold
  * @param bool   $orderbyid
  *
  * @return array
  */
 protected static function loadMessagesByTopic($topic_id, $start = 0, $limit = 0, $ordering = 'ASC', $hold = 0, $orderbyid = false)
 {
     $db = JFactory::getDBO();
     $query = "SELECT m.*, t.message\n\t\t\tFROM #__kunena_messages AS m\n\t\t\tINNER JOIN #__kunena_messages_text AS t ON m.id=t.mesid\n\t\t\tWHERE m.thread={$db->quote($topic_id)} AND m.hold IN ({$hold}) ORDER BY m.time {$ordering}";
     $db->setQuery($query, $start, $limit);
     $results = (array) $db->loadAssocList('id');
     KunenaError::checkDatabaseError();
     $location = $orderbyid || $ordering == 'ASC' ? $start : KunenaForumTopicHelper::get($topic_id)->getTotal($hold) - $start - 1;
     $order = $ordering == 'ASC' ? 1 : -1;
     $list = array();
     foreach ($results as $id => $result) {
         $instance = new KunenaForumMessage($result);
         $instance->exists(true);
         self::$_instances[$id] = $instance;
         $list[$orderbyid ? $id : $location] = $instance;
         $location += $order;
     }
     unset($results);
     return $list;
 }
예제 #26
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 = '';
 }
예제 #27
0
 public function getTopic()
 {
     return KunenaForumTopicHelper::get($this->topic_id);
 }
예제 #28
0
파일: access.php 프로젝트: rich20/Kunena
	public function getSubscribers($catid, $topic, $subscriptions = false, $moderators = false, $admins = false, $excludeList = null) {
		$topic = KunenaForumTopicHelper::get($topic);
		if (!$topic->exists())
			return array();

		if ($subscriptions) {
			$subslist = $this->loadSubscribers($topic, (int)$subscriptions);
		}
		if ($moderators) {
			$modlist = array();
			if (!empty(self::$moderatorsByCatid[0])) $modlist += self::$moderatorsByCatid[0];
			if (!empty(self::$moderatorsByCatid[$catid])) $modlist += self::$moderatorsByCatid[$catid];

			// If category has no moderators, send email to admins instead
			if (empty($modlist)) $admins = true;
		}
		if ($admins) {
			$adminlist = array();
			if (!empty(self::$adminsByCatid[0])) $adminlist += self::$adminsByCatid[0];
			if (!empty(self::$adminsByCatid[$catid])) $adminlist += self::$adminsByCatid[$catid];
		}

		$query = new KunenaDatabaseQuery();
		$query->select('u.id, u.name, u.username, u.email');
		$query->from('#__users AS u');
		$query->where("u.block=0");
		$userlist = array();
		if (!empty($subslist)) {
			$userlist = $subslist;
			$subslist = implode(',', array_keys($subslist));
			$query->select("IF( u.id IN ({$subslist}), 1, 0 ) AS subscription");
		} else {
			$query->select("0 AS subscription");
		}
		if (!empty($modlist)) {
			$userlist += $modlist;
			$modlist = implode(',', array_keys($modlist));
			$query->select("IF( u.id IN ({$modlist}), 1, 0 ) AS moderator");
		} else {
			$query->select("0 AS moderator");
		}
		if (!empty($adminlist)) {
			$userlist += $adminlist;
			$adminlist = implode(',', array_keys($adminlist));
			$query->select("IF( u.id IN ({$adminlist}), 1, 0 ) AS admin");
		} else {
			$query->select("0 AS admin");
		}
		if (empty($excludeList)) {
			// false, null, '', 0 and array(): get all subscribers
			$excludeList = array();
		} elseif (is_array($excludeList)) {
			// array() needs to be flipped to get userids into keys
			$excludeList = array_flip($excludeList);
		} else {
			// Others: let's assume that we have comma separated list of values (string)
			$excludeList = array_flip(explode(',', (string) $excludeList));
		}
		$userlist = array_diff_key($userlist, $excludeList);
		$userids = array();
		if (!empty($userlist)) {
			$userlist = implode(',', array_keys($userlist));
			$query->where("u.id IN ({$userlist})");
			$db = JFactory::getDBO();
			$db->setQuery ( $query );
			$userids = (array) $db->loadObjectList ();
			KunenaError::checkDatabaseError();
		}
		return $userids;
	}
예제 #29
0
파일: view.html.php 프로젝트: rich20/Kunena
	function displayBreadcrumb($tpl = null) {
		$catid = JRequest::getInt ( 'catid', 0 );
		$id = JRequest::getInt ( 'id', 0 );
		$view = JRequest::getWord ( 'view', 'default' );
		$layout = JRequest::getWord ( 'layout', 'default' );

		$app = JFactory::getApplication();
		$pathway = $app->getPathway();
		$active = JFactory::getApplication()->getMenu ()->getActive ();

		if (empty($this->pathway)) {
			if ($catid) {
				$parents = KunenaForumCategoryHelper::getParents($catid);
				$parents[$catid] = KunenaForumCategoryHelper::get($catid);

				// Remove categories from pathway if menu item contains/excludes them
				if (!empty($active->query['catid']) && isset($parents[$active->query['catid']])) {
					$curcatid = $active->query['catid'];
					while (($item = array_shift($parents)) !== null) {
						if ($item->id == $curcatid) break;
					}
				}
				foreach ( $parents as $parent ) {
					$pathway->addItem($this->escape( $parent->name ), KunenaRoute::normalize("index.php?option=com_kunena&view=category&catid={$parent->id}"));
				}
			}
			if ($id) {
				$topic = KunenaForumTopicHelper::get($id);
				$pathway->addItem($this->escape( $topic->subject ), KunenaRoute::normalize("index.php?option=com_kunena&view=category&catid={$catid}&id={$topic->id}"));
			}
			if ($view == 'topic') {
				$active_layout = (!empty($active->query['view']) && $active->query['view'] == 'topic' && !empty($active->query['layout'])) ? $active->query['layout'] : '';
				switch ($layout) {
					case 'create':
						if ($active_layout != 'create') $pathway->addItem($this->escape( JText::_('COM_KUNENA_BUTTON_NEW_TOPIC'), KunenaRoute::normalize() ));
						break;
					case 'reply':
						if ($active_layout != 'reply') $pathway->addItem($this->escape( JText::_('COM_KUNENA_BUTTON_REPLY_TOPIC'), KunenaRoute::normalize() ));
						break;
					case 'edit':
						if ($active_layout != 'edit') $pathway->addItem($this->escape( JText::_('COM_KUNENA_BUTTON_EDIT'), KunenaRoute::normalize() ));
						break;
				}
			}
		}
		$this->pathway = array();
		foreach ($pathway->getPathway() as $pitem) {
			$item = new StdClass();
			$item->name = $this->escape($pitem->name);
			$item->link = KunenaRoute::_($pitem->link);
			if ($item->link) $this->pathway[] = $item;
		}

		$result = $this->loadTemplate($tpl);
		if (JError::isError($result)) {
			return $result;
		}
		echo $result;
	}
예제 #30
0
 public function resetvotes()
 {
     if (!JSession::checkToken('get')) {
         $this->app->enqueueMessage(JText::_('COM_KUNENA_ERROR_TOKEN'), 'error');
         $this->setRedirectBack();
         return;
     }
     $topic = KunenaForumTopicHelper::get($this->id);
     $topic->resetvotes();
     $this->app->enqueueMessage(JText::_('COM_KUNENA_TOPIC_VOTE_RESET_SUCCESS'));
     $this->setRedirect($topic->getUrl($this->return, false));
 }