Skip to content

Commit

Permalink
* Move permission checks to BaseElementExtension
Browse files Browse the repository at this point in the history
  • Loading branch information
robbieaverill committed Jun 8, 2016
1 parent 2a56498 commit 1098ad8
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 38 deletions.
4 changes: 2 additions & 2 deletions _config/elemental.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Name: elemental
---
Widget:
extensions:
- 'VersionedDataObject'
- 'BaseElementExtension'

BaseElement:
extensions:
Expand All @@ -15,7 +15,7 @@ ElementImage:
- 'image_medium' : 'Normal'
- 'image_small' : 'Small'


LeftAndMain:
extra_requirements_css:
- 'elemental/css/elemental-admin.css'

38 changes: 38 additions & 0 deletions code/extensions/BaseElementExtension.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php
/**
* @package elemental
*/
class BaseElementExtension extends VersionedDataObject
{
/**
* {@inheritDoc}
*/
public function canView($member = null)
{
return Permission::check('CMS_ACCESS_CMSMain', 'any', $member);
}

/**
* {@inheritDoc}
*/
public function canEdit($member = null)
{
return Permission::check('CMS_ACCESS_CMSMain', 'any', $member);
}

/**
* {@inheritDoc}
*/
public function canDelete($member = null)
{
return Permission::check('CMS_ACCESS_CMSMain', 'any', $member);
}

/**
* {@inheritDoc}
*/
public function canCreate($member = null)
{
return Permission::check('CMS_ACCESS_CMSMain', 'any', $member);
}
}
36 changes: 0 additions & 36 deletions code/models/BaseElement.php
Original file line number Diff line number Diff line change
Expand Up @@ -187,42 +187,6 @@ public function getCMSTitle()
}
}

public function canView($member = null)
{
$extended = $this->extendedCan(__FUNCTION__, $member);
if ($extended !== null) {
return $extended;
}
return Permission::check('CMS_ACCESS_CMSMain', 'any', $member);
}

public function canEdit($member = null)
{
$extended = $this->extendedCan(__FUNCTION__, $member);
if ($extended !== null) {
return $extended;
}
return Permission::check('CMS_ACCESS_CMSMain', 'any', $member);
}

public function canDelete($member = null)
{
$extended = $this->extendedCan(__FUNCTION__, $member);
if ($extended !== null) {
return $extended;
}
return Permission::check('CMS_ACCESS_CMSMain', 'any', $member);
}

public function canCreate($member = null)
{
$extended = $this->extendedCan(__FUNCTION__, $member);
if ($extended !== null) {
return $extended;
}
return Permission::check('CMS_ACCESS_CMSMain', 'any', $member);
}

public function ControllerTop()
{
return Controller::curr();
Expand Down

0 comments on commit 1098ad8

Please sign in to comment.