Created
July 15, 2015 19:50
-
-
Save wernerkrauss/34238007031ef9ea8b79 to your computer and use it in GitHub Desktop.
Silverstripe Extension for DataObjects to be editable by other members. You can enable this in Security section
This file contains hidden or 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
<?php | |
class NetwerkstattDataObjectCMSPermissionExtension extends DataExtension implements PermissionProvider { | |
/** | |
* Return a map of permission codes to add to the dropdown shown in the Security section of the CMS. | |
* array( | |
* 'VIEW_SITE' => 'View the site', | |
* ); | |
*/ | |
public function providePermissions() | |
{ | |
return array( | |
'CMS_MANAGE_ITEM' => array('name' => 'Items bearbeiten', 'category' => _t('Permissions.CONTENT_CATEGORY')), | |
'CMS_DELETE_ITEM' => array('name' => 'Items löschen', 'category' => _t('Permissions.CONTENT_CATEGORY')) | |
); | |
} | |
public function canCreate($member = null){ | |
return Permission::check('CMS_ACCESS_CMSMain', 'any', $member) || | |
Permission::check('CMS_MANAGE_ITEM', 'any', $member); | |
} | |
public function canView($member = null){ | |
return Permission::check('CMS_ACCESS_CMSMain', 'any', $member) || | |
Permission::check('CMS_MANAGE_ITEM', 'any', $member); | |
} | |
public function canEdit($member = null){ | |
return Permission::check('CMS_ACCESS_CMSMain', 'any', $member) || | |
Permission::check('CMS_MANAGE_ITEM', 'any', $member); | |
} | |
public function canDelete($member = null){ | |
return Permission::check('CMS_ACCESS_CMSMain', 'any', $member) || | |
Permission::check('CMS_DELETE_ITEM', 'any', $member); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment