예제 #1
0
	/**
	 * Prepare search results display.
	 *
	 * @return void
	 */
	protected function before()
	{
		parent::before();

		require_once KPATH_SITE . '/models/search.php';
		$this->model = new KunenaModelSearch(array(), $this->input);
		$this->model->initialize($this->getOptions(), $this->getOptions()->get('embedded', false));
		$this->state = $this->model->getState();

		$this->me = KunenaUserHelper::getMyself();
		$this->message_ordering = $this->me->getMessageOrdering();

		$this->searchwords = $this->model->getSearchWords();
		$this->isModerator = ($this->me->isAdmin() || KunenaAccess::getInstance()->getModeratorStatus());

		$this->results = array();
		$this->total = $this->model->getTotal();
		$this->results = $this->model->getResults();

		$this->pagination = new KunenaPagination(
			$this->total,
			$this->state->get('list.start'),
			$this->state->get('list.limit')
		);

		$this->error = $this->model->getError();
	}
예제 #2
0
 /**
  * Prepare topics by pre-loading needed information.
  *
  * @param   array  $userIds  List of additional user Ids to be loaded.
  * @param   array  $mesIds   List of additional message Ids to be loaded.
  *
  * @return  void
  */
 protected function prepareTopics(array $userIds = array(), array $mesIds = array())
 {
     // Collect user Ids for avatar prefetch when integrated.
     $lastIds = array();
     foreach ($this->topics as $topic) {
         $userIds[(int) $topic->first_post_userid] = (int) $topic->first_post_userid;
         $userIds[(int) $topic->last_post_userid] = (int) $topic->last_post_userid;
         $lastIds[(int) $topic->last_post_id] = (int) $topic->last_post_id;
     }
     // Prefetch all users/avatars to avoid user by user queries during template iterations.
     if (!empty($userIds)) {
         KunenaUserHelper::loadUsers($userIds);
     }
     $topicIds = array_keys($this->topics);
     KunenaForumTopicHelper::getUserTopics($topicIds);
     /* KunenaForumTopicHelper::getKeywords($topicIds); */
     $mesIds += KunenaForumTopicHelper::fetchNewStatus($this->topics);
     // Fetch also last post positions when user can see unapproved or deleted posts.
     // TODO: Optimize? Take account of configuration option...
     if ($this->me->isAdmin() || KunenaAccess::getInstance()->getModeratorStatus()) {
         $mesIds += $lastIds;
     }
     // Load position information for all selected messages.
     if ($mesIds) {
         KunenaForumMessageHelper::loadLocation($mesIds);
     }
 }
예제 #3
0
	function displayDefault($tpl = null)
	{
		$this->message_ordering = $this->me->getMessageOrdering();
		//TODO: Need to move the select markup outside of view.  Otherwise difficult to stylize

		$this->searchwords = $this->get('SearchWords');
		$this->isModerator = ($this->me->isAdmin() || KunenaAccess::getInstance()->getModeratorStatus($this->me));

		$this->results = array();
		$this->total   = $this->get('Total');

		if ($this->total)
		{
			$this->results      = $this->get('Results');
			$this->search_class = ' open';
			$this->search_style = ' style="display: none;"';
			$this->search_title = JText::_('COM_KUNENA_TOGGLER_EXPAND');
		}
		else
		{
			$this->search_class = ' close';
			$this->search_style = '';
			$this->search_title = JText::_('COM_KUNENA_TOGGLER_COLLAPSE');
		}

		$this->selected = ' selected="selected"';
		$this->checked  = ' checked="checked"';
		$this->error    = $this->get('Error');

		$this->_prepareDocument();

		$this->render('Search', $tpl);
	}
예제 #4
0
	public static function getInstance() {
		KUNENA_PROFILER ? KunenaProfiler::instance()->start('function '.__CLASS__.'::'.__FUNCTION__.'()') : null;
		if (!self::$instance) {
			self::$instance = new KunenaAccess();
		}
		KUNENA_PROFILER ? KunenaProfiler::instance()->stop('function '.__CLASS__.'::'.__FUNCTION__.'()') : null;
		return self::$instance;
	}
예제 #5
0
 protected function loadModerators()
 {
     $list = $this->joomlaAccess->loadModerators();
     // TODO: add support into CB
     $params = array('list' => &$list);
     $this->integration->trigger('loadModerators', $params);
     return parent::loadModerators($list);
 }
예제 #6
0
 public function onAfterReply($message)
 {
     if (JString::strlen($message->message) > $this->params->get('activity_points_limit', 0)) {
         CFactory::load('libraries', 'userpoints');
         CUserPoints::assignPoint('com_kunena.thread.reply');
     }
     // Get users who have subscribed to the topic, excluding current user.
     $acl = KunenaAccess::getInstance();
     $subscribers = $acl->getSubscribers($message->catid, $message->thread, KunenaAccess::TOPIC_SUBSCRIPTION, false, false, array($message->userid));
     foreach ($subscribers as $userid) {
         $actor = CFactory::getUser($message->userid);
         $target = CFactory::getUser($userid);
         $params = new CParameter('');
         $params->set('actorName', $actor->getDisplayName());
         $params->set('recipientName', $target->getDisplayName());
         $params->set('url', JUri::getInstance()->toString(array('scheme', 'host', 'port')) . $message->getPermaUrl(null));
         // {url} tag for activity. Used when hovering over avatar in notification window, as well as in email notification
         $params->set('title', $message->displayField('subject'));
         // (title) tag in language file
         $params->set('title_url', $message->getPermaUrl());
         // Make the title in notification - linkable
         $params->set('message', $message->displayField('message'));
         // (message) tag in language file
         $params->set('actor', $actor->getDisplayName());
         // Actor in the stream
         $params->set('actor_url', 'index.php?option=com_community&view=profile&userid=' . $actor->id);
         // Actor Link
         // Finally, send notifications
         CNotificationLibrary::add('kunena_reply', $actor->id, $target->id, JText::sprintf('PLG_KUNENA_COMMUNITY_ACTIVITY_REPLY_TITLE_ACT'), JText::sprintf('PLG_KUNENA_COMMUNITY_ACTIVITY_REPLY_TEXT'), '', $params);
     }
     /* Activity stream */
     $act = new stdClass();
     $act->cmd = 'wall.write';
     $act->actor = $message->userid;
     $act->target = 0;
     // no target
     $act->title = JText::_('{single}{actor}{/single}{multiple}{actors}{/multiple} ' . JText::sprintf('PLG_KUNENA_COMMUNITY_ACTIVITY_REPLY_TITLE', '<a href="' . $message->getTopic()->getUrl() . '">' . $message->subject . '</a>'));
     $act->content = $this->buildContent($message);
     $act->app = 'kunena.thread.reply';
     $act->cid = $message->thread;
     $act->access = $this->getAccess($message->getCategory());
     // Comments and like support
     $act->comment_id = $message->thread;
     $act->comment_type = 'kunena.thread.reply';
     $act->like_id = $message->thread;
     $act->like_type = 'kunena.thread.reply';
     // Do not add private activities
     if ($act->access > 20) {
         return;
     }
     CFactory::load('libraries', 'activities');
     $table = CActivityStream::add($act);
     if (is_object($table)) {
         $table->like_id = $table->id;
         $table->store();
     }
 }
예제 #7
0
 protected function loadModerators()
 {
     $db = JFactory::getDBO();
     $query = "SELECT u.id AS userid, m.catid\n\t\t\t\tFROM #__users AS u\n\t\t\t\tINNER JOIN #__kunena_users AS ku ON u.id=ku.userid\n\t\t\t\tLEFT JOIN #__kunena_moderation AS m ON u.id=m.userid\n\t\t\t\tLEFT JOIN #__kunena_categories AS c ON m.catid=c.id\n\t\t\t\tWHERE u.block='0' AND ku.moderator='1' AND (m.catid IS NULL OR c.moderated='1')";
     $db->setQuery($query);
     $list = (array) $db->loadObjectList();
     KunenaError::checkDatabaseError();
     return parent::loadModerators($list);
 }
예제 #8
0
 protected function loadModerators()
 {
     $list = $this->joomlaAccess->loadModerators();
     $db = JFactory::getDBO();
     $query = "SELECT g.memberid AS userid, c.id AS catid\n\t\t\tFROM #__kunena_categories AS c\n\t\t\tINNER JOIN #__community_groups_members AS g ON c.accesstype='jomsocial' AND c.access=g.groupid\n\t\t\tWHERE c.published=1 AND g.approved=1 AND g.permissions={$db->Quote(COMMUNITY_GROUP_ADMIN)}";
     $db->setQuery($query);
     $jslist = (array) $db->loadObjectList();
     KunenaError::checkDatabaseError();
     return parent::loadModerators(array_merge($list, $jslist));
 }
예제 #9
0
 public static function getInstance($integration = null)
 {
     if (self::$instance === false) {
         $config = KunenaFactory::getConfig();
         if (!$integration) {
             $integration = $config->integration_access;
         }
         self::$instance = KunenaIntegration::initialize('access', $integration);
     }
     return self::$instance;
 }
예제 #10
0
 /**
  * Prepare search form display.
  *
  * @return void
  */
 protected function before()
 {
     parent::before();
     require_once KPATH_SITE . '/models/search.php';
     $this->model = new KunenaModelSearch(array(), $this->input);
     $this->model->initialize($this->getOptions(), $this->getOptions()->get('embedded', false));
     $this->state = $this->model->getState();
     $this->me = KunenaUserHelper::getMyself();
     $this->isModerator = $this->me->isAdmin() || KunenaAccess::getInstance()->getModeratorStatus();
     $this->error = $this->model->getError();
 }
예제 #11
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();
 }
예제 #12
0
	protected function populateState() {
		$active = $this->app->getMenu ()->getActive ();
		$active = $active ? (int) $active->id : 0;

		$layout = $this->me->getTopicLayout ();
		$this->setState ( 'layout', $layout );

		$template = KunenaFactory::getTemplate();
		$profile_location = $template->params->get('avatarPosition', 'left');
		$profile_direction = $profile_location == 'left' || $profile_location == 'right' ? 'vertical' : 'horizontal';
		$this->setState ( 'profile.location', $profile_location );
		$this->setState ( 'profile.direction', $profile_direction );

		$catid = $this->getInt ( 'catid', 0 );
		$this->setState ( 'item.catid', $catid );

		$id = $this->getInt ( 'id', 0 );
		$this->setState ( 'item.id', $id );

		$id = $this->getInt ( 'mesid', 0 );
		$this->setState ( 'item.mesid', $id );

		$access = KunenaAccess::getInstance();
		$value = $access->getAllowedHold($this->me, $catid);
		$this->setState ( 'hold', $value );

		$value = $this->getInt ( 'limit', 0 );
		if ($value < 1 || $value > 100) $value = $this->config->messages_per_page;
		$this->setState ( 'list.limit', $value );

		//$value = $this->getUserStateFromRequest ( "com_kunena.topic_{$active}_{$layout}_list_ordering", 'filter_order', 'time', 'cmd' );
		//$this->setState ( 'list.ordering', $value );

		$value = $this->getInt ( 'limitstart', 0 );
		if ($value < 0) $value = 0;
		$this->setState ( 'list.start', $value );

		$value = $this->getUserStateFromRequest ( "com_kunena.topic_{$active}_{$layout}_list_direction", 'filter_order_Dir', '', 'word' );
		if (!$value) {
			if ($this->me->ordering != '0') {
				$value = $this->me->ordering == '1' ? 'desc' : 'asc';
			} else {
				$value = $this->config->default_sort == 'asc' ? 'asc' : 'desc';
			}
		}
		if ($value != 'asc')
			$value = 'desc';
		$this->setState ( 'list.direction', $value );
	}
예제 #13
0
파일: access.php 프로젝트: rich20/Kunena
	public function clearCache() {
		self::$adminsByCatid = array();
		self::$adminsByUserid = array();
		self::$moderatorsByCatid = array();
		self::$moderatorsByUserid = array();
		self::$instance->loadAdmins();
		self::$instance->loadModerators();

		// Store new data into cache
		$cache = JFactory::getCache('com_kunena', 'output');
		$cache->store(serialize(array(
			'ac'=>self::$adminsByCatid,
			'au'=>self::$adminsByUserid,
			'mc'=>self::$moderatorsByCatid,
			'mu'=>self::$moderatorsByUserid,
			)), self::$cacheKey, 'com_kunena');
	}
예제 #14
0
 function save()
 {
     $db = JFactory::getDBO();
     if (!JRequest::checkToken()) {
         $this->app->enqueueMessage(JText::_('COM_KUNENA_ERROR_TOKEN'), 'error');
         $this->app->redirect(KunenaRoute::_($this->baseurl, false));
     }
     $newview = JRequest::getVar('newview');
     $newrank = JRequest::getVar('newrank');
     $signature = JRequest::getVar('signature');
     $deleteSig = JRequest::getVar('deleteSig');
     $moderator = JRequest::getInt('moderator');
     $uid = JRequest::getInt('uid');
     $avatar = JRequest::getVar('avatar');
     $deleteAvatar = JRequest::getVar('deleteAvatar');
     $neworder = JRequest::getInt('neworder');
     $modCatids = $moderator ? JRequest::getVar('catid', array()) : array();
     if ($deleteSig == 1) {
         $signature = "";
     }
     $avatar = '';
     if ($deleteAvatar == 1) {
         $avatar = ",avatar=''";
     }
     $db->setQuery("UPDATE #__kunena_users SET signature={$db->quote($signature)}, view='{$newview}', ordering='{$neworder}', rank='{$newrank}' {$avatar} WHERE userid='{$uid}'");
     $db->query();
     if (KunenaError::checkDatabaseError()) {
         return;
     }
     $this->app->enqueueMessage(JText::_('COM_KUNENA_USER_PROFILE_SAVED_SUCCESSFULLY'));
     // Update moderator rights
     $categories = KunenaForumCategoryHelper::getCategories(false, false, 'admin');
     $user = KunenaFactory::getUser($uid);
     foreach ($categories as $category) {
         $category->setModerator($user, in_array($category->id, $modCatids));
     }
     // Global moderator is a special case
     if ($this->me->isAdmin()) {
         KunenaAccess::getInstance()->setModerator(0, $user, in_array(0, $modCatids));
     }
     $this->app->redirect(KunenaRoute::_($this->baseurl, false));
 }
예제 #15
0
 function displayForumJump($tpl = null)
 {
     if ($this->offline) {
         return;
     }
     $allowed = md5(serialize(KunenaAccess::getInstance()->getAllowedCategories()));
     $cache = JFactory::getCache('com_kunena', 'output');
     if ($cache->start("{$this->ktemplate->name}.common.jump.{$allowed}", 'com_kunena.template')) {
         return;
     }
     $options = array();
     $options[] = JHtml::_('select.option', '0', JText::_('COM_KUNENA_FORUM_TOP'));
     $cat_params = array('sections' => 1, 'catid' => 0);
     $this->categorylist = JHtml::_('kunenaforum.categorylist', 'catid', 0, $options, $cat_params, 'class="inputbox fbs" size="1" onchange = "this.form.submit()"', 'value', 'text', $this->catid);
     $result = $this->loadTemplateFile($tpl);
     if (JError::isError($result)) {
         return $result;
     }
     echo $result;
     $cache->end();
 }
예제 #16
0
파일: display.php 프로젝트: Jougito/DynWeb
 /**
  * Prepare topic list for moderators.
  *
  * @return void
  */
 protected function before()
 {
     parent::before();
     $this->me = KunenaUserHelper::getMyself();
     $access = KunenaAccess::getInstance();
     $this->moreUri = null;
     $params = $this->app->getParams('com_kunena');
     $start = $this->input->getInt('limitstart', 0);
     $limit = $this->input->getInt('limit', 0);
     if ($limit < 1 || $limit > 100) {
         $limit = $this->config->threads_per_page;
     }
     // Get configuration from menu item.
     $categoryIds = $params->get('topics_categories', array());
     $reverse = !$params->get('topics_catselection', 1);
     // Make sure that category list is an array.
     if (!is_array($categoryIds)) {
         $categoryIds = explode(',', $categoryIds);
     }
     if (!$reverse && empty($categoryIds) || in_array(0, $categoryIds)) {
         $categoryIds = false;
     }
     $categories = KunenaForumCategoryHelper::getCategories($categoryIds, $reverse);
     $finder = new KunenaForumTopicFinder();
     $finder->filterByCategories($categories)->filterAnsweredBy(array_keys($access->getModerators() + $access->getAdmins()), true)->filterByMoved(false)->where('locked', '=', 0);
     $this->pagination = new KunenaPagination($finder->count(), $start, $limit);
     if ($this->moreUri) {
         $this->pagination->setUri($this->moreUri);
     }
     $this->topics = $finder->order('last_post_time', -1)->start($this->pagination->limitstart)->limit($this->pagination->limit)->find();
     if ($this->topics) {
         $this->prepareTopics();
     }
     $actions = array('delete', 'approve', 'undelete', 'move', 'permdelete');
     $this->actions = $this->getTopicActions($this->topics, $actions);
     // TODO <-
     $this->headerText = JText::_('Topics Needing Attention');
 }
예제 #17
0
 public function getListmodcats()
 {
     $user = $this->getUser();
     $modCatList = array_keys(KunenaAccess::getInstance()->getModeratorStatus($user));
     if (empty($modCatList)) {
         $modCatList[] = 0;
     }
     $categoryList = array();
     if ($this->me->isAdmin()) {
         $categoryList[] = JHtml::_('select.option', 0, JText::_('COM_KUNENA_GLOBAL_MODERATOR'));
     }
     $params = array('sections' => false, 'action' => 'read');
     $modCats = JHtml::_('kunenaforum.categorylist', 'catid[]', 0, $categoryList, $params, 'class="inputbox" multiple="multiple" size="15"', 'value', 'text', $modCatList, 'kforums');
     return $modCats;
 }
예제 #18
0
파일: user.php 프로젝트: madcsaba/li-de
 /**
  * @param int  $catid
  * @param bool|string $code
  *
  * @return string
  */
 public function getType($catid = 0, $code = false)
 {
     static $types = array('admin' => 'COM_KUNENA_VIEW_ADMIN', 'globalmod' => 'COM_KUNENA_VIEW_GLOBAL_MODERATOR', 'moderator' => 'COM_KUNENA_VIEW_MODERATOR', 'user' => 'COM_KUNENA_VIEW_USER', 'guest' => 'COM_KUNENA_VIEW_VISITOR', 'banned' => 'COM_KUNENA_VIEW_BANNED', 'blocked' => 'COM_KUNENA_VIEW_BANNED');
     $moderatedCategories = KunenaAccess::getInstance()->getModeratorStatus($this);
     if (!$this->_type) {
         if ($this->userid == 0) {
             $this->_type = 'guest';
         } elseif ($this->isBanned()) {
             $this->_type = 'banned';
         } elseif ($this->isAdmin(KunenaForumCategoryHelper::get($catid))) {
             $this->_type = 'admin';
         } elseif ($this->isModerator(null)) {
             $this->_type = 'globalmod';
         } elseif (!$catid && !empty($moderatedCategories)) {
             $this->_type = 'moderator';
         } elseif ($catid && isset($moderatedCategories[$catid])) {
             $this->_type = 'moderator';
         } else {
             $this->_type = 'user';
         }
         $userClasses = KunenaFactory::getTemplate()->getUserClasses();
         $this->_class = isset($userClasses[$this->_type]) ? $userClasses[$this->_type] : $userClasses[0] . $this->_type;
     }
     return $code == 'class' ? $this->_class : ($code == false ? $types[$this->_type] : $this->_type);
 }
예제 #19
0
?>
						<label id="childforums-lbl">
							<input type="checkbox" name="childforums" value="1" <?php 
if ($this->state->get('query.childforums')) {
    echo 'checked="checked"';
}
?>
 />
							<span onclick="document.searchform.childforums.checked=(! document.searchform.childforums.checked);"><?php 
echo JText::_('COM_KUNENA_SEARCH_SEARCHIN_CHILDREN');
?>
</span>
						</label>
					</fieldset>
					<?php 
if (KunenaAccess::getInstance()->getModeratorStatus()) {
    ?>
					<fieldset class="fieldset">
						<legend><?php 
    echo JText::_('COM_KUNENA_SEARCH_SHOW');
    ?>
</legend>
						<input id="show0" type="radio" name="show" value="0" <?php 
    if ($this->state->get('query.show') == 0) {
        echo 'checked="checked"';
    }
    ?>
 />
						<label for="show0"><?php 
    echo JText::_('COM_KUNENA_SEARCH_SHOW_NORMAL');
    ?>
예제 #20
0
 /**
  * Get a list of subscribers for a thread
  *
  * @since	5.0
  * @access	public
  * @param	string
  * @return
  */
 public function getSubscribers($message)
 {
     $config = KunenaFactory::getConfig();
     if ($message->hold > 1) {
         return false;
     } elseif ($message->hold == 1) {
         $mailsubs = 0;
         $mailmods = $config->mailmod >= 0;
         $mailadmins = $config->mailadmin >= 0;
     } else {
         $mailsubs = (bool) $config->allowsubscriptions;
         $mailmods = $config->mailmod >= 1;
         $mailadmins = $config->mailadmin >= 1;
     }
     $once = false;
     if ($mailsubs) {
         if (!$message->parent) {
             // New topic: Send email only to category subscribers
             $mailsubs = $config->category_subscriptions != 'disabled' ? KunenaAccess::CATEGORY_SUBSCRIPTION : 0;
             $once = $config->category_subscriptions == 'topic';
         } elseif ($config->category_subscriptions != 'post') {
             // Existing topic: Send email only to topic subscribers
             $mailsubs = $config->topic_subscriptions != 'disabled' ? KunenaAccess::TOPIC_SUBSCRIPTION : 0;
             $once = $config->topic_subscriptions == 'first';
         } else {
             // Existing topic: Send email to both category and topic subscribers
             $mailsubs = $config->topic_subscriptions == 'disabled' ? KunenaAccess::CATEGORY_SUBSCRIPTION : KunenaAccess::CATEGORY_SUBSCRIPTION | KunenaAccess::TOPIC_SUBSCRIPTION;
             // FIXME: category subcription can override topic
             $once = $config->topic_subscriptions == 'first';
         }
     }
     //get all subscribers, moderators and admins who will get the email
     $me = KunenaUserHelper::get();
     $acl = KunenaAccess::getInstance();
     $subscribers = $acl->getSubscribers($message->catid, $message->thread, $mailsubs, $mailmods, $mailadmins, $me->userid);
     if (!$subscribers) {
         return false;
     }
     $result = array();
     foreach ($subscribers as $subscriber) {
         if ($subscriber->id) {
             $result[] = $subscriber->id;
         }
     }
     return $result;
 }
예제 #21
0
 /**
  * @param   array $userlist
  * @param   array $postlist
  */
 protected function _common(array $userlist = array(), array $postlist = array())
 {
     if ($this->total > 0) {
         // collect user ids for avatar prefetch when integrated
         $lastpostlist = array();
         foreach ($this->topics as $topic) {
             $userlist[intval($topic->first_post_userid)] = intval($topic->first_post_userid);
             $userlist[intval($topic->last_post_userid)] = intval($topic->last_post_userid);
             $lastpostlist[intval($topic->last_post_id)] = intval($topic->last_post_id);
         }
         // Prefetch all users/avatars to avoid user by user queries during template iterations
         if (!empty($userlist)) {
             KunenaUserHelper::loadUsers($userlist);
         }
         KunenaForumTopicHelper::getUserTopics(array_keys($this->topics));
         KunenaForumTopicHelper::getKeywords(array_keys($this->topics));
         $lastreadlist = KunenaForumTopicHelper::fetchNewStatus($this->topics);
         // Fetch last / new post positions when user can see unapproved or deleted posts
         if ($postlist || $lastreadlist || $this->me->userid && ($this->me->isAdmin() || KunenaAccess::getInstance()->getModeratorStatus())) {
             KunenaForumMessageHelper::loadLocation($postlist + $lastpostlist + $lastreadlist);
         }
     }
 }
예제 #22
0
 /**
  * @param null $tpl
  *
  * @throws Exception
  */
 protected function displayCommon($tpl = null)
 {
     $userid = JFactory::getApplication()->input->getInt('userid');
     $this->_db = JFactory::getDBO();
     $this->do = JFactory::getApplication()->input->getWord('layout');
     if (!$userid) {
         $this->user = JFactory::getUser();
     } else {
         $this->user = JFactory::getUser($userid);
     }
     if ($this->user->id == 0 || $this->me->userid == 0 && !$this->config->pubprofile) {
         $this->app->enqueueMessage(JText::_('COM_KUNENA_PROFILEPAGE_NOT_ALLOWED_FOR_GUESTS'), 'notice');
         return;
     }
     $integration = KunenaFactory::getProfile();
     $activityIntegration = KunenaFactory::getActivityIntegration();
     $template = KunenaFactory::getTemplate();
     $this->params = $template->params;
     if (get_class($integration) == 'KunenaProfileNone') {
         $this->app->enqueueMessage(JText::_('COM_KUNENA_PROFILE_DISABLED'), 'notice');
         return;
     }
     $this->allow = true;
     $this->profile = KunenaFactory::getUser($this->user->id);
     if (!$this->profile->exists()) {
         $this->profile->save();
     }
     if ($this->profile->userid == $this->me->userid) {
         if ($this->do != 'edit') {
             $this->editlink = $this->profile->getLink(JText::_('COM_KUNENA_EDIT') . ' &raquo;', JText::_('COM_KUNENA_EDIT') . ' &raquo;', 'nofollow', 'edit', '');
         } else {
             $this->editlink = $this->profile->getLink(JText::_('COM_KUNENA_BACK') . ' &raquo;', JText::_('COM_KUNENA_BACK') . ' &raquo;', 'nofollow', '', '');
         }
     }
     $this->name = $this->user->username;
     if ($this->config->showuserstats) {
         $this->rank_image = $this->profile->getRank(0, 'image');
         $this->rank_title = $this->profile->getRank(0, 'title');
         $this->posts = $this->profile->posts;
         $this->thankyou = $this->profile->thankyou;
         $this->userpoints = $activityIntegration->getUserPoints($this->profile->userid);
         $this->usermedals = $activityIntegration->getUserMedals($this->profile->userid);
     }
     if ($this->config->userlist_joindate || $this->me->isModerator()) {
         $this->registerdate = $this->user->registerDate;
     }
     if ($this->config->userlist_lastvisitdate || $this->me->isModerator()) {
         $this->lastvisitdate = $this->user->lastvisitDate;
     }
     if (!isset($this->lastvisitdate) || $this->lastvisitdate == "0000-00-00 00:00:00") {
         $this->lastvisitdate = null;
     }
     $this->avatarlink = $this->profile->getAvatarImage('kavatar', 'profile');
     $this->personalText = $this->profile->personalText;
     $this->signature = $this->profile->signature;
     $this->signatureHtml = KunenaHtmlParser::parseBBCode($this->signature, null, $this->config->maxsig);
     $this->localtime = KunenaDate::getInstance('now', $this->user->getParam('timezone', $this->app->get('offset', null)));
     try {
         $offset = new DateTimeZone($this->user->getParam('timezone', $this->app->get('offset', null)));
     } catch (Exception $e) {
         $offset = null;
     }
     $this->localtime->setTimezone($offset);
     $this->moderator = KunenaAccess::getInstance()->getModeratorStatus($this->profile);
     $this->admin = $this->profile->isAdmin();
     switch ($this->profile->gender) {
         case 1:
             $this->genderclass = 'male';
             $this->gender = JText::_('COM_KUNENA_MYPROFILE_GENDER_MALE');
             break;
         case 2:
             $this->genderclass = 'female';
             $this->gender = JText::_('COM_KUNENA_MYPROFILE_GENDER_FEMALE');
             break;
         default:
             $this->genderclass = 'unknown';
             $this->gender = JText::_('COM_KUNENA_MYPROFILE_GENDER_UNKNOWN');
     }
     if ($this->profile->location) {
         $this->locationlink = '<a href="http://maps.google.com?q=' . $this->escape($this->profile->location) . '" target="_blank">' . $this->escape($this->profile->location) . '</a>';
     } else {
         $this->locationlink = JText::_('COM_KUNENA_LOCATION_UNKNOWN');
     }
     $this->online = $this->profile->isOnline();
     $this->showUnusedSocial = true;
     if (!preg_match("~^(?:f|ht)tps?://~i", $this->profile->websiteurl)) {
         $this->websiteurl = 'http://' . $this->profile->websiteurl;
     } else {
         $this->websiteurl = $this->profile->websiteurl;
     }
     $avatar = KunenaFactory::getAvatarIntegration();
     $this->editavatar = $avatar instanceof KunenaAvatarKunena ? true : false;
     $this->banInfo = KunenaUserBan::getInstanceByUserid($userid, true);
     $this->canBan = $this->banInfo->canBan();
     if ($this->config->showbannedreason) {
         $this->banReason = $this->banInfo->reason_public;
     }
     // Which tabs to show?
     $this->showUserPosts = true;
     $this->showSubscriptions = $this->config->allowsubscriptions && $this->me->userid == $this->profile->userid;
     $this->showFavorites = $this->config->allowfavorites && $this->me->userid == $this->profile->userid;
     $this->showThankyou = $this->config->showthankyou && $this->me->exists();
     $this->showUnapprovedPosts = $this->me->isAdmin() || KunenaAccess::getInstance()->getModeratorStatus();
     // || $this->me->userid == $this->profile->userid;
     $this->showAttachments = $this->canManageAttachments() && ($this->me->isModerator() || $this->me->userid == $this->profile->userid);
     $this->showBanManager = $this->me->isModerator() && $this->me->userid == $this->profile->userid;
     $this->showBanHistory = $this->me->isModerator() && $this->me->userid != $this->profile->userid;
     $this->showBanUser = $this->canBan;
     if ($this->me->userid != $this->profile->userid) {
         $this->profile->uhits++;
         $this->profile->save();
     }
     $private = KunenaFactory::getPrivateMessaging();
     if ($this->me->userid == $this->user->id) {
         $this->pmCount = $private->getUnreadCount($this->me->userid);
         $this->pmLink = $private->getInboxLink($this->pmCount ? JText::sprintf('COM_KUNENA_PMS_INBOX_NEW', $this->pmCount) : JText::_('COM_KUNENA_PMS_INBOX'));
     } else {
         $this->pmLink = $this->profile->profileIcon('private');
     }
     $this->_prepareDocument('common');
     $layout = $this->getLayout() != 'default' ? "User/{$this->getLayout()}" : 'User/Item';
     $this->render($layout, $tpl);
 }
예제 #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;
 }
예제 #24
0
 /**
  * Get users type as a string inside the specified category.
  *
  * @param int  $catid   Category id or 0 for global.
  * @param bool $code    True if we want to return the code, otherwise return translation key.
  *
  * @return string
  */
 public function getType($catid = 0, $code = false)
 {
     static $types = array('admin' => 'COM_KUNENA_VIEW_ADMIN', 'localadmin' => 'COM_KUNENA_VIEW_ADMIN', 'globalmod' => 'COM_KUNENA_VIEW_GLOBAL_MODERATOR', 'moderator' => 'COM_KUNENA_VIEW_MODERATOR', 'user' => 'COM_KUNENA_VIEW_USER', 'guest' => 'COM_KUNENA_VIEW_VISITOR', 'banned' => 'COM_KUNENA_VIEW_BANNED', 'blocked' => 'COM_KUNENA_VIEW_BLOCKED');
     $adminCategories = KunenaAccess::getInstance()->getAdminStatus($this);
     $moderatedCategories = KunenaAccess::getInstance()->getModeratorStatus($this);
     if ($this->userid == 0) {
         $type = 'guest';
     } elseif ($this->isBlocked()) {
         $type = 'blocked';
     } elseif ($this->isBanned()) {
         $type = 'banned';
     } elseif (!empty($adminCategories[0])) {
         $type = 'admin';
     } elseif (!empty($adminCategories[$catid])) {
         $type = 'localadmin';
     } elseif (!empty($moderatedCategories[0])) {
         $type = 'globalmod';
     } elseif (!empty($moderatedCategories[$catid])) {
         $type = 'moderator';
     } elseif (!$catid && !empty($moderatedCategories)) {
         $type = 'moderator';
     } else {
         $type = 'user';
     }
     // Deprecated in K4.0
     if ($code === 'class') {
         $userClasses = KunenaFactory::getTemplate()->getUserClasses();
         return isset($userClasses[$type]) ? $userClasses[$type] : $userClasses[0] . $type;
     }
     return $code ? $type : $types[$type];
 }
예제 #25
0
 /**
  * @param KunenaUser $user
  *
  * @return KunenaExceptionAuthorise|null
  */
 protected function authoriseRead(KunenaUser $user)
 {
     // Check that user can read topic
     if (!$this->exists()) {
         return new KunenaExceptionAuthorise(JText::_('COM_KUNENA_NO_ACCESS'), 404);
     }
     // TODO: Allow owner to see his posts.
     if ($this->hold) {
         if (!$user->exists()) {
             return new KunenaExceptionAuthorise(JText::_('COM_KUNENA_NO_ACCESS'), 401);
         }
         $access = KunenaAccess::getInstance();
         $hold = $access->getAllowedHold($user->userid, $this->category_id, false);
         if (!in_array($this->hold, $hold)) {
             return new KunenaExceptionAuthorise(JText::_('COM_KUNENA_NO_ACCESS'), 403);
         }
     }
     return null;
 }
예제 #26
0
 /**
  * @param KunenaUser $user
  *
  * @return KunenaExceptionAuthorise|null
  */
 protected function authoriseRead(KunenaUser $user)
 {
     if ($this->hold && !$user->exists()) {
         return new KunenaExceptionAuthorise(JText::_('COM_KUNENA_NO_ACCESS'), 401);
     }
     // Check that user has the right to see the post (user can see his own unapproved posts)
     if ($this->hold > 1 || $this->hold == 1 && $this->userid != $user->userid) {
         $access = KunenaAccess::getInstance();
         $hold = $access->getAllowedHold($user->userid, $this->catid, false);
         if (!in_array($this->hold, $hold)) {
             return new KunenaExceptionAuthorise(JText::_('COM_KUNENA_NO_ACCESS'), 403);
         }
     }
     return null;
 }
예제 #27
0
 /**
  * @param   bool|array   $ids
  * @param   bool   $reverse
  * @param   string $authorise
  *
  * @return array|KunenaForumCategory[]
  */
 public static function getCategories($ids = false, $reverse = false, $authorise = 'read')
 {
     KUNENA_PROFILER ? KunenaProfiler::instance()->start('function ' . __CLASS__ . '::' . __FUNCTION__ . '()') : null;
     if ($ids === false) {
         if ($authorise == 'none') {
             KUNENA_PROFILER ? KunenaProfiler::instance()->stop('function ' . __CLASS__ . '::' . __FUNCTION__ . '()') : null;
             return self::$_instances;
         }
         $ids = self::$_instances;
     } elseif (is_array($ids)) {
         $ids = array_flip($ids);
     } else {
         $ids = array(intval($ids) => 1);
     }
     if (!$reverse) {
         $allowed = $authorise != 'none' ? array_intersect_key($ids, KunenaAccess::getInstance()->getAllowedCategories()) : $ids;
         $list = array_intersect_key(self::$_instances, $allowed);
         if ($authorise != 'none' && $authorise != 'read') {
             foreach ($list as $category) {
                 // @var KunenaForumCategory $category
                 if (!$category->authorise($authorise, null, true)) {
                     unset($list[$category->id]);
                 }
             }
         }
     } else {
         $allowed = $authorise != 'none' ? array_intersect_key(self::$_instances, KunenaAccess::getInstance()->getAllowedCategories()) : self::$_instances;
         $list = array_diff_key($allowed, $ids);
         if ($authorise != 'none' && $authorise != 'read') {
             foreach ($list as $category) {
                 // @var KunenaForumCategory $category
                 if (!$category->authorise($authorise, null, true)) {
                     unset($list[$category->id]);
                 }
             }
         }
     }
     KUNENA_PROFILER ? KunenaProfiler::instance()->stop('function ' . __CLASS__ . '::' . __FUNCTION__ . '()') : null;
     return $list;
 }
예제 #28
0
	/**
	 * Clear Kunena access cache.
	 */
	public static function clearAccess()
	{
		KunenaAccess::getInstance()->clearCache();
	}
예제 #29
0
 public function getAdminOptions()
 {
     $category = $this->getAdminCategory();
     if (!$category) {
         return false;
     }
     $catList = array();
     $catList[] = JHtml::_('select.option', 0, JText::_('COM_KUNENA_TOPLEVEL'));
     // make a standard yes/no list
     $published = array();
     $published[] = JHtml::_('select.option', 1, JText::_('COM_KUNENA_PUBLISHED'));
     $published[] = JHtml::_('select.option', 0, JText::_('COM_KUNENA_UNPUBLISHED'));
     // make a standard yes/no list
     $yesno = array();
     $yesno[] = JHtml::_('select.option', 0, JText::_('COM_KUNENA_NO'));
     $yesno[] = JHtml::_('select.option', 1, JText::_('COM_KUNENA_YES'));
     // Anonymous posts default
     $post_anonymous = array();
     $post_anonymous[] = JHtml::_('select.option', '0', JText::_('COM_KUNENA_CATEGORY_ANONYMOUS_X_REG'));
     $post_anonymous[] = JHtml::_('select.option', '1', JText::_('COM_KUNENA_CATEGORY_ANONYMOUS_X_ANO'));
     $cat_params = array();
     $cat_params['ordering'] = 'ordering';
     $cat_params['toplevel'] = JText::_('COM_KUNENA_TOPLEVEL');
     $cat_params['sections'] = 1;
     $cat_params['unpublished'] = 1;
     $cat_params['catid'] = $category->id;
     $cat_params['action'] = 'admin';
     $channels_params = array();
     $channels_params['catid'] = $category->id;
     $channels_params['action'] = 'admin';
     $channels_options = array();
     $channels_options[] = JHtml::_('select.option', 'THIS', JText::_('COM_KUNENA_CATEGORY_CHANNELS_OPTION_THIS'));
     $channels_options[] = JHtml::_('select.option', 'CHILDREN', JText::_('COM_KUNENA_CATEGORY_CHANNELS_OPTION_CHILDREN'));
     if (empty($category->channels)) {
         $category->channels = 'THIS';
     }
     $topic_ordering_options = array();
     $topic_ordering_options[] = JHtml::_('select.option', 'lastpost', JText::_('COM_KUNENA_CATEGORY_TOPIC_ORDERING_OPTION_LASTPOST'));
     $topic_ordering_options[] = JHtml::_('select.option', 'creation', JText::_('COM_KUNENA_CATEGORY_TOPIC_ORDERING_OPTION_CREATION'));
     $topic_ordering_options[] = JHtml::_('select.option', 'alpha', JText::_('COM_KUNENA_CATEGORY_TOPIC_ORDERING_OPTION_ALPHA'));
     $aliases = array_keys($category->getAliases());
     $lists = array();
     $lists['accesstypes'] = KunenaAccess::getInstance()->getAccessTypesList($category);
     $lists['accesslists'] = KunenaAccess::getInstance()->getAccessOptions($category);
     $lists['categories'] = JHtml::_('kunenaforum.categorylist', 'parent_id', 0, null, $cat_params, 'class="inputbox"', 'value', 'text', $category->parent_id);
     $lists['channels'] = JHtml::_('kunenaforum.categorylist', 'channels[]', 0, $channels_options, $channels_params, 'class="inputbox" multiple="multiple"', 'value', 'text', explode(',', $category->channels));
     $lists['aliases'] = $aliases ? JHtml::_('kunenaforum.checklist', 'aliases', $aliases, true) : null;
     $lists['published'] = JHtml::_('select.genericlist', $published, 'published', 'class="inputbox"', 'value', 'text', $category->published);
     $lists['forumLocked'] = JHtml::_('select.genericlist', $yesno, 'locked', 'class="inputbox" size="1"', 'value', 'text', $category->locked);
     $lists['forumReview'] = JHtml::_('select.genericlist', $yesno, 'review', 'class="inputbox" size="1"', 'value', 'text', $category->review);
     $lists['allow_polls'] = JHtml::_('select.genericlist', $yesno, 'allow_polls', 'class="inputbox" size="1"', 'value', 'text', $category->allow_polls);
     $lists['allow_anonymous'] = JHtml::_('select.genericlist', $yesno, 'allow_anonymous', 'class="inputbox" size="1"', 'value', 'text', $category->allow_anonymous);
     $lists['post_anonymous'] = JHtml::_('select.genericlist', $post_anonymous, 'post_anonymous', 'class="inputbox" size="1"', 'value', 'text', $category->post_anonymous);
     $lists['topic_ordering'] = JHtml::_('select.genericlist', $topic_ordering_options, 'topic_ordering', 'class="inputbox" size="1"', 'value', 'text', $category->topic_ordering);
     // TODO:
     /*
     $topicicons = array ();
     jimport( 'joomla.filesystem.folder' );
     $topiciconslist = JFolder::folders(JPATH_ROOT.'/media/kunena/topicicons');
     foreach( $topiciconslist as $icon ) {
     	$topicicons[] = JHtml::_ ( 'select.option', $icon, $icon );
     }
     $lists ['category_iconset'] = JHtml::_ ( 'select.genericlist', $topicicons, 'iconset', 'class="inputbox" size="1"', 'value', 'text', $category->iconset );
     */
     return $lists;
 }
예제 #30
0
 /**
  * @param KunenaUser $user
  *
  * @return KunenaExceptionAuthorise|null
  */
 protected function authoriseRead(KunenaUser $user)
 {
     static $catids = false;
     if ($catids === false) {
         $catids = KunenaAccess::getInstance()->getAllowedCategories($user);
     }
     // Checks if user can read category
     if (!$this->exists()) {
         return new KunenaExceptionAuthorise(JText::_('COM_KUNENA_NO_ACCESS'), 404);
     }
     if (empty($catids[$this->id])) {
         if ($user->exists()) {
             return new KunenaExceptionAuthorise(JText::_('COM_KUNENA_NO_ACCESS'), 403);
         } else {
             return new KunenaExceptionAuthorise(JText::_('COM_KUNENA_NO_ACCESS'), 401);
         }
     }
     return null;
 }