本文整理汇总了PHP中KunenaUser::_ranks方法的典型用法代码示例。如果您正苦于以下问题:PHP KunenaUser::_ranks方法的具体用法?PHP KunenaUser::_ranks怎么用?PHP KunenaUser::_ranks使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KunenaUser
的用法示例。
在下文中一共展示了KunenaUser::_ranks方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getRank
/**
* @param int $catid Category Id for the rank (user can have different rank in different categories).
* @param string $type Possible values: 'title' | 'image' | false (for object).
* @param bool|null $special True if special only, false if post count, otherwise combined.
*
* @return stdClass|string|null
*/
public function getRank($catid = 0, $type = null, $special = null)
{
$config = KunenaConfig::getInstance();
if (!$config->showranking) {
return null;
}
// Guests do not have post rank, they only have special rank.
if ($special === false && !$this->userid) {
return null;
}
// First run? Initialize ranks.
if (self::$_ranks === null) {
$this->_db->setQuery("SELECT * FROM #__kunena_ranks");
self::$_ranks = $this->_db->loadObjectList('rank_id');
KunenaError::checkDatabaseError();
}
$userType = $special !== false ? $this->getType($catid, true) : 'count';
if (isset(self::$_ranks[$this->rank]) && !in_array($userType, array('guest', 'blocked', 'banned', 'count'))) {
// Use rank specified to the user.
$rank = self::$_ranks[$this->rank];
} else {
// Generate user rank.
$rank = new stdClass();
$rank->rank_id = 0;
$rank->rank_title = JText::_('COM_KUNENA_RANK_USER');
$rank->rank_min = 0;
$rank->rank_special = 0;
$rank->rank_image = 'rank0.gif';
switch ($userType) {
case 'guest':
$rank->rank_title = JText::_('COM_KUNENA_RANK_VISITOR');
$rank->rank_special = 1;
foreach (self::$_ranks as $cur) {
if ($cur->rank_special == 1 && strstr($cur->rank_image, 'guest')) {
$rank = $cur;
break;
}
}
break;
case 'blocked':
$rank->rank_title = JText::_('COM_KUNENA_RANK_BLOCKED');
$rank->rank_special = 1;
$rank->rank_image = 'rankdisabled.gif';
foreach (self::$_ranks as $cur) {
if ($cur->rank_special == 1 && strstr($cur->rank_image, 'disabled')) {
$rank = $cur;
break;
}
}
break;
case 'banned':
$rank->rank_title = JText::_('COM_KUNENA_RANK_BANNED');
$rank->rank_special = 1;
$rank->rank_image = 'rankbanned.gif';
foreach (self::$_ranks as $cur) {
if ($cur->rank_special == 1 && strstr($cur->rank_image, 'banned')) {
$rank = $cur;
break;
}
}
break;
case 'admin':
case 'localadmin':
$rank->rank_title = JText::_('COM_KUNENA_RANK_ADMINISTRATOR');
$rank->rank_special = 1;
$rank->rank_image = 'rankadmin.gif';
foreach (self::$_ranks as $cur) {
if ($cur->rank_special == 1 && strstr($cur->rank_image, 'admin')) {
$rank = $cur;
break;
}
}
break;
case 'globalmod':
case 'moderator':
$rank->rank_title = JText::_('COM_KUNENA_RANK_MODERATOR');
$rank->rank_special = 1;
$rank->rank_image = 'rankmod.gif';
foreach (self::$_ranks as $cur) {
if ($cur->rank_special == 1 && (strstr($cur->rank_image, 'rankmod') || strstr($cur->rank_image, 'moderator'))) {
$rank = $cur;
break;
}
}
break;
case 'user':
case 'count':
foreach (self::$_ranks as $cur) {
if ($cur->rank_special == 0 && $cur->rank_min <= $this->posts && $cur->rank_min >= $rank->rank_min) {
$rank = $cur;
}
}
break;
//.........这里部分代码省略.........
示例2: getRank
/**
* @param int $catid
* @param bool $type
*
* @return stdClass|string
*/
public function getRank($catid = 0, $type = false)
{
// Default rank
$rank = new stdClass();
$rank->rank_id = false;
$rank->rank_title = null;
$rank->rank_min = 0;
$rank->rank_special = 0;
$rank->rank_image = null;
$config = KunenaFactory::getConfig();
$category = KunenaForumCategoryHelper::get($catid);
if (!$config->showranking) {
return;
}
if (self::$_ranks === null) {
$this->_db->setQuery("SELECT * FROM #__kunena_ranks");
self::$_ranks = $this->_db->loadObjectList('rank_id');
KunenaError::checkDatabaseError();
}
$rank->rank_title = JText::_('COM_KUNENA_RANK_USER');
$rank->rank_image = 'rank0.gif';
if ($this->userid == 0) {
$rank->rank_id = 0;
$rank->rank_title = JText::_('COM_KUNENA_RANK_VISITOR');
$rank->rank_special = 1;
} else {
if ($this->isBanned()) {
$rank->rank_id = 0;
$rank->rank_title = JText::_('COM_KUNENA_RANK_BANNED');
$rank->rank_special = 1;
$rank->rank_image = 'rankbanned.gif';
foreach (self::$_ranks as $cur) {
if ($cur->rank_special == 1 && JFile::stripExt($cur->rank_image) == 'rankbanned') {
$rank = $cur;
break;
}
}
} else {
if ($this->rank != 0 && isset(self::$_ranks[$this->rank])) {
$rank = self::$_ranks[$this->rank];
} else {
if ($this->rank == 0 && $this->isAdmin($category)) {
$rank->rank_id = 0;
$rank->rank_title = JText::_('COM_KUNENA_RANK_ADMINISTRATOR');
$rank->rank_special = 1;
$rank->rank_image = 'rankadmin.gif';
foreach (self::$_ranks as $cur) {
if ($cur->rank_special == 1 && JFile::stripExt($cur->rank_image) == 'rankadmin') {
$rank = $cur;
break;
}
}
} else {
if ($this->rank == 0 && $this->isModerator($category)) {
$rank->rank_id = 0;
$rank->rank_title = JText::_('COM_KUNENA_RANK_MODERATOR');
$rank->rank_special = 1;
$rank->rank_image = 'rankmod.gif';
foreach (self::$_ranks as $cur) {
if ($cur->rank_special == 1 && JFile::stripExt($cur->rank_image) == 'rankmod') {
$rank = $cur;
break;
}
}
}
}
}
}
}
if ($rank->rank_id === false) {
//post count rank
$rank->rank_id = 0;
foreach (self::$_ranks as $cur) {
if ($cur->rank_special == 0 && $cur->rank_min <= $this->posts && $cur->rank_min >= $rank->rank_min) {
$rank = $cur;
}
}
}
if ($type == 'title') {
return $rank->rank_title;
}
if ($type == 'image') {
$template = KunenaTemplate::getInstance();
if (!$config->rankimages) {
return;
}
$iconurl = $template->getRankPath($rank->rank_image, true);
return '<img src="' . $iconurl . '" alt="" />';
}
if (!$config->rankimages) {
$rank->rank_image = null;
}
return $rank;
}
示例3: getRank
public function getRank($catid = 0, $type = false)
{
// Default rank
$rank = new stdClass();
$rank->rank_id = false;
$rank->rank_title = null;
$rank->rank_min = 0;
$rank->rank_special = 0;
$rank->rank_image = null;
$config = KunenaFactory::getConfig();
if (!$config->showranking) {
return;
}
if (self::$_ranks === null) {
kimport('error');
$this->_db->setQuery("SELECT * FROM #__kunena_ranks");
self::$_ranks = $this->_db->loadObjectList('rank_id');
KunenaError::checkDatabaseError();
}
$rank->rank_title = JText::_('COM_KUNENA_RANK_USER');
$rank->rank_image = 'rank0.gif';
if ($this->userid == 0) {
$rank->rank_id = 0;
$rank->rank_title = JText::_('COM_KUNENA_RANK_VISITOR');
$rank->rank_special = 1;
} else {
if ($this->isBanned()) {
$rank->rank_id = 0;
$rank->rank_title = JText::_('COM_KUNENA_RANK_BANNED');
$rank->rank_special = 1;
$rank->rank_image = 'rankbanned.gif';
jimport('joomla.filesystem.file');
foreach (self::$_ranks as $cur) {
if ($cur->rank_special == 1 && JFile::stripExt($cur->rank_image) == 'rankbanned') {
$rank = $cur;
break;
}
}
} else {
if ($this->rank != 0 && isset(self::$_ranks[$this->rank])) {
$rank = self::$_ranks[$this->rank];
} else {
if ($this->rank == 0 && $this->isAdmin($catid)) {
$rank->rank_id = 0;
$rank->rank_title = JText::_('COM_KUNENA_RANK_ADMINISTRATOR');
$rank->rank_special = 1;
$rank->rank_image = 'rankadmin.gif';
jimport('joomla.filesystem.file');
foreach (self::$_ranks as $cur) {
if ($cur->rank_special == 1 && JFile::stripExt($cur->rank_image) == 'rankadmin') {
$rank = $cur;
break;
}
}
} else {
if ($this->rank == 0 && $this->isModerator($catid)) {
$rank->rank_id = 0;
$rank->rank_title = JText::_('COM_KUNENA_RANK_MODERATOR');
$rank->rank_special = 1;
$rank->rank_image = 'rankmod.gif';
jimport('joomla.filesystem.file');
foreach (self::$_ranks as $cur) {
if ($cur->rank_special == 1 && JFile::stripExt($cur->rank_image) == 'rankmod') {
$rank = $cur;
break;
}
}
}
}
}
}
}
if ($rank->rank_id === false) {
//post count rank
$rank->rank_id = 0;
foreach (self::$_ranks as $cur) {
if ($cur->rank_special == 0 && $cur->rank_min <= $this->posts && $cur->rank_min >= $rank->rank_min) {
$rank = $cur;
}
}
}
if ($type == 'title') {
return $rank->rank_title;
}
if ($type == 'image') {
if (!$config->rankimages) {
return;
}
if (is_file(KUNENA_ABSTMPLTPATH . '/images/ranks/' . $rank->rank_image)) {
$iconurl = KUNENA_TMPLTMAINIMGURL . 'images/ranks/' . $rank->rank_image;
} else {
$iconurl = KUNENA_DIRECTURL . 'template/default/images/ranks/' . $rank->rank_image;
}
return '<img src="' . $iconurl . '" alt="" />';
}
if (!$config->rankimages) {
$rank->rank_image = null;
}
return $rank;
}