4 * Copyright © 2003-2024 The Galette Team
6 * This file is part of Galette (https://galette.eu).
8 * Galette is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or
11 * (at your option) any later version.
13 * Galette is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with Galette. If not, see <http://www.gnu.org/licenses/>.
22 namespace Galette\Features
;
24 use Galette\Entity\FieldsConfig
;
27 use Galette\Core\L10n
;
28 use Laminas\Db\Sql\Expression
;
33 * @author Johan Cwiklinski <johan@x-tnd.be>
38 protected ?
int $permission = null;
40 /* FIXME/ requires PHP 8.2
41 public const NOBODY = 0;
42 public const USER_WRITE = 1;
43 public const ADMIN = 2;
44 public const STAFF = 3;
45 public const MANAGER = 4;
46 public const USER_READ = 5;
47 public const ALL = 10;*/
50 * Get permissions list
52 * @param bool $can_public Can have "public" permission
54 * @return array<int, string>
56 public static function getPermissionsList(bool $can_public = false): array
59 FieldsConfig
::NOBODY
=> _T("Inaccessible"),
60 FieldsConfig
::USER_READ
=> _T("User, read only"),
61 FieldsConfig
::USER_WRITE
=> _T("User, read/write"),
62 FieldsConfig
::MANAGER
=> _T("Group manager"),
63 FieldsConfig
::STAFF
=> _T("Staff member"),
64 FieldsConfig
::ADMIN
=> _T("Administrator"),
68 $all = [FieldsConfig
::ALL
=> _T("Public")];
69 $list = array_unshift($all);
80 public function getPermissionName(): string
82 $perms = self
::getPermissionsList();
83 return $perms[$this->getPermission()];
87 * Get current permissions
89 * @return integer|null
91 public function getPermission(): ?
int
93 return $this->permission
;