ILIAS  release_8 Revision v8.19-1-g4e8f2f9140c
All Data Structures Namespaces Files Functions Variables Modules Pages
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)
 
- 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)
 

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 ()
 
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_... 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...
 

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.

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

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: feed.php:28
+ 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 
)

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

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

66  : bool
67  {
69  $lng = $this->lng;
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  $ilAccess->addInfoItem(ilAccessInfo::IL_NO_OBJECT_ACCESS, $lng->txt("warning_survey_not_complete"));
94  return false;
95  }
96  break;
97 
98  case "evaluation":
99  if (!self::_lookupCreationComplete($obj_id)) {
100  $ilAccess->addInfoItem(ilAccessInfo::IL_NO_OBJECT_ACCESS, $lng->txt("warning_survey_not_complete"));
101  return false;
102  }
103  if ($rbacsystem->checkAccess("write", $ref_id) || self::_hasEvaluationAccess($obj_id, $user_id)) {
104  return true;
105  } else {
106  $ilAccess->addInfoItem(ilAccessInfo::IL_NO_OBJECT_ACCESS, $lng->txt("status_no_permission"));
107  return false;
108  }
109  }
110 
111  return true;
112  }
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...
checkAccessOfUser(int $a_user_id, string $a_operations, int $a_ref_id, string $a_type="")
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 ...
$ref_id
Definition: ltiauth.php:67
$ilUser
Definition: imgupload.php:34
+ Here is the call graph for this function:

◆ _checkGoto()

static ilObjSurveyAccess::_checkGoto ( string  $target)
static

check whether goto script will succeed

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

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

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

◆ _getCommands()

static ilObjSurveyAccess::_getCommands ( )
static

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

Referenced by ilObjSurveyListGUI\init().

115  : array
116  {
117  $commands = array(
118  array("permission" => "read", "cmd" => "infoScreen", "lang_var" => "svy_run", "default" => true),
119  array("permission" => "write", "cmd" => "questions", "lang_var" => "edit_questions"),
120  array("permission" => "write", "cmd" => "properties", "lang_var" => "settings"),
121  array("permission" => "read", "cmd" => "evaluation", "lang_var" => "svy_results")
122  );
123 
124  return $commands;
125  }
+ Here is the caller graph for this function:

◆ _hasEvaluationAccess()

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

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

References $DIC, $ilDB, ANONYMOUS_USER_ID, ilObjSurvey\MODE_360, ilObjSurvey\MODE_IND_FEEDB, ilObjSurvey\MODE_SELF_EVAL, ilObjSurvey\RESULTS_360_ALL, ilObjSurvey\RESULTS_360_NONE, ilObjSurvey\RESULTS_360_OWN, and ilObjSurvey\RESULTS_SELF_EVAL_NONE.

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

216  : bool {
217  $evaluation_access = self::_lookupEvaluationAccess($a_obj_id);
218  $svy_mode = self::_lookupMode($a_obj_id);
219 
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  return true;
282  }
283 
284  // no break
285  default:
286  // evaluation access for participants
287  // check if the user with the given id is a survey participant
288 
289  // show the evaluation button for anonymized surveys for all users
290  // access is only granted with the survey access code
291  if (self::_lookupAnonymize($a_obj_id)) {
292  return true;
293  }
294 
295  global $DIC;
296 
297  $ilDB = $DIC->database();
298  $result = $ilDB->queryF(
299  "SELECT survey_id FROM svy_svy WHERE obj_fi = %s",
300  array('integer'),
301  array($a_obj_id)
302  );
303  if ($result->numRows() === 1) {
304  $row = $ilDB->fetchAssoc($result);
305 
306  if (self::_isSurveyParticipant($user_id, $row["survey_id"])) {
307  return true;
308  }
309  }
310  return false;
311  }
312  }
313  return false;
314  }
const ANONYMOUS_USER_ID
Definition: constants.php:27
global $DIC
Definition: feed.php:28
const RESULTS_SELF_EVAL_NONE
+ Here is the caller graph for this function:

◆ _isSurveyParticipant()

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

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

References $DIC, and $ilDB.

Referenced by ilLPStatusSurveyFinished\determineStatus().

180  : bool {
181  global $DIC;
182 
183  $ilDB = $DIC->database();
184 
185  $result = $ilDB->queryF(
186  "SELECT finished_id FROM svy_finished WHERE user_fi = %s AND survey_fi = %s",
187  array('integer','integer'),
188  array($user_id, $survey_id)
189  );
190  return $result->numRows() === 1;
191  }
global $DIC
Definition: feed.php:28
+ Here is the caller graph for this function:

◆ _lookup360Mode()

static ilObjSurveyAccess::_lookup360Mode ( int  $a_obj_id)
static

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

References $DIC, $ilDB, and ilObjSurvey\MODE_360.

393  : bool {
394  global $DIC;
395 
396  $ilDB = $DIC->database();
397 
398  $result = $ilDB->queryF(
399  "SELECT mode FROM svy_svy" .
400  " WHERE obj_fi = %s AND mode = %s",
401  array('integer','integer'),
402  array($a_obj_id, ilObjSurvey::MODE_360)
403  );
404  return (bool) $ilDB->numRows($result);
405  }
global $DIC
Definition: feed.php:28

◆ _lookupAnonymize()

static ilObjSurveyAccess::_lookupAnonymize ( int  $a_obj_id)
static

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

References $DIC, and $ilDB.

Referenced by ilSurveyLP\isAnonymized().

195  : bool {
196  global $DIC;
197 
198  $ilDB = $DIC->database();
199 
200  $result = $ilDB->queryF(
201  "SELECT anonymize FROM svy_svy WHERE obj_fi = %s",
202  array('integer'),
203  array($a_obj_id)
204  );
205  if ($result->numRows() === 1) {
206  $row = $ilDB->fetchAssoc($result);
207  return (bool) $row["anonymize"];
208  } else {
209  return false;
210  }
211  }
global $DIC
Definition: feed.php:28
+ 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 134 of file class.ilObjSurveyAccess.php.

References $DIC, and $ilDB.

Referenced by ilObjSurveyListGUI\getProperties().

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

◆ _lookupEvaluationAccess()

static ilObjSurveyAccess::_lookupEvaluationAccess ( int  $a_obj_id)
static

get evaluation access

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

References $DIC, and $ilDB.

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

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

References $DIC, $ilDB, $ilUser, and ILIAS\Repository\int().

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

325  : int {
326  global $DIC;
327 
328  $ilDB = $DIC->database();
329  $ilUser = $DIC->user();
330 
331  $finished = 0;
332  if ($a_user_id === 0) {
333  $a_user_id = $ilUser->getId();
334  }
335 
336  $result = $ilDB->queryF(
337  "SELECT * FROM svy_svy WHERE obj_fi = %s",
338  array('integer'),
339  array($a_obj_id)
340  );
341  if ($result->numRows() === 1) {
342  $row = $ilDB->fetchObject($result);
343  if ((int) $row->anonymize === 1) {
344  $result = $ilDB->queryF(
345  "SELECT * FROM svy_finished, svy_anonymous WHERE svy_finished.survey_fi = %s " .
346  "AND svy_finished.survey_fi = svy_anonymous.survey_fi AND svy_anonymous.user_key = %s " .
347  "AND svy_anonymous.survey_key = svy_finished.anonymous_id",
348  array('integer','text'),
349  array($row->survey_id, md5($a_user_id))
350  );
351  } else {
352  $result = $ilDB->queryF(
353  "SELECT * FROM svy_finished WHERE survey_fi = %s AND user_fi = %s",
354  array('integer','integer'),
355  array($row->survey_id, $a_user_id)
356  );
357  }
358  if ($result->numRows() === 1) {
359  $foundrow = $ilDB->fetchAssoc($result);
360  $finished = (int) $foundrow["state"];
361  }
362  }
363 
364  return $finished;
365  }
global $DIC
Definition: feed.php:28
$ilUser
Definition: imgupload.php:34
+ Here is the call graph for this function:
+ 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 370 of file class.ilObjSurveyAccess.php.

References $DIC, and $ilDB.

Referenced by ilObjSurveyListGUI\getProperties().

372  : int {
373  global $DIC;
374  $ilDB = $DIC->database();
375 
376  $result = $ilDB->queryF(
377  "SELECT mode FROM svy_svy" .
378  " WHERE obj_fi = %s",
379  array('integer'),
380  array($a_obj_id)
381  );
382 
383  if ($result->numRows() === 1) {
384  $row = $ilDB->fetchAssoc($result);
385  return (int) $row["mode"];
386  }
387 
388  return 0;
389  }
global $DIC
Definition: feed.php:28
+ 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.

References ilConditionHandler\OPERATOR_FINISHED.

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  }

◆ 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.

References ilConditionHandler\OPERATOR_FINISHED.

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

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: