class vB_Library_Userrank extends vB_Library

Traits

Properties

static protected $instance from vB_Library

Methods

__sleep()

No description

__wakeup()

No description

__construct()

No description

static vB_PageCache
instance($class)

Returns singleton instance of self.

static 
getLibraryClassNameInternal($controller)

No description

static 
getContentInstance($contenttypeid)

No description

static 
clearCache()

No description

array
fetchById(int $rankid)

Fetch Userrank By RankID

array
fetchAll()

Fetch All user ranks

int
save(array $data, int $rankid = 0)

Insert a new user rank or update existing user rank

void
delete(int $rankid)

Delete an user rank

deleteForUsergroup(int $usergroupid)

Delete all user ranks based for a given usergroup

haveRanks()

Determines if we have ranks defined in the system. This allows us to determine if we even need to worry about changing a user's rank.

string
getRankHtml($userinfo)

Gets the current rank for a user.

Details

in vB_Trait_NoSerialize at line 15
__sleep()

in vB_Trait_NoSerialize at line 20
__wakeup()

in vB_Library at line 25
protected __construct()

in vB_Library at line 35
static vB_PageCache instance($class)

Returns singleton instance of self.

Parameters

$class

Return Value

vB_PageCache
  • Reference to singleton instance of the cache handler

in vB_Library at line 52
static protected getLibraryClassNameInternal($controller)

Parameters

$controller

in vB_Library at line 91
static getContentInstance($contenttypeid)

Parameters

$contenttypeid

in vB_Library at line 99
static clearCache()

at line 32
array fetchById(int $rankid)

Fetch Userrank By RankID

Parameters

int $rankid Rank ID

Return Value

array User rank information

at line 52
array fetchAll()

Fetch All user ranks

Return Value

array Array of user ranks

at line 73
int save(array $data, int $rankid = 0)

Insert a new user rank or update existing user rank

Parameters

array $data User rank data to be inserted or updated 'ranklevel' => Number of times to repeat rank 'usergroupid' => Usergroup 'minposts' => Minimum Posts 'stack' => Stack Rank. Boolean. 'display' => Display Type. 0 - Always, 1 - If Displaygroup = This Group 'rankimg' => User Rank File Path (only used if rankhtml is empty) 'rankhtml' => User Rank HTML Text (if not empty rankimg will be ignored)
int $rankid If not 0, it's the ID of the user rank to be updated

Return Value

int New rank's ID or updated rank's ID

at line 170
void delete(int $rankid)

Delete an user rank

Parameters

int $rankid The ID of user rank to be deleted

Return Value

void

at line 187
deleteForUsergroup(int $usergroupid)

Delete all user ranks based for a given usergroup

This is primarily intended for cleanup when a usergroup is deleted.

Parameters

int $usergroupid The usergroup to clear the ranks for.

at line 200
haveRanks()

Determines if we have ranks defined in the system. This allows us to determine if we even need to worry about changing a user's rank.

at line 253
string getRankHtml($userinfo)

Gets the current rank for a user.

Intended to allow updating the user after a change is made.

We use the following logic to find the ranks for a user.

A rank is a match if
* We our user has greater than or equal to the min post count for the rank

* We are a member of the ranks group (or the rank is set to all user groups) * If we are set to only match the display group then our display group is the same as the rank group If the rank is set to "all groups" and set to only match a display group then we match the rank if we have not matched a previous rank.

Additionally we will not consider any ranks if we have previously matched a rank for the same usergroup with a higher minimum post count. If there are several ranks with the same user group and post count that match we will select all of them if they are the highest that match. For this purpose ranks set to "all groups" are considered their own usergroup (that is we will select up to one rank per usergroup and one for "all usergroups" assuming we do not select multiple ranks with the same postcount).

Note that there is undocumented (in the UI) behavior surrounding the seemingly nonsensical combination of "all groups" and "display group = this group". We specifically only match the group if we haven't matched a previous ranks (for any usergroup, not just "all groups"). As an additional quirk, if we would match an "all group" rank with a lower post count and without the display group flag set we will match the rank with the display group flag instead, which seems inconsistant (this is because we encounter the higher post cont rank first in process order and make a decision on it before looking at the ranks farther down -- and when we encounter the lower ranks we've already selected the higher count rank for all groups and therefore we do not consider the lower rank for inclusion).

This behavior was clearly done for a reason (based the specifical inclusion of code to handle that case), however the reasons for it are lost to history. It does not appear to be a widely used case in the wild. The current thinking is that it is not a useful feature and we should consider it an error to enter a rank in that state. The logic has not yet been changed to reflect this (its been that way for a long time and doesn't appear to be hurting anything).

Parameters

$userinfo -- The user info array. We only actually use the following fields * posts * usergroupid * displaygroupid * membergroupids

Return Value

string The user rank html