当前位置: 首页>>代码示例>>PHP>>正文


PHP KunenaUser::exists方法代码示例

本文整理汇总了PHP中KunenaUser::exists方法的典型用法代码示例。如果您正苦于以下问题:PHP KunenaUser::exists方法的具体用法?PHP KunenaUser::exists怎么用?PHP KunenaUser::exists使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在KunenaUser的用法示例。


在下文中一共展示了KunenaUser::exists方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: before

	/**
	 * Load user profile.
	 *
	 * @return void
	 *
	 * @throws KunenaExceptionAuthorise
	 */
	protected function before()
	{
		parent::before();

		// If profile integration is disabled, this view doesn't exist.
		$integration = KunenaFactory::getProfile();

		if (get_class($integration) == 'KunenaProfileNone')
		{
			throw new KunenaExceptionAuthorise(JText::_('COM_KUNENA_PROFILE_DISABLED'), 404);
		}

		$userid = $this->input->getInt('userid');

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

		$this->me = KunenaUserHelper::getMyself();
		$this->user = JFactory::getUser($userid);
		$this->profile = KunenaUserHelper::get($userid);
		$this->profile->tryAuthorise('read');

		// Update profile hits.
		if (!$this->profile->exists() || !$this->profile->isMyself())
		{
			$this->profile->uhits++;
			$this->profile->save();
		}

		$this->headerText = JText::sprintf('COM_KUNENA_VIEW_USER_DEFAULT', $this->profile->getName());
	}
开发者ID:BillVGN,项目名称:PortalPRP,代码行数:40,代码来源:display.php

示例2: execute

 public function execute()
 {
     KUNENA_PROFILER ? KunenaProfiler::instance()->start('function ' . get_class($this) . '::' . __FUNCTION__ . '()') : null;
     // Run before executing action.
     $result = $this->before();
     if ($result === false) {
         KUNENA_PROFILER ? KunenaProfiler::instance()->stop('function ' . get_class($this) . '::' . __FUNCTION__ . '()') : null;
         throw new KunenaExceptionAuthorise(JText::_('COM_KUNENA_NO_ACCESS'), 404);
     }
     // Wrapper layout.
     $this->output = KunenaLayout::factory('Page')->set('me', $this->me)->setOptions($this->getOptions());
     if ($this->config->board_offline && !$this->me->isAdmin()) {
         // Forum is offline.
         $this->setResponseStatus(503);
         $this->output->setLayout('offline');
         $this->content = KunenaLayout::factory('Widget/Custom')->set('header', JText::_('COM_KUNENA_FORUM_IS_OFFLINE'))->set('body', $this->config->offline_message);
     } elseif ($this->config->regonly && !$this->me->exists()) {
         // Forum is for registered users only.
         $this->setResponseStatus(403);
         $this->output->setLayout('offline');
         $this->content = KunenaLayout::factory('Widget/Custom')->set('header', JText::_('COM_KUNENA_LOGIN_NOTIFICATION'))->set('body', JText::_('COM_KUNENA_LOGIN_FORUM'));
     } else {
         // Display real content.
         try {
             // Split into two lines for exception handling.
             $content = $this->display()->set('breadcrumb', $this->breadcrumb);
             $this->content = $content->render();
         } catch (KunenaExceptionAuthorise $e) {
             $this->setResponseStatus($e->getResponseCode());
             $this->output->setLayout('unauthorized');
             $this->document->setTitle($e->getResponseStatus());
             $this->content = KunenaLayout::factory('Widget/Custom')->set('header', $e->getResponseStatus())->set('body', $e->getMessage());
         } catch (Exception $e) {
             if (!$e instanceof KunenaExceptionAuthorise) {
                 $header = 'Error while rendering layout';
                 $content = isset($content) ? $content->renderError($e) : $this->content->renderError($e);
                 $e = new KunenaExceptionAuthorise($e->getMessage(), $e->getCode(), $e);
             } else {
                 $header = $e->getResponseStatus();
                 $content = $e->getMessage();
             }
             $this->setResponseStatus($e->getResponseCode());
             $this->output->setLayout('unauthorized');
             $this->document->setTitle($header);
             $this->content = KunenaLayout::factory('Widget/Custom')->set('header', $header)->set('body', $content);
         }
     }
     // Display wrapper layout with given parameters.
     $this->output->set('content', $this->content)->set('breadcrumb', $this->breadcrumb);
     // Run after executing action.
     $this->after();
     KUNENA_PROFILER ? KunenaProfiler::instance()->stop('function ' . get_class($this) . '::' . __FUNCTION__ . '()') : null;
     return $this->output;
 }
开发者ID:giabmf11,项目名称:Kunena-Forum,代码行数:54,代码来源:display.php

示例3: authoriseRead

 /**
  * @param KunenaUser $user
  *
  * @return KunenaExceptionAuthorise|null
  *
  * @since  K4.0
  */
 protected function authoriseRead(KunenaUser $user)
 {
     // Checks if attachment exists
     if (!$this->exists()) {
         return new KunenaExceptionAuthorise(JText::_('COM_KUNENA_ATTACHMENT_NO_ACCESS'), 404);
     }
     if (!$user->exists()) {
         $config = KunenaConfig::getInstance();
         if ($this->isImage() && !$config->showimgforguest) {
             return new KunenaExceptionAuthorise(JText::_('COM_KUNENA_SHOWIMGFORGUEST_HIDEIMG'), 401);
         }
         if (!$this->isImage() && !$config->showfileforguest) {
             return new KunenaExceptionAuthorise(JText::_('COM_KUNENA_SHOWIMGFORGUEST_HIDEFILE'), 401);
         }
     }
     return null;
 }
开发者ID:densem-2013,项目名称:exikom,代码行数:24,代码来源:attachment.php

示例4: loadUsers

 public static function loadUsers(array $userids = array())
 {
     // Make sure that userids are unique and that indexes are correct
     $e_userids = array();
     foreach ($userids as &$userid) {
         if (!$userid || $userid != intval($userid)) {
             unset($userid);
         } elseif (empty(self::$_instances[$userid])) {
             $e_userids[$userid] = $userid;
         }
     }
     if (!empty($e_userids)) {
         $userlist = implode(',', $e_userids);
         $db = JFactory::getDBO();
         $query = "SELECT u.name, u.username, u.email, u.block as blocked, u.registerDate, u.lastvisitDate, ku.*\n\t\t\t\tFROM #__users AS u\n\t\t\t\tLEFT JOIN #__kunena_users AS ku ON u.id = ku.userid\n\t\t\t\tWHERE u.id IN ({$userlist})";
         $db->setQuery($query);
         $results = $db->loadAssocList();
         KunenaError::checkDatabaseError();
         foreach ($results as $user) {
             $instance = new KunenaUser(false);
             $instance->setProperties($user);
             $instance->exists(true);
             self::$_instances[$instance->userid] = $instance;
         }
         // Preload avatars if configured
         $avatars = KunenaFactory::getAvatarIntegration();
         $avatars->load($e_userids);
     }
     $list = array();
     foreach ($userids as $userid) {
         if (isset(self::$_instances[$userid])) {
             $list[$userid] = self::$_instances[$userid];
         }
     }
     return $list;
 }
开发者ID:laiello,项目名称:senluonirvana,代码行数:36,代码来源:helper.php

示例5: authoriseOwn

 /**
  * @param KunenaUser $user
  *
  * @return null|string
  */
 protected function authoriseOwn(KunenaUser $user)
 {
     // Guests cannot own a topic.
     if (!$user->exists()) {
         return new KunenaExceptionAuthorise(JText::_('COM_KUNENA_POST_NOT_MODERATOR'), 401);
     }
     // Check that topic owned by the user or user is a moderator
     $usertopic = $this->getUserTopic($user);
     if (!$usertopic->owner && !$user->isModerator($this->getCategory())) {
         return new KunenaExceptionAuthorise(JText::_('COM_KUNENA_POST_NOT_MODERATOR'), 403);
     }
     return null;
 }
开发者ID:giabmf11,项目名称:Kunena-Forum,代码行数:18,代码来源:topic.php

示例6: authoriseOwn

 /**
  * @param KunenaUser $user
  *
  * @return KunenaExceptionAuthorise|null
  */
 protected function authoriseOwn(KunenaUser $user)
 {
     // Guests cannot own posts.
     if (!$user->exists()) {
         return new KunenaExceptionAuthorise(JText::_('COM_KUNENA_POST_EDIT_NOT_ALLOWED'), 401);
     }
     // Check that topic owned by the user or user is a moderator
     // TODO: check #__kunena_user_topics
     if ($this->userid != $user->userid && !$user->isModerator($this->getCategory())) {
         return new KunenaExceptionAuthorise(JText::_('COM_KUNENA_POST_EDIT_NOT_ALLOWED'), 403);
     }
     return null;
 }
开发者ID:giabmf11,项目名称:Kunena-Forum,代码行数:18,代码来源:message.php

示例7: loadUsers

 /**
  * @param array $userids
  *
  * @return array
  */
 public static function loadUsers(array $userids = array())
 {
     KUNENA_PROFILER ? KunenaProfiler::instance()->start('function ' . __CLASS__ . '::' . __FUNCTION__ . '()') : null;
     // Make sure that userids are unique and that indexes are correct
     $e_userids = array();
     foreach ($userids as $userid) {
         // Ignore guests and imported users, which haven't been mapped to Joomla (id<0).
         if ($userid > 0 && empty(self::$_instances[$userid])) {
             $e_userids[(int) $userid] = (int) $userid;
         }
     }
     if (!empty($e_userids)) {
         $userlist = implode(',', $e_userids);
         $db = JFactory::getDBO();
         $query = "SELECT u.name, u.username, u.email, u.block as blocked, u.registerDate, u.lastvisitDate, ku.*, u.id AS userid\n\t\t\t\tFROM #__users AS u\n\t\t\t\tLEFT JOIN #__kunena_users AS ku ON u.id = ku.userid\n\t\t\t\tWHERE u.id IN ({$userlist})";
         $db->setQuery($query);
         $results = $db->loadAssocList();
         KunenaError::checkDatabaseError();
         foreach ($results as $user) {
             $instance = new KunenaUser(false);
             $instance->setProperties($user);
             $instance->exists(isset($user['posts']));
             self::$_instances[$instance->userid] = $instance;
         }
         // Preload avatars if configured
         $avatars = KunenaFactory::getAvatarIntegration();
         $avatars->load($e_userids);
     }
     $list = array();
     foreach ($userids as $userid) {
         if (isset(self::$_instances[$userid])) {
             $list[$userid] = self::$_instances[$userid];
         }
     }
     KUNENA_PROFILER ? KunenaProfiler::instance()->stop('function ' . __CLASS__ . '::' . __FUNCTION__ . '()') : null;
     return $list;
 }
开发者ID:giabmf11,项目名称:Kunena-Forum,代码行数:42,代码来源:helper.php

示例8: before

 /**
  * 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'));
 }
开发者ID:Ruud68,项目名称:Kunena-Forum,代码行数:69,代码来源:display.php

示例9: before

 /**
  * 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.
//.........这里部分代码省略.........
开发者ID:giabmf11,项目名称:Kunena-Forum,代码行数:101,代码来源:display.php

示例10: loadUsers

	static public function loadUsers($userids = array()) {
		if (!is_array($userids)) {
			JError::raiseError ( 500, __CLASS__ . '::' . __FUNCTION__.'(): Parameter $userids is not array' );
		}

		// Make sure that userids are unique and that indexes are correct
		$e_userids = array();
		foreach($userids as $userid){
			if (empty ( self::$_instances [intval($userid)] )) $e_userids[intval($userid)] = intval($userid);
		}
		unset($e_userids[0]);
		if (empty($e_userids)) return array();

		$userlist = implode ( ',', $e_userids );

		$db = JFactory::getDBO ();
		$query = "SELECT u.name, u.username, u.email, u.block as blocked, u.registerDate, u.lastvisitDate, ku.*
			FROM #__users AS u
			LEFT JOIN #__kunena_users AS ku ON u.id = ku.userid
			WHERE u.id IN ({$userlist})";
		$db->setQuery ( $query );
		$results = $db->loadAssocList ();
		KunenaError::checkDatabaseError ();

		$list = array ();
		foreach ( $results as $user ) {
			$instance = new KunenaUser (false);
			$instance->setProperties ( $user );
			$instance->exists(true);
			self::$_instances [$instance->userid] = $instance;
		}

		// Finally call integration preload as well
		// Preload avatars if configured
		$avatars = KunenaFactory::getAvatarIntegration();
		$avatars->load($userids);

		foreach ($userids as $userid) {
			if (isset(self::$_instances [$userid])) $list [$userid] = self::$_instances [$userid];
		}
		return $list;
	}
开发者ID:GoremanX,项目名称:Kunena-2.0,代码行数:42,代码来源:helper.php

示例11: authoriseWrite

	/**
	 * @param KunenaUser $user
	 *
	 * @return null|string
	 */
	protected function authoriseWrite(KunenaUser $user)
	{
		// Check that user is global moderator
		if (!$user->exists())
		{
			return new KunenaExceptionAuthorise(JText::_('COM_KUNENA_POST_NOT_MODERATOR'), 401);
		}

		if (!$user->isModerator())
		{
			return new KunenaExceptionAuthorise(JText::_('COM_KUNENA_POST_NOT_MODERATOR'), 403);
		}

		return null;
	}
开发者ID:BillVGN,项目名称:PortalPRP,代码行数:20,代码来源:announcement.php


注:本文中的KunenaUser::exists方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。