class Role extends UrlModel implements NamedModel

A role a player is assigned

Constants

DEVELOPER

ADMINISTRATOR

COP

REFEREE

SYSADMIN

PLAYER

PLAYER_NO_PM

TABLE

The name of the database table used for queries

CREATE_PERMISSION

EDIT_PERMISSION

SOFT_DELETE_PERMISSION

HARD_DELETE_PERMISSION

Methods

bool
displayAsLeader()

Check whether or not this role should appear on the "Admins" page

string
getDisplayColor()

Get the color this role will have as the background in their badge

string
getDisplayName()

Get the "display name" of a role. The display name differs from the name of the role where the "Administrators" role can be displayed as "League Council" when the role is used to displayed players assigned to this role.

int
getDisplayOrder()

Get the order this role should be displayed on the "Admins" page

string
getDisplayIcon()

Get the Font Awesome class that will be used as the symbol for the role on the "Admins" page

Player[]
getUsers()

Get an array of players who have this role assigned to them

string
getName()

Get the name of the role as displayed in the admin interface

bool
isReusable()

Check if this role is for a conversation of users or if it's a role for a single user

bool
isProtected()

Check if this role is protected from being deleted

bool
addPerm(string|Permission $perm_name)

Add a permission to a role

bool[]
getPerms()

Get the permissions a role has

getPermObjects()

Return the permissions a role has as models

bool
hasPerm(string $permission)

Check whether a role has a specified permission

bool
removePerm(string|Permission $perm_name)

Revoke a permission from a role

setPerms(Permission[] $perms)

Set the permissions of the role

setName(string $name)

Set the name of the role

setDisplayAsLeader(bool $display)

Set whether the Role is displayed as a leader role

setDisplayIcon(string $displayIcon)

Set the icon class of the role

setDisplayColor(string $displayColor)

Set the color of the role

setDisplayName(string $displayName)

Set the display name of the role

setDisplayOrder(int $displayOrder)

Set the display order of the role

static Role
createNewRole(string $name, bool $reusable, bool $display = false, string $displayIcon = '', string $displayColor = '', null $displayName = null, int $displayOrder)

Create a new role

static Role[]
getRoles(int $user_id)

Get the roles a player has

static Role[]
getLeaderRoles()

Get the roles that should be displayed on the "Admins" page

static QueryBuilder
getQueryBuilder()

Get a query builder for Roles

Details

at line line 119
bool displayAsLeader()

Check whether or not this role should appear on the "Admins" page

Return Value

bool True if the role should be displayed on the "Admins" page

at line line 130
string getDisplayColor()

Get the color this role will have as the background in their badge

Return Value

string The color this role will have in their badge. If there is no color set, it will return green which has chosen randomly by a fair dice roll.

at line line 141
string getDisplayName()

Get the "display name" of a role. The display name differs from the name of the role where the "Administrators" role can be displayed as "League Council" when the role is used to displayed players assigned to this role.

Return Value

string Returns the display name. If the display name is blank, the role name will be returned.

at line line 151
int getDisplayOrder()

Get the order this role should be displayed on the "Admins" page

Return Value

int The order the role should be displayed on the "Admins" page

at line line 161
string getDisplayIcon()

Get the Font Awesome class that will be used as the symbol for the role on the "Admins" page

Return Value

string The Font Awesome class for the symbol

at line line 171
Player[] getUsers()

Get an array of players who have this role assigned to them

Return Value

Player[] An array of players with this role assigned to them

at line line 186
string getName()

Get the name of the role as displayed in the admin interface

Return Value

string

at line line 196
bool isReusable()

Check if this role is for a conversation of users or if it's a role for a single user

Return Value

bool True if multiple users can be assigned this role

at line line 206
bool isProtected()

Check if this role is protected from being deleted

Return Value

bool True if this role is protected from being deleted

at line line 218
bool addPerm(string|Permission $perm_name)

Add a permission to a role

Parameters

string|Permission $perm_name The name of the permission to add

Return Value

bool Whether or not the operation was successful

at line line 228
bool[] getPerms()

Get the permissions a role has

Return Value

bool[] An array of permissions

at line line 248
Permission[] getPermObjects()

Return the permissions a role has as models

Return Value

Permission[]

at line line 260
bool hasPerm(string $permission)

Check whether a role has a specified permission

Parameters

string $permission The permission to check for

Return Value

bool Whether or not the role has the permission

at line line 272
bool removePerm(string|Permission $perm_name)

Revoke a permission from a role

Parameters

string|Permission $perm_name The permission to remove

Return Value

bool Whether or not the operation was successful

at line line 322
Role setPerms(Permission[] $perms)

Set the permissions of the role

Parameters

Permission[] $perms The permissions to set

Return Value

Role

at line line 351
Role setName(string $name)

Set the name of the role

Parameters

string $name The new name of the role

Return Value

Role

at line line 362
Role setDisplayAsLeader(bool $display)

Set whether the Role is displayed as a leader role

Parameters

bool $display

Return Value

Role

at line line 373
Role setDisplayIcon(string $displayIcon)

Set the icon class of the role

Parameters

string $displayIcon

Return Value

Role

at line line 384
Role setDisplayColor(string $displayColor)

Set the color of the role

Parameters

string $displayColor

Return Value

Role

at line line 395
Role setDisplayName(string $displayName)

Set the display name of the role

Parameters

string $displayName

Return Value

Role

at line line 406
Role setDisplayOrder(int $displayOrder)

Set the display order of the role

Parameters

int $displayOrder

Return Value

Role

at line line 424
static Role createNewRole(string $name, bool $reusable, bool $display = false, string $displayIcon = '', string $displayColor = '', null $displayName = null, int $displayOrder)

Create a new role

Parameters

string $name The name of new role to be created
bool $reusable Whether or not to have the role
bool $display Whether or not to display the role on the 'Admins' page
string $displayIcon
string $displayColor
null $displayName The name that will be used on the 'Admins' page, if $display is set to true
int $displayOrder The order the role will be displayed on, if $display is set to true

Return Value

Role

at line line 445
static Role[] getRoles(int $user_id)

Get the roles a player has

Parameters

int $user_id The user ID to get the roles for

Return Value

Role[] An array of Roles a player belongs to

at line line 460
static Role[] getLeaderRoles()

Get the roles that should be displayed on the "Admins" page

Return Value

Role[] An array of Roles that should be displayed on the "Admins" page

at line line 474
static QueryBuilder getQueryBuilder()

Get a query builder for Roles

Return Value

QueryBuilder