ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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...
 
- 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...
 
static getConditionOperators ()
 Returns an array with valid operators for the specific object type. More...
 
static checkCondition ($a_trigger_obj_id, $a_operator, $a_value, $a_usr_id)
 check condition for a specific user and object 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

Reimplemented from ilObjectAccess.

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

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

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

+ Here is the call graph for this function:

◆ _checkGoto()

static ilObjSurveyAccess::_checkGoto (   $a_target)
static

check whether goto script will succeed

Reimplemented from ilObjectAccess.

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

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

References $_GET, and ilObjSurvey\validateExternalRaterCode().

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

Reimplemented from ilObjectAccess.

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

174 {
175 $commands = array
176 (
177 array("permission" => "read", "cmd" => "infoScreen", "lang_var" => "svy_run", "default" => true),
178 array("permission" => "write", "cmd" => "questionsrepo", "lang_var" => "edit_questions"),
179 array("permission" => "write", "cmd" => "properties", "lang_var" => "settings"),
180 array("permission" => "read", "cmd" => "evaluation", "lang_var" => "svy_results")
181 );
182
183 return $commands;
184 }

Referenced by ilObjSurveyListGUI\init().

+ Here is the caller graph for this function:

◆ _hasEvaluationAccess()

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

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

263 {
264 $evaluation_access = ilObjSurveyAccess::_lookupEvaluationAccess($a_obj_id);
265 switch ($evaluation_access)
266 {
267 case 0:
268 // no evaluation access
269 return false;
270 break;
271 case 1:
272 // evaluation access for all registered users
273 if (($user_id > 0) && ($user_id != ANONYMOUS_USER_ID))
274 {
275 return true;
276 }
277 else
278 {
279 return false;
280 }
281 break;
282 case 2:
283 if(!self::_lookup360Mode($a_obj_id))
284 {
285 // evaluation access for participants
286 // check if the user with the given id is a survey participant
287
288 // show the evaluation button for anonymized surveys for all users
289 // access is only granted with the survey access code
290 if (ilObjSurveyAccess::_lookupAnonymize($a_obj_id) == 1) return true;
291
292 global $ilDB;
293 $result = $ilDB->queryF("SELECT survey_id FROM svy_svy WHERE obj_fi = %s",
294 array('integer'),
295 array($a_obj_id)
296 );
297 if ($result->numRows() == 1)
298 {
299 $row = $ilDB->fetchAssoc($result);
300
301 if (ilObjSurveyAccess::_isSurveyParticipant($user_id, $row["survey_id"]))
302 {
303 return true;
304 }
305 }
306 return false;
307 }
308 // 360°
309 else
310 {
311 include_once "Modules/Survey/classes/class.ilObjSurvey.php";
312 $svy = new ilObjSurvey($a_obj_id, false);
313 $svy->read();
314 switch($svy->get360Results())
315 {
317 return false;
318
320 return $svy->isAppraiseeClosed($user_id);
321
323 return $svy->isAppraisee($user_id);
324 }
325 }
326 break;
327 }
328 }
$result
static _isSurveyParticipant($user_id, $survey_id)
static _lookupEvaluationAccess($a_obj_id)
get evaluation access
static _lookupAnonymize($a_obj_id)
global $ilDB

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(), ilObjSurveyGUI\infoScreen(), and ilSurveyExecutionGUI\runShowFinishedPage().

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

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

References $ilDB, and $result.

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

+ Here is the caller graph for this function:

◆ _lookup360Mode()

static ilObjSurveyAccess::_lookup360Mode (   $a_obj_id)
static

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

394 {
395 global $ilDB;
396
397 $result = $ilDB->queryF("SELECT mode_360 FROM svy_svy".
398 " WHERE obj_fi = %s AND mode_360 = %s",
399 array('integer','integer'),
400 array($a_obj_id, 1)
401 );
402 return (bool)$ilDB->numRows($result);
403 }

References $ilDB, and $result.

Referenced by ilObjSurveyListGUI\getProperties().

+ Here is the caller graph for this function:

◆ _lookupAnonymize()

static ilObjSurveyAccess::_lookupAnonymize (   $a_obj_id)
static

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

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

References $ilDB, $result, and $row.

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

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

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

References $ilDB, $result, and $row.

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

+ Here is the caller graph for this function:

◆ _lookupEvaluationAccess()

static ilObjSurveyAccess::_lookupEvaluationAccess (   $a_obj_id)
static

get evaluation access

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

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

References $ilDB, $result, and $row.

Referenced by _hasEvaluationAccess().

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

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

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

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

+ Here is the caller graph for this function:

◆ _lookupOnline()

static ilObjSurveyAccess::_lookupOnline (   $a_obj_id)
static

get status

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

334 {
335 global $ilDB;
336
337 $result = $ilDB->queryF("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->fetchAssoc($result);
343 }
344
345 return $row["status"];
346 }

References $ilDB, $result, and $row.

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

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

61 {
62 switch($a_operator)
63 {
65 include_once("./Modules/Survey/classes/class.ilObjSurveyAccess.php");
66 if (ilObjSurveyAccess::_lookupFinished($a_svy_id, $a_usr_id))
67 {
68 return true;
69 }
70 else
71 {
72 return false;
73 }
74 break;
75
76 default:
77 return true;
78 }
79 return true;
80 }
static _lookupFinished($a_obj_id, $a_user_id="")
get finished status

References _lookupFinished(), and ilConditionHandler\OPERATOR_FINISHED.

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

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

References ilConditionHandler\OPERATOR_FINISHED.


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