Files
hocusfokus-web/kirby/src/Cms/UserPermissions.php
Bastian Allgeier 01277f79f2 first version
2019-01-13 23:17:34 +01:00

27 lines
598 B
PHP
Executable File

<?php
namespace Kirby\Cms;
class UserPermissions extends ModelPermissions
{
protected $category = 'users';
public function __construct(Model $model)
{
parent::__construct($model);
// change the scope of the permissions, when the current user is this user
$this->category = $this->user && $this->user->is($model) ? 'user' : 'users';
}
protected function canChangeRole(): bool
{
return $this->model->isLastAdmin() !== true;
}
protected function canDelete(): bool
{
return $this->model->isLastAdmin() !== true;
}
}