ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilObjExerciseAccess.php
Go to the documentation of this file.
1<?php
2
23{
24 protected ilLanguage $lng;
27 protected ilObjUser $user;
28
29 public function __construct()
30 {
31 global $DIC;
32 $this->user = $DIC->user();
33 $this->lng = $DIC->language();
34 $this->access = $DIC->access();
35 $this->rbacsystem = $DIC->rbac()->system();
36 }
37
38
43 public static function getConditionOperators(): array
44 {
45 return array(
48 );
49 }
50
51
55 public static function checkCondition(int $a_trigger_obj_id, string $a_operator, string $a_value, int $a_usr_id): bool
56 {
57 switch ($a_operator) {
59 return ilExerciseMembers::_lookupStatus($a_trigger_obj_id, $a_usr_id) == "passed";
60
62 return ilExerciseMembers::_lookupStatus($a_trigger_obj_id, $a_usr_id) == 'failed';
63
64 default:
65 return true;
66 }
67 }
68
69
82 public static function _getCommands(): array
83 {
84 return array(
85 array("permission" => "read", "cmd" => "showOverview", "lang_var" => "show",
86 "default" => true),
87 array("permission" => "write", "cmd" => "listAssignments", "lang_var" => "edit_assignments"),
88 array("permission" => "write", "cmd" => "edit", "lang_var" => "settings")
89 );
90 }
91
95 public static function _lookupRemainingWorkingTimeString(
96 int $a_obj_id
97 ): array {
98 global $DIC;
99
100 $ilDB = $DIC->database();
101
102 // #14077 - mind peer deadline, too
103
104 $dl = null;
105 $cnt = array();
106
107 $q = "SELECT id, time_stamp, deadline2, peer_dl" .
108 " FROM exc_assignment WHERE exc_id = " . $ilDB->quote($a_obj_id, "integer") .
109 " AND (time_stamp > " . $ilDB->quote(time(), "integer") .
110 " OR (peer_dl > " . $ilDB->quote(time(), "integer") .
111 " AND peer > " . $ilDB->quote(0, "integer") . "))";
112 $set = $ilDB->query($q);
113 while ($row = $ilDB->fetchAssoc($set)) {
114 if ($row["time_stamp"] > time() &&
115 ($row["time_stamp"] < $dl || !$dl)) {
116 $dl = $row["time_stamp"];
117 }
118 /* extended deadline should not be presented anywhere
119 if($row["deadline2"] > time() &&
120 ($row["deadline2"] < $dl || !$dl))
121 {
122 $dl = $row["deadline2"];
123 }
124 */
125 if ($row["peer_dl"] > time() &&
126 ($row["peer_dl"] < $dl || !$dl)) {
127 $dl = $row["peer_dl"];
128 }
129 $cnt[$row["id"]] = true;
130 }
131
132 // :TODO: mind personal deadline?
133
134 if ($dl) {
136 }
137
138 return array(
139 "mtime" => $dl,
140 "cnt" => count($cnt)
141 );
142 }
143
147 public static function _checkGoto($a_target): bool
148 {
149 global $DIC;
150
151 $ilAccess = $DIC->access();
152
153 $t_arr = explode("_", $a_target);
154
155 if ($t_arr[0] != "exc" || ((int) $t_arr[1]) <= 0) {
156 return false;
157 }
158 return $ilAccess->checkAccess("read", "", $t_arr[1]) ||
159 $ilAccess->checkAccess("visible", "", $t_arr[1]);
160 }
161
162 public function canBeDelivered(ilWACPath $ilWACPath): bool
163 {
164 return true;
165 }
166
167 public function _checkAccess(string $cmd, string $permission, int $ref_id, int $obj_id, ?int $user_id = null): bool
168 {
169 $ilUser = $this->user;
170 $rbacsystem = $this->rbacsystem;
171
172 if ($user_id === null) {
173 $user_id = $ilUser->getId();
174 }
175
176 if (self::_isOffline($obj_id)) {
177 if (($permission === "visible" || $permission === "read") && !$rbacsystem->checkAccessOfUser($user_id, 'write', $ref_id)) {
178 $this->access->addInfoItem(ilAccessInfo::IL_NO_OBJECT_ACCESS, $this->lng->txt("offline"));
179 return false;
180 }
181 }
182
183 return true;
184 }
185
186}
const IL_CAL_UNIX
@classDescription Date and time handling
static _lookupStatus(int $a_obj_id, int $a_user_id)
Lookup current status (notgraded|passed|failed)
language handling
static period2String(ilDateTime $a_from, $a_to=null)
Return a string of time period.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _checkGoto($a_target)
check whether goto script will succeed
static checkCondition(int $a_trigger_obj_id, string $a_operator, string $a_value, int $a_usr_id)
check condition
static _getCommands()
get commands
static _lookupRemainingWorkingTimeString(int $a_obj_id)
_checkAccess(string $cmd, string $permission, int $ref_id, int $obj_id, ?int $user_id=null)
Checks whether a user may invoke a command or not (this method is called by ilAccessHandler::checkAcc...
canBeDelivered(ilWACPath $ilWACPath)
static getConditionOperators()
Get possible conditions operators.
User class.
Class ilObjectAccess.
class ilRbacSystem system function like checkAccess, addActiveRole ... Supporting system functions ar...
checkAccessOfUser(int $a_user_id, string $a_operations, int $a_ref_id, string $a_type="")
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Interface ilAccessHandler This interface combines all available interfaces which can be called via gl...
Interface for condition handling.
$ref_id
Definition: ltiauth.php:66
global $DIC
Definition: shib_login.php:26
$q
Definition: shib_logout.php:23