mirror of
https://github.com/silverstripe/silverstripe-dms
synced 2024-10-22 12:05:56 +00:00
Merge pull request #39 from normann/master
NEW best way to keep extended 'can' functions effected with DataObject's...
This commit is contained in:
commit
b2ee719667
@ -38,31 +38,48 @@ class DMSDocument extends DataObject implements DMSDocumentInterface {
|
|||||||
|
|
||||||
|
|
||||||
public function canView($member = null) {
|
public function canView($member = null) {
|
||||||
$canView = false;
|
if(!$member || !(is_a($member, 'Member')) || is_numeric($member)) $member = Member::currentUser();
|
||||||
if($member == null) $member = Member::currentUser();
|
// extended access checks
|
||||||
|
$results = $this->extend('canView', $member);
|
||||||
if($member->ID){
|
if($results && is_array($results)) {
|
||||||
$canView = true;
|
if(!min($results)) return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->extend('canView', $canView);
|
if($member->ID){
|
||||||
return $canView;
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
|
||||||
}
|
}
|
||||||
public function canEdit($member = null) {
|
public function canEdit($member = null) {
|
||||||
$canEdit = $this->canView();
|
if(!$member || !(is_a($member, 'Member')) || is_numeric($member)) $member = Member::currentUser();
|
||||||
$this->extend('canEdit', $canEdit);
|
|
||||||
return $canEdit;
|
$results = $this->extend('canEdit', $member);
|
||||||
|
if($results && is_array($results)) {
|
||||||
|
if(!min($results)) return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->canView();
|
||||||
}
|
}
|
||||||
public function canCreate($member = null) {
|
public function canCreate($member = null) {
|
||||||
$canCreate = $this->canView();
|
if(!$member || !(is_a($member, 'Member')) || is_numeric($member)) $member = Member::currentUser();
|
||||||
$this->extend('canCreate', $canCreate);
|
|
||||||
return $canCreate;
|
$results = $this->extend('canCreate', $member);
|
||||||
|
if($results && is_array($results)) {
|
||||||
|
if(!min($results)) return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->canView();
|
||||||
}
|
}
|
||||||
public function canDelete($member = null) {
|
public function canDelete($member = null) {
|
||||||
$canDelete = $this->canView();
|
if(!$member || !(is_a($member, 'Member')) || is_numeric($member)) $member = Member::currentUser();
|
||||||
$this->extend('canDelete', $canDelete);
|
|
||||||
return $canDelete;
|
$results = $this->extend('canDelete', $member);
|
||||||
|
if($results && is_array($results)) {
|
||||||
|
if(!min($results)) return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->canView();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user