https://crispy.cat/software/crispage Crispage is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. */ namespace Crispage\Assets; defined("ROOT") or die(); require_once ROOT . "/core/app/assets/Asset.php"; use \Crispage\Auth\CorePermissions; class Role extends \Crispage\Asset { public static function getNames(): array { return ["{%ROLE}", "{%ROLES}"]; } public static function getPermissions(): array { return [ "create" => CorePermissions::MODIFY_ROLES, "modify" => CorePermissions::MODIFY_ROLES, "modify_own"=> CorePermissions::MODIFY_ROLES, "delete" => CorePermissions::MODIFY_ROLES, "delete_own"=> CorePermissions::MODIFY_ROLES ]; } public static function getSortingInfo(): array { return [ "field" => "rank", "desc" => false ]; } public static function getListColumns(): array { global $Crispage; return [ "id" => ["label" => "{%ID}"], "slug" => [ "label" => "{%SLUG}", "filter" => "\\Crispage\\Utils\\TextUtils::codeify" ], "name" => [ "label" => "{%NAME}", "filter" => "htmlentities" ], "rank" => [ "label" => "{%RANK}", "filter" => null ], "mtime" => [ "label" => "{%MODIFIED}", "filter" => [$Crispage->i18n, "datetime"] ] ]; } public static function getEditorFields(): array { return [ "name" => [ "column" => 0, "component" => "\\Crispage\\Components\\Fields\\TextFieldComponent", "com_data" => [ "label" => "{%NAME}:", "attrs" => ["required"] ], "filter" => "strval" ], "permissions" => [ "column" => 0, "component" => "\\Crispage\\Components\\Fields\\PermissionsFieldComponent", "com_data" => [ "label" => "{%PERMISSIONS}:", "attrs" => ["required"] ], "filter" => "intval" ], "slug" => [ "column" => 1, "component" => "\\Crispage\\Components\\Fields\\TextFieldComponent", "com_data" => [ "label" => "{%SLUG}:", "attrs" => ["placeholder" => "automatic"] ], "filter" => "strval" ], "rank" => [ "column" => 1, "component" => "\\Crispage\\Components\\Fields\\NumberFieldComponent", "com_data" => [ "label" => "{%RANK}:", "attrs" => ["required"] ], "filter" => "intval" ] ]; } public string $name; public int $permissions; public int $rank; public function __construct(array $props) { parent::__construct($props); $this->name = $props["name"] ?? ""; $this->permissions = $props["permissions"] ?? 0; $this->rank = $props["rank"] ?? 0; } public function getName(): string { return $this->name; } } ?>