ILIAS  trunk Revision v11.0_alpha-1689-g66c127b4ae8
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
class.SkillTreeAccess.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
21 namespace ILIAS\Skill\Access;
22 
28 {
29  protected \ilRbacSystem $access;
30  protected int $ref_id = 0;
31  protected string $obj_type = "";
32  protected int $usr_id = 0;
33 
34  public function __construct(\ilRbacSystem $access, int $ref_id, int $usr_id)
35  {
36  $this->access = $access;
37  $this->ref_id = $ref_id;
38  $this->obj_type = \ilObject::_lookupType($this->ref_id, true);
39  $this->usr_id = $usr_id;
40  }
41 
42  public function hasVisibleTreePermission(int $a_usr_id = 0): bool
43  {
44  if ($a_usr_id == 0) {
45  $a_usr_id = $this->usr_id;
46  }
47  return $this->access->checkAccessOfUser($a_usr_id, "visible", $this->ref_id);
48  }
49 
50  public function hasReadTreePermission(int $a_usr_id = 0): bool
51  {
52  if ($a_usr_id == 0) {
53  $a_usr_id = $this->usr_id;
54  }
55  return $this->access->checkAccessOfUser($a_usr_id, "read", $this->ref_id);
56  }
57 
58  public function hasEditTreeSettingsPermission(int $a_usr_id = 0): bool
59  {
60  if ($a_usr_id == 0) {
61  $a_usr_id = $this->usr_id;
62  }
63  return $this->access->checkAccessOfUser($a_usr_id, "write", $this->ref_id);
64  }
65 
66  public function hasEditTreePermissionsPermission(int $a_usr_id = 0): bool
67  {
68  if ($a_usr_id == 0) {
69  $a_usr_id = $this->usr_id;
70  }
71  return $this->access->checkAccessOfUser($a_usr_id, "edit_permission", $this->ref_id);
72  }
73 
74  public function hasReadCompetencesPermission(int $a_usr_id = 0): bool
75  {
76  if ($a_usr_id == 0) {
77  $a_usr_id = $this->usr_id;
78  }
79  return $this->access->checkAccessOfUser($a_usr_id, "read_comp", $this->ref_id);
80  }
81 
82  public function hasManageCompetencesPermission(int $a_usr_id = 0): bool
83  {
84  if ($a_usr_id == 0) {
85  $a_usr_id = $this->usr_id;
86  }
87  return $this->access->checkAccessOfUser($a_usr_id, "manage_comp", $this->ref_id);
88  }
89 
90  public function hasManageCompetenceTemplatesPermission(int $a_usr_id = 0): bool
91  {
92  if ($a_usr_id == 0) {
93  $a_usr_id = $this->usr_id;
94  }
95  return $this->access->checkAccessOfUser($a_usr_id, "manage_comp_temp", $this->ref_id);
96  }
97 
98  public function hasReadProfilesPermission(int $a_usr_id = 0): bool
99  {
100  if ($a_usr_id == 0) {
101  $a_usr_id = $this->usr_id;
102  }
103  if ($this->obj_type == "crs" || $this->obj_type == "grp") {
104  return $this->access->checkAccessOfUser($a_usr_id, "read", $this->ref_id);
105  }
106  return $this->access->checkAccessOfUser($a_usr_id, "read_profiles", $this->ref_id);
107  }
108 
109  public function hasManageProfilesPermission(int $a_usr_id = 0): bool
110  {
111  if ($a_usr_id == 0) {
112  $a_usr_id = $this->usr_id;
113  }
114  if ($this->obj_type == "crs" || $this->obj_type == "grp") {
115  return $this->access->checkAccessOfUser($a_usr_id, "write", $this->ref_id);
116  }
117  return $this->access->checkAccessOfUser($a_usr_id, "manage_profiles", $this->ref_id);
118  }
119 }
__construct(\ilRbacSystem $access, int $ref_id, int $usr_id)
static _lookupType(int $id, bool $reference=false)