mirror of
https://github.com/silverstripe/silverstripe-userforms.git
synced 2024-10-22 17:05:42 +02:00
Merge pull request #866 from quantum-dragons/bugfix/editableoption-canmethods-fix
BUGFIX: re-added can* methods for EditableOption field
This commit is contained in:
commit
830e3a1100
@ -4,6 +4,7 @@ namespace SilverStripe\UserForms\Model\EditableFormField;
|
||||
|
||||
use SilverStripe\Core\Convert;
|
||||
use SilverStripe\ORM\DataObject;
|
||||
use SilverStripe\Security\Member;
|
||||
use SilverStripe\Versioned\Versioned;
|
||||
|
||||
/**
|
||||
@ -30,12 +31,12 @@ class EditableOption extends DataObject
|
||||
];
|
||||
|
||||
private static $extensions = [
|
||||
Versioned::class . "('Stage', 'Live')"
|
||||
Versioned::class . "('Stage', 'Live')",
|
||||
];
|
||||
|
||||
private static $summary_fields = [
|
||||
'Title',
|
||||
'Default'
|
||||
'Default',
|
||||
];
|
||||
|
||||
protected static $allow_empty_values = false;
|
||||
@ -94,4 +95,68 @@ class EditableOption extends DataObject
|
||||
|
||||
parent::onBeforeWrite();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Member $member
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function canEdit($member = null)
|
||||
{
|
||||
return $this->Parent()->canEdit($member);
|
||||
}
|
||||
/**
|
||||
* @param Member $member
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function canDelete($member = null)
|
||||
{
|
||||
return $this->canEdit($member);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Member $member
|
||||
* @return bool
|
||||
*/
|
||||
public function canView($member = null)
|
||||
{
|
||||
return $this->Parent()->canView($member);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return whether a user can create an object of this type
|
||||
*
|
||||
* @param Member $member
|
||||
* @param array $context Virtual parameter to allow context to be passed in to check
|
||||
* @return bool
|
||||
*/
|
||||
public function canCreate($member = null, $context = [])
|
||||
{
|
||||
// Check parent object
|
||||
$parent = $this->Parent();
|
||||
if ($parent) {
|
||||
return $parent->canCreate($member);
|
||||
}
|
||||
|
||||
// Fall back to secure admin permissions
|
||||
return parent::canCreate($member);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Member $member
|
||||
* @return bool
|
||||
*/
|
||||
public function canPublish($member = null)
|
||||
{
|
||||
return $this->canEdit($member);
|
||||
}
|
||||
/**
|
||||
* @param Member $member
|
||||
* @return bool
|
||||
*/
|
||||
public function canUnpublish($member = null)
|
||||
{
|
||||
return $this->canDelete($member);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user