mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
63 lines
1.8 KiB
PHP
63 lines
1.8 KiB
PHP
<?php
|
|
|
|
namespace SilverStripe\Security;
|
|
|
|
use SilverStripe\ORM\DataExtension;
|
|
use SilverStripe\ORM\ManyManyList;
|
|
|
|
/**
|
|
* Provides standard permission fields for inheritable permissions
|
|
*
|
|
* @property string $CanViewType
|
|
* @property string $CanEditType
|
|
* @method ManyManyList<Group> EditorGroups()
|
|
* @method ManyManyList<Member> EditorMembers()
|
|
* @method ManyManyList<Group> ViewerGroups()
|
|
* @method ManyManyList<Member> ViewerMembers()
|
|
*
|
|
* @extends DataExtension<DataObject>
|
|
*/
|
|
class InheritedPermissionsExtension extends DataExtension
|
|
{
|
|
private static array $db = [
|
|
'CanViewType' => "Enum('Anyone, LoggedInUsers, OnlyTheseUsers, OnlyTheseMembers, Inherit', 'Inherit')",
|
|
'CanEditType' => "Enum('LoggedInUsers, OnlyTheseUsers, OnlyTheseMembers, Inherit', 'Inherit')",
|
|
];
|
|
|
|
private static array $many_many = [
|
|
'ViewerGroups' => Group::class,
|
|
'EditorGroups' => Group::class,
|
|
'ViewerMembers' => Member::class,
|
|
'EditorMembers' => Member::class,
|
|
];
|
|
|
|
private static array $defaults = [
|
|
'CanViewType' => InheritedPermissions::INHERIT,
|
|
'CanEditType' => InheritedPermissions::INHERIT,
|
|
];
|
|
|
|
private static array $cascade_duplicates = [
|
|
'ViewerGroups',
|
|
'EditorGroups',
|
|
'ViewerMembers',
|
|
'EditorMembers',
|
|
];
|
|
|
|
/**
|
|
* These fields will need to be added manually, since SiteTree wants it in the special settings tab
|
|
* and nothing else in code that uses these fields is scaffolded.
|
|
*/
|
|
private static array $scaffold_cms_fields_settings = [
|
|
'ignoreFields' => [
|
|
'CanViewType',
|
|
'CanEditType',
|
|
],
|
|
'ignoreRelations' => [
|
|
'ViewerGroups',
|
|
'EditorGroups',
|
|
'ViewerMembers',
|
|
'EditorMembers',
|
|
],
|
|
];
|
|
}
|