ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
class.ilCmiXapiAccess.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
31 {
32  protected ilObjCmiXapi $object;
34 
38  public function __construct(ilObjCmiXapi $object)
39  {
40  global $DIC;
41  $this->object = $object;
42  $this->access = $DIC->access();
43  }
44 
45  public function hasLearningProgressAccess(): bool
46  {
47  return ilLearningProgressAccess::checkAccess($this->object->getRefId());
48  }
49 
50  public function hasWriteAccess(?int $usrId = null): bool
51  {
52  if (isset($usrId)) {
53  return $this->access->checkAccessOfUser(
54  $usrId,
55  'write',
56  '',
57  $this->object->getRefId(),
58  $this->object->getType(),
59  $this->object->getId()
60  );
61  } else {
62  return $this->access->checkAccess(
63  'write',
64  '',
65  $this->object->getRefId(),
66  $this->object->getType(),
67  $this->object->getId()
68  );
69  }
70  }
71 
72  public function hasReadAccess(?int $usrId = null): bool
73  {
74  if (isset($usrId)) {
75  return $this->access->checkAccessOfUser(
76  $usrId,
77  'read',
78  '',
79  $this->object->getRefId(),
80  $this->object->getType(),
81  $this->object->getId()
82  );
83  } else {
84  return $this->access->checkAccess(
85  'read',
86  '',
87  $this->object->getRefId(),
88  $this->object->getType(),
89  $this->object->getId()
90  );
91  }
92  }
93 
94  public function hasEditPermissionsAccess(?int $usrId = null): bool
95  {
96  if (isset($usrId)) {
97  return $this->access->checkAccessOfUser(
98  $usrId,
99  'edit_permission',
100  '',
101  $this->object->getRefId(),
102  $this->object->getType(),
103  $this->object->getId()
104  );
105  } else {
106  return $this->access->checkAccess(
107  'edit_permission',
108  '',
109  $this->object->getRefId(),
110  $this->object->getType(),
111  $this->object->getId()
112  );
113  }
114  }
115 
116  public function hasOutcomesAccess(?int $usrId = null): bool
117  {
118  if (isset($usrId)) {
119  return $this->access->checkAccessOfUser(
120  $usrId,
121  'read_outcomes',
122  '',
123  $this->object->getRefId(),
124  $this->object->getType(),
125  $this->object->getId()
126  );
127  } else {
128  return $this->access->checkAccess(
129  'read_outcomes',
130  '',
131  $this->object->getRefId(),
132  $this->object->getType(),
133  $this->object->getId()
134  );
135  }
136  }
137 
138  public function hasStatementsAccess(): bool
139  {
140  if ($this->object->isStatementsReportEnabled() && $this->hasReadAccess()) {
141  return true;
142  }
143  return false;
144  }
145 
146  public function hasHighscoreAccess(): bool
147  {
148  if ($this->object->getHighscoreEnabled() && $this->hasReadAccess()) {
149  return true;
150  }
151  return false;
152  }
153 
154  public static function getInstance(ilObjCmiXapi $object): \ilCmiXapiAccess
155  {
156  return new self($object);
157  }
158 }
hasWriteAccess(?int $usrId=null)
static getInstance(ilObjCmiXapi $object)
static checkAccess(int $a_ref_id, bool $a_allow_only_read=true)
check access to learning progress
hasOutcomesAccess(?int $usrId=null)
hasEditPermissionsAccess(?int $usrId=null)
global $DIC
Definition: shib_login.php:25
__construct(ilObjCmiXapi $object)
ilCmiXapiAccess constructor.
hasReadAccess(?int $usrId=null)
ilAccessHandler $access