ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
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 25 of file class.ilObjSurveyAccess.php.

Constructor & Destructor Documentation

◆ __construct()

ilObjSurveyAccess::__construct ( )

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

33 {
34 global $DIC;
35
36 $this->user = $DIC->user();
37 $this->lng = $DIC->language();
38 $this->rbacsystem = $DIC->rbac()->system();
39 $this->access = $DIC->access();
40 }
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 66 of file class.ilObjSurveyAccess.php.

66 : bool
67 {
68 $ilUser = $this->user;
71 $ilAccess = $this->access;
72
73 if (is_null($user_id)) {
74 $user_id = $ilUser->getId();
75 }
76
77 $is_admin = $rbacsystem->checkAccessOfUser($user_id, 'write', $ref_id);
78
79 switch ($permission) {
80 case "visible":
81 case "read":
82 if (!self::_lookupCreationComplete($obj_id) &&
83 !$is_admin) {
84 $ilAccess->addInfoItem(ilAccessInfo::IL_NO_OBJECT_ACCESS, $lng->txt("warning_survey_not_complete"));
85 return false;
86 }
87 break;
88 }
89
90 switch ($cmd) {
91 case "run":
92 if (!self::_lookupCreationComplete($obj_id) &&
93 !$is_admin) {
94 $ilAccess->addInfoItem(ilAccessInfo::IL_NO_OBJECT_ACCESS, $lng->txt("warning_survey_not_complete"));
95 return false;
96 }
97 break;
98
99 case "evaluation":
100 if (!self::_lookupCreationComplete($obj_id)) {
101 $ilAccess->addInfoItem(ilAccessInfo::IL_NO_OBJECT_ACCESS, $lng->txt("warning_survey_not_complete"));
102 return false;
103 }
104 if ($rbacsystem->checkAccess("write", $ref_id) || self::_hasEvaluationAccess($obj_id, $user_id)) {
105 return true;
106 } else {
107 $ilAccess->addInfoItem(ilAccessInfo::IL_NO_OBJECT_ACCESS, $lng->txt("status_no_permission"));
108 return false;
109 }
110 }
111
112 return true;
113 }
txt(string $a_topic, string $a_default_lang_fallback_mod="")
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="")
$ref_id
Definition: ltiauth.php:66

References $access, $lng, $rbacsystem, $ref_id, $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 416 of file class.ilObjSurveyAccess.php.

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

References $DIC, and Vendor\Package\$e.

◆ _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 116 of file class.ilObjSurveyAccess.php.

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

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 214 of file class.ilObjSurveyAccess.php.

217 : bool {
218 $evaluation_access = self::_lookupEvaluationAccess($a_obj_id);
219 $svy_mode = self::_lookupMode($a_obj_id);
220 if ($svy_mode === ilObjSurvey::MODE_IND_FEEDB) {
221 $svy = new ilObjSurvey($a_obj_id, false);
222 $svy->read();
223 switch ($svy->get360Results()) {
226 return false;
227
229 return true;
230
231 // not applicable
232 }
233 }
234
235 switch ($evaluation_access) {
236 case 0:
237 // no evaluation access
238 return false;
239 case 1:
240 // evaluation access for all registered users
241 return ($user_id > 0) && ($user_id !== ANONYMOUS_USER_ID);
242 case 2:
243 switch ($svy_mode) {
245 $svy = new ilObjSurvey($a_obj_id, false);
246 $svy->read();
247 switch ($svy->get360Results()) {
249 return false;
250
252 return $svy->isAppraiseeClosed($user_id);
253
255 return $svy->isAppraisee($user_id);
256 }
257 break;
258
260 $svy = new ilObjSurvey($a_obj_id, false);
261 $svy->read();
262 switch ($svy->get360Results()) {
264 return false;
265
267 return true;
268
270 return $svy->isAppraisee($user_id);
271 }
272 break;
273
275 $svy = new ilObjSurvey($a_obj_id, false);
276 $svy->read();
277 switch ($svy->getSelfEvaluationResults()) {
279 return false;
280 default:
281 global $DIC;
282 $run_manager = $DIC->survey()->internal()->domain()
283 ->execution()->run($svy, $user_id);
284 return $run_manager->hasFinished();
285 }
286
287 // no break
288 default:
289 // evaluation access for participants
290 // check if the user with the given id is a survey participant
291
292 // show the evaluation button for anonymized surveys for all users
293 // access is only granted with the survey access code
294 if (self::_lookupAnonymize($a_obj_id)) {
295 return true;
296 }
297
298 global $DIC;
299
300 $ilDB = $DIC->database();
301 $result = $ilDB->queryF(
302 "SELECT survey_id FROM svy_svy WHERE obj_fi = %s",
303 array('integer'),
304 array($a_obj_id)
305 );
306 if ($result->numRows() === 1) {
307 $row = $ilDB->fetchAssoc($result);
308
309 if (self::_isSurveyParticipant($user_id, $row["survey_id"])) {
310 $survey = new ilObjSurvey($a_obj_id, false);
311 $run_manager = $DIC->survey()->internal()->domain()
312 ->execution()->run($survey, $user_id);
313 return $run_manager->hasFinished();
314 }
315 }
316 return false;
317 }
318 }
319 return false;
320 }
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 178 of file class.ilObjSurveyAccess.php.

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

◆ _lookup360Mode()

static ilObjSurveyAccess::_lookup360Mode ( int  $a_obj_id)
static

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

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

◆ _lookupAnonymize()

static ilObjSurveyAccess::_lookupAnonymize ( int  $a_obj_id)
static

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

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

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 135 of file class.ilObjSurveyAccess.php.

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

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 160 of file class.ilObjSurveyAccess.php.

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

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 328 of file class.ilObjSurveyAccess.php.

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

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 376 of file class.ilObjSurveyAccess.php.

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

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 50 of file class.ilObjSurveyAccess.php.

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

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 43 of file class.ilObjSurveyAccess.php.

43 : array
44 {
45 return array(
47 );
48 }

References ilConditionHandler\OPERATOR_FINISHED.

Field Documentation

◆ $access

ilAccessHandler ilObjSurveyAccess::$access
protected

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

Referenced by _checkAccess().

◆ $lng

ilLanguage ilObjSurveyAccess::$lng
protected

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

Referenced by _checkAccess().

◆ $rbacsystem

ilRbacSystem ilObjSurveyAccess::$rbacsystem
protected

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

Referenced by _checkAccess().

◆ $user

ilObjUser ilObjSurveyAccess::$user
protected

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

Referenced by _checkAccess().


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