本文整理汇总了PHP中KunenaUserHelper::loadUsers方法的典型用法代码示例。如果您正苦于以下问题:PHP KunenaUserHelper::loadUsers方法的具体用法?PHP KunenaUserHelper::loadUsers怎么用?PHP KunenaUserHelper::loadUsers使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KunenaUserHelper
的用法示例。
在下文中一共展示了KunenaUserHelper::loadUsers方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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);
}
}
示例2: before
/**
* Prepare reply history display.
*
* @return void
*/
protected function before()
{
parent::before();
$id = $this->input->getInt('id');
$this->topic = KunenaForumTopicHelper::get($id);
$this->history = KunenaForumMessageHelper::getMessagesByTopic($this->topic, 0, (int) $this->config->historylimit, 'DESC');
$this->replycount = $this->topic->getReplies();
$this->historycount = count($this->history);
KunenaAttachmentHelper::getByMessage($this->history);
$userlist = array();
foreach ($this->history as $message) {
$userlist[(int) $message->userid] = (int) $message->userid;
}
KunenaUserHelper::loadUsers($userlist);
// Run events
$params = new JRegistry();
$params->set('ksource', 'kunena');
$params->set('kunena_view', 'topic');
$params->set('kunena_layout', 'history');
$dispatcher = JEventDispatcher::getInstance();
JPluginHelper::importPlugin('kunena');
$dispatcher->trigger('onKunenaPrepare', array('kunena.messages', &$this->history, &$params, 0));
// FIXME: need to improve BBCode class on this...
$this->attachments = KunenaAttachmentHelper::getByMessage($this->history);
$this->inline_attachments = array();
$this->headerText = JText::_('COM_KUNENA_POST_EDIT') . ' ' . $this->topic->subject;
}
示例3: getAvatars
/**
* Gets the users avatars from Kunena
*
* @param array $userIds - array with user ids
*
* @return array
*/
public static function getAvatars($userIds)
{
$avatars = array();
$users = KunenaUserHelper::loadUsers($userIds);
foreach ($users as $user) {
$avatars[$user->userid] = $user->getAvatarURL();
}
return $avatars;
}
示例4: before
/**
* Prepare ban manager.
*
* @return void
*/
protected function before()
{
parent::before();
$this->me = KunenaUserHelper::getMyself();
// TODO: add authorisation
// TODO: add pagination
$this->userBans = KunenaUserBan::getBannedUsers(0, 50);
if (!empty($this->userBans)) {
KunenaUserHelper::loadUsers(array_keys($this->userBans));
}
$this->headerText = JText::_('COM_KUNENA_BAN_BANMANAGER');
}
示例5: displaySubscriptions
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();
}
示例6: before
/**
* Prepare Who is online display.
*
* @return void
*
* @throws KunenaExceptionAuthorise
*/
protected function before()
{
parent::before();
$this->config = KunenaConfig::getInstance();
if (!$this->config->get('showwhoisonline')) {
throw new KunenaExceptionAuthorise(JText::_('COM_KUNENA_NO_ACCESS'), '404');
}
$me = KunenaUserHelper::getMyself();
$moderator = intval($me->isModerator()) + intval($me->isAdmin());
$users = KunenaUserHelper::getOnlineUsers();
KunenaUserHelper::loadUsers(array_keys($users));
$onlineusers = KunenaUserHelper::getOnlineCount();
$who = '<strong>' . $onlineusers['user'] . ' </strong>';
if ($onlineusers['user'] == 1) {
$who .= JText::_('COM_KUNENA_WHO_ONLINE_MEMBER') . ' ';
} else {
$who .= JText::_('COM_KUNENA_WHO_ONLINE_MEMBERS') . ' ';
}
$who .= JText::_('COM_KUNENA_WHO_AND');
$who .= '<strong> ' . $onlineusers['guest'] . ' </strong>';
if ($onlineusers['guest'] == 1) {
$who .= JText::_('COM_KUNENA_WHO_ONLINE_GUEST') . ' ';
} else {
$who .= JText::_('COM_KUNENA_WHO_ONLINE_GUESTS') . ' ';
}
$who .= JText::_('COM_KUNENA_WHO_ONLINE_NOW');
$this->membersOnline = $who;
$this->onlineList = array();
$this->hiddenList = array();
foreach ($users as $userid => $usertime) {
$user = KunenaUserHelper::get($userid);
if (!$user->showOnline) {
if ($moderator) {
$this->hiddenList[$user->getName()] = $user;
}
} else {
$this->onlineList[$user->getName()] = $user;
}
}
ksort($this->onlineList);
ksort($this->hiddenList);
$profile = KunenaFactory::getProfile();
$this->usersUrl = $profile->getUserListURL();
}
示例7: before
/**
* Prepare poll display.
*
* @return void
*
* @throws KunenaExceptionAuthorise
*/
protected function before()
{
parent::before();
$this->topic = KunenaForumTopicHelper::get($this->input->getInt('id'));
$this->category = $this->topic->getCategory();
$this->config = KunenaFactory::getConfig();
$this->me = KunenaUserHelper::getMyself();
// Need to check if poll is allowed in this category.
$this->topic->tryAuthorise('poll.read');
$this->poll = $this->topic->getPoll();
$this->usercount = $this->poll->getUserCount();
$this->usersvoted = $this->poll->getUsers();
$this->voted = $this->poll->getMyVotes();
if (!empty($this->alwaysVote)) {
// Authorise forced vote.
$this->topic->tryAuthorise('poll.vote');
$this->name = 'Topic/Poll/Vote';
} elseif (!$this->voted && $this->topic->isAuthorised('poll.vote')) {
$this->name = 'Topic/Poll/Vote';
} else {
$this->name = 'Topic/Poll/Results';
$this->show_title = true;
$this->users_voted_list = array();
$this->users_voted_morelist = array();
if ($this->config->pollresultsuserslist && !empty($this->usersvoted)) {
$userids_votes = array();
foreach ($this->usersvoted as $userid => $vote) {
$userids_votes[] = $userid;
}
$loaded_users = KunenaUserHelper::loadUsers($userids_votes);
$i = 0;
foreach ($loaded_users as $userid => $user) {
if ($i <= '4') {
$this->users_voted_list[] = $loaded_users[$userid]->getLink();
} else {
$this->users_voted_morelist[] = $loaded_users[$userid]->getLink();
}
$i++;
}
}
}
$this->uri = "index.php?option=com_kunena&view=topic&layout=poll&catid={$this->category->id}&id={$this->topic->id}";
}
示例8: before
/**
* 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');
}
示例9: _common
/**
* @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);
}
}
}
示例10: displayThreadHistory
function displayThreadHistory() {
if (! $this->hasThreadHistory())
return;
$db = JFactory::getDBO();
$this->history = KunenaForumMessageHelper::getMessagesByTopic($this->topic, 0, (int) $this->config->historylimit, $ordering='DESC');
$this->historycount = count ( $this->history );
KunenaForumMessageAttachmentHelper::getByMessage($this->history);
$userlist = array();
foreach ($this->history as $message) {
$userlist[(int) $message->userid] = (int) $message->userid;
}
KunenaUserHelper::loadUsers($userlist);
echo $this->loadTemplate ( 'history' );
}
示例11: getMessages
public function getMessages()
{
if ($this->messages === false) {
$layout = $this->getState('layout');
$threaded = $layout == 'indented' || $layout == 'threaded';
$this->messages = KunenaForumMessageHelper::getMessagesByTopic($this->getState('item.id'), $this->getState('list.start'), $this->getState('list.limit'), $this->getState('list.direction'), $this->getState('hold'), $threaded);
// Get thankyous for all messages in the page
$thankyous = KunenaForumMessageThankyouHelper::getByMessage($this->messages);
// First collect ids and users
$userlist = array();
$this->threaded = array();
$location = $this->getState('list.start');
foreach ($this->messages as $message) {
$message->replynum = ++$location;
if ($threaded) {
// Threaded ordering
if (isset($this->messages[$message->parent])) {
$this->threaded[$message->parent][] = $message->id;
} else {
$this->threaded[0][] = $message->id;
}
}
$userlist[intval($message->userid)] = intval($message->userid);
$userlist[intval($message->modified_by)] = intval($message->modified_by);
$thankyou_list = $thankyous[$message->id]->getList();
$message->thankyou = array();
if (!empty($thankyou_list)) {
$message->thankyou = $thankyou_list;
}
}
if (!isset($this->messages[$this->getState('item.mesid')]) && !empty($this->messages)) {
$this->setState('item.mesid', reset($this->messages)->id);
}
if ($threaded) {
if (!isset($this->messages[$this->topic->first_post_id])) {
$this->messages = $this->getThreadedOrdering(0, array('edge'));
} else {
$this->messages = $this->getThreadedOrdering();
}
}
// Prefetch all users/avatars to avoid user by user queries during template iterations
KunenaUserHelper::loadUsers($userlist);
// Get attachments
KunenaForumMessageAttachmentHelper::getByMessage($this->messages);
}
return $this->messages;
}
示例12: batch_moderators
public function batch_moderators()
{
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);
$catids = JRequest::getVar('catid', array(), 'post', 'array');
// Array of integers
JArrayHelper::toInteger($catids);
if (empty($cid)) {
$this->app->enqueueMessage(JText::_('COM_KUNENA_USERS_BATCH_NO_USERS_SELECTED'), 'error');
$this->app->redirect(KunenaRoute::_($this->baseurl, false));
}
if (empty($catids)) {
$this->app->enqueueMessage(JText::_('COM_KUNENA_USERS_BATCH_NO_CATEGORIES_SELECTED'), 'error');
$this->app->redirect(KunenaRoute::_($this->baseurl, false));
}
// Update moderator rights
$categories = KunenaForumCategoryHelper::getCategories(false, false, 'admin');
$users = KunenaUserHelper::loadUsers($cid);
foreach ($users as $user) {
foreach ($categories as $category) {
if (in_array($category->id, $catids)) {
$category->setModerator($user, true);
}
}
// Global moderator is a special case
if ($this->me->isAdmin() && in_array(0, $catids)) {
KunenaAccess::getInstance()->setModerator(0, $user, true);
}
}
$this->app->enqueueMessage(JText::_('COM_KUNENA_USERS_SET_MODERATORS_DONE'));
$this->app->redirect(KunenaRoute::_($this->baseurl, false));
}
示例13: before
/**
* Prepare displaying message.
*
* @return void
*
* @throws KunenaExceptionAuthorise
*/
protected function before()
{
parent::before();
$mesid = $this->input->getInt('mesid', 0);
$this->me = KunenaUserHelper::getMyself();
$this->location = $this->input->getInt('location', 0);
$this->detail = $this->input->get('detail', false);
$this->message = KunenaForumMessageHelper::get($mesid);
$this->message->tryAuthorise();
$this->topic = $this->message->getTopic();
$this->category = $this->topic->getCategory();
$this->profile = $this->message->getAuthor();
$this->ktemplate = KunenaFactory::getTemplate();
$this->captchaEnabled = false;
if ($this->message->isAuthorised('reply') && $this->me->canDoCaptcha()) {
if (JPluginHelper::isEnabled('captcha')) {
$plugin = JPluginHelper::getPlugin('captcha');
$params = new JRegistry($plugin[0]->params);
$captcha_pubkey = $params->get('public_key');
$catcha_privkey = $params->get('private_key');
if (!empty($captcha_pubkey) && !empty($catcha_privkey)) {
JPluginHelper::importPlugin('captcha');
$dispatcher = JDispatcher::getInstance();
$result = $dispatcher->trigger('onInit', "dynamic_recaptcha_{$this->message->id}");
$this->captchaEnabled = $result[0];
}
}
}
// Thank you info and buttons.
$this->thankyou = array();
$this->total_thankyou = 0;
$this->more_thankyou = 0;
$this->thankyou_delete = array();
if (isset($this->message->thankyou)) {
if ($this->config->showthankyou && $this->profile->exists()) {
$task = "index.php?option=com_kunena&view=topic&task=%s&catid={$this->category->id}" . "&id={$this->topic->id}&mesid={$this->message->id}&" . JSession::getFormToken() . '=1';
// Ror normal users, show only limited number of thankyou (config->thankyou_max).
if (!$this->me->isAdmin() && !$this->me->isModerator()) {
if (count($this->message->thankyou) > $this->config->thankyou_max) {
$this->more_thankyou = count($this->message->thankyou) - $this->config->thankyou_max;
}
$this->total_thankyou = count($this->message->thankyou);
$thankyous = array_slice($this->message->thankyou, 0, $this->config->thankyou_max, true);
} else {
$thankyous = $this->message->thankyou;
}
$userids_thankyous = array();
foreach ($thankyous as $userid => $time) {
$userids_thankyous[] = $userid;
}
$loaded_users = KunenaUserHelper::loadUsers($userids_thankyous);
foreach ($loaded_users as $userid => $user) {
if ($this->message->authorise('unthankyou') && $this->me->isModerator($this->message->getCategory())) {
$this->thankyou_delete[$userid] = KunenaRoute::_(sprintf($task, "unthankyou&userid={$userid}"));
}
$this->thankyou[$userid] = $loaded_users[$userid]->getLink();
}
}
}
if ($this->config->reportmsg && $this->me->exists()) {
if ($this->config->user_report && $this->me->userid == $this->message->userid && !$this->me->isModerator()) {
$this->reportMessageLink = JHTML::_('kunenaforum.link', 'index.php?option=com_kunena&view=topic&layout=report&catid=' . intval($this->category->id) . '&id=' . intval($this->message->thread) . '&mesid=' . intval($this->message->id), JText::_('COM_KUNENA_REPORT'), JText::_('COM_KUNENA_REPORT'));
}
}
// Show admins the IP address of the user.
if ($this->category->isAuthorised('admin') || $this->category->isAuthorised('moderate') && !$this->config->hide_ip) {
if (!empty($this->message->ip)) {
$this->ipLink = '<a href="http://whois.domaintools.com/' . $this->message->ip . '" target="_blank"> IP: ' . $this->message->ip . '</a>';
} else {
$this->ipLink = ' ';
}
}
}
示例14: getModerators
/**
* Get userids, who can moderate this category
**/
public function getModerators($includeGlobal = true, $objects = true) {
$access = KunenaFactory::getAccessControl();
$userlist = array();
if (!empty($this->id)) {
$userlist += $access->getModerators($this->id);
}
if ($includeGlobal) {
$userlist += $access->getModerators();
}
if (empty($userlist)) return $userlist;
$userlist = array_keys($userlist);
return $objects ? KunenaUserHelper::loadUsers($userlist) : array_combine($userlist, $userlist);
}
示例15: load_users
public static function load_users($system, $ids)
{
if (empty($ids)) {
return;
}
switch ($system) {
case 'cjforum':
$api = JPATH_ROOT . '/components/com_cjforum/helpers/api.php';
if (file_exists($api)) {
require_once $api;
CjForumApi::load_users($ids);
}
break;
case 'cjblog':
$api = JPATH_ROOT . DS . 'components' . DS . 'com_cjblog' . DS . 'api.php';
if (file_exists($api)) {
require_once $api;
CjBlogApi::load_users($ids);
}
break;
case 'kunena':
if (CJFunctions::_initialize_kunena()) {
KunenaUserHelper::loadUsers($ids);
}
case 'cb':
$api = JPATH_ADMINISTRATOR . '/components/com_comprofiler/plugin.foundation.php';
if (!is_file($api)) {
return;
}
require_once $api;
cbimport('cb.database');
cbimport('cb.tables');
cbimport('language.front');
cbimport('cb.tabs');
cbimport('cb.field');
global $ueConfig;
CBuser::advanceNoticeOfUsersNeeded($ids);
break;
}
}