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


PHP KunenaUser类代码示例

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


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

示例1: filterByUserAccess

 /**
  * Filter by user access to the categories.
  *
  * It is very important to use this or category filter. Otherwise topics from unauthorized categories will be
  * included to the search results.
  *
  * @param KunenaUser $user
  *
  * @return $this
  */
 public function filterByUserAccess(KunenaUser $user)
 {
     $categories = $user->getAllowedCategories();
     $list = implode(',', $categories);
     $this->query->where("a.category_id IN ({$list})");
     return $this;
 }
开发者ID:giabmf11,项目名称:Kunena-Forum,代码行数:17,代码来源:finder.php

示例2: prepareTopics

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

示例3: before

 /**
  * Prepare ban form.
  *
  * @return void
  *
  * @throws KunenaExceptionAuthorise
  */
 protected function before()
 {
     parent::before();
     $userid = $this->input->getInt('userid');
     $this->profile = KunenaUserHelper::get($userid);
     $this->profile->tryAuthorise('ban');
     $this->banInfo = KunenaUserBan::getInstanceByUserid($userid, true);
     $this->headerText = $this->banInfo->exists() ? JText::_('COM_KUNENA_BAN_EDIT') : JText::_('COM_KUNENA_BAN_NEW');
 }
开发者ID:giabmf11,项目名称:Kunena-Forum,代码行数:16,代码来源:display.php

示例4: before

 /**
  * Prepare user for editing.
  *
  * @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');
     $this->user = JFactory::getUser($userid);
     $this->profile = KunenaUserHelper::get($userid);
     $this->profile->tryAuthorise('edit');
     $this->headerText = JText::sprintf('COM_KUNENA_VIEW_USER_DEFAULT', $this->profile->getName());
 }
开发者ID:giabmf11,项目名称:Kunena-Forum,代码行数:21,代码来源:display.php

示例5: before

 /**
  * Prepare category display.
  *
  * @return void
  *
  * @throws KunenaExceptionAuthorise
  */
 protected function before()
 {
     parent::before();
     require_once KPATH_SITE . '/models/category.php';
     $this->model = new KunenaModelCategory();
     $this->me = KunenaUserHelper::getMyself();
     $catid = $this->input->getInt('catid');
     $limitstart = $this->input->getInt('limitstart', 0);
     $limit = $this->input->getInt('limit', 0);
     if ($limit < 1 || $limit > 100) {
         $limit = $this->config->threads_per_page;
     }
     // TODO:
     $direction = 'DESC';
     $this->category = KunenaForumCategoryHelper::get($catid);
     $this->category->tryAuthorise();
     $this->headerText = JText::_('COM_KUNENA_THREADS_IN_FORUM') . ': ' . $this->category->name;
     $topic_ordering = $this->category->topic_ordering;
     $access = KunenaAccess::getInstance();
     $hold = $access->getAllowedHold($this->me, $catid);
     $moved = 1;
     $params = array('hold' => $hold, 'moved' => $moved);
     switch ($topic_ordering) {
         case 'alpha':
             $params['orderby'] = 'tt.ordering DESC, tt.subject ASC ';
             break;
         case 'creation':
             $params['orderby'] = 'tt.ordering DESC, tt.first_post_time ' . $direction;
             break;
         case 'lastpost':
         default:
             $params['orderby'] = 'tt.ordering DESC, tt.last_post_time ' . $direction;
     }
     list($this->total, $this->topics) = KunenaForumTopicHelper::getLatestTopics($catid, $limitstart, $limit, $params);
     if ($this->total > 0) {
         // Collect user ids for avatar prefetch when integrated.
         $userlist = array();
         $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 ($lastreadlist || $this->me->isAdmin() || KunenaAccess::getInstance()->getModeratorStatus()) {
             KunenaForumMessageHelper::loadLocation($lastpostlist + $lastreadlist);
         }
     }
     $this->topicActions = $this->model->getTopicActions();
     $this->actionMove = $this->model->getActionMove();
     $this->pagination = new KunenaPagination($this->total, $limitstart, $limit);
     $this->pagination->setDisplayedPages(5);
 }
开发者ID:anawu2006,项目名称:PeerLearning,代码行数:67,代码来源:display.php

示例6: before

 protected function before()
 {
     KUNENA_PROFILER ? KunenaProfiler::instance()->start('function ' . get_class($this) . '::' . __FUNCTION__ . '()') : null;
     if (!$this->exists()) {
         KUNENA_PROFILER ? KunenaProfiler::instance()->stop('function ' . get_class($this) . '::' . __FUNCTION__ . '()') : null;
         throw new RuntimeException("Layout '{$this->input->getWord('view')}/{$this->input->getWord('layout', 'default')}' does not exist!", 404);
     }
     // Load language files.
     KunenaFactory::loadLanguage('com_kunena.sys', 'admin');
     KunenaFactory::loadLanguage('com_kunena.templates');
     KunenaFactory::loadLanguage('com_kunena.models');
     KunenaFactory::loadLanguage('com_kunena.views');
     $this->me = KunenaUserHelper::getMyself();
     $this->config = KunenaConfig::getInstance();
     $this->document = JFactory::getDocument();
     $this->template = KunenaFactory::getTemplate();
     $this->template->initialize();
     if ($this->me->isAdmin()) {
         // Display warnings to the administrator if forum is either offline or debug has been turned on.
         if ($this->config->board_offline) {
             $this->app->enqueueMessage(JText::_('COM_KUNENA_FORUM_IS_OFFLINE'), 'notice');
         }
         if ($this->config->debug) {
             $this->app->enqueueMessage(JText::_('COM_KUNENA_WARNING_DEBUG'), 'notice');
         }
     }
     if ($this->me->isBanned()) {
         // Display warnings to the banned users.
         $banned = KunenaUserBan::getInstanceByUserid($this->me->userid, true);
         if (!$banned->isLifetime()) {
             $this->app->enqueueMessage(JText::sprintf('COM_KUNENA_POST_ERROR_USER_BANNED_NOACCESS_EXPIRY', KunenaDate::getInstance($banned->expiration)->toKunena('date_today')), 'notice');
         } else {
             $this->app->enqueueMessage(JText::_('COM_KUNENA_POST_ERROR_USER_BANNED_NOACCESS'), 'notice');
         }
     }
     // Remove base and add canonical link.
     $this->document->setBase('');
     $this->document->addHeadLink(KunenaRoute::_(), 'canonical', 'rel', '');
     // Initialize breadcrumb.
     $this->breadcrumb = $this->app->getPathway();
     KUNENA_PROFILER ? KunenaProfiler::instance()->stop('function ' . get_class($this) . '::' . __FUNCTION__ . '()') : null;
 }
开发者ID:giabmf11,项目名称:Kunena-Forum,代码行数:42,代码来源:display.php

示例7: authoriseAttachmentsFile

 /**
  * Check if user has the right to upload file attachment
  *
  * @param KunenaUser $user
  * @return KunenaExceptionAuthorise|NULL
  */
 protected function authoriseAttachmentsFile(KunenaUser $user)
 {
     if (empty(KunenaFactory::getConfig()->file_upload)) {
         return new KunenaExceptionAuthorise(JText::_('COM_KUNENA_POST_ATTACHMENTS_NOT_ALLOWED'), 403);
     }
     if (KunenaFactory::getConfig()->file_upload == 'admin') {
         if (!$user->isAdmin()) {
             return new KunenaExceptionAuthorise(JText::_('COM_KUNENA_POST_ATTACHMENTS_FILE_ONLY_FOR_ADMINISTRATORS'), 403);
         }
     }
     if (KunenaFactory::getConfig()->file_upload == 'registered') {
         if (!$user->userid) {
             return new KunenaExceptionAuthorise(JText::_('COM_KUNENA_POST_ATTACHMENTS_FILE_ONLY_FOR_REGISTERED_USERS'), 403);
         }
     }
     if (KunenaFactory::getConfig()->file_upload == 'moderator') {
         if (!$user->isModerator()) {
             return new KunenaExceptionAuthorise(JText::_('COM_KUNENA_POST_ATTACHMENTS_FILE_ONLY_FOR_MODERATORS'), 403);
         }
     }
     return null;
 }
开发者ID:giabmf11,项目名称:Kunena-Forum,代码行数:28,代码来源:message.php

示例8: authoriseOwn

 protected function authoriseOwn(KunenaUser $user)
 {
     // Checks if attachment is users own or user is moderator in the category (or global)
     if ($user->userid && $this->userid != $user->userid && !$user->isModerator($this->getMessage()->getCategory())) {
         $this->setError(JText::_('COM_KUNENA_NO_ACCESS'));
         return false;
     }
     return true;
 }
开发者ID:laiello,项目名称:senluonirvana,代码行数:9,代码来源:attachment.php

示例9: 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

示例10: authoriseAdmin

 /**
  * @param KunenaUser $user
  *
  * @return KunenaExceptionAuthorise|null
  */
 protected function authoriseAdmin(KunenaUser $user)
 {
     // Check that user is admin
     if (!$user->userid) {
         return new KunenaExceptionAuthorise(JText::_('COM_KUNENA_MODERATION_ERROR_NOT_ADMIN'), 401);
     }
     if (!$user->isAdmin($this)) {
         return new KunenaExceptionAuthorise(JText::_('COM_KUNENA_MODERATION_ERROR_NOT_ADMIN'), 403);
     }
     return null;
 }
开发者ID:densem-2013,项目名称:exikom,代码行数:16,代码来源:category.php

示例11: authoriseDelete

	/**
	 * @param KunenaUser $user
	 *
	 * @return bool
	 */
	protected function authoriseDelete(KunenaUser $user) {
		$config = KunenaFactory::getConfig();
		if (!$user->isModerator($this->getCategory())
				&& $config->userdeletetmessage != '2' && ($config->userdeletetmessage == '0' || $this->getTopic()->last_post_id != $this->id)) {
			$this->setError (JText::_ ( 'COM_KUNENA_POST_ERROR_DELETE_REPLY_AFTER' ) );
			return false;
		}
		return true;
	}
开发者ID:kosmosby,项目名称:medicine-prof,代码行数:14,代码来源:message.php

示例12: authoriseOwn

 /**
  * @param KunenaUser $user
  *
  * @return KunenaExceptionAuthorise|null
  *
  * @since  K4.0
  */
 protected function authoriseOwn(KunenaUser $user)
 {
     // Checks if attachment is users own or user is moderator in the category (or global)
     if ($user->userid && $this->userid != $user->userid && !$user->isModerator($this->getMessage()->getCategory())) {
         return new KunenaExceptionAuthorise(JText::_('COM_KUNENA_ATTACHMENT_NO_ACCESS'), 403);
     }
     return null;
 }
开发者ID:densem-2013,项目名称:exikom,代码行数:15,代码来源:attachment.php

示例13: 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

示例14: _common

 protected function _common()
 {
     $this->totalpages = ceil($this->total / $this->threads_per_page);
     if (!empty($this->threadids)) {
         $idstr = implode(",", $this->threadids);
         if (empty($this->loadids)) {
             $loadstr = '';
         } else {
             $loadstr = 'OR a.id IN (' . implode(",", $this->loadids) . ')';
         }
         $query = "SELECT a.*, j.id AS userid, t.message, l.myfavorite, l.favcount, l.threadhits, l.lasttime, l.threadattachments, COUNT(aa.id) AS attachments,\n\t\t\t\tl.msgcount, l.mycount, l.lastid, l.mylastid, l.lastid AS lastread, 0 AS unread, u.avatar, j.username, j.name AS uname, c.name AS catname, c.class_sfx\n\t\t\tFROM (\n\t\t\t\tSELECT m.thread, MAX(m.hits) AS threadhits, MAX(f.userid IS NOT null AND f.userid={$this->db->Quote($this->my->id)}) AS myfavorite, COUNT(DISTINCT f.userid) AS favcount,\n\t\t\t\t\tCOUNT(DISTINCT a.id) AS threadattachments, COUNT(DISTINCT m.id) AS msgcount, COUNT(DISTINCT IF(m.userid={$this->db->Quote($this->user->id)}, m.id, NULL)) AS mycount,\n\t\t\t\t\tMAX(m.id) AS lastid, MAX(IF(m.userid={$this->db->Quote($this->user->id)}, m.id, 0)) AS mylastid, MAX(m.time) AS lasttime\n\t\t\t\tFROM #__kunena_messages AS m";
         if ($this->config->allowfavorites) {
             $query .= " LEFT JOIN #__kunena_favorites AS f ON f.thread = m.thread";
         } else {
             $query .= " LEFT JOIN #__kunena_favorites AS f ON f.thread = 0";
         }
         $query .= "\n\t\t\t\tLEFT JOIN #__kunena_attachments AS a ON a.mesid = m.id\n\t\t\t\tWHERE m.hold IN ({$this->hold}) AND m.moved='0' AND m.thread IN ({$idstr})\n\t\t\t\tGROUP BY thread\n\t\t\t) AS l\n\t\t\tINNER JOIN #__kunena_messages AS a ON a.thread = l.thread\n\t\t\tINNER JOIN #__kunena_messages_text AS t ON a.id = t.mesid\n\t\t\tLEFT JOIN #__users AS j ON j.id = a.userid\n\t\t\tLEFT JOIN #__kunena_users AS u ON u.userid = j.id\n\t\t\tLEFT JOIN #__kunena_categories AS c ON c.id = a.catid\n\t\t\tLEFT JOIN #__kunena_attachments AS aa ON aa.mesid = a.id\n\t\t\tWHERE (a.parent='0' OR a.id=l.lastid {$loadstr})\n\t\t\tGROUP BY a.id\n\t\t\tORDER BY {$this->order}";
         $this->db->setQuery($query);
         $this->messages = $this->db->loadObjectList('id');
         KunenaError::checkDatabaseError();
         // collect user ids for avatar prefetch when integrated
         $userlist = array();
         foreach ($this->messages as $message) {
             if ($message->parent == 0) {
                 $this->threads[$message->thread] = $message;
                 $routerlist[$message->id] = $message->subject;
                 if ($this->func == 'mylatest' && $message->myfavorite) {
                     $this->highlight++;
                 }
             }
             if ($message->id == $message->lastid) {
                 $this->lastreply[$message->thread] = $message;
             }
             if (isset($this->loadids) && in_array($message->id, $this->loadids)) {
                 $this->customreply[$message->id] = $message;
             }
             $userlist[intval($message->userid)] = intval($message->userid);
             $userlist[intval($message->modified_by)] = intval($message->modified_by);
         }
         // Load threads to Kunena router to avoid extra SQL queries
         if (!empty($routerlist)) {
             include_once KUNENA_PATH . '/router.php';
             KunenaRouter::loadMessages($routerlist);
         }
         // Prefetch all users/avatars to avoid user by user queries during template iterations
         KunenaUser::loadUsers($userlist);
         if ($this->config->shownew && $this->my->id) {
             $readlist = $this->session->readtopics;
             $this->db->setQuery("SELECT thread, MIN(id) AS lastread, SUM(1) AS unread FROM #__kunena_messages " . "WHERE hold IN ({$this->hold}) AND moved='0' AND thread NOT IN ({$readlist}) AND thread IN ({$idstr}) AND time>{$this->db->Quote($this->prevCheck)} GROUP BY thread");
             // TODO: check input
             $msgidlist = $this->db->loadObjectList();
             KunenaError::checkDatabaseError();
             foreach ($msgidlist as $msgid) {
                 $this->messages[$msgid->thread]->lastread = $msgid->lastread;
                 $this->messages[$msgid->thread]->unread = $msgid->unread;
             }
         }
     }
 }
开发者ID:vuchannguyen,项目名称:hoctap,代码行数:59,代码来源:latestx.php

示例15: getUserSettings

 /**
  * Puts user forum settings into object
  *
  * @param moscomprofilerUser $user
  * @param object             $forum
  * @param mixed              $additional
  * @return object
  */
 function getUserSettings($user, $forum, $additional = null)
 {
     global $_CB_database;
     static $cache = array();
     if (!isset($cache[$user->id])) {
         if ($forum->prefix != 'kunena' || $forum->prefix == 'kunena' && !class_exists('KunenaForum')) {
             $query = 'SELECT f.*' . $additional . "\n FROM " . $_CB_database->NameQuote('#__' . $forum->prefix . '_users') . 'AS f' . ', ' . $_CB_database->NameQuote('#__users') . 'AS u' . "\n WHERE f." . $_CB_database->NameQuote('userid') . " = u." . $_CB_database->NameQuote('id') . "\n AND f." . $_CB_database->NameQuote('userid') . " = " . (int) $user->id;
             $_CB_database->setQuery($query, 0, 1);
             $settings = null;
             $_CB_database->loadObject($settings);
         } elseif (class_exists('KunenaUser')) {
             $settings = KunenaUser::getInstance((int) $user->id);
         } else {
             $settings = null;
         }
         $cache[$user->id] = $settings ? $settings : null;
     }
     return $cache[$user->id];
 }
开发者ID:rogatnev-nikita,项目名称:cloudinterpreter,代码行数:27,代码来源:cb.simpleboardtab.model.php


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