12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- <?php
- /**
- * This file is part of the ForkBB <https://github.com/forkbb>.
- *
- * @copyright (c) Visman <mio.visman@yandex.ru, https://github.com/MioVisman>
- * @license The MIT License (MIT)
- */
- declare(strict_types=1);
- namespace ForkBB\Models\Rules;
- use ForkBB\Models\Model;
- use ForkBB\Models\Rules;
- use ForkBB\Models\User\User;
- use ForkBB\Models\Rules\Profile as ProfileRules;
- class Users extends Rules
- {
- /**
- * Инициализирует
- */
- public function init(): Users
- {
- $this->setAttrs([]);
- $this->ready = true;
- $this->user = $this->c->user;
- return $this;
- }
- protected function getviewIP(): bool
- {
- return $this->user->isAdmin;
- }
- protected function getdeleteUsers(): bool
- {
- return $this->user->isAdmin;
- }
- protected function getbanUsers(): bool
- {
- return $this->user->isAdmin || ($this->user->isAdmMod && 1 === $this->user->g_mod_ban_users);
- }
- protected function getchangeGroup(): bool
- {
- return $this->user->isAdmin;
- }
- public function canDeleteUser(User $user): bool
- {
- if (! $this->profileRules instanceof ProfileRules) {
- $this->profileRules = $this->c->ProfileRules;
- }
- return $this->profileRules->setUser($user)->deleteUser;
- }
- public function canBanUser(User $user): bool
- {
- if (! $this->profileRules instanceof ProfileRules) {
- $this->profileRules = $this->c->ProfileRules;
- }
- return $this->profileRules->setUser($user)->banUser;
- }
- public function canChangeGroup(User $user, bool $profile = false): bool
- {
- if (! $this->profileRules instanceof ProfileRules) {
- $this->profileRules = $this->c->ProfileRules;
- }
- if (
- $profile
- && $this->user->isAdmin
- ) {
- return true;
- } elseif (
- ! $profile
- && $user->isAdmin
- ) {
- return false;
- }
- return $this->profileRules->setUser($user)->changeGroup;
- }
- }
|