ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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...
 
 canBeDelivered (ilWACPath $ilWACPath)
 
Parameters
ilWACPath$ilWACPath
Returns
bool
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 _lookupFinished ($a_obj_id, $a_user_id="")
 get finished status More...
 
static _lookupMode ($a_obj_id)
 Get survey mode. 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 if object type does not support centralized offline handling. 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(), 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  switch ($a_permission) {
141  case "visible":
142  case "read":
144  !$is_admin) {
145  $ilAccess->addInfoItem(IL_NO_OBJECT_ACCESS, $lng->txt("warning_survey_not_complete"));
146  return false;
147  }
148  break;
149  }
150 
151  switch ($a_cmd) {
152  case "run":
154  $ilAccess->addInfoItem(IL_NO_OBJECT_ACCESS, $lng->txt("warning_survey_not_complete"));
155  return false;
156  }
157  break;
158 
159  case "evaluation":
161  $ilAccess->addInfoItem(IL_NO_OBJECT_ACCESS, $lng->txt("warning_survey_not_complete"));
162  return false;
163  }
164  if ($rbacsystem->checkAccess("write", $a_ref_id) || ilObjSurveyAccess::_hasEvaluationAccess($a_obj_id, $a_user_id)) {
165  return true;
166  } else {
167  $ilAccess->addInfoItem(IL_NO_OBJECT_ACCESS, $lng->txt("status_no_permission"));
168  return false;
169  }
170  break;
171  }
172 
173  return true;
174  }
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
+ Here is the call graph for this function:

◆ _checkGoto()

static ilObjSurveyAccess::_checkGoto (   $a_target)
static

check whether goto script will succeed

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

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

454  {
455  global $DIC;
456 
457  $ilAccess = $DIC->access();
458 
459  $t_arr = explode("_", $a_target);
460 
461  if ($t_arr[0] != "svy" || ((int) $t_arr[1]) <= 0) {
462  return false;
463  }
464 
465  // 360° external raters
466  if ($_GET["accesscode"]) {
467  include_once "Modules/Survey/classes/class.ilObjSurvey.php";
468  if (ilObjSurvey::validateExternalRaterCode($t_arr[1], $_GET["accesscode"])) {
469  return true;
470  }
471  }
472 
473  if ($ilAccess->checkAccess("visible", "", $t_arr[1]) ||
474  $ilAccess->checkAccess("read", "", $t_arr[1])) {
475  return true;
476  }
477  return false;
478  }
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 189 of file class.ilObjSurveyAccess.php.

Referenced by ilObjSurveyListGUI\init().

190  {
191  $commands = array(
192  array("permission" => "read", "cmd" => "infoScreen", "lang_var" => "svy_run", "default" => true),
193  array("permission" => "write", "cmd" => "questionsrepo", "lang_var" => "edit_questions"),
194  array("permission" => "write", "cmd" => "properties", "lang_var" => "settings"),
195  array("permission" => "read", "cmd" => "evaluation", "lang_var" => "svy_results")
196  );
197 
198  return $commands;
199  }
+ Here is the caller graph for this function:

◆ _hasEvaluationAccess()

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

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

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

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

284  {
285  $evaluation_access = ilObjSurveyAccess::_lookupEvaluationAccess($a_obj_id);
286  switch ($evaluation_access) {
287  case 0:
288  // no evaluation access
289  return false;
290  break;
291  case 1:
292  // evaluation access for all registered users
293  if (($user_id > 0) && ($user_id != ANONYMOUS_USER_ID)) {
294  return true;
295  } else {
296  return false;
297  }
298  break;
299  case 2:
300  $svy_mode = self::_lookupMode($a_obj_id);
301  switch ($svy_mode) {
303  include_once "Modules/Survey/classes/class.ilObjSurvey.php";
304  $svy = new ilObjSurvey($a_obj_id, false);
305  $svy->read();
306  switch ($svy->get360Results()) {
308  return false;
309 
311  return $svy->isAppraiseeClosed($user_id);
312 
314  return $svy->isAppraisee($user_id);
315  }
316  break;
317 
319  include_once "Modules/Survey/classes/class.ilObjSurvey.php";
320  $svy = new ilObjSurvey($a_obj_id, false);
321  $svy->read();
322  switch ($svy->getSelfEvaluationResults()) {
324  return false;
325  default:
326  return true;
327  }
328  break;
329 
330  default:
331  // evaluation access for participants
332  // check if the user with the given id is a survey participant
333 
334  // show the evaluation button for anonymized surveys for all users
335  // access is only granted with the survey access code
336  if (ilObjSurveyAccess::_lookupAnonymize($a_obj_id) == 1) {
337  return true;
338  }
339 
340  global $DIC;
341 
342  $ilDB = $DIC->database();
343  $result = $ilDB->queryF(
344  "SELECT survey_id FROM svy_svy WHERE obj_fi = %s",
345  array('integer'),
346  array($a_obj_id)
347  );
348  if ($result->numRows() == 1) {
349  $row = $ilDB->fetchAssoc($result);
350 
351  if (ilObjSurveyAccess::_isSurveyParticipant($user_id, $row["survey_id"])) {
352  return true;
353  }
354  }
355  return false;
356  break;
357  }
358  break;
359  }
360  }
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)
$row
global $ilDB
const RESULTS_SELF_EVAL_NONE
+ 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 250 of file class.ilObjSurveyAccess.php.

References $DIC, $ilDB, and $result.

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

251  {
252  global $DIC;
253 
254  $ilDB = $DIC->database();
255 
256  $result = $ilDB->queryF(
257  "SELECT finished_id FROM svy_finished WHERE user_fi = %s AND survey_fi = %s",
258  array('integer','integer'),
259  array($user_id, $survey_id)
260  );
261  return ($result->numRows() == 1) ? true : false;
262  }
$result
global $DIC
Definition: saml.php:7
global $ilDB
+ Here is the caller graph for this function:

◆ _lookup360Mode()

static ilObjSurveyAccess::_lookup360Mode (   $a_obj_id)
static

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

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

Referenced by ilObjSurveyListGUI\getProperties().

436  {
437  global $DIC;
438 
439  $ilDB = $DIC->database();
440 
441  $result = $ilDB->queryF(
442  "SELECT mode FROM svy_svy" .
443  " WHERE obj_fi = %s AND mode = %s",
444  array('integer','integer'),
445  array($a_obj_id, ilObjSurvey::MODE_360)
446  );
447  return (bool) $ilDB->numRows($result);
448  }
$result
global $DIC
Definition: saml.php:7
global $ilDB
+ Here is the caller graph for this function:

◆ _lookupAnonymize()

static ilObjSurveyAccess::_lookupAnonymize (   $a_obj_id)
static

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

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

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

265  {
266  global $DIC;
267 
268  $ilDB = $DIC->database();
269 
270  $result = $ilDB->queryF(
271  "SELECT anonymize FROM svy_svy WHERE obj_fi = %s",
272  array('integer'),
273  array($a_obj_id)
274  );
275  if ($result->numRows() == 1) {
276  $row = $ilDB->fetchAssoc($result);
277  return $row["anonymize"];
278  } else {
279  return 0;
280  }
281  }
$result
global $DIC
Definition: saml.php:7
$row
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 208 of file class.ilObjSurveyAccess.php.

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

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

209  {
210  global $DIC;
211 
212  $ilDB = $DIC->database();
213 
214  $result = $ilDB->queryF(
215  "SELECT * FROM svy_svy WHERE obj_fi=%s",
216  array('integer'),
217  array($a_obj_id)
218  );
219 
220  if ($result->numRows() == 1) {
221  $row = $ilDB->fetchAssoc($result);
222  }
223  if (!$row["complete"]) {
224  return false;
225  }
226  return true;
227  }
$result
global $DIC
Definition: saml.php:7
$row
global $ilDB
+ Here is the caller graph for this function:

◆ _lookupEvaluationAccess()

static ilObjSurveyAccess::_lookupEvaluationAccess (   $a_obj_id)
static

get evaluation access

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

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

Referenced by _hasEvaluationAccess().

233  {
234  global $DIC;
235 
236  $ilDB = $DIC->database();
237 
238  $result = $ilDB->queryF(
239  "SELECT * FROM svy_svy WHERE obj_fi=%s",
240  array('integer'),
241  array($a_obj_id)
242  );
243  if ($result->numRows() == 1) {
244  $row = $ilDB->fetchAssoc($result);
245  }
246 
247  return $row["evaluation_access"];
248  }
$result
global $DIC
Definition: saml.php:7
$row
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 368 of file class.ilObjSurveyAccess.php.

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

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

369  {
370  global $DIC;
371 
372  $ilDB = $DIC->database();
373  $ilUser = $DIC->user();
374 
375  $finished = "";
376  if (!strlen($a_user_id)) {
377  $a_user_id = $ilUser->getId();
378  }
379 
380  $result = $ilDB->queryF(
381  "SELECT * FROM svy_svy WHERE obj_fi = %s",
382  array('integer'),
383  array($a_obj_id)
384  );
385  if ($result->numRows() == 1) {
386  $row = $ilDB->fetchObject($result);
387  if ($row->anonymize == 1) {
388  $result = $ilDB->queryF(
389  "SELECT * FROM svy_finished, svy_anonymous WHERE svy_finished.survey_fi = %s " .
390  "AND svy_finished.survey_fi = svy_anonymous.survey_fi AND svy_anonymous.user_key = %s " .
391  "AND svy_anonymous.survey_key = svy_finished.anonymous_id",
392  array('integer','text'),
393  array($row->survey_id, md5($a_user_id))
394  );
395  } else {
396  $result = $ilDB->queryF(
397  "SELECT * FROM svy_finished WHERE survey_fi = %s AND user_fi = %s",
398  array('integer','integer'),
399  array($row->survey_id, $a_user_id)
400  );
401  }
402  if ($result->numRows() == 1) {
403  $foundrow = $ilDB->fetchAssoc($result);
404  $finished = (int) $foundrow["state"];
405  }
406  }
407 
408  return $finished;
409  }
$result
global $DIC
Definition: saml.php:7
$ilUser
Definition: imgupload.php:18
$row
global $ilDB
+ Here is the caller graph for this function:

◆ _lookupMode()

static ilObjSurveyAccess::_lookupMode (   $a_obj_id)
static

Get survey mode.

Parameters
$a_obj_id
Returns
int

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

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

417  {
418  global $DIC;
419  $ilDB = $DIC->database();
420 
421  $result = $ilDB->queryF(
422  "SELECT mode FROM svy_svy" .
423  " WHERE obj_fi = %s",
424  array('integer'),
425  array($a_obj_id)
426  );
427 
428  if ($result->numRows() == 1) {
429  $row = $ilDB->fetchAssoc($result);
430  }
431 
432  return $row["mode"];
433  }
$result
global $DIC
Definition: saml.php:7
$row
global $ilDB

◆ 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 ilConditionHandler\OPERATOR_FINISHED.

78  {
79  include_once './Services/Conditions/classes/class.ilConditionHandler.php';
80  return array(
82  );
83  }

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: