本文整理汇总了PHP中KunenaUserHelper::get方法的典型用法代码示例。如果您正苦于以下问题:PHP KunenaUserHelper::get方法的具体用法?PHP KunenaUserHelper::get怎么用?PHP KunenaUserHelper::get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KunenaUserHelper
的用法示例。
在下文中一共展示了KunenaUserHelper::get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: before
/**
* Prepare user attachments list.
*
* @return void
*/
protected function before()
{
parent::before();
$userid = $this->input->getInt('userid');
$params = array('file' => '1', 'image' => '1', 'orderby' => 'desc', 'limit' => '30');
$this->template = KunenaFactory::getTemplate();
$this->me = KunenaUserHelper::getMyself();
$this->profile = KunenaUserHelper::get($userid);
$this->attachments = KunenaAttachmentHelper::getByUserid($this->profile, $params);
// Pre-load messages.
$messageIds = array();
foreach ($this->attachments as $attachment)
{
$messageIds[] = (int) $attachment->mesid;
}
$messages = KunenaForumMessageHelper::getMessages($messageIds, 'none');
// Pre-load topics.
$topicIds = array();
foreach ($messages as $message)
{
$topicIds[] = $message->thread;
}
KunenaForumTopicHelper::getTopics($topicIds, 'none');
$this->headerText = JText::_('COM_KUNENA_MANAGE_ATTACHMENTS');
}
示例2: check
public function check() {
$user = KunenaUserHelper::get($this->userid);
$message = KunenaForumMessageHelper::get($this->mesid);
if ($this->userid != 0 && !$user->exists()) {
$this->setError(JText::sprintf('COM_KUNENA_LIB_TABLE_ATTACHMENTS_ERROR_USER_INVALID', (int) $user->userid));
}
if (!$message->exists()) {
$this->setError(JText::sprintf('COM_KUNENA_LIB_TABLE_ATTACHMENTS_ERROR_MESSAGE_INVALID', (int) $message->id));
}
$this->folder = trim($this->folder, '/');
if (!$this->folder) {
$this->setError(JText::_('COM_KUNENA_LIB_TABLE_ATTACHMENTS_ERROR_NO_FOLDER'));
}
if (!$this->filename) {
$this->setError(JText::_('COM_KUNENA_LIB_TABLE_ATTACHMENTS_ERROR_NO_FILENAME'));
}
$file = JPATH_ROOT . "/{$this->folder}/{$this->filename}";
if (!file_exists($file)) {
$this->setError(JText::sprintf('COM_KUNENA_LIB_TABLE_ATTACHMENTS_ERROR_FILE_MISSING', "{$this->folder}/{$this->filename}"));
} else {
if (!$this->hash) $this->hash = md5_file ( $file );
if (!$this->size) $this->size = filesize ( $file );
}
return ($this->getError () == '');
}
示例3: getTopics
/**
* @param bool|array $ids
* @param mixed $user
*
* @return KunenaForumTopicUserRead[]
*/
static public function getTopics($ids = false, $user = null)
{
$user = KunenaUserHelper::get($user);
if ($ids === false)
{
return isset(self::$_instances[$user->userid]) ? self::$_instances[$user->userid] : array();
}
elseif (!is_array ($ids))
{
$ids = array($ids);
}
// Convert topic objects into ids
foreach ($ids as $i=>$id)
{
if ($id instanceof KunenaForumTopic) $ids[$i] = $id->id;
}
$ids = array_unique($ids);
self::loadTopics($ids, $user);
$list = array ();
foreach ( $ids as $id )
{
if (!empty(self::$_instances [$user->userid][$id])) {
$list [$id] = self::$_instances [$user->userid][$id];
}
}
return $list;
}
示例4: getProfileURL
/**
* @param $user
* @param string $task
* @param bool $xhtml
*
* @return bool
*/
public function getProfileURL($user, $task = '', $xhtml = true)
{
if ($user == 0) {
return false;
}
if (!$user instanceof KunenaUser) {
$user = KunenaUserHelper::get($user);
}
if ($user === false) {
return false;
}
$userid = "&userid={$user->userid}";
if ($task && $task != 'edit') {
// TODO: remove in the future.
$do = $task ? '&do=' . $task : '';
return KunenaRoute::_("index.php?option=com_kunena&func=profile{$do}{$userid}", $xhtml);
} else {
$layout = $task ? '&layout=' . $task : '';
if ($layout) {
return KunenaRoute::_("index.php?option=com_kunena&view=user{$layout}{$userid}", $xhtml);
} else {
return KunenaRoute::getUserUrl($user, $xhtml);
}
}
}
示例5: markRead
public static function markRead(array $ids, $user = null)
{
$user = KunenaUserHelper::get($user);
$items = self::getCategories($ids, $user);
$updateList = array();
$insertList = array();
$db = JFactory::getDbo();
$time = JFactory::getDate()->toUnix();
foreach ($items as $item) {
if ($item->exists()) {
$updateList[] = (int) $item->category_id;
} else {
$insertList[] = "{$db->quote($user->userid)}, {$db->quote($item->category_id)}, {$db->quote($time)}";
}
}
if ($updateList) {
$idlist = implode(',', $updateList);
$query = $db->getQuery(true);
$query->update('#__kunena_user_categories')->set("allreadtime={$db->quote($time)}")->where("user_id={$db->quote($user->userid)}")->where("category_id IN ({$idlist})");
$db->setQuery($query);
$db->execute();
}
if ($insertList) {
$query = $db->getQuery(true);
$query->insert('#__kunena_user_categories')->columns('user_id, category_id, allreadtime')->values($insertList);
$db->setQuery($query);
$db->execute();
}
}
示例6: populateState
protected function populateState() {
$layout = $this->getCmd ( 'layout', 'default' );
$this->setState ( 'layout', $layout );
// Administrator state
if ($layout == 'manage' || $layout == 'create' || $layout == 'edit') {
return parent::populateState();
}
$app = JFactory::getApplication ();
$this->config = KunenaFactory::getConfig ();
$this->me = KunenaUserHelper::get();
$active = $app->getMenu ()->getActive ();
$active = $active ? (int) $active->id : 0;
$catid = $this->getInt ( 'catid', 0 );
$this->setState ( 'item.id', $catid );
// List state information
$value = $this->getUserStateFromRequest ( "com_kunena.category{$catid}_list_limit", 'limit', 0, 'int' );
if ($value < 1) $value = $this->config->threads_per_page;
$this->setState ( 'list.limit', $value );
$value = $this->getUserStateFromRequest ( "com_kunena.category{$catid}_{$active}_list_ordering", 'filter_order', 'time', 'cmd' );
//$this->setState ( 'list.ordering', $value );
$value = $this->getUserStateFromRequest ( "com_kunena.category{$catid}_list_start", 'limitstart', 0, 'int' );
$this->setState ( 'list.start', $value );
$value = $this->getUserStateFromRequest ( "com_kunena.category{$catid}_{$active}_list_direction", 'filter_order_Dir', 'desc', 'word' );
if ($value != 'asc')
$value = 'desc';
$this->setState ( 'list.direction', $value );
}
示例7: check
function check() {
$user = KunenaUserHelper::get($this->userid);
if (!$user->exists()) {
$this->setError ( JText::sprintf ( 'COM_KUNENA_LIB_TABLE_SESSIONS_ERROR_USER_INVALID', (int) $user->userid ) );
}
return ($this->getError () == '');
}
示例8: getCategories
/**
* Get categories for a specific user.
*
* @param bool|array|int $ids The category ids to load.
* @param mixed $user The user id to load.
*
* @return KunenaForumCategoryUser[]
*/
public static function getCategories($ids = false, $user = null)
{
$user = KunenaUserHelper::get($user);
if ($ids === false) {
// Get categories which are seen by current user
$ids = KunenaForumCategoryHelper::getCategories();
} elseif (!is_array($ids)) {
$ids = array($ids);
}
// Convert category objects into ids
foreach ($ids as $i => $id) {
if ($id instanceof KunenaForumCategory) {
$ids[$i] = $id->id;
}
}
$ids = array_unique($ids);
self::loadCategories($ids, $user);
$list = array();
foreach ($ids as $id) {
if (!empty(self::$_instances[$user->userid][$id])) {
$list[$id] = self::$_instances[$user->userid][$id];
}
}
return $list;
}
示例9: getUser
public function getUser()
{
$userid = $this->getState($this->getName() . '.id');
$user = KunenaUserHelper::get($userid);
return $user;
}
示例10: getSubscriptions
static public function getSubscriptions($user = null) {
$user = KunenaUserHelper::get($user);
$db = JFactory::getDBO ();
$query = "SELECT category_id FROM #__kunena_user_categories WHERE user_id={$db->Quote($user->userid)} AND subscribed=1";
$db->setQuery ( $query );
$subscribed = (array) $db->loadResultArray ();
if (KunenaError::checkDatabaseError()) return;
return KunenaForumCategoryHelper::getCategories($subscribed);
}
示例11: 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');
}
示例12: check
function check() {
$user = KunenaUserHelper::get($this->user_id);
if (!$user->exists()) {
$this->setError ( JText::sprintf ( 'COM_KUNENA_LIB_TABLE_USERCATEGORIES_ERROR_USER_INVALID', (int) $user->userid ) );
}
if ($this->category_id && !KunenaForumCategoryHelper::get($this->category_id)->exists()) {
$this->setError ( JText::sprintf ( 'COM_KUNENA_LIB_TABLE_USERCATEGORIES_ERROR_CATEGORY_INVALID', (int) $category->id ) );
}
return ($this->getError () == '');
}
示例13: populateState
protected function populateState() {
$app = JFactory::getApplication ();
$this->me = KunenaUserHelper::get();
$config = KunenaFactory::getConfig ();
$active = $app->getMenu ()->getActive ();
$active = $active ? (int) $active->id : 0;
$layout = $this->getWord ( 'layout', 'default' );
$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 = KunenaFactory::getAccessControl();
$value = $access->getAllowedHold($this->me, $catid);
$this->setState ( 'hold', $value );
$value = $this->getInt ( 'limit', 0 );
if ($value < 1) $value = $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 = $config->default_sort == 'asc' ? 'asc' : 'desc';
}
}
if ($value != 'asc')
$value = 'desc';
$this->setState ( 'list.direction', $value );
}
示例14: check
public function check()
{
$user = KunenaUserHelper::get($this->user_id);
$topic = KunenaForumTopicHelper::get($this->topic_id);
if (!$user->exists()) {
$this->setError(JText::sprintf('COM_KUNENA_LIB_TABLE_USERTOPICS_ERROR_USER_INVALID', (int) $user->userid));
}
if (!$topic->exists()) {
$this->setError(JText::sprintf('COM_KUNENA_LIB_TABLE_USERTOPICS_ERROR_TOPIC_INVALID', (int) $topic->id));
}
$this->category_id = $topic->category_id;
return $this->getError() == '';
}
示例15: before
/**
* Prepare statistics box display.
*
* @return boolean
*/
protected function before()
{
parent::before();
$this->config = KunenaConfig::getInstance();
if (!$this->config->get('showstats') || !$this->config->statslink_allowed && !KunenaUserHelper::get()->exists()) {
throw new KunenaExceptionAuthorise(JText::_('COM_KUNENA_NO_ACCESS'), '404');
}
$statistics = KunenaForumStatistics::getInstance();
$statistics->loadGeneral();
$this->setProperties($statistics);
$this->latestMemberLink = KunenaFactory::getUser(intval($this->lastUserId))->getLink();
$this->statisticsUrl = KunenaFactory::getProfile()->getStatisticsURL();
return true;
}