2017-10-27 04:49:54 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Pterodactyl\Traits\Services;
|
|
|
|
|
|
|
|
use Pterodactyl\Models\User;
|
|
|
|
|
|
|
|
trait HasUserLevels
|
|
|
|
{
|
2022-10-14 16:59:20 +00:00
|
|
|
private int $userLevel = User::USER_LEVEL_USER;
|
2017-10-27 04:49:54 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the access level for running this function.
|
|
|
|
*/
|
2022-10-14 16:59:20 +00:00
|
|
|
public function setUserLevel(int $level): self
|
2017-10-27 04:49:54 +00:00
|
|
|
{
|
|
|
|
$this->userLevel = $level;
|
2018-01-28 23:14:14 +00:00
|
|
|
|
|
|
|
return $this;
|
2017-10-27 04:49:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Determine which level this function is running at.
|
|
|
|
*/
|
|
|
|
public function getUserLevel(): int
|
|
|
|
{
|
|
|
|
return $this->userLevel;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Determine if the current user level is set to a specific level.
|
|
|
|
*/
|
|
|
|
public function isUserLevel(int $level): bool
|
|
|
|
{
|
|
|
|
return $this->getUserLevel() === $level;
|
|
|
|
}
|
|
|
|
}
|