-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add permissionProvider for Elements and related classes fixes non-admins not being able to publish pages
- Loading branch information
Showing
17 changed files
with
305 additions
and
474 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
<?php | ||
|
||
namespace Dynamic\Elements\ORM; | ||
|
||
use SilverStripe\ORM\DataExtension; | ||
use SilverStripe\Security\PermissionProvider; | ||
|
||
/** | ||
* Class ElementPermissions. | ||
*/ | ||
class ElementPermissions extends DataExtension implements PermissionProvider | ||
{ | ||
/** | ||
* @return array | ||
*/ | ||
public function providePermissions() | ||
{ | ||
return [ | ||
'Create_Element' => [ | ||
'name' => _t( | ||
'ELEMENT.CREATE_ELEMENT', | ||
'Create Elemental Blocks' | ||
), | ||
'category' => _t( | ||
'Permissions.PERMISSIONS_ELEMENT_PERMISSION', | ||
'Elemental' | ||
), | ||
'help' => _t( | ||
'Element.CREATE_PERMISSION_ELEMENT_PERMISSION', | ||
'Ability to create new Elemental Blocks.' | ||
), | ||
'sort' => 400, | ||
], | ||
'Edit_Element' => [ | ||
'name' => _t( | ||
'ELEMENT.EDIT_ELEMENT', | ||
'Edit Elemental Blocks' | ||
), | ||
'category' => _t( | ||
'Permissions.PERMISSIONS_ELEMENT_PERMISSION', | ||
'Elemental' | ||
), | ||
'help' => _t( | ||
'Element.EDIT_PERMISSION_ELEMENT_PERMISSION', | ||
'Ability to update Elemental Blocks.' | ||
), | ||
'sort' => 400, | ||
], | ||
'Delete_Element' => [ | ||
'name' => _t( | ||
'ELEMENT.PUBLISH_ELEMENT', | ||
'Delete Elemental Blocks' | ||
), | ||
'category' => _t( | ||
'Permissions.PERMISSIONS_ELEMENT_PERMISSION', | ||
'Elemental' | ||
), | ||
'help' => _t( | ||
'Element.PUBLISH_PERMISSION_ELEMENT_PERMISSION', | ||
'Ability to delete Elemental Blocks.' | ||
), | ||
'sort' => 400, | ||
], | ||
'Publish_Element' => [ | ||
'name' => _t( | ||
'ELEMENT.PUBLISH_ELEMENT', | ||
'Publish Elemental Blocks' | ||
), | ||
'category' => _t( | ||
'Permissions.PERMISSIONS_ELEMENT_PERMISSION', | ||
'Elemental' | ||
), | ||
'help' => _t( | ||
'Element.PUBLISH_PERMISSION_ELEMENT_PERMISSION', | ||
'Ability to publish Elemental Blocks.' | ||
), | ||
'sort' => 400, | ||
], | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?php | ||
|
||
namespace Dynamic\Elements\ORM; | ||
|
||
use SilverStripe\ORM\DataExtension; | ||
use SilverStripe\Security\Permission; | ||
|
||
/** | ||
* Class ElementalAreaPermissions. | ||
*/ | ||
class ElementalPermissions extends DataExtension | ||
{ | ||
/** | ||
* @param null $member | ||
* @return bool|int|void | ||
*/ | ||
public function canCreate($member = null) | ||
{ | ||
return Permission::check('Create_Element', 'any', $member); | ||
} | ||
|
||
/** | ||
* @param null $member | ||
* @return bool|int|void | ||
*/ | ||
public function canEdit($member = null) | ||
{ | ||
return Permission::check('Edit_Element', 'any', $member); | ||
} | ||
|
||
/** | ||
* @param null $member | ||
* @return bool|int|void | ||
*/ | ||
public function canDelete($member = null) | ||
{ | ||
return Permission::check('Delete_Element', 'any', $member); | ||
} | ||
|
||
/** | ||
* @param null $member | ||
* @return bool|int | ||
*/ | ||
public function canPublish($member = null) | ||
{ | ||
return Permission::check('Publish_Element', 'any', $member); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.