/** * 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. * * @param string $a_cmd command (not permission!) * @param string $a_permission permission * @param int $a_ref_id reference id * @param int $a_obj_id object id * @param int $a_user_id user id (if not provided, current user is taken) * * @return boolean true, if everything is ok */ function _checkAccess($a_cmd, $a_permission, $a_ref_id, $a_obj_id, $a_user_id = "") { global $ilUser, $lng, $rbacsystem, $ilAccess; if ($a_user_id == "") { $a_user_id = $ilUser->getId(); } $is_admin = $rbacsystem->checkAccessOfUser($a_user_id, 'write', $a_ref_id); // check "global" online switch if (!self::_lookupOnline($a_obj_id) && !$is_admin) { $ilAccess->addInfoItem(IL_NO_OBJECT_ACCESS, $lng->txt("offline")); return false; } switch ($a_permission) { case "visible": case "read": if (!ilObjSurveyAccess::_lookupCreationComplete($a_obj_id) && !$is_admin) { $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("status_no_permission")); return false; } break; } return true; }
/** * Get item properties * * @return array array of property arrays: * "alert" (boolean) => display as an alert property (usually in red) * "property" (string) => property name * "value" (string) => property value */ function getProperties() { global $lng, $ilUser, $rbacsystem; $props = array(); if (!$rbacsystem->checkAccess("visible,read", $this->ref_id)) { return $props; } include_once "./Modules/Survey/classes/class.ilObjSurveyAccess.php"; if (!ilObjSurveyAccess::_lookupOnline($this->obj_id)) { $props[] = array("alert" => true, "property" => $lng->txt("status"), "value" => $lng->txt("offline")); } else { // BEGIN Usability Distinguish between status and participation if (!ilObjSurveyAccess::_lookupCreationComplete($this->obj_id)) { // no completion $props[] = array("alert" => true, "property" => $lng->txt("svy_participation"), "value" => $lng->txt("svy_warning_survey_not_complete"), 'propertyNameVisible' => false); } else { if ($ilUser->getId() != ANONYMOUS_USER_ID) { $finished = ilObjSurveyAccess::_lookupFinished($this->obj_id, $ilUser->id); // finished if ($finished === 1) { $stat = $this->lng->txt("svy_finished"); } else { if ($finished === 0) { $stat = $this->lng->txt("svy_not_finished"); } else { $stat = $this->lng->txt("svy_not_started"); } } $props[] = array("alert" => false, "property" => $lng->txt("participation"), "value" => $stat, 'propertyNameVisible' => false); } } // END Usability Distinguish between status and participation } return $props; }