-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathDynamicRole.php
More file actions
40 lines (33 loc) · 866 Bytes
/
DynamicRole.php
File metadata and controls
40 lines (33 loc) · 866 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<?php
class DynamicRole extends Role {
protected $hasEditPermission = null;
/**
* Get predefined template (template method)
*
* @return Template
*
*/
protected function getPredefinedTemplate() {
return $this->wire('templates')->get(DynamicRoleSupport::templateName);
}
/**
* Get predefined parent page (template method)
*
* @return Page
*
*/
protected function getPredefinedParent() {
return $this->wire('pages')->get($this->wire('modules')->get('DynamicRoleSupport')->parent_id);
}
public function hasEditPermission() {
if(is_null($this->hasEditPermission)) {
foreach($this->permissions as $permission) {
if($permission->name == 'page-edit') {
$this->hasEditPermission = true;
}
}
if(is_null($this->hasEditPermission)) $this->hasEditPermission = false;
}
return $this->hasEditPermission;
}
}