ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilObjSurveyAccess Class Reference

Class ilObjSurveyAccess. More...

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

Public Member Functions

 __construct ()
 Constructor. More...
 
 _checkAccess ($a_cmd, $a_permission, $a_ref_id, $a_obj_id, $a_user_id="")
 Checks wether a user may invoke a command or not (this method is called by ilAccessHandler::checkAccess) More...
 
- Public Member Functions inherited from ilObjectAccess
 _checkAccess ($a_cmd, $a_permission, $a_ref_id, $a_obj_id, $a_user_id="")
 Checks wether a user may invoke a command or not (this method is called by ilAccessHandler::checkAccess) More...
 
 _checkCondition ($a_obj_id, $a_operator, $a_value, $a_usr_id)
 check condition More...
 

Static Public Member Functions

static getConditionOperators ()
 Get possible conditions operators. More...
 
static checkCondition ($a_svy_id, $a_operator, $a_value, $a_usr_id)
 check condition More...
 
static _getCommands ()
 get commands More...
 
static _lookupCreationComplete ($a_obj_id)
 checks wether all necessary parts of the survey are given More...
 
static _lookupEvaluationAccess ($a_obj_id)
 get evaluation access More...
 
static _isSurveyParticipant ($user_id, $survey_id)
 
static _lookupAnonymize ($a_obj_id)
 
static _hasEvaluationAccess ($a_obj_id, $user_id)
 
static _lookupOnline ($a_obj_id)
 get status More...
 
static _lookupFinished ($a_obj_id, $a_user_id="")
 get finished status More...
 
static _lookup360Mode ($a_obj_id)
 
static _checkGoto ($a_target)
 check whether goto script will succeed More...
 
- Static Public Member Functions inherited from ilObjectAccess
static _getCommands ()
 get commands More...
 
static _checkGoto ($a_target)
 check whether goto script will succeed More...
 
static _isOffline ($a_obj_id)
 Type-specific implementation of general status, has to be overwritten. More...
 
static _preloadData ($a_obj_ids, $a_ref_ids)
 Preload data. More...
 

Protected Attributes

 $user
 
 $lng
 
 $rbacsystem
 
 $access
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilObjSurveyAccess::__construct ( )

Constructor.

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

References $DIC, and user().

64  {
65  global $DIC;
66 
67  $this->user = $DIC->user();
68  $this->lng = $DIC->language();
69  $this->rbacsystem = $DIC->rbac()->system();
70  $this->access = $DIC->access();
71  }
global $DIC
Definition: saml.php:7
user()
Definition: user.php:4
+ Here is the call graph for this function:

Member Function Documentation

◆ _checkAccess()

ilObjSurveyAccess::_checkAccess (   $a_cmd,
  $a_permission,
  $a_ref_id,
  $a_obj_id,
  $a_user_id = "" 
)

Checks wether 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.

Parameters
string$a_cmdcommand (not permission!)
string$a_permissionpermission
int$a_ref_idreference id
int$a_obj_idobject id
int$a_user_iduser id (if not provided, current user is taken)
Returns
boolean true, if everything is ok

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

References $access, $ilUser, $lng, $rbacsystem, $user, _hasEvaluationAccess(), _lookupCreationComplete(), _lookupOnline(), and IL_NO_OBJECT_ACCESS.

128  {
130  $lng = $this->lng;
132  $ilAccess = $this->access;
133 
134  if ($a_user_id == "") {
135  $a_user_id = $ilUser->getId();
136  }
137 
138  $is_admin = $rbacsystem->checkAccessOfUser($a_user_id, 'write', $a_ref_id);
139 
140  // check "global" online switch
141  if (!self::_lookupOnline($a_obj_id) && !$is_admin) {
142  $ilAccess->addInfoItem(IL_NO_OBJECT_ACCESS, $lng->txt("offline"));
143  return false;
144  }
145 
146  switch ($a_permission) {
147  case "visible":
148  case "read":
150  !$is_admin) {
151  $ilAccess->addInfoItem(IL_NO_OBJECT_ACCESS, $lng->txt("warning_survey_not_complete"));
152  return false;
153  }
154  break;
155  }
156 
157  switch ($a_cmd) {
158  case "run":
160  || !(ilObjSurveyAccess::_lookupOnline($a_obj_id) == 1)) {
161  $ilAccess->addInfoItem(IL_NO_OBJECT_ACCESS, $lng->txt("warning_survey_not_complete"));
162  return false;
163  }
164  break;
165 
166  case "evaluation":
168  $ilAccess->addInfoItem(IL_NO_OBJECT_ACCESS, $lng->txt("warning_survey_not_complete"));
169  return false;
170  }
171  if ($rbacsystem->checkAccess("write", $a_ref_id) || ilObjSurveyAccess::_hasEvaluationAccess($a_obj_id, $a_user_id)) {
172  return true;
173  } else {
174  $ilAccess->addInfoItem(IL_NO_OBJECT_ACCESS, $lng->txt("status_no_permission"));
175  return false;
176  }
177  break;
178  }
179 
180  return true;
181  }
const IL_NO_OBJECT_ACCESS
$ilUser
Definition: imgupload.php:18
static _hasEvaluationAccess($a_obj_id, $user_id)
static _lookupCreationComplete($a_obj_id)
checks wether all necessary parts of the survey are given
static _lookupOnline($a_obj_id)
get status
+ Here is the call graph for this function:

◆ _checkGoto()

static ilObjSurveyAccess::_checkGoto (   $a_target)
static

check whether goto script will succeed

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

References $_GET, $DIC, and ilObjSurvey\validateExternalRaterCode().

442  {
443  global $DIC;
444 
445  $ilAccess = $DIC->access();
446 
447  $t_arr = explode("_", $a_target);
448 
449  if ($t_arr[0] != "svy" || ((int) $t_arr[1]) <= 0) {
450  return false;
451  }
452 
453  // 360° external raters
454  if ($_GET["accesscode"]) {
455  include_once "Modules/Survey/classes/class.ilObjSurvey.php";
456  if (ilObjSurvey::validateExternalRaterCode($t_arr[1], $_GET["accesscode"])) {
457  return true;
458  }
459  }
460 
461  if ($ilAccess->checkAccess("visible", "", $t_arr[1]) ||
462  $ilAccess->checkAccess("read", "", $t_arr[1])) {
463  return true;
464  }
465  return false;
466  }
global $DIC
Definition: saml.php:7
static validateExternalRaterCode($a_ref_id, $a_code)
$_GET["client_id"]
+ Here is the call graph for this function:

◆ _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"), );

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

References array.

Referenced by ilObjSurveyListGUI\init().

197  {
198  $commands = array(
199  array("permission" => "read", "cmd" => "infoScreen", "lang_var" => "svy_run", "default" => true),
200  array("permission" => "write", "cmd" => "questionsrepo", "lang_var" => "edit_questions"),
201  array("permission" => "write", "cmd" => "properties", "lang_var" => "settings"),
202  array("permission" => "read", "cmd" => "evaluation", "lang_var" => "svy_results")
203  );
204 
205  return $commands;
206  }
Create styles array
The data for the language used.
+ Here is the caller graph for this function:

◆ _hasEvaluationAccess()

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

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

References $DIC, $ilDB, $result, $row, _isSurveyParticipant(), _lookupAnonymize(), _lookupEvaluationAccess(), array, ilObjSurvey\RESULTS_360_ALL, ilObjSurvey\RESULTS_360_NONE, and ilObjSurvey\RESULTS_360_OWN.

Referenced by _checkAccess(), ilSurveyEvaluationGUI\checkAnonymizedEvaluationAccess(), ilObjSurveyGUI\getTabs(), ilObjSurveyGUI\infoScreen(), and ilSurveyExecutionGUI\runShowFinishedPage().

291  {
292  $evaluation_access = ilObjSurveyAccess::_lookupEvaluationAccess($a_obj_id);
293  switch ($evaluation_access) {
294  case 0:
295  // no evaluation access
296  return false;
297  break;
298  case 1:
299  // evaluation access for all registered users
300  if (($user_id > 0) && ($user_id != ANONYMOUS_USER_ID)) {
301  return true;
302  } else {
303  return false;
304  }
305  break;
306  case 2:
307  if (!self::_lookup360Mode($a_obj_id)) {
308  // evaluation access for participants
309  // check if the user with the given id is a survey participant
310 
311  // show the evaluation button for anonymized surveys for all users
312  // access is only granted with the survey access code
313  if (ilObjSurveyAccess::_lookupAnonymize($a_obj_id) == 1) {
314  return true;
315  }
316 
317  global $DIC;
318 
319  $ilDB = $DIC->database();
320  $result = $ilDB->queryF(
321  "SELECT survey_id FROM svy_svy WHERE obj_fi = %s",
322  array('integer'),
323  array($a_obj_id)
324  );
325  if ($result->numRows() == 1) {
326  $row = $ilDB->fetchAssoc($result);
327 
328  if (ilObjSurveyAccess::_isSurveyParticipant($user_id, $row["survey_id"])) {
329  return true;
330  }
331  }
332  return false;
333  }
334  // 360°
335  else {
336  include_once "Modules/Survey/classes/class.ilObjSurvey.php";
337  $svy = new ilObjSurvey($a_obj_id, false);
338  $svy->read();
339  switch ($svy->get360Results()) {
341  return false;
342 
344  return $svy->isAppraiseeClosed($user_id);
345 
347  return $svy->isAppraisee($user_id);
348  }
349  }
350  break;
351  }
352  }
static _isSurveyParticipant($user_id, $survey_id)
static _lookupEvaluationAccess($a_obj_id)
get evaluation access
$result
global $DIC
Definition: saml.php:7
static _lookupAnonymize($a_obj_id)
Create styles array
The data for the language used.
global $ilDB
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _isSurveyParticipant()

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

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

References $DIC, $ilDB, $result, and array.

Referenced by _hasEvaluationAccess(), and ilLPStatusSurveyFinished\determineStatus().

258  {
259  global $DIC;
260 
261  $ilDB = $DIC->database();
262 
263  $result = $ilDB->queryF(
264  "SELECT finished_id FROM svy_finished WHERE user_fi = %s AND survey_fi = %s",
265  array('integer','integer'),
266  array($user_id, $survey_id)
267  );
268  return ($result->numRows() == 1) ? true : false;
269  }
$result
global $DIC
Definition: saml.php:7
Create styles array
The data for the language used.
global $ilDB
+ Here is the caller graph for this function:

◆ _lookup360Mode()

static ilObjSurveyAccess::_lookup360Mode (   $a_obj_id)
static

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

References $DIC, $ilDB, $result, and array.

Referenced by ilObjSurveyListGUI\getProperties().

424  {
425  global $DIC;
426 
427  $ilDB = $DIC->database();
428 
429  $result = $ilDB->queryF(
430  "SELECT mode_360 FROM svy_svy" .
431  " WHERE obj_fi = %s AND mode_360 = %s",
432  array('integer','integer'),
433  array($a_obj_id, 1)
434  );
435  return (bool) $ilDB->numRows($result);
436  }
$result
global $DIC
Definition: saml.php:7
Create styles array
The data for the language used.
global $ilDB
+ Here is the caller graph for this function:

◆ _lookupAnonymize()

static ilObjSurveyAccess::_lookupAnonymize (   $a_obj_id)
static

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

References $DIC, $ilDB, $result, $row, and array.

Referenced by _hasEvaluationAccess(), and ilSurveyLP\isAnonymized().

272  {
273  global $DIC;
274 
275  $ilDB = $DIC->database();
276 
277  $result = $ilDB->queryF(
278  "SELECT anonymize FROM svy_svy WHERE obj_fi = %s",
279  array('integer'),
280  array($a_obj_id)
281  );
282  if ($result->numRows() == 1) {
283  $row = $ilDB->fetchAssoc($result);
284  return $row["anonymize"];
285  } else {
286  return 0;
287  }
288  }
$result
global $DIC
Definition: saml.php:7
Create styles array
The data for the language used.
global $ilDB
+ Here is the caller graph for this function:

◆ _lookupCreationComplete()

static ilObjSurveyAccess::_lookupCreationComplete (   $a_obj_id)
static

checks wether all necessary parts of the survey are given

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

References $DIC, $ilDB, $result, $row, and array.

Referenced by _checkAccess(), and ilObjSurveyListGUI\getProperties().

216  {
217  global $DIC;
218 
219  $ilDB = $DIC->database();
220 
221  $result = $ilDB->queryF(
222  "SELECT * FROM svy_svy WHERE obj_fi=%s",
223  array('integer'),
224  array($a_obj_id)
225  );
226 
227  if ($result->numRows() == 1) {
228  $row = $ilDB->fetchAssoc($result);
229  }
230  if (!$row["complete"]) {
231  return false;
232  }
233  return true;
234  }
$result
global $DIC
Definition: saml.php:7
Create styles array
The data for the language used.
global $ilDB
+ Here is the caller graph for this function:

◆ _lookupEvaluationAccess()

static ilObjSurveyAccess::_lookupEvaluationAccess (   $a_obj_id)
static

get evaluation access

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

References $DIC, $ilDB, $result, $row, and array.

Referenced by _hasEvaluationAccess().

240  {
241  global $DIC;
242 
243  $ilDB = $DIC->database();
244 
245  $result = $ilDB->queryF(
246  "SELECT * FROM svy_svy WHERE obj_fi=%s",
247  array('integer'),
248  array($a_obj_id)
249  );
250  if ($result->numRows() == 1) {
251  $row = $ilDB->fetchAssoc($result);
252  }
253 
254  return $row["evaluation_access"];
255  }
$result
global $DIC
Definition: saml.php:7
Create styles array
The data for the language used.
global $ilDB
+ Here is the caller graph for this function:

◆ _lookupFinished()

static ilObjSurveyAccess::_lookupFinished (   $a_obj_id,
  $a_user_id = "" 
)
static

get finished status

Parameters
int$a_obj_idsurvey id

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

References $DIC, $ilDB, $ilUser, $result, $row, and array.

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

381  {
382  global $DIC;
383 
384  $ilDB = $DIC->database();
385  $ilUser = $DIC->user();
386 
387  $finished = "";
388  if (!strlen($a_user_id)) {
389  $a_user_id = $ilUser->getId();
390  }
391 
392  $result = $ilDB->queryF(
393  "SELECT * FROM svy_svy WHERE obj_fi = %s",
394  array('integer'),
395  array($a_obj_id)
396  );
397  if ($result->numRows() == 1) {
398  $row = $ilDB->fetchObject($result);
399  if ($row->anonymize == 1) {
400  $result = $ilDB->queryF(
401  "SELECT * FROM svy_finished, svy_anonymous WHERE svy_finished.survey_fi = %s " .
402  "AND svy_finished.survey_fi = svy_anonymous.survey_fi AND svy_anonymous.user_key = %s " .
403  "AND svy_anonymous.survey_key = svy_finished.anonymous_id",
404  array('integer','text'),
405  array($row->survey_id, md5($a_user_id))
406  );
407  } else {
408  $result = $ilDB->queryF(
409  "SELECT * FROM svy_finished WHERE survey_fi = %s AND user_fi = %s",
410  array('integer','integer'),
411  array($row->survey_id, $a_user_id)
412  );
413  }
414  if ($result->numRows() == 1) {
415  $foundrow = $ilDB->fetchAssoc($result);
416  $finished = (int) $foundrow["state"];
417  }
418  }
419 
420  return $finished;
421  }
$result
global $DIC
Definition: saml.php:7
$ilUser
Definition: imgupload.php:18
Create styles array
The data for the language used.
global $ilDB
+ Here is the caller graph for this function:

◆ _lookupOnline()

static ilObjSurveyAccess::_lookupOnline (   $a_obj_id)
static

get status

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

References $DIC, $ilDB, $result, $row, and array.

Referenced by _checkAccess(), and ilObjSurveyListGUI\getProperties().

358  {
359  global $DIC;
360 
361  $ilDB = $DIC->database();
362 
363  $result = $ilDB->queryF(
364  "SELECT * FROM svy_svy WHERE obj_fi=%s",
365  array('integer'),
366  array($a_obj_id)
367  );
368  if ($result->numRows() == 1) {
369  $row = $ilDB->fetchAssoc($result);
370  }
371 
372  return $row["status"];
373  }
$result
global $DIC
Definition: saml.php:7
Create styles array
The data for the language used.
global $ilDB
+ Here is the caller graph for this function:

◆ checkCondition()

static ilObjSurveyAccess::checkCondition (   $a_svy_id,
  $a_operator,
  $a_value,
  $a_usr_id 
)
static

check condition

Parameters
type$a_svy_id
type$a_operator
type$a_value
type$a_usr_id
Returns
boolean

Implements ilConditionHandling.

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

References _lookupFinished(), and ilConditionHandler\OPERATOR_FINISHED.

95  {
96  switch ($a_operator) {
98  include_once("./Modules/Survey/classes/class.ilObjSurveyAccess.php");
99  if (ilObjSurveyAccess::_lookupFinished($a_svy_id, $a_usr_id)) {
100  return true;
101  } else {
102  return false;
103  }
104  break;
105 
106  default:
107  return true;
108  }
109  return true;
110  }
static _lookupFinished($a_obj_id, $a_user_id="")
get finished status
+ Here is the call graph for this function:

◆ getConditionOperators()

static ilObjSurveyAccess::getConditionOperators ( )
static

Get possible conditions operators.

Implements ilConditionHandling.

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

References array, and ilConditionHandler\OPERATOR_FINISHED.

78  {
79  include_once './Services/AccessControl/classes/class.ilConditionHandler.php';
80  return array(
82  );
83  }
Create styles array
The data for the language used.

Field Documentation

◆ $access

ilObjSurveyAccess::$access
protected

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

Referenced by _checkAccess().

◆ $lng

ilObjSurveyAccess::$lng
protected

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

Referenced by _checkAccess().

◆ $rbacsystem

ilObjSurveyAccess::$rbacsystem
protected

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

Referenced by _checkAccess().

◆ $user

ilObjSurveyAccess::$user
protected

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

Referenced by _checkAccess().


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