2015-10-10 21:17:50 +00:00
|
|
|
<?php
|
|
|
|
/*
|
|
|
|
* Rank Class
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace Sakura;
|
|
|
|
|
2015-10-18 19:06:30 +00:00
|
|
|
/**
|
|
|
|
* Class Rank
|
|
|
|
* @package Sakura
|
|
|
|
*/
|
2015-10-10 21:17:50 +00:00
|
|
|
class Rank
|
|
|
|
{
|
2015-10-14 19:35:16 +00:00
|
|
|
// Rank data
|
2015-11-12 17:29:14 +00:00
|
|
|
private $data = [
|
|
|
|
'rank_id' => 0,
|
|
|
|
'rank_name' => 'Rank',
|
|
|
|
'rank_hierarchy' => 0,
|
|
|
|
'rank_multiple' => null,
|
|
|
|
'rank_hidden' => 1,
|
|
|
|
'rank_colour' => '#444',
|
|
|
|
'rank_description' => '',
|
|
|
|
'rank_title' => '',
|
|
|
|
];
|
2015-10-10 21:17:50 +00:00
|
|
|
|
2015-10-14 19:35:16 +00:00
|
|
|
// Initialise the rank object
|
|
|
|
public function __construct($rid)
|
|
|
|
{
|
|
|
|
|
|
|
|
// Get the rank database row
|
2015-11-12 17:29:14 +00:00
|
|
|
$getRank = Database::fetch(
|
2015-10-14 19:35:16 +00:00
|
|
|
'ranks',
|
|
|
|
false,
|
|
|
|
[
|
|
|
|
'rank_id' => [$rid, '=', true],
|
|
|
|
]
|
|
|
|
);
|
|
|
|
|
|
|
|
// Check if the rank actually exists
|
2015-11-12 17:29:14 +00:00
|
|
|
if (!empty($getRank)) {
|
2015-10-14 19:35:16 +00:00
|
|
|
// If not assign as the fallback rank
|
2015-11-12 17:29:14 +00:00
|
|
|
$this->data = $getRank;
|
2015-10-14 19:35:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Get the rank id
|
|
|
|
public function id()
|
|
|
|
{
|
|
|
|
return $this->data['rank_id'];
|
|
|
|
}
|
|
|
|
|
|
|
|
// Get the rank hierarchy
|
|
|
|
public function hierarchy()
|
|
|
|
{
|
|
|
|
return $this->data['rank_hierarchy'];
|
|
|
|
}
|
|
|
|
|
|
|
|
// Get the rank name
|
|
|
|
public function name($multi = false)
|
|
|
|
{
|
|
|
|
return $this->data['rank_name'] . ($multi ? $this->data['rank_multiple'] : null);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Get the rank title
|
|
|
|
public function title()
|
|
|
|
{
|
|
|
|
return $this->data['rank_title'];
|
|
|
|
}
|
|
|
|
|
|
|
|
// Get the rank description
|
|
|
|
public function description()
|
|
|
|
{
|
|
|
|
return $this->data['rank_description'];
|
|
|
|
}
|
|
|
|
|
|
|
|
// Get the rank colour
|
|
|
|
public function colour()
|
|
|
|
{
|
|
|
|
return $this->data['rank_colour'];
|
|
|
|
}
|
|
|
|
|
|
|
|
// Check if the rank is hidden
|
|
|
|
public function hidden()
|
|
|
|
{
|
|
|
|
return $this->data['rank_hidden'] || $this->checkPermission('SITE', 'DEACTIVATED') || $this->checkPermission('SITE', 'RESTRICTED');
|
|
|
|
}
|
|
|
|
|
|
|
|
// Check if the rank has the proper permissions
|
|
|
|
public function checkPermission($layer, $action)
|
|
|
|
{
|
|
|
|
return Permissions::check($layer, $action, [$this->id()], 2);
|
|
|
|
}
|
2015-10-10 21:17:50 +00:00
|
|
|
}
|