本文整理汇总了PHP中KunenaFactory::getUser方法的典型用法代码示例。如果您正苦于以下问题:PHP KunenaFactory::getUser方法的具体用法?PHP KunenaFactory::getUser怎么用?PHP KunenaFactory::getUser使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KunenaFactory
的用法示例。
在下文中一共展示了KunenaFactory::getUser方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testGet
/**
* Test get()
*/
public function testGet()
{
$admin = KunenaFactory::getUser('admin');
$topicuser = KunenaForumTopicUserHelper::get();
$this->assertEquals(null, $topicuser->topic_id);
$this->assertEquals(0, $topicuser->user_id);
}
示例2: _getURL
/**
* @param $user
* @param $sizex
* @param $sizey
*
* @return string
*/
protected function _getURL($user, $sizex, $sizey)
{
$user = KunenaFactory::getUser($user);
$avatar = $user->avatar;
$config = KunenaFactory::getConfig();
$path = KPATH_MEDIA . "/avatars";
$origPath = "{$path}/{$avatar}";
if (!is_file($origPath)) {
// If avatar does not exist use default image.
if ($sizex <= 90) {
$avatar = 's_nophoto.jpg';
} else {
$avatar = 'nophoto.jpg';
}
// Search from the template.
$template = KunenaFactory::getTemplate();
$origPath = JPATH_SITE . '/' . $template->getAvatarPath($avatar);
$avatar = $template->name . '/' . $avatar;
}
$dir = dirname($avatar);
$file = basename($avatar);
if ($sizex == $sizey) {
$resized = "resized/size{$sizex}/{$dir}";
} else {
$resized = "resized/size{$sizex}x{$sizey}/{$dir}";
}
// TODO: make timestamp configurable?
$timestamp = '';
if (!is_file("{$path}/{$resized}/{$file}")) {
KunenaImageHelper::version($origPath, "{$path}/{$resized}", $file, $sizex, $sizey, intval($config->avatarquality), KunenaImage::SCALE_INSIDE, intval($config->avatarcrop));
$timestamp = '?' . round(microtime(true));
}
return KURL_MEDIA . "avatars/{$resized}/{$file}{$timestamp}";
}
示例3: __construct
/**
* @param object $subject
* @param array $params
*/
public function __construct(&$subject, $params)
{
$this->app = JFactory::getApplication();
// Do not register plug-in in administration.
if ($this->app->isAdmin()) {
return;
}
// If scope isn't articles or Kunena, do not register plug-in.
if ($this->app->scope != 'com_content' && $this->app->scope != 'com_kunena') {
return;
}
// Kunena detection and version check
$minKunenaVersion = '3.0';
if (!class_exists('KunenaForum') || !KunenaForum::isCompatible($minKunenaVersion)) {
$this->loadLanguage();
$this->app->enqueueMessage(JText::sprintf('PLG_KUNENADISCUSS_DEPENDENCY_FAIL', $minKunenaVersion));
return;
}
// Kunena online check
if (!KunenaForum::enabled()) {
return;
}
// Initialize variables
$this->db = JFactory::getDbo();
$this->user = KunenaFactory::getUser();
$this->config = KunenaFactory::getConfig();
// Initialize plugin
parent::__construct($subject, $params);
$this->debug("Constructor called in {$this->app->scope}");
}
示例4: _getURL
protected function _getURL($user, $sizex, $sizey)
{
$user = KunenaFactory::getUser($user);
// Get CUser object
$avatar=AwdwallHelperUser::getBigAvatar51($user->userid);
return $avatar;
}
示例5: testGet
/**
* Test get()
*/
public function testGet()
{
$admin = KunenaFactory::getUser('admin');
$categoryuser = KunenaForumCategoryUserHelper::get(0, $admin->userid);
$this->assertEquals(0, $categoryuser->category_id);
$this->assertEquals($admin->userid, $categoryuser->user_id);
}
示例6: _getURL
protected function _getURL($user, $sizex, $sizey)
{
$user = KunenaFactory::getUser($user);
$avatar = $user->avatar;
$config = KunenaFactory::getConfig();
$path = KPATH_MEDIA . "/avatars";
if (!is_file("{$path}/{$avatar}")) {
// If avatar does not exist use default image
if ($sizex <= 90) {
$avatar = 's_nophoto.jpg';
} else {
$avatar = 'nophoto.jpg';
}
}
$dir = dirname($avatar);
$file = basename($avatar);
if ($sizex == $sizey) {
$resized = "resized/size{$sizex}/{$dir}";
} else {
$resized = "resized/size{$sizex}x{$sizey}/{$dir}";
}
if (!is_file("{$path}/{$resized}/{$file}")) {
require_once KPATH_SITE . '/lib/kunena.image.class.php';
CKunenaImageHelper::version("{$path}/{$avatar}", "{$path}/{$resized}", $file, $sizex, $sizey, intval($config->avatarquality));
}
return KURL_MEDIA . "avatars/{$resized}/{$file}";
}
示例7: _getURL
protected function _getURL($user, $sizex, $sizey)
{
global $_CB_framework;
$app = JFactory::getApplication();
$user = KunenaFactory::getUser($user);
if ($app->getClientId() == 0) {
$cbclient_id = 1;
}
if ($app->getClientId() == 1) {
$cbclient_id = 2;
}
$_CB_framework->cbset('_ui', $cbclient_id);
// Get CUser object
$cbUser = null;
if ($user->userid) {
$cbUser = CBuser::getInstance($user->userid);
}
if ($cbUser === null) {
if ($sizex <= 90) {
return selectTemplate() . 'images/avatar/tnnophoto_n.png';
}
return selectTemplate() . 'images/avatar/nophoto_n.png';
}
if ($sizex <= 90) {
return $cbUser->getField('avatar', null, 'csv');
}
return $cbUser->getField('avatar', null, 'csv', 'none', 'list');
}
示例8: testGetInstance
/**
* Test getInstance()
*
* @param KunenaForumCategoryUser $categoryuser
* @return KunenaForumCategoryUser
* @depends testCreate
*/
public function testGetInstance(KunenaForumCategoryUser $categoryuser)
{
$admin = KunenaFactory::getUser('admin');
$categoryuser2 = KunenaForumCategoryUser::getInstance($categoryuser->category_id, $admin->userid);
$this->assertSame($categoryuser, $categoryuser2);
return $categoryuser;
}
示例9: displayRows
/**
* Method to display the layout of search results
*
* @return void
*/
public function displayRows()
{
// Run events
$params = new JRegistry();
$params->set('ksource', 'kunena');
$params->set('kunena_view', 'search');
$params->set('kunena_layout', 'default');
$dispatcher = JDispatcher::getInstance();
JPluginHelper::importPlugin('kunena');
$dispatcher->trigger('onKunenaPrepare', array('kunena.messages', &$this->results, &$params, 0));
foreach ($this->results as $this->message) {
$this->topic = $this->message->getTopic();
$this->category = $this->message->getCategory();
$this->categoryLink = $this->getCategoryLink($this->category->getParent()) . ' / ' . $this->getCategoryLink($this->category);
$ressubject = KunenaHtmlParser::parseText($this->message->subject);
$resmessage = KunenaHtmlParser::parseBBCode($this->message->message, 500);
$profile = KunenaFactory::getUser((int) $this->message->userid);
$this->useravatar = $profile->getAvatarImage('kavatar', 'post');
foreach ($this->searchwords as $searchword) {
if (empty($searchword)) {
continue;
}
$ressubject = preg_replace("/" . preg_quote($searchword, '/') . "/iu", '<span class="searchword" >' . $searchword . '</span>', $ressubject);
// FIXME: enable highlighting, but only after we can be sure that we do not break html
// $resmessage = preg_replace ( "/" . preg_quote ( $searchword, '/' ) . "/iu", '<span class="searchword" >' . $searchword . '</span>', $resmessage );
}
$this->author = $this->message->getAuthor();
$this->topicAuthor = $this->topic->getAuthor();
$this->topicTime = $this->topic->first_post_time;
$this->subjectHtml = $ressubject;
$this->messageHtml = $resmessage;
$contents = $this->subLayout('Search/Results/Row')->setProperties($this->getProperties());
echo $contents;
}
}
示例10: _deleteUser
/**
* Delete a user
*
* @access protected
* @param unknown_type $UserID
* @return boolean
*/
protected function _deleteUser($UserID) {
// Sanitize parameters!
$UserID = intval ( $UserID );
$user = KunenaFactory::getUser($UserID);
if ( !$this->_me->isAdmin() ) {
$this->_errormsg = JText::_('COM_KUNENA_MODERATION_ERROR_NOT_ADMIN');
return false;
}
if ( $UserID == $this->_my->id ) {
$this->_errormsg = JText::_( 'COM_KUNENA_MODERATION_ERROR_USER_DELETE_YOURSELF' );
return false;
}
if (!$UserID) {
$this->_errormsg = JText::_( 'COM_KUNENA_MODERATION_ERROR_USER_DELETE_ANONYMOUS' );
return false;
}
$user = JUser::getInstance($UserID);
if (!$user->id) {
$this->_errormsg = JText::_( 'COM_KUNENA_MODERATION_ERROR_USER_DELETE_NO_USER', $UserID );
return false;
}
// Nobody can delete admins
if ( $user->isAdmin() ) {
$this->_errormsg = JText::_( 'COM_KUNENA_MODERATION_ERROR_USER_DELETE_ADMIN', $user->username );
return false;
}
$user->delete();
$this->_db->setQuery ( "DELETE FROM #__kunena_users WHERE `userid`={$this->_db->Quote($UserID)};" );
$this->_db->query ();
if (KunenaError::checkDatabaseError()) return false;
return true;
}
示例11: onUserAfterSave
public function onUserAfterSave($user, $isnew, $success, $msg) {
//Don't continue if the user wasn't stored succesfully
if (! $success) {
return false;
}
if ($isnew) {
$user = KunenaFactory::getUser(intval($user ['id']));
$user->save();
}
/*
// See: http://www.kunena.org/forum/159-k-16-common-questions/63438-category-subscriptions-default-subscribed#63554
// TODO: Subscribe user to every category if he is new and Kunena is configured to do so
if ($isnew) {
$subscribedCategories = '1,2,3,4,5,6,7,8,9,10';
$db = Jfactory::getDBO();
$query = "INSERT INTO #__kunena_user_categories (user_id,category_id)
SELECT {$user->userid} AS user_id, c.id as category_id
FROM #__kunena_categories AS c
LEFT JOIN #__kunena_user_categories AS s ON c.id=s.category_id AND s.user_id={$user->userid}
WHERE c.parent>0 AND c.id IN ({$subscribedCategories}) AND s.user_id IS NULL";
$db->setQuery ( $query );
$db->query ();
KunenaError::checkDatabaseError();
// Here's also query to subscribe all users (including blocked) to all existing cats:
$query = "INSERT INTO #__kunena_user_categories (user_id,category_id)
SELECT u.id AS user_id, c.id AS category_id
FROM #__users AS u
JOIN #__kunena_categories AS c ON c.parent>0
LEFT JOIN #__kunena_user_categories AS s ON u.id=s.user_id
WHERE c.id IN ({$subscribedCategories}) AND s.user_id IS NULL";
}
*/
}
示例12: display
/**
* Display module contents.
*/
public final function display()
{
// Load CSS only once
if (static::$css) {
$this->document->addStyleSheet(JURI::root(true) . static::$css);
static::$css = null;
}
// Use caching also for registered users if enabled.
if ($this->params->get('owncache', 0)) {
/** @var $cache JCacheControllerOutput */
$cache = JFactory::getCache('com_kunena', 'output');
$me = KunenaFactory::getUser();
$cache->setLifeTime($this->params->get('cache_time', 180));
$hash = md5(serialize($this->params));
if ($cache->start("display.{$me->userid}.{$hash}", 'mod_kunenalatest')) {
return;
}
}
// Initialize Kunena.
KunenaForum::setup();
// Display module.
$this->_display();
// Store cached page.
if (isset($cache)) {
$cache->end();
}
}
示例13: displayDefault
function displayDefault($tpl = null)
{
if (!$this->config->enablerss) {
JError::raiseError(404, JText::_('COM_KUNENA_RSS_DISABLED'));
}
KunenaHtmlParser::$relative = false;
$this->category = $this->get('Category');
if (!$this->category->authorise('read')) {
JError::raiseError(404, $this->category->getError());
}
$this->topics = $this->get('Topics');
$title = JText::_('COM_KUNENA_THREADS_IN_FORUM') . ': ' . $this->category->name;
$this->setTitle($title);
$metaDesc = $this->document->getDescription() . '. ' . $this->escape("{$this->category->name} - {$this->config->board_title}");
$this->document->setDescription($metaDesc);
// Create image for feed
$image = new JFeedImage();
$image->title = $this->document->getTitle();
$image->url = $this->ktemplate->getImagePath('icons/rss.png');
$image->description = $this->document->getDescription();
$this->document->image = $image;
foreach ($this->topics as $topic) {
$description = $topic->last_post_message;
$date = new JDate($topic->last_post_time);
$userid = $topic->last_post_userid;
$username = KunenaFactory::getUser($userid)->getName($topic->last_post_guest_name);
$title = $topic->subject;
$category = $topic->getCategory();
$url = $topic->getUrl($category, true, 'last');
$this->createItem($title, $url, $description, $category->name, $date, $userid, $username);
}
}
示例14: testGetInstance
/**
* Test getInstance()
*
* @param KunenaForumTopicUser $topicuser
* @return KunenaForumTopicUser
* @depends testCreate
*/
public function testGetInstance(KunenaForumTopicUser $topicuser)
{
$admin = KunenaFactory::getUser('admin');
$topicuser2 = KunenaForumTopicUser::getInstance($topicuser->topic_id, $admin->userid);
$this->assertSame($topicuser, $topicuser2);
return $topicuser;
}
示例15: populateState
protected function populateState() {
$app = JFactory::getApplication ();
$params = $this->getParameters();
$this->setState ( 'params', $params );
$config = KunenaFactory::getConfig ();
$active = $app->getMenu ()->getActive ();
$active = $active ? (int) $active->id : 0;
$layout = $this->getWord ( 'layout', 'default' );
$this->setState ( 'layout', $layout );
$userid = $this->getInt ( 'userid', -1 );
if ($userid < 0) {
$userid = KunenaFactory::getUser()->userid;
} elseif($userid > 0) {
$userid = KunenaFactory::getUser($userid)->userid;
} else {
$userid = 0;
}
$this->setState ( 'user', $userid );
$mode = $this->getWord ( 'mode', 'default' );
$this->setState ( 'list.mode', $mode );
$catid = $this->getInt ( 'catid' );
if ($catid) {
$latestcategory = array($catid);
$latestcategory_in = true;
} else {
$latestcategory = $params->get('topics_categories', $config->latestcategory );
if (!is_array($latestcategory)) $latestcategory = explode ( ',', $latestcategory );
if (empty($latestcategory) || in_array(0, $latestcategory)) {
$latestcategory = false;
}
$latestcategory_in = (bool)$params->get('topics_catselection', $config->latestcategory_in);
}
$this->setState ( 'list.categories', $latestcategory );
$this->setState ( 'list.categories.in', $latestcategory_in );
$value = $this->getUserStateFromRequest ( "com_kunena.topics_{$active}_{$layout}_{$mode}_list_time", 'sel', $params->get('topics_time', $config->show_list_time), 'int' );
$this->setState ( 'list.time', $value );
// List state information
$value = $this->getUserStateFromRequest ( "com_kunena.topics_{$active}_{$layout}_{$mode}_list_limit", 'limit', 0, 'int' );
if ($value < 1) $value = $config->threads_per_page;
$this->setState ( 'list.limit', $value );
$value = $this->getUserStateFromRequest ( "com_kunena.topics_{$active}_{$layout}_{$mode}_list_ordering", 'filter_order', 'time', 'cmd' );
//$this->setState ( 'list.ordering', $value );
$value = $this->getUserStateFromRequest ( "com_kunena.topics_{$active}_{$layout}_{$mode}_list_start", 'limitstart', 0, 'int' );
//$value = $this->getInt ( 'limitstart', 0 );
$this->setState ( 'list.start', $value );
$value = $this->getUserStateFromRequest ( "com_kunena.topics_{$active}_{$layout}_{$mode}_list_direction", 'filter_order_Dir', 'desc', 'word' );
if ($value != 'asc')
$value = 'desc';
$this->setState ( 'list.direction', $value );
}