Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save wernerkrauss/34238007031ef9ea8b79 to your computer and use it in GitHub Desktop.
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
<?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