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