예제 #1
0
파일: user.php 프로젝트: BillVGN/PortalPRP
	public function getSubscriptions()
	{
		$db     = JFactory::getDBO();
		$userid = $this->getState($this->getName() . '.id');

		$db->setQuery("SELECT topic_id AS thread FROM #__kunena_user_topics WHERE user_id='$userid' AND subscribed=1");
		$subslist = (array) $db->loadObjectList();

		if (KunenaError::checkDatabaseError())
		{
			return array();
		}

		$topic_list = array();

		if (!empty($subslist))
		{
			foreach ($subslist as $sub)
			{
				$topic_list[] = $sub->thread;
			}

			$topic_list = KunenaForumTopicHelper::getTopics($topic_list);
		}

		return $topic_list;
	}
예제 #2
0
	/**
	 * Prepare user attachments list.
	 *
	 * @return void
	 */
	protected function before()
	{
		parent::before();

		$userid = $this->input->getInt('userid');
		$params = array('file' => '1', 'image' => '1', 'orderby' => 'desc', 'limit' => '30');

		$this->template = KunenaFactory::getTemplate();
		$this->me = KunenaUserHelper::getMyself();
		$this->profile = KunenaUserHelper::get($userid);
		$this->attachments = KunenaAttachmentHelper::getByUserid($this->profile, $params);

		// Pre-load messages.
		$messageIds = array();

		foreach ($this->attachments as $attachment)
		{
			$messageIds[] = (int) $attachment->mesid;
		}

		$messages = KunenaForumMessageHelper::getMessages($messageIds, 'none');

		// Pre-load topics.
		$topicIds = array();

		foreach ($messages as $message)
		{
			$topicIds[] = $message->thread;
		}

		KunenaForumTopicHelper::getTopics($topicIds, 'none');

		$this->headerText = JText::_('COM_KUNENA_MANAGE_ATTACHMENTS');
	}
예제 #3
0
 /**
  * Prepare category subscriptions display.
  *
  * @return void
  *
  * @throws KunenaExceptionAuthorise
  */
 protected function before()
 {
     parent::before();
     $me = KunenaUserHelper::getMyself();
     if (!$me->exists()) {
         throw new KunenaExceptionAuthorise(JText::_('COM_KUNENA_NO_ACCESS'), 401);
     }
     $limit = $this->input->getInt('limit', 0);
     if ($limit < 1 || $limit > 100) {
         $limit = 20;
     }
     $limitstart = $this->input->getInt('limitstart', 0);
     if ($limitstart < 0) {
         $limitstart = 0;
     }
     list($total, $this->categories) = KunenaForumCategoryHelper::getLatestSubscriptions($me->userid);
     $topicIds = array();
     $userIds = array();
     $postIds = array();
     foreach ($this->categories as $category) {
         // Get list of topics.
         if ($category->last_topic_id) {
             $topicIds[$category->last_topic_id] = $category->last_topic_id;
         }
     }
     // Pre-fetch topics (also display unauthorized topics as they are in allowed categories).
     $topics = KunenaForumTopicHelper::getTopics($topicIds, 'none');
     // Pre-fetch users (and get last post ids for moderators).
     foreach ($topics as $topic) {
         $userIds[$topic->last_post_userid] = $topic->last_post_userid;
         $postIds[$topic->id] = $topic->last_post_id;
     }
     KunenaUserHelper::loadUsers($userIds);
     KunenaForumMessageHelper::getMessages($postIds);
     // Pre-fetch user related stuff.
     if ($me->exists() && !$me->isBanned()) {
         // Load new topic counts.
         KunenaForumCategoryHelper::getNewTopics(array_keys($this->categories));
     }
     $this->actions = $this->getActions();
     $this->pagination = new JPagination($total, $limitstart, $limit);
     $this->headerText = JText::_('COM_KUNENA_CATEGORY_SUBSCRIPTIONS');
 }
예제 #4
0
파일: topics.php 프로젝트: rich20/Kunena
	protected function getPosts() {
		$this->topics = array();

		$start = $this->getState ( 'list.start' );
		$limit = $this->getState ( 'list.limit' );
		$params = array();
		$params['mode'] = $this->getState ( 'list.mode' );
		$params['reverse'] = ! $this->getState ( 'list.categories.in' );
		$params['starttime'] = $this->getState ( 'list.time' );
		$params['user'] = $this->getState ( 'user' );
		list ($this->total, $this->messages) = KunenaForumMessageHelper::getLatestMessages($this->getState ( 'list.categories' ), $start, $limit, $params);

		$topicids = array();
		foreach ( $this->messages as $message ) {
			$topicids[$message->thread] = $message->thread;
		}
		$authorise = 'read';
		switch ($params['mode']) {
			case 'unapproved':
				$authorise = 'approve';
				break;
			case 'deleted':
				$authorise = 'undelete';
				break;
		}
		$this->topics = KunenaForumTopicHelper::getTopics ( $topicids, $authorise );
		$this->_common();
	}
예제 #5
0
 /**
  *
  */
 function displayAttachments()
 {
     $this->title = JText::_('COM_KUNENA_MANAGE_ATTACHMENTS');
     $this->items = $this->userattachs;
     if (!empty($this->userattachs)) {
         // Preload messages
         $attach_mesids = array();
         foreach ($this->userattachs as $attach) {
             $attach_mesids[] = (int) $attach->mesid;
         }
         $messages = KunenaForumMessageHelper::getMessages($attach_mesids, 'none');
         // Preload topics
         $topic_ids = array();
         foreach ($messages as $message) {
             $topic_ids[] = $message->thread;
         }
         KunenaForumTopicHelper::getTopics($topic_ids, 'none');
     }
     echo $this->loadTemplateFile('attachments');
 }
예제 #6
0
 public function getResults()
 {
     if ($this->messages !== false) {
         return $this->messages;
     }
     $q = $this->getState('searchwords');
     if (!$q && !$this->getState('query.searchuser')) {
         $this->setError(JText::_('COM_KUNENA_SEARCH_ERR_SHORTKEYWORD'));
         return array();
     }
     /* get results */
     $hold = $this->getState('query.show');
     if ($hold == 1) {
         $mode = 'unapproved';
     } elseif ($hold >= 2) {
         $mode = 'deleted';
     } else {
         $mode = 'recent';
     }
     $params = array('mode' => $mode, 'childforums' => $this->getState('query.childforums'), 'where' => $this->buildWhere(), 'orderby' => $this->buildOrderBy(), 'starttime' => -1);
     $limitstart = $this->getState('list.start');
     $limit = $this->getState('list.limit');
     list($this->total, $this->messages) = KunenaForumMessageHelper::getLatestMessages($this->getState('query.catids'), $limitstart, $limit, $params);
     if ($this->total < $limitstart) {
         $this->setState('list.start', intval($this->total / $limit) * $limit);
     }
     $topicids = array();
     $userids = array();
     foreach ($this->messages as $message) {
         $topicids[$message->thread] = $message->thread;
         $userids[$message->userid] = $message->userid;
     }
     if ($topicids) {
         $topics = KunenaForumTopicHelper::getTopics($topicids);
         foreach ($topics as $topic) {
             $userids[$topic->first_post_userid] = $topic->first_post_userid;
         }
     }
     KunenaUserHelper::loadUsers($userids);
     KunenaForumMessageHelper::loadLocation($this->messages);
     if (empty($this->messages)) {
         $this->app->enqueueMessage(JText::sprintf('COM_KUNENA_SEARCH_NORESULTS_FOUND', $q));
     }
     return $this->messages;
 }
예제 #7
0
 function restore()
 {
     if (!JSession::checkToken('post')) {
         $this->app->enqueueMessage(JText::_('COM_KUNENA_ERROR_TOKEN'), 'error');
         $this->app->redirect(KunenaRoute::_($this->baseurl, false));
     }
     $cid = JRequest::getVar('cid', array(), 'post', 'array');
     // Array of integers
     JArrayHelper::toInteger($cid);
     $type = JRequest::getCmd('type', 'topics', 'post');
     if (empty($cid)) {
         $this->app->enqueueMessage(JText::_('COM_KUNENA_A_NO_MESSAGES_SELECTED'), 'notice');
         $this->app->redirect(KunenaRoute::_($this->baseurl, false));
     }
     $nb_items = 0;
     if ($type == 'messages') {
         $messages = KunenaForumMessageHelper::getMessages($cid, 'none');
         foreach ($messages as $target) {
             if ($target->publish(KunenaForum::PUBLISHED)) {
                 $nb_items++;
             } else {
                 $this->app->enqueueMessage($target->getError(), 'notice');
             }
         }
     } elseif ($type == 'topics') {
         $topics = KunenaForumTopicHelper::getTopics($cid, 'none');
         foreach ($topics as $target) {
             if ($target->publish(KunenaForum::PUBLISHED)) {
                 $nb_items++;
             } else {
                 $this->app->enqueueMessage($target->getError(), 'notice');
             }
         }
     } else {
         // Error...
     }
     if ($nb_items > 0) {
         $this->app->enqueueMessage(JText::sprintf('COM_KUNENA_TRASH_ITEMS_RESTORE_DONE', $nb_items));
     }
     KunenaUserHelper::recount();
     KunenaForumTopicHelper::recount();
     KunenaForumCategoryHelper::recount();
     $this->app->redirect(KunenaRoute::_($this->baseurl, false));
 }
예제 #8
0
파일: topics.php 프로젝트: rich20/Kunena
	function unsubscribe() {
		$app = JFactory::getApplication ();
		if (! JRequest::checkToken ()) {
			$app->enqueueMessage ( JText::_ ( 'COM_KUNENA_ERROR_TOKEN' ), 'error' );
			$this->redirectBack ();
		}

		$topics = KunenaForumTopicHelper::getTopics(array_keys(JRequest::getVar('topics', array ( 0 ), 'post', 'array')));
		if ( KunenaForumTopicHelper::subscribe(array_keys($topics), 0) ) {
			$app->enqueueMessage ( JText::_('COM_KUNENA_USER_UNSUBSCRIBE_YES') );
		} else {
			$app->enqueueMessage ( JText::_('COM_KUNENA_POST_NO_UNSUBSCRIBED_TOPIC') );
		}
		$this->redirectBack ();
	}
예제 #9
0
 /**
  * Method to get details on selected items.
  *
  * @return	Array
  * @since	1.6
  */
 public function getPurgeItems()
 {
     $ids = $this->app->getUserState('com_kunena.purge');
     $topic = $this->app->getUserState('com_kunena.topic');
     $message = $this->app->getUserState('com_kunena.message');
     $ids = implode(',', $ids);
     if ($topic) {
         $items = KunenaForumTopicHelper::getTopics($ids);
     } elseif ($message) {
         $items = KunenaForumMessageHelper::getMessages($ids);
     } else {
     }
     return $items;
 }
예제 #10
0
 /**
  * Retrieves a list of tasks created by a particular user.
  *
  * @since	1.0
  * @access	public
  * @param	int		$userId		The user's / creator's id.
  *
  * @return	Array				A list of notes item.
  */
 public function getPosts($userId, $total = 10)
 {
     $db = FD::db();
     $sql = $db->sql();
     $sql->select('#__kunena_messages', 'a');
     $sql->column('a.thread');
     $sql->where('a.parent', 0);
     $sql->where('a.userid', $userId);
     $sql->where('a.hold', '0', '=');
     $sql->order('a.time', 'DESC');
     $sql->limit(0, $total);
     $db->setQuery($sql);
     $result = $db->loadColumn();
     if (!$result) {
         return array();
     }
     $posts = KunenaForumTopicHelper::getTopics($result);
     return $posts;
 }
예제 #11
0
	static public function getByTopics($ids = false, $userid = 0)
	{
		$userid = (int) $userid;

		if ($ids === false)
		{
			$ids = array_keys(KunenaForumTopicHelper::getTopics());
		}
		elseif (is_array ($ids))
		{
			$ids = array_unique($ids);
		}
		else
		{
			$ids = array($ids);
			$single = true;
		}

		self::loadTopics($ids, $userid);

		$list = array ();

		if (isset($single))
		{
			$list = !empty(self::$_users [$userid][end($ids)]) ? self::$_users [$userid][end($ids)] : array();
		}
		else
		{
			foreach ( $ids as $id )
			{
				if (!empty(self::$_users [$userid][$id]))
				{
					$list [$id] = self::$_users [$userid][$id];
				}
			}
		}

		return $list;
	}
예제 #12
0
 /**
  * Get topics.
  *
  * @param  string  $access  Kunena action access control check.
  * @return array|KunenaForumTopic[]
  */
 public function find($access = 'read')
 {
     $results = parent::find();
     return KunenaForumTopicHelper::getTopics($results, $access);
 }
예제 #13
0
 function unsubscribe()
 {
     if (!JSession::checkToken('post')) {
         $this->app->enqueueMessage(JText::_('COM_KUNENA_ERROR_TOKEN'), 'error');
         $this->setRedirectBack();
         return;
     }
     $ids = array_keys(JRequest::getVar('topics', array(), 'post', 'array'));
     // Array of integer keys
     JArrayHelper::toInteger($ids);
     $topics = KunenaForumTopicHelper::getTopics($ids);
     if (KunenaForumTopicHelper::subscribe(array_keys($topics), 0)) {
         $this->app->enqueueMessage(JText::_('COM_KUNENA_USER_UNSUBSCRIBE_YES'));
     } else {
         $this->app->enqueueMessage(JText::_('COM_KUNENA_POST_NO_UNSUBSCRIBED_TOPIC'));
     }
     $this->setRedirectBack();
 }
예제 #14
0
파일: category.php 프로젝트: madcsaba/li-de
 public function getCategories()
 {
     if ($this->items === false) {
         $this->items = array();
         $catid = $this->getState('item.id');
         $layout = $this->getState('layout');
         $flat = false;
         if ($layout == 'user') {
             $categories[0] = KunenaForumCategoryHelper::getSubscriptions();
             $flat = true;
         } elseif ($catid) {
             $categories[0] = KunenaForumCategoryHelper::getCategories($catid);
             if (empty($categories[0])) {
                 return array();
             }
         } else {
             $categories[0] = KunenaForumCategoryHelper::getChildren();
         }
         if ($flat) {
             $allsubcats = $categories[0];
         } else {
             $allsubcats = KunenaForumCategoryHelper::getChildren(array_keys($categories[0]), 1);
         }
         if (empty($allsubcats)) {
             return array();
         }
         KunenaForumCategoryHelper::getNewTopics(array_keys($allsubcats));
         $modcats = array();
         $lastpostlist = array();
         $userlist = array();
         $topiclist = array();
         foreach ($allsubcats as $subcat) {
             if ($flat || isset($categories[0][$subcat->parent_id])) {
                 $last = $subcat->getLastCategory();
                 if ($last->last_topic_id) {
                     // Get list of topics
                     $topiclist[$last->last_topic_id] = $last->last_topic_id;
                 }
                 if ($this->config->listcat_show_moderators) {
                     // Get list of moderators
                     $subcat->moderators = $subcat->getModerators(false, false);
                     $userlist += $subcat->moderators;
                 }
                 if ($this->me->isModerator($subcat)) {
                     $modcats[] = $subcat->id;
                 }
             }
             $categories[$subcat->parent_id][] = $subcat;
         }
         // Prefetch topics
         $topics = KunenaForumTopicHelper::getTopics($topiclist);
         foreach ($topics as $topic) {
             // Prefetch users
             $userlist[$topic->last_post_userid] = $topic->last_post_userid;
             $lastpostlist[$topic->id] = $topic->last_post_id;
         }
         if ($this->me->ordering != 0) {
             $topic_ordering = $this->me->ordering == 1 ? true : false;
         } else {
             $topic_ordering = $this->config->default_sort == 'asc' ? false : true;
         }
         $this->pending = array();
         if ($this->me->userid && count($modcats)) {
             $catlist = implode(',', $modcats);
             $db = JFactory::getDBO();
             $db->setQuery("SELECT catid, COUNT(*) AS count\n\t\t\t\tFROM #__kunena_messages\n\t\t\t\tWHERE catid IN ({$catlist}) AND hold=1\n\t\t\t\tGROUP BY catid");
             $pending = $db->loadAssocList();
             KunenaError::checkDatabaseError();
             foreach ($pending as $item) {
                 if ($item['count']) {
                     $this->pending[$item['catid']] = $item['count'];
                 }
             }
         }
         // Fix last post position when user can see unapproved or deleted posts
         if ($lastpostlist && !$topic_ordering && ($this->me->isAdmin() || KunenaAccess::getInstance()->getModeratorStatus())) {
             KunenaForumMessageHelper::getMessages($lastpostlist);
             KunenaForumMessageHelper::loadLocation($lastpostlist);
         }
         // Prefetch all users/avatars to avoid user by user queries during template iterations
         KunenaUserHelper::loadUsers($userlist);
         if ($flat) {
             $this->items = $allsubcats;
         } else {
             $this->items = $categories;
         }
     }
     return $this->items;
 }
예제 #15
0
 /**
  * Prepare category index display.
  *
  * @return void
  */
 protected function before()
 {
     parent::before();
     $this->me = KunenaUserHelper::getMyself();
     // Get sections to display.
     $catid = $this->input->getInt('catid', 0);
     if ($catid) {
         $sections = KunenaForumCategoryHelper::getCategories($catid);
     } else {
         $sections = KunenaForumCategoryHelper::getChildren();
     }
     $sectionIds = array();
     $this->more[$catid] = 0;
     foreach ($sections as $key => $category) {
         $this->categories[$category->id] = array();
         $this->more[$category->id] = 0;
         // Display only categories which are supposed to show up.
         if ($catid || $category->params->get('display.index.parent', 3) > 0) {
             if ($catid || $category->params->get('display.index.children', 3) > 1) {
                 $sectionIds[] = $category->id;
             } else {
                 $this->more[$category->id]++;
             }
         } else {
             $this->more[$category->parent_id]++;
             unset($sections[$key]);
             continue;
         }
     }
     // Get categories and subcategories.
     if (empty($sections)) {
         return;
     }
     $this->sections = $sections;
     $categories = KunenaForumCategoryHelper::getChildren($sectionIds);
     if (empty($categories)) {
         return;
     }
     $categoryIds = array();
     $topicIds = array();
     $userIds = array();
     $postIds = array();
     foreach ($categories as $key => $category) {
         $this->more[$category->id] = 0;
         // Display only categories which are supposed to show up.
         if ($catid || $category->params->get('display.index.parent', 3) > 1) {
             if ($catid || $category->getParent()->params->get('display.index.children', 3) > 2 && $category->params->get('display.index.children', 3) > 2) {
                 $categoryIds[] = $category->id;
             } else {
                 $this->more[$category->id]++;
             }
         } else {
             $this->more[$category->parent_id]++;
             unset($categories[$key]);
             continue;
         }
         // Get list of topics.
         $last = $category->getLastCategory();
         if ($last->last_topic_id) {
             $topicIds[$last->last_topic_id] = $last->last_topic_id;
         }
         $this->categories[$category->parent_id][] = $category;
         $rssURL = $category->getRSSUrl();
         if (!empty($rssURL)) {
             $category->rssURL = $category->getRSSUrl();
         }
     }
     $subcategories = KunenaForumCategoryHelper::getChildren($categoryIds);
     foreach ($subcategories as $category) {
         // Display only categories which are supposed to show up.
         if ($catid || $category->params->get('display.index.parent', 3) > 2) {
             $this->categories[$category->parent_id][] = $category;
         } else {
             $this->more[$category->parent_id]++;
         }
     }
     // Pre-fetch topics (also display unauthorized topics as they are in allowed categories).
     $topics = KunenaForumTopicHelper::getTopics($topicIds, 'none');
     // Pre-fetch users (and get last post ids for moderators).
     foreach ($topics as $topic) {
         $userIds[$topic->last_post_userid] = $topic->last_post_userid;
         $postIds[$topic->id] = $topic->last_post_id;
     }
     KunenaUserHelper::loadUsers($userIds);
     KunenaForumMessageHelper::getMessages($postIds);
     // Pre-fetch user related stuff.
     $this->pending = array();
     if ($this->me->exists() && !$this->me->isBanned()) {
         // Load new topic counts.
         KunenaForumCategoryHelper::getNewTopics(array_keys($categories + $subcategories));
         // Get categories which are moderated by current user.
         $access = KunenaAccess::getInstance();
         $moderate = $access->getAdminStatus($this->me) + $access->getModeratorStatus($this->me);
         if (!empty($moderate[0])) {
             // Global moderators.
             $moderate = $categories;
         } else {
             // Category moderators.
             $moderate = array_intersect_key($categories, $moderate);
         }
         if (!empty($moderate)) {
             // Get pending messages.
             $catlist = implode(',', array_keys($moderate));
             $db = JFactory::getDbo();
             $db->setQuery("SELECT catid, COUNT(*) AS count\n\t\t\t\t\tFROM #__kunena_messages\n\t\t\t\t\tWHERE catid IN ({$catlist}) AND hold=1\n\t\t\t\t\tGROUP BY catid");
             $pending = $db->loadAssocList();
             KunenaError::checkDatabaseError();
             foreach ($pending as $item) {
                 if ($item['count']) {
                     $this->pending[$item['catid']] = $item['count'];
                 }
             }
             if ($this->me->ordering != 0) {
                 $topic_ordering = $this->me->ordering == 1 ? true : false;
             } else {
                 $topic_ordering = $this->config->default_sort == 'asc' ? false : true;
             }
             // Fix last post position when user can see unapproved or deleted posts.
             if (!$topic_ordering) {
                 KunenaForumMessageHelper::loadLocation($postIds);
             }
         }
     }
 }
예제 #16
0
파일: trash.php 프로젝트: rich20/Kunena
	/**
	 * Method to get details on selected items.
	 *
	 * @return	Array
	 * @since	1.6
	 */
	public function getPurgeItems() {
		kimport('kunena.error');

		$app = JFactory::getApplication ();

		$ids = $app->getUserState ( 'com_kunena.purge' );
		$topic = $app->getUserState('com_kunena.topic');
		$message = $app->getUserState('com_kunena.message');

		$ids = implode ( ',', $ids );

		if ( $topic ) {
			$items = KunenaForumTopicHelper::getTopics($ids);
		} elseif ( $message ) {
			$items = KunenaForumMessageHelper::getMessages($ids);
		} else {

		}

		return $items;
	}
예제 #17
0
 /**
  * Prepare category list display.
  *
  * @return void
  */
 protected function before()
 {
     parent::before();
     require_once KPATH_SITE . '/models/topics.php';
     $this->model = new KunenaModelTopics(array(), $this->input);
     $this->model->initialize($this->getOptions(), $this->getOptions()->get('embedded', false));
     $this->state = $this->model->getState();
     $this->me = KunenaUserHelper::getMyself();
     $this->moreUri = null;
     $this->embedded = $this->getOptions()->get('embedded', false);
     if ($this->embedded) {
         $this->moreUri = new JUri('index.php?option=com_kunena&view=topics&layout=posts&mode=' . $this->state->get('list.mode') . '&userid=' . $this->state->get('user') . '&sel=' . $this->state->get('list.time') . '&limit=' . $this->state->get('list.limit'));
         $this->moreUri->setVar('Itemid', KunenaRoute::getItemID($this->moreUri));
     }
     $start = $this->state->get('list.start');
     $limit = $this->state->get('list.limit');
     // Handle &sel=x parameter.
     $time = $this->state->get('list.time');
     if ($time < 0) {
         $time = null;
     } elseif ($time == 0) {
         $time = new JDate(KunenaFactory::getSession()->lasttime);
     } else {
         $time = new JDate(JFactory::getDate()->toUnix() - $time * 3600);
     }
     $userid = $this->state->get('user');
     $user = is_numeric($userid) ? KunenaUserHelper::get($userid) : null;
     // Get categories for the filter.
     $categoryIds = $this->state->get('list.categories');
     $reverse = !$this->state->get('list.categories.in');
     $authorise = 'read';
     $order = 'time';
     $finder = new KunenaForumMessageFinder();
     $finder->filterByTime($time);
     switch ($this->state->get('list.mode')) {
         case 'unapproved':
             $authorise = 'topic.post.approve';
             $finder->filterByUser(null, 'author')->filterByHold(array(1));
             break;
         case 'deleted':
             $authorise = 'topic.post.undelete';
             $finder->filterByUser($user, 'author')->filterByHold(array(2, 3));
             break;
         case 'mythanks':
             $finder->filterByUser($user, 'thanker')->filterByHold(array(0));
             break;
         case 'thankyou':
             $finder->filterByUser($user, 'thankee')->filterByHold(array(0));
             break;
         default:
             $finder->filterByUser($user, 'author')->filterByHold(array(0));
             break;
     }
     $categories = KunenaForumCategoryHelper::getCategories($categoryIds, $reverse, $authorise);
     $finder->filterByCategories($categories);
     $this->pagination = new KunenaPagination($finder->count(), $start, $limit);
     if ($this->moreUri) {
         $this->pagination->setUri($this->moreUri);
     }
     $this->messages = $finder->order($order, -1)->start($this->pagination->limitstart)->limit($this->pagination->limit)->find();
     // Load topics...
     $topicIds = array();
     foreach ($this->messages as $message) {
         $topicIds[(int) $message->thread] = (int) $message->thread;
     }
     $this->topics = KunenaForumTopicHelper::getTopics($topicIds, 'none');
     $userIds = $mesIds = array();
     foreach ($this->messages as $message) {
         $userIds[(int) $message->userid] = (int) $message->userid;
         $mesIds[(int) $message->id] = (int) $message->id;
     }
     if ($this->topics) {
         $this->prepareTopics($userIds, $mesIds);
     }
     switch ($this->state->get('list.mode')) {
         case 'unapproved':
             $this->headerText = JText::_('COM_KUNENA_VIEW_TOPICS_POSTS_MODE_UNAPPROVED');
             $actions = array('approve', 'delete', 'permdelete');
             break;
         case 'deleted':
             $this->headerText = JText::_('COM_KUNENA_VIEW_TOPICS_POSTS_MODE_DELETED');
             $actions = array('undelete', 'delete', 'permdelete');
             break;
         case 'mythanks':
             $this->headerText = JText::_('COM_KUNENA_VIEW_TOPICS_POSTS_MODE_MYTHANKS');
             $actions = array('approve', 'delete', 'permdelete');
             break;
         case 'thankyou':
             $this->headerText = JText::_('COM_KUNENA_VIEW_TOPICS_POSTS_MODE_THANKYOU');
             $actions = array('approve', 'delete', 'permdelete');
             break;
         case 'recent':
         default:
             $this->headerText = JText::_('COM_KUNENA_VIEW_TOPICS_POSTS_MODE_DEFAULT');
             $actions = array('delete', 'permdelete');
     }
     $this->actions = $this->getMessageActions($this->messages, $actions);
 }
예제 #18
0
	function restore() {
		$app = JFactory::getApplication ();
		if (! JRequest::checkToken ()) {
			$app->enqueueMessage ( JText::_ ( 'COM_KUNENA_ERROR_TOKEN' ), 'error' );
			$app->redirect ( KunenaRoute::_($this->baseurl, false) );
		}

		$kunena_db = JFactory::getDBO ();
		$cid = JRequest::getVar ( 'cid', array (), 'post', 'array' );
		$topics = JRequest::getInt ( 'topics', 0, 'post' );
		$messages = JRequest::getInt ( 'messages', 0, 'post' );

		if (empty ( $cid )) {
			$app->enqueueMessage ( JText::_ ( 'COM_KUNENA_A_NO_MESSAGES_SELECTED' ), 'notice' );
			$app->redirect ( KunenaRoute::_($this->baseurl, false) );
		}

		$msg = JText::_('COM_KUNENA_TRASH_RESTORE_DONE');

		if ( $messages ) {
			$messages = KunenaForumMessageHelper::getMessages($cid);
			foreach ( $messages as $target ) {
				if ( $target->authorise('undelete') && $target->publish(KunenaForum::PUBLISHED) ) {
					$app->enqueueMessage ( $msg );
				} else {
					$app->enqueueMessage ( $target->getError(), 'notice' );
				}
			}
		} elseif ( $topics ) {
			$topics = KunenaForumTopicHelper::getTopics($cid);
			foreach ( $topics as $target ) {
				if ( $target->authorise('undelete') && $target->publish(KunenaForum::PUBLISHED) ) {
					$app->enqueueMessage ( $msg );
				} else {
					$app->enqueueMessage ( $target->getError(), 'notice' );
				}
			}
		} else {
			// error
		}

		KunenaUserHelper::recount();
		KunenaForumTopicHelper::recount();
		KunenaForumCategoryHelper::recount ();

		$app->redirect(KunenaRoute::_($this->baseurl, false));
	}
예제 #19
0
 /**
  * @param int $limit
  *
  * @return array
  */
 public function loadTopPolls($limit = 0)
 {
     $limit = $limit ? $limit : $this->_config->poppollscount;
     if (count($this->topPolls) < $limit) {
         $query = "SELECT poll.threadid AS id, SUM(opt.votes) AS count\n\t\t\t\t\tFROM #__kunena_polls_options AS opt\n\t\t\t\t\tINNER JOIN #__kunena_polls AS poll ON poll.id=opt.pollid\n\t\t\t\t\tGROUP BY pollid\n\t\t\t\t\tHAVING count > 0\n\t\t\t\t\tORDER BY count DESC";
         $this->_db->setQuery($query, 0, $limit);
         $polls = (array) $this->_db->loadObjectList('id');
         KunenaError::checkDatabaseError();
         $this->topPolls = KunenaForumTopicHelper::getTopics(array_keys($polls));
         $top = reset($this->topPolls);
         if (!$top) {
             return array();
         }
         $top->title = JText::_('COM_KUNENA_LIB_STAT_TOP_POLLS');
         $top->titleName = JText::_('COM_KUNENA_POLL_STATS_NAME');
         $top->titleCount = JText::_('COM_KUNENA_USRL_VOTES');
         $top->count = $polls[$top->id]->count;
         foreach ($this->topPolls as &$item) {
             $item = clone $item;
             $item->count = $polls[$item->id]->count;
             $item->link = JHtml::_('kunenaforum.link', $item->getUri(), KunenaHtmlParser::parseText($item->subject));
             $item->percent = round(100 * $item->count / $top->count);
         }
     }
     return array_slice($this->topPolls, 0, $limit);
 }
예제 #20
0
 /**
  * Method to get details on selected items.
  *
  * @return    Array
  * @since    1.6
  */
 public function getPurgeItems()
 {
     $ids = (array) $this->app->getUserState('com_kunena.purge');
     $type = (string) $this->app->getUserState('com_kunena.type');
     $items = array();
     if ($type == 'topics') {
         $items = KunenaForumTopicHelper::getTopics($ids, 'none');
     } elseif ($type == 'messages') {
         $items = KunenaForumMessageHelper::getMessages($ids, 'none');
     }
     return $items;
 }