ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
ilObjSurveyAccess Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

+ Inheritance diagram for ilObjSurveyAccess:
+ Collaboration diagram for ilObjSurveyAccess:

Public Member Functions

 __construct ()
 
 _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::checkAccess) More...
 
- Public Member Functions inherited from ilObjectAccess
 _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::checkAccess) More...
 
 canBeDelivered (ilWACPath $ilWACPath)
 
 canBeDelivered (ilWACPath $ilWACPath)
 

Static Public Member Functions

static getConditionOperators ()
 Returns an array with valid operators for the specific object type. More...
 
static checkCondition (int $a_trigger_obj_id, string $a_operator, string $a_value, int $a_usr_id)
 check condition for a specific user and object More...
 
static _getCommands ()
 get commands More...
 
static _lookupCreationComplete (int $a_obj_id)
 checks whether all necessary parts of the survey are given More...
 
static _lookupEvaluationAccess (int $a_obj_id)
 get evaluation access More...
 
static _isSurveyParticipant (int $user_id, int $survey_id)
 
static _lookupAnonymize (int $a_obj_id)
 
static _hasEvaluationAccess (int $a_obj_id, int $user_id)
 
static _lookupFinished (int $a_obj_id, int $a_user_id=0)
 get finished status More...
 
static _lookupMode (int $a_obj_id)
 Get survey mode (see ilObjSurvey::MODE_... constants) More...
 
static _lookup360Mode (int $a_obj_id)
 
static _checkGoto (string $target)
 check whether goto script will succeed More...
 
- Static Public Member Functions inherited from ilObjectAccess
static _getCommands ()
 get commands More...
 
static _checkGoto (string $target)
 check whether goto script will succeed More...
 
static _isOffline (int $obj_id)
 Type-specific implementation of general status, has to be overwritten if object type does not support centralized offline handling. More...
 
static _preloadData (array $obj_ids, array $ref_ids)
 Preload data. More...
 
static getConditionOperators ()
 Returns an array with valid operators for the specific object type. More...
 
static checkCondition (int $a_trigger_obj_id, string $a_operator, string $a_value, int $a_usr_id)
 check condition for a specific user and object More...
 

Protected Attributes

ilObjUser $user
 
ilLanguage $lng
 
ilRbacSystem $rbacsystem
 
ilAccessHandler $access
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning Class ilObjSurveyAccess

Author
Alex Killing alex..nosp@m.kill.nosp@m.ing@g.nosp@m.mx.d.nosp@m.e
Helmut Schottmüller helmu.nosp@m.t.sc.nosp@m.hottm.nosp@m.uell.nosp@m.er@ma.nosp@m.c.co.nosp@m.m

Definition at line 27 of file class.ilObjSurveyAccess.php.

Constructor & Destructor Documentation

◆ __construct()

ilObjSurveyAccess::__construct ( )

Definition at line 34 of file class.ilObjSurveyAccess.php.

35 {
36 global $DIC;
37
38 $this->user = $DIC->user();
39 $this->lng = $DIC->language();
40 $this->rbacsystem = $DIC->rbac()->system();
41 $this->access = $DIC->access();
42 }
global $DIC
Definition: shib_login.php:26

References $DIC, ILIAS\Repository\access(), ILIAS\Repository\lng(), and ILIAS\Repository\user().

+ Here is the call graph for this function:

Member Function Documentation

◆ _checkAccess()

ilObjSurveyAccess::_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::checkAccess)

Please do not check any preconditions handled by ilConditionHandler here. Also don't do any RBAC checks.

Reimplemented from ilObjectAccess.

Definition at line 68 of file class.ilObjSurveyAccess.php.

68 : bool
69 {
70 $ilUser = $this->user;
73 $ilAccess = $this->access;
74
75 if (is_null($user_id)) {
76 $user_id = $ilUser->getId();
77 }
78
79 $is_admin = $rbacsystem->checkAccessOfUser($user_id, 'write', $ref_id);
80
81 switch ($permission) {
82 case "visible":
83 case "read":
84 if (!self::_lookupCreationComplete($obj_id) &&
85 !$is_admin) {
86 $ilAccess->addInfoItem(ilAccessInfo::IL_NO_OBJECT_ACCESS, $lng->txt("warning_survey_not_complete"));
87 return false;
88 }
89 break;
90 }
91
92 switch ($cmd) {
93 case "run":
94 if (!self::_lookupCreationComplete($obj_id) &&
95 !$is_admin) {
96 $ilAccess->addInfoItem(ilAccessInfo::IL_NO_OBJECT_ACCESS, $lng->txt("warning_survey_not_complete"));
97 return false;
98 }
99 break;
100
101 case "evaluation":
102 if (!self::_lookupCreationComplete($obj_id)) {
103 $ilAccess->addInfoItem(ilAccessInfo::IL_NO_OBJECT_ACCESS, $lng->txt("warning_survey_not_complete"));
104 return false;
105 }
106 if ($rbacsystem->checkAccess("write", $ref_id) || self::_hasEvaluationAccess($obj_id, $user_id)) {
107 return true;
108 } else {
109 $ilAccess->addInfoItem(ilAccessInfo::IL_NO_OBJECT_ACCESS, $lng->txt("status_no_permission"));
110 return false;
111 }
112 }
113
114 return true;
115 }
txt(string|LanguageIdentifier $a_topic, ?int $n=null)
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
checkAccess(string $a_operations, int $a_ref_id, string $a_type="")
checkAccess represents the main method of the RBAC-system in ILIAS3 developers want to use With this ...
checkAccessOfUser(int $a_user_id, string $a_operations, int $a_ref_id, string $a_type="")

References $access, $lng, $rbacsystem, $user, $user_id, ilRbacSystem\checkAccess(), ilRbacSystem\checkAccessOfUser(), ilAccessInfo\IL_NO_OBJECT_ACCESS, and ilLanguage\txt().

+ Here is the call graph for this function:

◆ _checkGoto()

static ilObjSurveyAccess::_checkGoto ( string  $target)
static

check whether goto script will succeed

Reimplemented from ilObjectAccess.

Definition at line 418 of file class.ilObjSurveyAccess.php.

418 : bool
419 {
420 global $DIC;
421
422 $request = $DIC->survey()
423 ->internal()
424 ->gui()
425 ->execution()
426 ->request();
427
428 $ilAccess = $DIC->access();
429
430 $target_parts = explode("_", $target, 3);
431 if ($target_parts[0] !== "svy" ||
432 !isset($target_parts[1]) ||
433 !ctype_digit($target_parts[1]) ||
434 ($ref_id = (int) $target_parts[1]) <= 0) {
435 return false;
436 }
437
438 // 360° external raters
439 $access_code = ($request->getAccessCode() !== "")
440 ? $request->getAccessCode()
441 : ($target_parts[2] ?? "");
442 if ($access_code !== "") {
443 $survey = new ilObjSurvey($ref_id);
444 $run_manager = $DIC->survey()->internal()->domain()->execution()->run($survey, $DIC->user()->getId());
445 try {
446 $run_manager->initSession($access_code);
447 } catch (Exception $e) {
448 return false;
449 }
450 if (ilObjSurvey::validateExternalRaterCode($ref_id, $access_code)) {
451 return true;
452 }
453 }
454
455 if ($ilAccess->checkAccess("visible", "", $ref_id) ||
456 $ilAccess->checkAccess("read", "", $ref_id)) {
457 return true;
458 }
459 return false;
460 }
$request
@ilCtrl_Calls ilObjLearningSequenceContentGUI: ilObjLearningSequenceConditionsGUI
Definition: ltiauth.php:39

References $DIC, Vendor\Package\$e, $request, and ILIAS\Scripts\PHPStan\$target.

◆ _getCommands()

static ilObjSurveyAccess::_getCommands ( )
static

get commands

this method returns an array of all possible commands/permission combinations

example: $commands = array ( array("permission" => "read", "cmd" => "view", "lang_var" => "show"), array("permission" => "write", "cmd" => "edit", "lang_var" => "edit"), );

Returns
array{permission?:string, cmd?:string, lang_var?:string, default?:bool}[]

Reimplemented from ilObjectAccess.

Definition at line 118 of file class.ilObjSurveyAccess.php.

118 : array
119 {
120 $commands = array(
121 array("permission" => "read", "cmd" => "run", "lang_var" => "svy_run", "default" => true),
122 array("permission" => "write", "cmd" => "questions", "lang_var" => "edit_questions"),
123 array("permission" => "write", "cmd" => "properties", "lang_var" => "settings"),
124 array("permission" => "read", "cmd" => "evaluation", "lang_var" => "svy_results")
125 );
126
127 return $commands;
128 }

Referenced by ilObjSurveyListGUI\init().

+ Here is the caller graph for this function:

◆ _hasEvaluationAccess()

static ilObjSurveyAccess::_hasEvaluationAccess ( int  $a_obj_id,
int  $user_id 
)
static

Definition at line 216 of file class.ilObjSurveyAccess.php.

219 : bool {
220 $evaluation_access = self::_lookupEvaluationAccess($a_obj_id);
221 $svy_mode = self::_lookupMode($a_obj_id);
222 if ($svy_mode === ilObjSurvey::MODE_IND_FEEDB) {
223 $svy = new ilObjSurvey($a_obj_id, false);
224 $svy->read();
225 switch ($svy->get360Results()) {
228 return false;
229
231 return true;
232
233 // not applicable
234 }
235 }
236
237 switch ($evaluation_access) {
238 case 0:
239 // no evaluation access
240 return false;
241 case 1:
242 // evaluation access for all registered users
243 return ($user_id > 0) && ($user_id !== ANONYMOUS_USER_ID);
244 case 2:
245 switch ($svy_mode) {
247 $svy = new ilObjSurvey($a_obj_id, false);
248 $svy->read();
249 switch ($svy->get360Results()) {
251 return false;
252
254 return $svy->isAppraiseeClosed($user_id);
255
257 return $svy->isAppraisee($user_id);
258 }
259 break;
260
262 $svy = new ilObjSurvey($a_obj_id, false);
263 $svy->read();
264 switch ($svy->get360Results()) {
266 return false;
267
269 return true;
270
272 return $svy->isAppraisee($user_id);
273 }
274 break;
275
277 $svy = new ilObjSurvey($a_obj_id, false);
278 $svy->read();
279 switch ($svy->getSelfEvaluationResults()) {
281 return false;
282 default:
283 global $DIC;
284 $run_manager = $DIC->survey()->internal()->domain()
285 ->execution()->run($svy, $user_id);
286 return $run_manager->hasFinished();
287 }
288
289 // no break
290 default:
291 // evaluation access for participants
292 // check if the user with the given id is a survey participant
293
294 // show the evaluation button for anonymized surveys for all users
295 // access is only granted with the survey access code
296 if (self::_lookupAnonymize($a_obj_id)) {
297 return true;
298 }
299
300 global $DIC;
301
302 $ilDB = $DIC->database();
303 $result = $ilDB->queryF(
304 "SELECT survey_id FROM svy_svy WHERE obj_fi = %s",
305 array('integer'),
306 array($a_obj_id)
307 );
308 if ($result->numRows() === 1) {
309 $row = $ilDB->fetchAssoc($result);
310
311 if (self::_isSurveyParticipant($user_id, (int) $row["survey_id"])) {
312 $survey = new ilObjSurvey($a_obj_id, false);
313 $run_manager = $DIC->survey()->internal()->domain()
314 ->execution()->run($survey, $user_id);
315 return $run_manager->hasFinished();
316 }
317 }
318 return false;
319 }
320 }
321 return false;
322 }
static _lookupMode(int $a_obj_id)
Get survey mode (see ilObjSurvey::MODE_... constants)
static _lookupEvaluationAccess(int $a_obj_id)
get evaluation access
const RESULTS_SELF_EVAL_NONE
const ANONYMOUS_USER_ID
Definition: constants.php:27

Referenced by ILIAS\Survey\Access\AccessManager\canAccessEvaluation(), ilSurveyEvaluationGUI\checkAnonymizedEvaluationAccess(), ilObjSurveyGUI\executeCommand(), and ilSurveyExecutionGUI\runShowFinishedPage().

+ Here is the caller graph for this function:

◆ _isSurveyParticipant()

static ilObjSurveyAccess::_isSurveyParticipant ( int  $user_id,
int  $survey_id 
)
static

Definition at line 180 of file class.ilObjSurveyAccess.php.

183 : bool {
184 global $DIC;
185
186 $ilDB = $DIC->database();
187
188 $result = $ilDB->queryF(
189 "SELECT finished_id FROM svy_finished WHERE user_fi = %s AND survey_fi = %s",
190 array('integer','integer'),
191 array($user_id, $survey_id)
192 );
193 return $result->numRows() === 1;
194 }

◆ _lookup360Mode()

static ilObjSurveyAccess::_lookup360Mode ( int  $a_obj_id)
static

Definition at line 399 of file class.ilObjSurveyAccess.php.

401 : bool {
402 global $DIC;
403
404 $ilDB = $DIC->database();
405
406 $result = $ilDB->queryF(
407 "SELECT mode FROM svy_svy" .
408 " WHERE obj_fi = %s AND mode = %s",
409 array('integer','integer'),
410 array($a_obj_id, ilObjSurvey::MODE_360)
411 );
412 return (bool) $ilDB->numRows($result);
413 }

◆ _lookupAnonymize()

static ilObjSurveyAccess::_lookupAnonymize ( int  $a_obj_id)
static

Definition at line 196 of file class.ilObjSurveyAccess.php.

198 : bool {
199 global $DIC;
200
201 $ilDB = $DIC->database();
202
203 $result = $ilDB->queryF(
204 "SELECT anonymize FROM svy_svy WHERE obj_fi = %s",
205 array('integer'),
206 array($a_obj_id)
207 );
208 if ($result->numRows() === 1) {
209 $row = $ilDB->fetchAssoc($result);
210 return (bool) $row["anonymize"];
211 } else {
212 return false;
213 }
214 }

References $ilDB.

Referenced by ilSurveyLP\isAnonymized().

+ Here is the caller graph for this function:

◆ _lookupCreationComplete()

static ilObjSurveyAccess::_lookupCreationComplete ( int  $a_obj_id)
static

checks whether all necessary parts of the survey are given

Definition at line 137 of file class.ilObjSurveyAccess.php.

137 : bool
138 {
139 global $DIC;
140
141 $ilDB = $DIC->database();
142
143 $result = $ilDB->queryF(
144 "SELECT * FROM svy_svy WHERE obj_fi=%s",
145 array('integer'),
146 array($a_obj_id)
147 );
148
149 $row = null;
150 if ($result->numRows() === 1) {
151 $row = $ilDB->fetchAssoc($result);
152 }
153 if (is_null($row) || !$row["complete"]) {
154 return false;
155 }
156 return true;
157 }

References $DIC, and $ilDB.

Referenced by ilObjSurveyListGUI\getProperties().

+ Here is the caller graph for this function:

◆ _lookupEvaluationAccess()

static ilObjSurveyAccess::_lookupEvaluationAccess ( int  $a_obj_id)
static

get evaluation access

Definition at line 162 of file class.ilObjSurveyAccess.php.

162 : int
163 {
164 global $DIC;
165
166 $ilDB = $DIC->database();
167
168 $result = $ilDB->queryF(
169 "SELECT * FROM svy_svy WHERE obj_fi=%s",
170 array('integer'),
171 array($a_obj_id)
172 );
173 if ($result->numRows() === 1) {
174 $row = $ilDB->fetchAssoc($result);
175 return (int) $row["evaluation_access"];
176 }
177 return 0;
178 }

References $DIC, and $ilDB.

◆ _lookupFinished()

static ilObjSurveyAccess::_lookupFinished ( int  $a_obj_id,
int  $a_user_id = 0 
)
static

get finished status

Parameters
int$a_obj_idsurvey id

Definition at line 330 of file class.ilObjSurveyAccess.php.

333 : ?int {
334 global $DIC;
335
336 $ilDB = $DIC->database();
337 $ilUser = $DIC->user();
338
339 $finished = null;
340 if ($a_user_id === 0) {
341 $a_user_id = $ilUser->getId();
342 }
343
344 $result = $ilDB->queryF(
345 "SELECT * FROM svy_svy WHERE obj_fi = %s",
346 array('integer'),
347 array($a_obj_id)
348 );
349 if ($result->numRows() === 1) {
350 $row = $ilDB->fetchObject($result);
351 if ((int) $row->anonymize === 1) {
352 $result = $ilDB->queryF(
353 "SELECT * FROM svy_finished, svy_anonymous WHERE svy_finished.survey_fi = %s " .
354 "AND svy_finished.survey_fi = svy_anonymous.survey_fi AND svy_anonymous.user_key = %s " .
355 "AND svy_anonymous.survey_key = svy_finished.anonymous_id",
356 array('integer','text'),
357 array((int) $row->survey_id, md5((string) $a_user_id))
358 );
359 } else {
360 $result = $ilDB->queryF(
361 "SELECT * FROM svy_finished WHERE survey_fi = %s AND user_fi = %s",
362 array('integer','integer'),
363 array((int) $row->survey_id, $a_user_id)
364 );
365 }
366 if ($result->numRows() === 1) {
367 $foundrow = $ilDB->fetchAssoc($result);
368 $finished = (int) $foundrow["state"];
369 }
370 }
371
372 return $finished;
373 }

Referenced by ilObjSurveyListGUI\getProperties(), ilContainerStartObjects\isFullfilled(), and ilCourseStart\isFullfilled().

+ Here is the caller graph for this function:

◆ _lookupMode()

static ilObjSurveyAccess::_lookupMode ( int  $a_obj_id)
static

Get survey mode (see ilObjSurvey::MODE_... constants)

Definition at line 378 of file class.ilObjSurveyAccess.php.

380 : int {
381 global $DIC;
382 $ilDB = $DIC->database();
383
384 $result = $ilDB->queryF(
385 "SELECT mode FROM svy_svy" .
386 " WHERE obj_fi = %s",
387 array('integer'),
388 array($a_obj_id)
389 );
390
391 if ($result->numRows() === 1) {
392 $row = $ilDB->fetchAssoc($result);
393 return (int) $row["mode"];
394 }
395
396 return 0;
397 }

References $ilDB.

Referenced by ilObjSurveyListGUI\getProperties().

+ Here is the caller graph for this function:

◆ checkCondition()

static ilObjSurveyAccess::checkCondition ( int  $a_trigger_obj_id,
string  $a_operator,
string  $a_value,
int  $a_usr_id 
)
static

check condition for a specific user and object

Implements ilConditionHandling.

Definition at line 52 of file class.ilObjSurveyAccess.php.

52 : bool
53 {
54 switch ($a_operator) {
56 if (self::_lookupFinished($a_trigger_obj_id, $a_usr_id)) {
57 return true;
58 } else {
59 return false;
60 }
61
62 // no break
63 default:
64 return true;
65 }
66 }

References ilConditionHandler\OPERATOR_FINISHED.

◆ getConditionOperators()

static ilObjSurveyAccess::getConditionOperators ( )
static

Returns an array with valid operators for the specific object type.

Returns
string[]

Implements ilConditionHandling.

Definition at line 45 of file class.ilObjSurveyAccess.php.

45 : array
46 {
47 return array(
49 );
50 }

References ilConditionHandler\OPERATOR_FINISHED.

Field Documentation

◆ $access

ilAccessHandler ilObjSurveyAccess::$access
protected

Definition at line 32 of file class.ilObjSurveyAccess.php.

Referenced by _checkAccess().

◆ $lng

ilLanguage ilObjSurveyAccess::$lng
protected

Definition at line 30 of file class.ilObjSurveyAccess.php.

Referenced by _checkAccess().

◆ $rbacsystem

ilRbacSystem ilObjSurveyAccess::$rbacsystem
protected

Definition at line 31 of file class.ilObjSurveyAccess.php.

Referenced by _checkAccess().

◆ $user

ilObjUser ilObjSurveyAccess::$user
protected

Definition at line 29 of file class.ilObjSurveyAccess.php.

Referenced by _checkAccess().


The documentation for this class was generated from the following file: