1 <?php
2
3 4 5
6 class rex_structure_perm extends rex_complex_perm
7 {
8 9 10 11 12
13 public function hasCategoryPerm($category_id)
14 {
15 if ($this->hasAll() || in_array($category_id, $this->perms)) {
16 return true;
17 }
18 if ($c = rex_category::get($category_id)) {
19 foreach ($c->getPathAsArray() as $k) {
20 if (in_array($k, $this->perms)) {
21 return true;
22 }
23 }
24 }
25 return false;
26 }
27
28 29 30
31 public function hasStructurePerm()
32 {
33 return $this->hasAll() || count($this->perms) > 0;
34 }
35
36 37 38
39 public function getMountpoints()
40 {
41 return $this->hasAll() ? [] : $this->perms;
42 }
43
44 45 46
47 public function hasMountpoints()
48 {
49 return !$this->hasAll() && count($this->perms) > 0;
50 }
51
52 53 54
55 public static function getFieldParams()
56 {
57 return [
58 'label' => rex_i18n::msg('categories'),
59 'all_label' => rex_i18n::msg('all_categories'),
60 'select' => new rex_category_select(false, false, false, false),
61 ];
62 }
63 }
64