ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
ilObjSurveyAccess Class Reference

Class ilObjSurveyAccess. More...

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

Public Member Functions

 _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...
 
 _getCommands ()
 get commands More...
 
 _lookupCreationComplete ($a_obj_id)
 checks wether all necessary parts of the survey are given More...
 
 _lookupEvaluationAccess ($a_obj_id)
 get evaluation access More...
 
 _isSurveyParticipant ($user_id, $survey_id)
 
 _lookupAnonymize ($a_obj_id)
 
 _hasEvaluationAccess ($a_obj_id, $user_id)
 
 _lookupOnline ($a_obj_id)
 get status More...
 
 _lookupFinished ($a_obj_id, $a_user_id="")
 get finished status More...
 
 _lookup360Mode ($a_obj_id)
 
 _checkGoto ($a_target)
 check whether goto script will succeed 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...
 
 _getCommands ()
 get commands More...
 
 _checkGoto ($a_target)
 check whether goto script will succeed More...
 
 _preloadData ($a_obj_ids, $a_ref_ids)
 Preload data. 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 Public Member Functions inherited from ilObjectAccess
static _isOffline ($a_obj_id)
 Type-specific implementation of general status, has to be overwritten. More...
 

Detailed Description

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

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

99  {
100  global $ilUser, $lng, $rbacsystem, $ilAccess;
101 
102  if ($a_user_id == "")
103  {
104  $a_user_id = $ilUser->getId();
105  }
106 
107  $is_admin = $rbacsystem->checkAccessOfUser($a_user_id,'write',$a_ref_id);
108 
109  // check "global" online switch
110  if(!self::_lookupOnline($a_obj_id) && !$is_admin)
111  {
112  $ilAccess->addInfoItem(IL_NO_OBJECT_ACCESS, $lng->txt("offline"));
113  return false;
114  }
115 
116  switch ($a_permission)
117  {
118  case "visible":
119  case "read":
121  !$is_admin)
122  {
123  $ilAccess->addInfoItem(IL_NO_OBJECT_ACCESS, $lng->txt("warning_survey_not_complete"));
124  return false;
125  }
126  break;
127  }
128 
129  switch ($a_cmd)
130  {
131  case "run":
133  || !(ilObjSurveyAccess::_lookupOnline($a_obj_id) == 1))
134  {
135  $ilAccess->addInfoItem(IL_NO_OBJECT_ACCESS, $lng->txt("warning_survey_not_complete"));
136  return false;
137  }
138  break;
139 
140  case "evaluation":
142  {
143  $ilAccess->addInfoItem(IL_NO_OBJECT_ACCESS, $lng->txt("warning_survey_not_complete"));
144  return false;
145  }
146  if ($rbacsystem->checkAccess("write",$a_ref_id) || ilObjSurveyAccess::_hasEvaluationAccess($a_obj_id, $a_user_id))
147  {
148  return true;
149  }
150  else
151  {
152  $ilAccess->addInfoItem(IL_NO_OBJECT_ACCESS, $lng->txt("status_no_permission"));
153  return false;
154  }
155  break;
156  }
157 
158  return true;
159  }
const IL_NO_OBJECT_ACCESS
_lookupCreationComplete($a_obj_id)
checks wether all necessary parts of the survey are given
global $ilUser
Definition: imgupload.php:15
global $lng
Definition: privfeed.php:40
_hasEvaluationAccess($a_obj_id, $user_id)
_lookupOnline($a_obj_id)
get status
+ Here is the call graph for this function:

◆ _checkGoto()

ilObjSurveyAccess::_checkGoto (   $a_target)

check whether goto script will succeed

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

References $_GET, and ilObjSurvey\validateExternalRaterCode().

410  {
411  global $ilAccess;
412 
413  $t_arr = explode("_", $a_target);
414 
415  if ($t_arr[0] != "svy" || ((int) $t_arr[1]) <= 0)
416  {
417  return false;
418  }
419 
420  // 360° external raters
421  if ($_GET["accesscode"])
422  {
423  include_once "Modules/Survey/classes/class.ilObjSurvey.php";
424  if(ilObjSurvey::validateExternalRaterCode($t_arr[1], $_GET["accesscode"]))
425  {
426  return true;
427  }
428  }
429 
430  if ($ilAccess->checkAccess("read", "", $t_arr[1]))
431  {
432  return true;
433  }
434  return false;
435  }
static validateExternalRaterCode($a_ref_id, $a_code)
$_GET["client_id"]
+ Here is the call graph for this function:

◆ _getCommands()

ilObjSurveyAccess::_getCommands ( )

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

Referenced by ilObjSurveyListGUI\init().

175  {
176  $commands = array
177  (
178  array("permission" => "read", "cmd" => "infoScreen", "lang_var" => "svy_run", "default" => true),
179  array("permission" => "write", "cmd" => "questionsrepo", "lang_var" => "edit_questions"),
180  array("permission" => "write", "cmd" => "properties", "lang_var" => "settings"),
181  array("permission" => "read", "cmd" => "evaluation", "lang_var" => "svy_results")
182  );
183 
184  return $commands;
185  }
+ Here is the caller graph for this function:

◆ _hasEvaluationAccess()

ilObjSurveyAccess::_hasEvaluationAccess (   $a_obj_id,
  $user_id 
)

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

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

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

264  {
265  $evaluation_access = ilObjSurveyAccess::_lookupEvaluationAccess($a_obj_id);
266  switch ($evaluation_access)
267  {
268  case 0:
269  // no evaluation access
270  return false;
271  break;
272  case 1:
273  // evaluation access for all registered users
274  if (($user_id > 0) && ($user_id != ANONYMOUS_USER_ID))
275  {
276  return true;
277  }
278  else
279  {
280  return false;
281  }
282  break;
283  case 2:
284  if(!self::_lookup360Mode($a_obj_id))
285  {
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 (ilObjSurveyAccess::_lookupAnonymize($a_obj_id) == 1) return true;
292 
293  global $ilDB;
294  $result = $ilDB->queryF("SELECT survey_id FROM svy_svy WHERE obj_fi = %s",
295  array('integer'),
296  array($a_obj_id)
297  );
298  if ($result->numRows() == 1)
299  {
300  $row = $ilDB->fetchAssoc($result);
301 
302  if (ilObjSurveyAccess::_isSurveyParticipant($user_id, $row["survey_id"]))
303  {
304  return true;
305  }
306  }
307  return false;
308  }
309  // 360°
310  else
311  {
312  include_once "Modules/Survey/classes/class.ilObjSurvey.php";
313  $svy = new ilObjSurvey($a_obj_id, false);
314  $svy->read();
315  switch($svy->get360Results())
316  {
318  return false;
319 
321  return $svy->isAppraiseeClosed($user_id);
322 
324  return $svy->isAppraisee($user_id);
325  }
326  }
327  break;
328  }
329  }
$result
_lookupEvaluationAccess($a_obj_id)
get evaluation access
_isSurveyParticipant($user_id, $survey_id)
global $ilDB
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _isSurveyParticipant()

ilObjSurveyAccess::_isSurveyParticipant (   $user_id,
  $survey_id 
)

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

References $ilDB, and $result.

Referenced by _hasEvaluationAccess().

234  {
235  global $ilDB;
236 
237  $result = $ilDB->queryF("SELECT finished_id FROM svy_finished WHERE user_fi = %s AND survey_fi = %s",
238  array('integer','integer'),
239  array($user_id, $survey_id)
240  );
241  return ($result->numRows() == 1) ? true : false;
242  }
$result
global $ilDB
+ Here is the caller graph for this function:

◆ _lookup360Mode()

ilObjSurveyAccess::_lookup360Mode (   $a_obj_id)

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

References $ilDB, and $result.

Referenced by ilObjSurveyListGUI\getProperties().

395  {
396  global $ilDB;
397 
398  $result = $ilDB->queryF("SELECT mode_360 FROM svy_svy".
399  " WHERE obj_fi = %s AND mode_360 = %s",
400  array('integer','integer'),
401  array($a_obj_id, 1)
402  );
403  return (bool)$ilDB->numRows($result);
404  }
$result
global $ilDB
+ Here is the caller graph for this function:

◆ _lookupAnonymize()

ilObjSurveyAccess::_lookupAnonymize (   $a_obj_id)

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

References $ilDB, $result, and $row.

Referenced by _hasEvaluationAccess().

245  {
246  global $ilDB;
247 
248  $result = $ilDB->queryF("SELECT anonymize FROM svy_svy WHERE obj_fi = %s",
249  array('integer'),
250  array($a_obj_id)
251  );
252  if ($result->numRows() == 1)
253  {
254  $row = $ilDB->fetchAssoc($result);
255  return $row["anonymize"];
256  }
257  else
258  {
259  return 0;
260  }
261  }
$result
global $ilDB
+ Here is the caller graph for this function:

◆ _lookupCreationComplete()

ilObjSurveyAccess::_lookupCreationComplete (   $a_obj_id)

checks wether all necessary parts of the survey are given

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

References $ilDB, $result, and $row.

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

195  {
196  global $ilDB;
197 
198  $result = $ilDB->queryF("SELECT * FROM svy_svy WHERE obj_fi=%s",
199  array('integer'),
200  array($a_obj_id)
201  );
202 
203  if ($result->numRows() == 1)
204  {
205  $row = $ilDB->fetchAssoc($result);
206  }
207  if (!$row["complete"])
208  {
209  return false;
210  }
211  return true;
212  }
$result
global $ilDB
+ Here is the caller graph for this function:

◆ _lookupEvaluationAccess()

ilObjSurveyAccess::_lookupEvaluationAccess (   $a_obj_id)

get evaluation access

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

References $ilDB, $result, and $row.

Referenced by _hasEvaluationAccess().

218  {
219  global $ilDB;
220 
221  $result = $ilDB->queryF("SELECT * FROM svy_svy WHERE obj_fi=%s",
222  array('integer'),
223  array($a_obj_id)
224  );
225  if ($result->numRows() == 1)
226  {
227  $row = $ilDB->fetchAssoc($result);
228  }
229 
230  return $row["evaluation_access"];
231  }
$result
global $ilDB
+ Here is the caller graph for this function:

◆ _lookupFinished()

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

get finished status

Parameters
int$a_obj_idsurvey id

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

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

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

355  {
356  global $ilDB, $ilUser;
357 
358  $finished = "";
359  if (!strlen($a_user_id)) $a_user_id = $ilUser->getId();
360 
361  $result = $ilDB->queryF("SELECT * FROM svy_svy WHERE obj_fi = %s",
362  array('integer'),
363  array($a_obj_id)
364  );
365  if ($result->numRows() == 1)
366  {
367  $row = $ilDB->fetchObject($result);
368  if ($row->anonymize == 1)
369  {
370  $result = $ilDB->queryF("SELECT * FROM svy_finished, svy_anonymous WHERE svy_finished.survey_fi = %s ".
371  "AND svy_finished.survey_fi = svy_anonymous.survey_fi AND svy_anonymous.user_key = %s ".
372  "AND svy_anonymous.survey_key = svy_finished.anonymous_id",
373  array('integer','text'),
374  array($row->survey_id, md5($a_user_id))
375  );
376  }
377  else
378  {
379  $result = $ilDB->queryF("SELECT * FROM svy_finished WHERE survey_fi = %s AND user_fi = %s",
380  array('integer','integer'),
381  array($row->survey_id, $a_user_id)
382  );
383  }
384  if ($result->numRows() == 1)
385  {
386  $foundrow = $ilDB->fetchAssoc($result);
387  $finished = (int)$foundrow["state"];
388  }
389  }
390 
391  return $finished;
392  }
$result
global $ilUser
Definition: imgupload.php:15
global $ilDB
+ Here is the caller graph for this function:

◆ _lookupOnline()

ilObjSurveyAccess::_lookupOnline (   $a_obj_id)

get status

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

References $ilDB, $result, and $row.

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

335  {
336  global $ilDB;
337 
338  $result = $ilDB->queryF("SELECT * FROM svy_svy WHERE obj_fi=%s",
339  array('integer'),
340  array($a_obj_id)
341  );
342  if ($result->numRows() == 1) {
343  $row = $ilDB->fetchAssoc($result);
344  }
345 
346  return $row["status"];
347  }
$result
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 60 of file class.ilObjSurveyAccess.php.

References _lookupFinished(), and ilConditionHandler\OPERATOR_FINISHED.

61  {
62  switch($a_operator)
63  {
65  //if (ilExerciseMembers::_lookupStatus($a_exc_id, $ilias->account->getId()) == "passed")
66  include_once("./Modules/Survey/classes/class.ilObjSurveyAccess.php");
67  if (ilObjSurveyAccess::_lookupFinished($a_svy_id, $a_usr_id))
68  {
69  return true;
70  }
71  else
72  {
73  return false;
74  }
75  break;
76 
77  default:
78  return true;
79  }
80  return true;
81  }
_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 43 of file class.ilObjSurveyAccess.php.

References ilConditionHandler\OPERATOR_FINISHED.

44  {
45  include_once './Services/AccessControl/classes/class.ilConditionHandler.php';
46  return array(
48  );
49  }

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