Fallback to parent permissions

This commit is contained in:
Will Rossiter 2017-10-16 10:13:14 +13:00
parent 658b4dc02a
commit efae9a293e

View File

@ -142,10 +142,16 @@ class SubmittedForm extends DataObject
public function canView($member = null) public function canView($member = null)
{ {
$extended = $this->extendedCan(__FUNCTION__, $member); $extended = $this->extendedCan(__FUNCTION__, $member);
if ($extended !== null) { if ($extended !== null) {
return $extended; return $extended;
} }
return $this->Parent()->canView();
if ($this->Parent()) {
return $this->Parent()->canView($member);
}
return parent::canView($member);
} }
/** /**
@ -156,10 +162,16 @@ class SubmittedForm extends DataObject
public function canEdit($member = null) public function canEdit($member = null)
{ {
$extended = $this->extendedCan(__FUNCTION__, $member); $extended = $this->extendedCan(__FUNCTION__, $member);
if ($extended !== null) { if ($extended !== null) {
return $extended; return $extended;
} }
return $this->Parent()->canEdit();
if ($this->Parent()) {
return $this->Parent()->canEdit($member);
}
return parent::canEdit($member);
} }
/** /**
@ -170,15 +182,21 @@ class SubmittedForm extends DataObject
public function canDelete($member = null) public function canDelete($member = null)
{ {
$extended = $this->extendedCan(__FUNCTION__, $member); $extended = $this->extendedCan(__FUNCTION__, $member);
if ($extended !== null) { if ($extended !== null) {
return $extended; return $extended;
} }
return $this->Parent()->canDelete();
if ($this->Parent()) {
return $this->Parent()->canDelete($member);
}
return parent::canDelete($member);
} }
/** /**
* Before we delete this form make sure we delete all the * Before we delete this form make sure we delete all the field values so
* field values so that we don't leave old data round * that we don't leave old data round.
* *
* @return void * @return void
*/ */