This repository has been archived on 2024-04-19. You can view files and clone it, but cannot push or open issues or pull requests.
crispage-lite/patch/core/app/assets/class/Role.php

123 lines
2.9 KiB
PHP
Raw Normal View History

2023-12-07 14:07:15 -05:00
<?php
/*
Crispage CMS
crispycat <the@crispy.cat>
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;
}
}
?>