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). | |
| _getCommands () | |
| get commands | |
| _lookupCreationComplete ($a_obj_id) | |
| checks wether all necessary parts of the survey are given | |
| _lookupEvaluationAccess ($a_obj_id) | |
| get evaluation access | |
| _isSurveyParticipant ($user_id, $survey_id) | |
| _lookupAnonymize ($a_obj_id) | |
| _hasEvaluationAccess ($a_obj_id, $user_id) | |
| _lookupOnline ($a_obj_id) | |
| get status | |
| _lookupFinished ($a_obj_id, $a_user_id="") | |
| get finished status | |
Definition at line 37 of file class.ilObjSurveyAccess.php.
| 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.
| string | $a_cmd command (not permission!) | |
| string | $a_permission permission | |
| int | $a_ref_id reference id | |
| int | $a_obj_id object id | |
| int | $a_user_id user id (if not provided, current user is taken) |
Reimplemented from ilObjectAccess.
Definition at line 54 of file class.ilObjSurveyAccess.php.
References $ilAccess, $ilUser, $lng, $rbacsystem, _hasEvaluationAccess(), _lookupCreationComplete(), and _lookupOnline().
{
global $ilUser, $lng, $rbacsystem, $ilAccess;
if ($a_user_id == "")
{
$a_user_id = $ilUser->getId();
}
switch ($a_permission)
{
case "visible":
if (!ilObjSurveyAccess::_lookupCreationComplete($a_obj_id) &&
(!$rbacsystem->checkAccess('write', $a_ref_id)))
{
$ilAccess->addInfoItem(IL_NO_OBJECT_ACCESS, $lng->txt("warning_survey_not_complete"));
return false;
}
break;
}
switch ($a_cmd)
{
case "run":
if (!ilObjSurveyAccess::_lookupCreationComplete($a_obj_id)
|| !(ilObjSurveyAccess::_lookupOnline($a_obj_id) == 1))
{
$ilAccess->addInfoItem(IL_NO_OBJECT_ACCESS, $lng->txt("warning_survey_not_complete"));
return false;
}
break;
case "evaluation":
if (!ilObjSurveyAccess::_lookupCreationComplete($a_obj_id))
{
$ilAccess->addInfoItem(IL_NO_OBJECT_ACCESS, $lng->txt("warning_survey_not_complete"));
return false;
}
if ($rbacsystem->checkAccess("write",$a_ref_id) || ilObjSurveyAccess::_hasEvaluationAccess($a_obj_id, $a_user_id))
{
return true;
}
else
{
$ilAccess->addInfoItem(IL_NO_OBJECT_ACCESS, $lng->txt("no_permission"));
return false;
}
break;
}
return true;
}
Here is the call graph for this function:| 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"), );
Reimplemented from ilObjectAccess.
Definition at line 120 of file class.ilObjSurveyAccess.php.
Referenced by ilObjSurveyListGUI::init().
{
$commands = array
(
array("permission" => "read", "cmd" => "run", "lang_var" => "svy_run",
"default" => true),
array("permission" => "write", "cmd" => "properties", "lang_var" => "edit"),
array("permission" => "invite", "cmd" => "invite", "lang_var" => "invite"),
array("permission" => "read", "cmd" => "evaluation", "lang_var" => "svy_evaluation")
);
return $commands;
}
Here is the caller graph for this function:| ilObjSurveyAccess::_hasEvaluationAccess | ( | $ | a_obj_id, | |
| $ | user_id | |||
| ) |
Definition at line 219 of file class.ilObjSurveyAccess.php.
References $q, $result, $row, $user_id, _isSurveyParticipant(), _lookupAnonymize(), and _lookupEvaluationAccess().
Referenced by _checkAccess().
{
$evaluation_access = ilObjSurveyAccess::_lookupEvaluationAccess($a_obj_id);
switch ($evaluation_access)
{
case 0:
// no evaluation access
return false;
break;
case 1:
// evaluation access for all users
return true;
break;
case 2:
// evaluation access for participants
// check if the user with the given id is a survey participant
// show the evaluation button for anonymized surveys for all users
// access is only granted with the survey access code
if (ilObjSurveyAccess::_lookupAnonymize($a_obj_id) == 1) return true;
global $ilDB;
$q = sprintf("SELECT survey_id FROM survey_survey WHERE obj_fi = %s",
$ilDB->quote($a_obj_id . "")
);
$result = $ilDB->query($q);
if ($result->numRows() == 1)
{
$row = $result->fetchRow(DB_FETCHMODE_ASSOC);
if (ilObjSurveyAccess::_isSurveyParticipant($user_id, $row["survey_id"]))
{
return true;
}
}
// TODO: add an additional check for anonymous users who could have and survey access code
// on the other hand: if someone publishes a survey with anonymous access and evaluation access
// he or she should grant evaluation access for all users...
return false;
break;
}
}
Here is the call graph for this function:
Here is the caller graph for this function:| ilObjSurveyAccess::_isSurveyParticipant | ( | $ | user_id, | |
| $ | survey_id | |||
| ) |
Definition at line 181 of file class.ilObjSurveyAccess.php.
References $q, $result, and $user_id.
Referenced by _hasEvaluationAccess().
{
global $ilDB;
$q = sprintf("SELECT finished_id FROM survey_finished WHERE user_fi = %s AND survey_fi = %s",
$ilDB->quote($user_id . ""),
$ilDB->quote($survey_id . "")
);
$result = $ilDB->query($q);
if ($result->numRows() == 1)
{
return true;
}
else
{
return false;
}
}
Here is the caller graph for this function:| ilObjSurveyAccess::_lookupAnonymize | ( | $ | a_obj_id | ) |
Definition at line 200 of file class.ilObjSurveyAccess.php.
References $q, $result, and $row.
Referenced by _hasEvaluationAccess().
{
global $ilDB;
$q = sprintf("SELECT anonymize FROM survey_survey WHERE obj_fi = %s",
$ilDB->quote($a_obj_id . "")
);
$result = $ilDB->query($q);
if ($result->numRows() == 1)
{
$row = $result->fetchRow(DB_FETCHMODE_ASSOC);
return $row["anonymize"];
}
else
{
return 0;
}
}
Here is the caller graph for this function:| ilObjSurveyAccess::_lookupCreationComplete | ( | $ | a_obj_id | ) |
checks wether all necessary parts of the survey are given
Definition at line 141 of file class.ilObjSurveyAccess.php.
References $q, $result, and $row.
Referenced by _checkAccess(), and ilObjSurveyListGUI::getProperties().
{
global $ilDB;
$q = sprintf("SELECT * FROM survey_survey WHERE obj_fi=%s",
$ilDB->quote($a_obj_id)
);
$result = $ilDB->query($q);
if ($result->numRows() == 1)
{
$row = $result->fetchRow(DB_FETCHMODE_OBJECT);
}
if (!$row->complete)
{
return false;
}
return true;
}
Here is the caller graph for this function:| ilObjSurveyAccess::_lookupEvaluationAccess | ( | $ | a_obj_id | ) |
get evaluation access
Definition at line 165 of file class.ilObjSurveyAccess.php.
References $q, $result, and $row.
Referenced by _hasEvaluationAccess().
{
global $ilDB;
$q = sprintf("SELECT * FROM survey_survey WHERE obj_fi=%s",
$ilDB->quote($a_obj_id)
);
$result = $ilDB->query($q);
if ($result->numRows() == 1)
{
$row = $result->fetchRow(DB_FETCHMODE_OBJECT);
}
return $row->evaluation_access;
}
Here is the caller graph for this function:| ilObjSurveyAccess::_lookupFinished | ( | $ | a_obj_id, | |
| $ | a_user_id = "" | |||
| ) |
get finished status
| int | $a_obj_id survey id |
Definition at line 284 of file class.ilObjSurveyAccess.php.
References $ilUser, $q, $result, and $row.
Referenced by ilObjSurveyListGUI::getProperties().
{
global $ilDB, $ilUser;
$finished = "";
if (!strlen($a_user_id))
$a_user_id = $ilUser->id;
$q = sprintf("SELECT * FROM survey_survey WHERE obj_fi=%s",
$ilDB->quote($a_obj_id)
);
$result = $ilDB->query($q);
if ($result->numRows() == 1)
{
$row = $result->fetchRow(DB_FETCHMODE_OBJECT);
if ($row->anonymize == 1)
{
$q = sprintf("SELECT * FROM survey_finished WHERE survey_fi = %s AND anonymous_id = %s",
$ilDB->quote($row->survey_id),
$ilDB->quote(md5($a_user_id . $row->survey_id) . "")
);
}
else
{
$q = sprintf("SELECT * FROM survey_finished WHERE survey_fi = %s AND user_fi = %s",
$ilDB->quote($row->survey_id),
$ilDB->quote($a_user_id)
);
}
$result = $ilDB->query($q);
if ($result->numRows() == 1)
{
$row = $result->fetchRow(DB_FETCHMODE_OBJECT);
$finished = (int)$row->state;
}
}
return $finished;
}
Here is the caller graph for this function:| ilObjSurveyAccess::_lookupOnline | ( | $ | a_obj_id | ) |
get status
Definition at line 264 of file class.ilObjSurveyAccess.php.
References $q, $result, and $row.
Referenced by _checkAccess(), and ilObjSurveyListGUI::getProperties().
{
global $ilDB;
$q = sprintf("SELECT * FROM survey_survey WHERE obj_fi=%s",
$ilDB->quote($a_obj_id)
);
$result = $ilDB->query($q);
if ($result->numRows() == 1) {
$row = $result->fetchRow(DB_FETCHMODE_OBJECT);
}
return $row->status;
}
Here is the caller graph for this function:
1.7.1