/** * 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; }
/** * Show the detailed evaluation * * Show the detailed evaluation * * @access private */ function checkAnonymizedEvaluationAccess() { global $ilUser; if ($this->object->getAnonymize() == 1 && $_SESSION["anon_evaluation_access"] == $_GET["ref_id"]) { return true; } include_once "Modules/Survey/classes/class.ilObjSurveyAccess.php"; if (ilObjSurveyAccess::_hasEvaluationAccess(ilObject::_lookupObjId($_GET["ref_id"]), $ilUser->getId())) { if ($this->object->getAnonymize() == 1) { $_SESSION["anon_evaluation_access"] = $_GET["ref_id"]; } return true; } if ($this->object->getAnonymize() == 1) { // autocode $surveycode = $this->object->getUserAccessCode($ilUser->getId()); if ($this->object->isAnonymizedParticipant($surveycode)) { $_SESSION["anon_evaluation_access"] = $_GET["ref_id"]; return true; } /* try to find code for current (registered) user from existing run if($this->object->findCodeForUser($ilUser->getId())) { $_SESSION["anon_evaluation_access"] = $_GET["ref_id"]; return true; } */ // code needed $this->tpl->setVariable("TABS", ""); $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_svy_svy_evaluation_checkaccess.html", "Modules/Survey"); $this->tpl->setCurrentBlock("adm_content"); $this->tpl->setVariable("AUTHENTICATION_NEEDED", $this->lng->txt("svy_check_evaluation_authentication_needed")); $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this, "checkEvaluationAccess")); $this->tpl->setVariable("EVALUATION_CHECKACCESS_INTRODUCTION", $this->lng->txt("svy_check_evaluation_access_introduction")); $this->tpl->setVariable("VALUE_CHECK", $this->lng->txt("ok")); $this->tpl->setVariable("VALUE_CANCEL", $this->lng->txt("cancel")); $this->tpl->setVariable("TEXT_SURVEY_CODE", $this->lng->txt("survey_code")); $this->tpl->parseCurrentBlock(); } $_SESSION["anon_evaluation_access"] = null; return false; }
function evaluation($details = 0) { global $ilUser; global $rbacsystem; global $ilias; global $ilToolbar; if (!$rbacsystem->checkAccess("read", $_GET["ref_id"])) { ilUtil::sendFailure($this->lng->txt("permission_denied")); return; } $ilToolbar->setFormAction($this->ctrl->getFormAction($this)); include_once "Services/Form/classes/class.ilPropertyFormGUI.php"; $format = new ilSelectInputGUI("", "export_format"); $format->setOptions(array("excel" => $this->lng->txt('exp_type_excel'), "csv" => $this->lng->txt('exp_type_csv'))); $ilToolbar->addInputItem($format); include_once "Services/Form/classes/class.ilPropertyFormGUI.php"; $label = new ilSelectInputGUI("", "export_label"); $label->setOptions(array('label_only' => $this->lng->txt('export_label_only'), 'title_only' => $this->lng->txt('export_title_only'), 'title_label' => $this->lng->txt('export_title_label'))); $ilToolbar->addInputItem($label); if ($details) { $ilToolbar->addFormButton($this->lng->txt("export"), 'exportDetailData'); } else { $ilToolbar->addFormButton($this->lng->txt("export"), 'exportData'); } switch ($this->object->getEvaluationAccess()) { case EVALUATION_ACCESS_OFF: if (!$rbacsystem->checkAccess("write", $_GET["ref_id"])) { ilUtil::sendFailure($this->lng->txt("permission_denied")); return; } break; case EVALUATION_ACCESS_ALL: include_once "./Modules/Survey/classes/class.ilObjSurveyAccess.php"; if (!($rbacsystem->checkAccess("write", $_GET["ref_id"]) || ilObjSurveyAccess::_hasEvaluationAccess($this->object->getId(), $ilUser->getId()))) { ilUtil::sendFailure($this->lng->txt("permission_denied")); return; } break; case EVALUATION_ACCESS_PARTICIPANTS: if ($this->object->getAnonymize() == 1 && $_SESSION["anon_evaluation_access"] != $_GET["ref_id"]) { $this->checkAnonymizedEvaluationAccess(); return; } break; } $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_svy_svy_evaluation.html", "Modules/Survey"); $questions =& $this->object->getSurveyQuestions(); $data = array(); $counter = 1; $last_questionblock_id = null; foreach ($questions as $qdata) { include_once "./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php"; $question_gui = SurveyQuestion::_instanciateQuestionGUI($qdata["question_id"]); $question = $question_gui->object; $c = $question->getCumulatedResultData($this->object->getSurveyId(), $counter); if (is_array($c[0])) { foreach ($c as $a) { array_push($data, $a); } } else { array_push($data, $c); } $counter++; if ($details) { // questionblock title handling if ($qdata["questionblock_id"] && $qdata["questionblock_id"] != $last_questionblock_id) { $qblock = $this->object->getQuestionblock($qdata["questionblock_id"]); if ($qblock["show_blocktitle"]) { $this->tpl->setCurrentBlock("detail_qblock"); $this->tpl->setVariable("BLOCKTITLE", $qdata["questionblock_title"]); $this->tpl->parseCurrentBlock(); } $last_questionblock_id = $qdata["questionblock_id"]; } $detail = $question_gui->getCumulatedResultsDetails($this->object->getSurveyId(), $counter - 1); $this->tpl->setCurrentBlock("detail"); $this->tpl->setVariable("DETAIL", $detail); $this->tpl->parseCurrentBlock(); } } include_once "./Modules/Survey/classes/tables/class.ilSurveyResultsCumulatedTableGUI.php"; $table_gui = new ilSurveyResultsCumulatedTableGUI($this, 'evaluation', $detail); $table_gui->setData($data); $this->tpl->setVariable('CUMULATED', $table_gui->getHTML()); $this->tpl->addCss("./Modules/Survey/templates/default/survey_print.css", "print"); $this->tpl->setVariable('FORMACTION', $this->ctrl->getFormAction($this, 'evaluation')); }
/** * show information screen */ function infoScreen() { global $ilAccess, $ilTabs, $ilUser, $ilToolbar; if (!$this->external_rater_360 && !$ilAccess->checkAccess("visible", "", $this->ref_id)) { $this->ilias->raiseError($this->lng->txt("msg_no_perm_read"), $this->ilias->error_obj->MESSAGE); } $ilTabs->activateTab("info_short"); include_once "./Modules/Survey/classes/class.ilSurveyExecutionGUI.php"; $output_gui =& new ilSurveyExecutionGUI($this->object); include_once "./Services/InfoScreen/classes/class.ilInfoScreenGUI.php"; $info = new ilInfoScreenGUI($this); $info->enablePrivateNotes(); // "active" survey? $canStart = $this->object->canStartSurvey(null, $this->external_rater_360); $showButtons = $canStart["result"]; if (!$showButtons) { if ($canStart["edit_settings"] && $ilAccess->checkAccess("write", "", $this->ref_id)) { $canStart["messages"][] = "<a href=\"" . $this->ctrl->getLinkTarget($this, "properties") . "\">» " . $this->lng->txt("survey_edit_settings") . "</a>"; } ilUtil::sendInfo(implode("<br />", $canStart["messages"])); } $big_button = false; if ($showButtons) { // closing survey? $is_appraisee = false; if ($this->object->get360Mode() && $this->object->isAppraisee($ilUser->getId())) { $info->addSection($this->lng->txt("survey_360_appraisee_info")); $appr_data = $this->object->getAppraiseesData(); $appr_data = $appr_data[$ilUser->getId()]; $info->addProperty($this->lng->txt("survey_360_raters_status_info"), $appr_data["finished"]); if (!$appr_data["closed"]) { include_once "Services/UIComponent/Button/classes/class.ilLinkButton.php"; $button = ilLinkButton::getInstance(); $button->setCaption("survey_360_appraisee_close_action"); $button->setUrl($this->ctrl->getLinkTargetByClass("ilsurveyparticipantsgui", "confirmappraiseeclose")); $close_button_360 = '<div>' . $button->render() . '</div>'; $txt = "survey_360_appraisee_close_action_info"; if ($this->object->get360SkillService()) { $txt .= "_skill"; } $info->addProperty($this->lng->txt("status"), $close_button_360 . $this->lng->txt($txt)); } else { ilDatePresentation::setUseRelativeDates(false); $dt = new ilDateTime($appr_data["closed"], IL_CAL_UNIX); $info->addProperty($this->lng->txt("status"), sprintf($this->lng->txt("survey_360_appraisee_close_action_status"), ilDatePresentation::formatDate($dt))); } $is_appraisee = true; } // handle code // validate incoming $code_input = false; $anonymous_code = $_POST["anonymous_id"]; if ($anonymous_code) { $code_input = true; // if(!$this->object->isUnusedCode($anonymous_code, $ilUser->getId())) if (!$this->object->checkSurveyCode($anonymous_code)) { $anonymous_code = null; } else { // #15860 $this->object->bindSurveyCodeToUser($ilUser->getId(), $anonymous_code); } } if ($anonymous_code) { $_SESSION["anonymous_id"][$this->object->getId()] = $anonymous_code; } else { $anonymous_code = $_SESSION["anonymous_id"][$this->object->getId()]; if ($anonymous_code) { $code_input = true; } } // try to find code for current (registered) user from existing run if ($this->object->getAnonymize() && !$anonymous_code) { $anonymous_code = $this->object->findCodeForUser($ilUser->getId()); } // get existing runs for current user, might generate code $participant_status = $this->object->getUserSurveyExecutionStatus($anonymous_code); if ($participant_status) { $anonymous_code = $participant_status["code"]; $participant_status = $participant_status["runs"]; } // (final) check for proper anonymous code if (!$this->object->isAccessibleWithoutCode() && !$is_appraisee && $code_input && (!$anonymous_code || !$this->object->isAnonymousKey($anonymous_code))) { $anonymous_code = null; ilUtil::sendInfo($this->lng->txt("wrong_survey_code_used")); } // :TODO: really save in session? $_SESSION["anonymous_id"][$this->object->getId()] = $anonymous_code; // code is mandatory and not given yet if (!$is_appraisee && !$anonymous_code && !$this->object->isAccessibleWithoutCode()) { $info->setFormAction($this->ctrl->getFormAction($this, "infoScreen")); $info->addSection($this->lng->txt("anonymization")); $info->addProperty("", $this->lng->txt("anonymize_anonymous_introduction")); $info->addPropertyTextinput($this->lng->txt("enter_anonymous_id"), "anonymous_id", "", 8, "infoScreen", $this->lng->txt("submit"), true); } else { // trunk/default if (!$this->object->get360Mode()) { if ($anonymous_code) { $info->addHiddenElement("anonymous_id", $anonymous_code); } $survey_started = $this->object->isSurveyStarted($ilUser->getId(), $anonymous_code); if ($survey_started === 1) { if ($ilUser->getId() != ANONYMOUS_USER_ID) { if ($this->object->hasViewOwnResults()) { include_once "Services/UIComponent/Button/classes/class.ilLinkButton.php"; $button = ilLinkButton::getInstance(); $button->setCaption("svy_view_own_results"); $button->setUrl($this->ctrl->getLinkTarget($this, "viewUserResults")); $ilToolbar->addButtonInstance($button); } if ($this->object->hasMailOwnResults()) { if ($this->object->hasViewOwnResults()) { $ilToolbar->addSeparator(); } require_once "Services/Form/classes/class.ilTextInputGUI.php"; $mail = new ilTextInputGUI($this->lng->txt("email"), "mail"); $mail->setSize(25); $mail->setValue($ilUser->getEmail()); $ilToolbar->addInputItem($mail, true); $ilToolbar->setFormAction($this->ctrl->getFormAction($this, "mailUserResults")); include_once "Services/UIComponent/Button/classes/class.ilSubmitButton.php"; $button = ilSubmitButton::getInstance(); $button->setCaption("svy_mail_own_results"); $button->setCommand("mailUserResults"); $ilToolbar->addButtonInstance($button); } } ilUtil::sendInfo($this->lng->txt("already_completed_survey")); } elseif ($survey_started === 0) { $big_button = array("resume", $this->lng->txt("resume_survey")); } elseif ($survey_started === FALSE) { $big_button = array("start", $this->lng->txt("start_survey")); } } else { $appr_ids = array(); // use given code (if proper external one) if ($anonymous_code) { $anonymous_id = $this->object->getAnonymousIdByCode($anonymous_code); if ($anonymous_id) { $appr_ids = $this->object->getAppraiseesToRate(0, $anonymous_id); } } // registered user // if an auto-code was generated, we still have to check for the original user id if (!$appr_ids && $ilUser->getId() != ANONYMOUS_USER_ID) { $appr_ids = $this->object->getAppraiseesToRate($ilUser->getId()); } if (sizeof($appr_ids)) { // map existing runs to appraisees $active_appraisees = array(); if ($participant_status) { foreach ($participant_status as $item) { $active_appraisees[$item["appr_id"]] = $item["finished"]; } } $list = array(); foreach ($appr_ids as $appr_id) { if ($this->object->isAppraiseeClosed($appr_id)) { // closed $list[$appr_id] = $this->lng->txt("survey_360_appraisee_is_closed"); } else { if (array_key_exists($appr_id, $active_appraisees)) { // already done if ($active_appraisees[$appr_id]) { $list[$appr_id] = $this->lng->txt("already_completed_survey"); } else { $list[$appr_id] = array("resume", $this->lng->txt("resume_survey")); } } else { // start $list[$appr_id] = array("start", $this->lng->txt("start_survey")); } } } $info->addSection($this->lng->txt("survey_360_rate_other_appraisees")); include_once "Services/User/classes/class.ilUserUtil.php"; foreach ($list as $appr_id => $item) { $appr_name = ilUserUtil::getNamePresentation($appr_id, false, false, "", true); if (!is_array($item)) { $info->addProperty($appr_name, $item); } else { $this->ctrl->setParameter($output_gui, "appr_id", $appr_id); $href = $this->ctrl->getLinkTarget($output_gui, $item[0]); $this->ctrl->setParameter($output_gui, "appr_id", ""); include_once "Services/UIComponent/Button/classes/class.ilLinkButton.php"; $button = ilLinkButton::getInstance(); $button->setCaption($item[1], false); $button->setUrl($href); $big_button_360 = '<div>' . $button->render() . '</div>'; $info->addProperty($appr_name, $big_button_360); } } } else { if (!$is_appraisee) { ilUtil::sendFailure($this->lng->txt("survey_360_no_appraisees")); } } } } if ($this->object->get360Mode() && $this->object->get360SelfAppraisee() && !$this->object->isAppraisee($ilUser->getId()) && $ilUser->getId() != ANONYMOUS_USER_ID) { $link = $this->ctrl->getLinkTargetByClass("ilsurveyparticipantsgui", "addSelfAppraisee"); $link = '<a href="' . $link . '">' . $this->lng->txt("survey_360_add_self_appraisee") . '</a>'; $info->addProperty(" ", $link); } } if ($big_button) { $ilToolbar->setFormAction($this->ctrl->getFormAction($output_gui, "infoScreen")); include_once "Services/UIComponent/Button/classes/class.ilSubmitButton.php"; $button = ilSubmitButton::getInstance(); $button->setCaption($big_button[1], false); $button->setCommand($big_button[0]); $button->setPrimary(true); $ilToolbar->addButtonInstance($button); $ilToolbar->setCloseFormTag(false); $info->setOpenFormTag(false); } /* #12016 else { $info->setFormAction($this->ctrl->getFormAction($output_gui, "infoScreen")); } */ if (strlen($this->object->getIntroduction())) { $introduction = $this->object->getIntroduction(); $info->addSection($this->lng->txt("introduction")); $info->addProperty("", $this->object->prepareTextareaOutput($introduction) . "<br />" . $info->getHiddenToggleButton()); } else { $info->addSection(""); $info->addProperty("", $info->getHiddenToggleButton()); } $info->hideFurtherSections(false); if (!$this->object->get360Mode()) { $info->addSection($this->lng->txt("svy_general_properties")); $info->addProperty($this->lng->txt("survey_results_anonymization"), !$this->object->hasAnonymizedResults() ? $this->lng->txt("survey_results_personalized_info") : $this->lng->txt("survey_results_anonymized_info")); include_once "./Modules/Survey/classes/class.ilObjSurveyAccess.php"; if ($ilAccess->checkAccess("write", "", $this->ref_id) || ilObjSurveyAccess::_hasEvaluationAccess($this->object->getId(), $ilUser->getId())) { $info->addProperty($this->lng->txt("evaluation_access"), $this->lng->txt("evaluation_access_info")); } } $info->addMetaDataSections($this->object->getId(), 0, $this->object->getType()); $this->ctrl->forwardCommand($info); }
/** * adds tabs to tab gui object * * @param object $tabs_gui ilTabsGUI object */ function getTabs(&$tabs_gui) { global $ilAccess, $ilUser, $ilHelp; $ilHelp->setScreenIdComponent("svy"); if (strcmp($this->ctrl->getNextClass(), 'ilrepositorysearchgui') != 0) { switch ($this->ctrl->getCmd()) { case "browseForQuestions": case "browseForQuestionblocks": case "insertQuestions": case "filterQuestions": case "resetFilterQuestions": case "changeDatatype": case "start": case "resume": case "next": case "previous": case "redirectQuestion": case "preview": return; case "evaluation": case "checkEvaluationAccess": case "evaluationdetails": case "evaluationuser": $this->setEvalSubtabs(); break; } } $hidden_tabs = array(); $template = $this->object->getTemplate(); if ($template) { include_once "Services/Administration/classes/class.ilSettingsTemplate.php"; $template = new ilSettingsTemplate($template); $hidden_tabs = $template->getHiddenTabs(); } // questions if ($ilAccess->checkAccess("write", "", $this->ref_id)) { $force_active = $_GET["up"] != "" || $_GET["down"] != "" ? true : false; $cmd = $this->ctrl->getLinkTargetByClass("ilsurveypagegui", "renderPage"); // $cmd = $this->ctrl->getLinkTarget($this, "questions"); $tabs_gui->addTarget("survey_questions", $cmd, array("questions", "browseForQuestions", "createQuestion", "filterQuestions", "resetFilterQuestions", "changeDatatype", "insertQuestions", "removeQuestions", "cancelRemoveQuestions", "confirmRemoveQuestions", "defineQuestionblock", "saveDefineQuestionblock", "cancelDefineQuestionblock", "unfoldQuestionblock", "moveQuestions", "insertQuestionsBefore", "insertQuestionsAfter", "saveObligatory", "addHeading", "saveHeading", "cancelHeading", "editHeading", "confirmRemoveHeading", "cancelRemoveHeading", "printView", "renderPage", "addQuestionToolbarForm", "deleteBlock", "movePageForm", "copyQuestionsToPool"), "", "", $force_active); } if ($ilAccess->checkAccess("visible", "", $this->ref_id)) { $tabs_gui->addTarget("info_short", $this->ctrl->getLinkTarget($this, 'infoScreen'), array("infoScreen", "showSummary")); } // properties if ($ilAccess->checkAccess("write", "", $this->ref_id)) { $force_active = $this->ctrl->getCmd() == "" ? true : false; $tabs_gui->addTarget("settings", $this->ctrl->getLinkTarget($this, 'properties'), array("properties", "save", "cancel", 'saveProperties'), "", "", $force_active); } // questions if ($ilAccess->checkAccess("write", "", $this->ref_id) && !in_array("constraints", $hidden_tabs)) { // constraints $tabs_gui->addTarget("constraints", $this->ctrl->getLinkTarget($this, "constraints"), array("constraints", "constraintStep1", "constraintStep2", "constraintStep3", "constraintsAdd", "createConstraints", "editPrecondition"), ""); } // #6969 if ($ilAccess->checkAccess("invite", "", $this->ref_id) && !in_array("invitation", $hidden_tabs)) { // invite $tabs_gui->addTarget("invitation", $this->ctrl->getLinkTarget($this, 'invite'), array("invite", "saveInvitationStatus", "inviteUserGroup", "disinviteUserGroup"), ""); } if ($ilAccess->checkAccess("write", "", $this->ref_id)) { // maintenance $tabs_gui->addTarget("maintenance", $this->ctrl->getLinkTarget($this, 'maintenance'), array("maintenance", "deleteAllUserData"), ""); if ($this->object->getAnonymize() == 1 || $this->object->isAccessibleWithCodeForAll()) { // code $tabs_gui->addTarget("codes", $this->ctrl->getLinkTarget($this, 'codes'), array("codes", "exportCodes", 'codesMail', 'saveMailTableFields', 'importExternalMailRecipients', 'mailCodes', 'sendCodesMail', 'importExternalRecipientsFromFile', 'importExternalRecipientsFromText', 'importExternalRecipientsFromDataset', 'insertSavedMessage', 'deleteSavedMessage'), ""); } } include_once "./Modules/Survey/classes/class.ilObjSurveyAccess.php"; if ($ilAccess->checkAccess("write", "", $this->ref_id) || ilObjSurveyAccess::_hasEvaluationAccess($this->object->getId(), $ilUser->getId())) { // evaluation $tabs_gui->addTarget("svy_evaluation", $this->ctrl->getLinkTargetByClass("ilsurveyevaluationgui", "evaluation"), array("evaluation", "checkEvaluationAccess", "evaluationdetails", "evaluationuser"), ""); } if ($ilAccess->checkAccess("write", "", $this->ref_id)) { if (!in_array("meta_data", $hidden_tabs)) { // meta data $tabs_gui->addTarget("meta_data", $this->ctrl->getLinkTargetByClass('ilmdeditorgui', 'listSection'), "", "ilmdeditorgui"); } if (!in_array("export", $hidden_tabs)) { // export $tabs_gui->addTarget("export", $this->ctrl->getLinkTarget($this, 'export'), array("export", "createExportFile", "confirmDeleteExportFile", "downloadExportFile"), ""); } } if ($ilAccess->checkAccess("edit_permission", "", $this->ref_id)) { // permissions $tabs_gui->addTarget("perm_settings", $this->ctrl->getLinkTargetByClass(array(get_class($this), 'ilpermissiongui'), "perm"), array("perm", "info", "owner"), 'ilpermissiongui'); } }