00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 require_once "./survey/classes/class.SurveyNominalQuestionGUI.php";
00025 require_once "./survey/classes/class.SurveyTextQuestionGUI.php";
00026 require_once "./survey/classes/class.SurveyMetricQuestionGUI.php";
00027 require_once "./survey/classes/class.SurveyOrdinalQuestionGUI.php";
00028 require_once "./classes/class.ilObjectGUI.php";
00029 require_once "./classes/class.ilMetaDataGUI.php";
00030
00044 class ilObjSurveyQuestionPoolGUI extends ilObjectGUI
00045 {
00046 var $defaultscript;
00047
00052 function ilObjSurveyQuestionPoolGUI($a_data, $a_id, $a_call_by_reference = true, $a_prepare_output = true)
00053 {
00054 global $lng, $ilCtrl;
00055
00056 $this->type = "spl";
00057 $lng->loadLanguageModule("survey");
00058 $this->ilObjectGUI($a_data,$a_id,$a_call_by_reference, false);
00059 $this->ctrl =& $ilCtrl;
00060 $this->ctrl->saveParameter($this, array("ref_id", "calling_survey", "new_for_survey"));
00061 $this->ilObjectGUI($a_data,$a_id,$a_call_by_reference, false);
00062 if (!defined("ILIAS_MODULE"))
00063 {
00064 $this->setTabTargetScript("adm_object.php");
00065 $this->defaultscript = "adm_object.php";
00066 }
00067 else
00068 {
00069 $this->setTabTargetScript("questionpool.php");
00070 $this->defaultscript = "questionpool.php";
00071 }
00072 if ($a_prepare_output) {
00073 $this->prepareOutput();
00074 }
00075 }
00076
00081 function saveObject()
00082 {
00083 global $rbacadmin;
00084
00085
00086 $newObj = parent::saveObject();
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097 sendInfo($this->lng->txt("object_added"),true);
00098
00099 $returnlocation = "questionpool.php";
00100 if (!defined("ILIAS_MODULE"))
00101 {
00102 $returnlocation = "adm_object.php";
00103 }
00104 ilUtil::redirect($this->getReturnLocation("save","$returnlocation?".$this->link_params));
00105 exit();
00106 }
00107
00113 function getCallingScript()
00114 {
00115 return "questionpool.php";
00116 }
00117
00118 function getAddParameter()
00119 {
00120 return "?ref_id=" . $_GET["ref_id"] . "&cmd=" . $_GET["cmd"];
00121 }
00122
00131 function cancelAction($question_id = "")
00132 {
00133 $this->ctrl->redirect($this, "questions");
00134 }
00135
00143 function copyObject()
00144 {
00145
00146 $checked_questions = array();
00147 foreach ($_POST as $key => $value) {
00148 if (preg_match("/cb_(\d+)/", $key, $matches)) {
00149 array_push($checked_questions, $matches[1]);
00150 }
00151 }
00152
00153
00154 if (count($checked_questions) > 0) {
00155 $_SESSION["spl_copied_questions"] = join($checked_questions, ",");
00156 } elseif (count($checked_questions) == 0) {
00157 sendInfo($this->lng->txt("qpl_copy_select_none"), true);
00158 $_SESSION["spl_copied_questions"] = "";
00159 }
00160 $this->ctrl->redirect($this, "questions");
00161 }
00162
00170 function duplicateObject()
00171 {
00172
00173 $checked_questions = array();
00174 foreach ($_POST as $key => $value) {
00175 if (preg_match("/cb_(\d+)/", $key, $matches)) {
00176 array_push($checked_questions, $matches[1]);
00177 }
00178 }
00179
00180 if (count($checked_questions) > 0) {
00181 foreach ($checked_questions as $key => $value) {
00182 $this->object->duplicateQuestion($value);
00183 }
00184 } elseif (count($checked_questions) == 0) {
00185 sendInfo($this->lng->txt("qpl_duplicate_select_none"), true);
00186 }
00187 $this->ctrl->redirect($this, "questions");
00188 }
00189
00193 function exportQuestionsObject()
00194 {
00195
00196 $checked_questions = array();
00197 foreach ($_POST as $key => $value) {
00198 if (preg_match("/cb_(\d+)/", $key, $matches)) {
00199 array_push($checked_questions, $matches[1]);
00200 }
00201 }
00202
00203
00204 if (count($checked_questions) > 0)
00205 {
00206 $this->createExportFileObject($checked_questions);
00207 }
00208 else
00209 {
00210 sendInfo($this->lng->txt("qpl_export_select_none"), true);
00211 $this->ctrl->redirect($this, "questions");
00212 }
00213 }
00214
00222 function deleteQuestionsObject()
00223 {
00224 global $rbacsystem;
00225
00226 sendInfo();
00227
00228 $checked_questions = array();
00229 foreach ($_POST as $key => $value) {
00230 if (preg_match("/cb_(\d+)/", $key, $matches)) {
00231 array_push($checked_questions, $matches[1]);
00232 }
00233 }
00234
00235 if (count($checked_questions) > 0) {
00236 if ($rbacsystem->checkAccess('write', $this->ref_id)) {
00237 sendInfo($this->lng->txt("qpl_confirm_delete_questions"));
00238 } else {
00239 sendInfo($this->lng->txt("qpl_delete_rbac_error"), true);
00240 $this->ctrl->redirect($this, "questions");
00241 return;
00242 }
00243 } elseif (count($checked_questions) == 0) {
00244 sendInfo($this->lng->txt("qpl_delete_select_none"), true);
00245 $this->ctrl->redirect($this, "questions");
00246 return;
00247 }
00248 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_svy_qpl_confirm_delete_questions.html", true);
00249 $whereclause = join($checked_questions, " OR survey_question.question_id = ");
00250 $whereclause = " AND (survey_question.question_id = " . $whereclause . ")";
00251 $query = "SELECT survey_question.*, survey_questiontype.type_tag FROM survey_question, survey_questiontype WHERE survey_question.questiontype_fi = survey_questiontype.questiontype_id$whereclause ORDER BY survey_question.title";
00252 $query_result = $this->ilias->db->query($query);
00253 $colors = array("tblrow1", "tblrow2");
00254 $counter = 0;
00255 if ($query_result->numRows() > 0)
00256 {
00257 while ($data = $query_result->fetchRow(DB_FETCHMODE_OBJECT))
00258 {
00259 if (in_array($data->question_id, $checked_questions))
00260 {
00261 $this->tpl->setCurrentBlock("row");
00262 $this->tpl->setVariable("COLOR_CLASS", $colors[$counter % 2]);
00263 $this->tpl->setVariable("TXT_TITLE", $data->title);
00264 $this->tpl->setVariable("TXT_DESCRIPTION", $data->description);
00265 $this->tpl->setVariable("TXT_TYPE", $this->lng->txt($data->type_tag));
00266 $this->tpl->parseCurrentBlock();
00267 $counter++;
00268 }
00269 }
00270 }
00271 foreach ($checked_questions as $id)
00272 {
00273 $this->tpl->setCurrentBlock("hidden");
00274 $this->tpl->setVariable("HIDDEN_NAME", "id_$id");
00275 $this->tpl->setVariable("HIDDEN_VALUE", "1");
00276 $this->tpl->parseCurrentBlock();
00277 }
00278
00279 $this->tpl->setCurrentBlock("adm_content");
00280 $this->tpl->setVariable("TXT_TITLE", $this->lng->txt("title"));
00281 $this->tpl->setVariable("TXT_DESCRIPTION", $this->lng->txt("description"));
00282 $this->tpl->setVariable("TXT_TYPE", $this->lng->txt("question_type"));
00283 $this->tpl->setVariable("BTN_CONFIRM", $this->lng->txt("confirm"));
00284 $this->tpl->setVariable("BTN_CANCEL", $this->lng->txt("cancel"));
00285 $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
00286 $this->tpl->parseCurrentBlock();
00287 }
00288
00292 function confirmDeleteQuestionsObject()
00293 {
00294
00295 sendInfo($this->lng->txt("qpl_questions_deleted"), true);
00296 $checked_questions = array();
00297 foreach ($_POST as $key => $value) {
00298 if (preg_match("/id_(\d+)/", $key, $matches)) {
00299 array_push($checked_questions, $matches[1]);
00300 }
00301 }
00302
00303 foreach ($checked_questions as $key => $value) {
00304 $this->object->removeQuestion($value);
00305 }
00306 $this->ctrl->redirect($this, "questions");
00307 }
00308
00312 function cancelDeleteQuestionsObject()
00313 {
00314
00315 $this->ctrl->redirect($this, "questions");
00316 }
00317
00325 function pasteObject()
00326 {
00327 sendInfo();
00328
00329
00330 $checked_questions = array();
00331 foreach ($_POST as $key => $value) {
00332 if (preg_match("/cb_(\d+)/", $key, $matches)) {
00333 array_push($checked_questions, $matches[1]);
00334 }
00335 }
00336
00337
00338 if (strcmp($_SESSION["spl_copied_questions"], "") != 0)
00339 {
00340 $copied_questions = split("/,/", $_SESSION["spl_copied_questions"]);
00341 sendInfo($this->lng->txt("qpl_past_questions_confirmation"));
00342 }
00343 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_svy_qpl_confirm_paste_questions.html", true);
00344 $questions_info =& $this->object->getQuestionsInfo($copied_questions);
00345 $colors = array("tblrow1", "tblrow2");
00346 $counter = 0;
00347 foreach ($questions_info as $data)
00348 {
00349 $this->tpl->setCurrentBlock("row");
00350 $this->tpl->setVariable("COLOR_CLASS", $colors[$counter % 2]);
00351 $this->tpl->setVariable("TXT_TITLE", $data->title);
00352 $this->tpl->setVariable("TXT_DESCRIPTION", $data->description);
00353 $this->tpl->setVariable("TXT_TYPE", $this->lng->txt($data->type_tag));
00354 $this->tpl->parseCurrentBlock();
00355 $counter++;
00356 }
00357 foreach ($questions_info as $data)
00358 {
00359 $this->tpl->setCurrentBlock("hidden");
00360 $this->tpl->setVariable("HIDDEN_NAME", "id_$data->question_id");
00361 $this->tpl->setVariable("HIDDEN_VALUE", $data->question_id);
00362 $this->tpl->parseCurrentBlock();
00363 }
00364
00365 $this->tpl->setCurrentBlock("adm_content");
00366 $this->tpl->setVariable("TXT_TITLE", $this->lng->txt("title"));
00367 $this->tpl->setVariable("TXT_DESCRIPTION", $this->lng->txt("description"));
00368 $this->tpl->setVariable("TXT_TYPE", $this->lng->txt("question_type"));
00369 $this->tpl->setVariable("BTN_CONFIRM", $this->lng->txt("confirm"));
00370 $this->tpl->setVariable("BTN_CANCEL", $this->lng->txt("cancel"));
00371 $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
00372 $this->tpl->parseCurrentBlock();
00373 }
00374
00378 function confirmPasteQuestionsObject()
00379 {
00380
00381 sendInfo($this->lng->txt("qpl_questions_pasted"), true);
00382 $checked_questions = array();
00383 foreach ($_POST as $key => $value) {
00384 if (preg_match("/id_(\d+)/", $key, $matches)) {
00385 array_push($checked_questions, $matches[1]);
00386 }
00387 }
00388 foreach ($checked_questions as $key => $value) {
00389 $this->object->paste($value);
00390 }
00391
00392 $this->ctrl->redirect($this, "questions");
00393 }
00394
00398 function cancelPasteQuestionsObject()
00399 {
00400
00401 $this->ctrl->redirect($this, "questions");
00402 }
00403
00407 function cancelDeletePhraseObject()
00408 {
00409 $this->ctrl->redirect($this, "phrases");
00410 }
00411
00415 function confirmDeletePhraseObject()
00416 {
00417 $phrases = array();
00418 foreach ($_POST as $key => $value)
00419 {
00420 if (preg_match("/phrase_(\d+)/", $key, $matches))
00421 {
00422 array_push($phrases, $matches[1]);
00423 }
00424 }
00425 $this->object->deletePhrases($phrases);
00426 sendInfo($this->lng->txt("qpl_phrases_deleted"), true);
00427 $this->ctrl->redirect($this, "phrases");
00428 }
00429
00438 function deletePhrasesForm($checked_phrases)
00439 {
00440 sendInfo();
00441 $ordinal = new SurveyOrdinalQuestion();
00442 $phrases =& $ordinal->getAvailablePhrases(1);
00443 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_svy_qpl_confirm_delete_phrases.html", true);
00444 $colors = array("tblrow1", "tblrow2");
00445 $counter = 0;
00446 foreach ($checked_phrases as $id)
00447 {
00448 $this->tpl->setCurrentBlock("row");
00449 $this->tpl->setVariable("COLOR_CLASS", $colors[$counter++ % 2]);
00450 $this->tpl->setVariable("PHRASE_TITLE", $phrases[$id]["title"]);
00451 $categories =& $ordinal->getCategoriesForPhrase($id);
00452 $this->tpl->setVariable("PHRASE_CONTENT", join($categories, ", "));
00453 $this->tpl->parseCurrentBlock();
00454 $this->tpl->setCurrentBlock("hidden");
00455 $this->tpl->setVariable("HIDDEN_NAME", "phrase_$id");
00456 $this->tpl->setVariable("HIDDEN_VALUE", "1");
00457 $this->tpl->parseCurrentBlock();
00458 }
00459
00460 $this->tpl->setCurrentBlock("adm_content");
00461 $this->tpl->setVariable("TEXT_PHRASE_TITLE", $this->lng->txt("phrase"));
00462 $this->tpl->setVariable("TEXT_PHRASE_CONTENT", $this->lng->txt("categories"));
00463 $this->tpl->setVariable("BTN_CONFIRM", $this->lng->txt("confirm"));
00464 $this->tpl->setVariable("BTN_CANCEL", $this->lng->txt("cancel"));
00465 $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
00466 $this->tpl->parseCurrentBlock();
00467 }
00468
00476 function deletePhraseObject()
00477 {
00478 sendInfo();
00479
00480 $checked_phrases = array();
00481 foreach ($_POST as $key => $value)
00482 {
00483 if (preg_match("/phrase_(\d+)/", $key, $matches))
00484 {
00485 array_push($checked_phrases, $matches[1]);
00486 }
00487 }
00488 if (count($checked_phrases))
00489 {
00490 sendInfo($this->lng->txt("qpl_confirm_delete_phrases"));
00491 $this->deletePhrasesForm($checked_phrases);
00492 return;
00493 }
00494 else
00495 {
00496 sendInfo($this->lng->txt("qpl_delete_phrase_select_none"));
00497 $this->phrasesObject();
00498 return;
00499 }
00500
00501 $this->tpl->setCurrentBlock("obligatory");
00502 $this->tpl->setVariable("TEXT_OBLIGATORY", $this->lng->txt("obligatory"));
00503 $this->tpl->setVariable("CHECKED_OBLIGATORY", " checked=\"checked\"");
00504 $this->tpl->parseCurrentBlock();
00505 $this->tpl->setCurrentBlock("adm_content");
00506 $this->tpl->setVariable("DEFINE_QUESTIONBLOCK_HEADING", $this->lng->txt("define_questionblock"));
00507 $this->tpl->setVariable("TEXT_TITLE", $this->lng->txt("title"));
00508 $this->tpl->setVariable("TXT_REQUIRED_FLD", $this->lng->txt("required_field"));
00509 $this->tpl->setVariable("SAVE", $this->lng->txt("save"));
00510 $this->tpl->setVariable("CANCEL", $this->lng->txt("cancel"));
00511 $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
00512 $this->tpl->parseCurrentBlock();
00513 }
00514
00520 function phrasesObject()
00521 {
00522 global $rbacsystem;
00523
00524 if ($rbacsystem->checkAccess("write", $this->object->getRefId()))
00525 {
00526 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_svy_qpl_phrases.html", true);
00527 $ordinal = new SurveyOrdinalQuestion();
00528 $phrases =& $ordinal->getAvailablePhrases(1);
00529 if (count($phrases))
00530 {
00531 $colors = array("tblrow1", "tblrow2");
00532 $counter = 0;
00533 foreach ($phrases as $phrase_id => $phrase_array)
00534 {
00535 $this->tpl->setCurrentBlock("phraserow");
00536 $this->tpl->setVariable("PHRASE_ID", $phrase_id);
00537 $this->tpl->setVariable("COLOR_CLASS", $colors[$counter++ % 2]);
00538 $this->tpl->setVariable("PHRASE_TITLE", $phrase_array["title"]);
00539 $categories =& $ordinal->getCategoriesForPhrase($phrase_id);
00540 $this->tpl->setVariable("PHRASE_CONTENT", join($categories, ", "));
00541 $this->tpl->parseCurrentBlock();
00542 }
00543 $this->tpl->setCurrentBlock("Footer");
00544 $this->tpl->setVariable("ARROW", "<img src=\"" . ilUtil::getImagePath("arrow_downright.gif") . "\" alt=\"\">");
00545 $this->tpl->setVariable("TEXT_DELETE", $this->lng->txt("delete"));
00546 $this->tpl->parseCurrentBlock();
00547 }
00548 else
00549 {
00550 $this->tpl->setCurrentBlock("Emptytable");
00551 $this->tpl->setVariable("TEXT_EMPTYTABLE", $this->lng->txt("no_user_phrases_defined"));
00552 $this->tpl->parseCurrentBlock();
00553 }
00554 $this->tpl->setCurrentBlock("adm_content");
00555 $this->tpl->setVariable("INTRODUCTION_MANAGE_PHRASES", $this->lng->txt("introduction_manage_phrases"));
00556 $this->tpl->setVariable("TEXT_PHRASE_TITLE", $this->lng->txt("phrase"));
00557 $this->tpl->setVariable("TEXT_PHRASE_CONTENT", $this->lng->txt("categories"));
00558 $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
00559 $this->tpl->parseCurrentBlock();
00560 }
00561 else
00562 {
00563 sendInfo($this->lng->txt("cannot_manage_phrases"));
00564 }
00565 }
00566
00570 function importQuestionsObject()
00571 {
00572 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_svy_import_question.html", true);
00573 $this->tpl->setCurrentBlock("adm_content");
00574 $this->tpl->setVariable("TEXT_IMPORT_QUESTION", $this->lng->txt("import_question"));
00575 $this->tpl->setVariable("TEXT_SELECT_FILE", $this->lng->txt("select_file"));
00576 $this->tpl->setVariable("TEXT_UPLOAD", $this->lng->txt("upload"));
00577 $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
00578 $this->tpl->parseCurrentBlock();
00579 }
00580
00584 function uploadQuestionsObject()
00585 {
00586
00587 $source = $_FILES["qtidoc"]["tmp_name"];
00588 $error = 0;
00589 if (($source == 'none') || (!$source) || $_FILES["qtidoc"]["error"] > UPLOAD_ERR_OK)
00590 {
00591
00592 $error = 1;
00593 }
00594
00595 if (strcmp($_FILES["qtidoc"]["type"], "text/xml") != 0)
00596 {
00597
00598 $error = 1;
00599 }
00600 if (!$error)
00601 {
00602
00603
00604 $this->object->createImportDirectory();
00605
00606
00607 $full_path = $this->object->getImportDirectory()."/".$_FILES["qtidoc"]["name"];
00608
00609 ilUtil::moveUploadedFile($_FILES["qtidoc"]["tmp_name"],
00610 $_FILES["qtidoc"]["name"], $full_path);
00611
00612 $source = $full_path;
00613
00614 $fh = fopen($source, "r") or die("");
00615 $xml = fread($fh, filesize($source));
00616 fclose($fh) or die("");
00617 unlink($source);
00618 if (preg_match_all("/(<item[^>]*>.*?<\/item>)/si", $xml, $matches))
00619 {
00620 foreach ($matches[1] as $index => $item)
00621 {
00622 $question = "";
00623 if (preg_match("/<qticomment>Questiontype\=(.*?)<\/qticomment>/is", $item, $questiontype))
00624 {
00625 switch ($questiontype[1])
00626 {
00627 case NOMINAL_QUESTION_IDENTIFIER:
00628 $question = new SurveyNominalQuestion();
00629 break;
00630 case ORDINAL_QUESTION_IDENTIFIER:
00631 $question = new SurveyOrdinalQuestion();
00632 break;
00633 case METRIC_QUESTION_IDENTIFIER:
00634 $question = new SurveyMetricQuestion();
00635 break;
00636 case TEXT_QUESTION_IDENTIFIER:
00637 $question = new SurveyTextQuestion();
00638 break;
00639 }
00640 if ($question)
00641 {
00642 $question->setObjId($this->object->getId());
00643 if ($question->from_xml("<questestinterop>$item</questestinterop>"))
00644 {
00645 $question->saveToDb();
00646 }
00647 else
00648 {
00649 $this->ilias->raiseError($this->lng->txt("error_importing_question"), $this->ilias->error_obj->MESSAGE);
00650 }
00651 }
00652 }
00653 }
00654 }
00655 }
00656 $this->ctrl->redirect($this, "questions");
00657 }
00658
00659 function filterObject()
00660 {
00661 $this->questionsObject();
00662 }
00663
00664 function resetObject()
00665 {
00666 $this->questionsObject();
00667 }
00668
00673 function questionsObject()
00674 {
00675 global $rbacsystem;
00676
00677 $add_parameter = $this->getAddParameter();
00678
00679 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_svy_qpl_questions.html", true);
00680 if ($rbacsystem->checkAccess('write', $this->ref_id)) {
00681 $this->tpl->addBlockFile("CREATE_QUESTION", "create_question", "tpl.il_svy_qpl_create_new_question.html", true);
00682 $this->tpl->addBlockFile("A_BUTTONS", "a_buttons", "tpl.il_svy_qpl_action_buttons.html", true);
00683 }
00684 $this->tpl->addBlockFile("FILTER_QUESTION_MANAGER", "filter_questions", "tpl.il_svy_qpl_filter_questions.html", true);
00685
00686
00687 $filter_fields = array(
00688 "title" => $this->lng->txt("title"),
00689 "description" => $this->lng->txt("description"),
00690 "author" => $this->lng->txt("author"),
00691 );
00692 $this->tpl->setCurrentBlock("filterrow");
00693 foreach ($filter_fields as $key => $value) {
00694 $this->tpl->setVariable("VALUE_FILTER_TYPE", "$key");
00695 $this->tpl->setVariable("NAME_FILTER_TYPE", "$value");
00696 if (!$_POST["cmd"]["reset"]) {
00697 if (strcmp($_POST["sel_filter_type"], $key) == 0) {
00698 $this->tpl->setVariable("VALUE_FILTER_SELECTED", " selected=\"selected\"");
00699 }
00700 }
00701 $this->tpl->parseCurrentBlock();
00702 }
00703
00704 $this->tpl->setCurrentBlock("filter_questions");
00705 $this->tpl->setVariable("FILTER_TEXT", $this->lng->txt("filter"));
00706 $this->tpl->setVariable("TEXT_FILTER_BY", $this->lng->txt("by"));
00707 if (!$_POST["cmd"]["reset"]) {
00708 $this->tpl->setVariable("VALUE_FILTER_TEXT", $_POST["filter_text"]);
00709 }
00710 $this->tpl->setVariable("VALUE_SUBMIT_FILTER", $this->lng->txt("set_filter"));
00711 $this->tpl->setVariable("VALUE_RESET_FILTER", $this->lng->txt("reset_filter"));
00712 $this->tpl->parseCurrentBlock();
00713
00714
00715 if ($rbacsystem->checkAccess('write', $this->ref_id)) {
00716 $this->tpl->setCurrentBlock("standard");
00717 $this->tpl->setVariable("DELETE", $this->lng->txt("delete"));
00718 $this->tpl->setVariable("DUPLICATE", $this->lng->txt("duplicate"));
00719 $this->tpl->setVariable("COPY", $this->lng->txt("copy"));
00720 $this->tpl->setVariable("EXPORT", $this->lng->txt("export"));
00721 $this->tpl->setVariable("PASTE", $this->lng->txt("paste"));
00722 if (strcmp($_SESSION["spl_copied_questions"], "") == 0)
00723 {
00724 $this->tpl->setVariable("PASTE_DISABLED", " disabled=\"disabled\"");
00725 }
00726 $this->tpl->setVariable("QUESTIONBLOCK", $this->lng->txt("define_questionblock"));
00727 $this->tpl->setVariable("UNFOLD", $this->lng->txt("unfold"));
00728 $this->tpl->parseCurrentBlock();
00729 $this->tpl->setCurrentBlock("Footer");
00730 $this->tpl->setVariable("ARROW", "<img src=\"" . ilUtil::getImagePath("arrow_downright.gif") . "\" alt=\"\">");
00731 $this->tpl->parseCurrentBlock();
00732 }
00733
00734 if ($_POST["cmd"]["reset"])
00735 {
00736 $_POST["filter_text"] = "";
00737 }
00738 $startrow = 0;
00739 if ($_GET["prevrow"])
00740 {
00741 $startrow = $_GET["prevrow"];
00742 }
00743 if ($_GET["nextrow"])
00744 {
00745 $startrow = $_GET["nextrow"];
00746 }
00747 if ($_GET["startrow"])
00748 {
00749 $startrow = $_GET["startrow"];
00750 }
00751 if (!$_GET["sort"])
00752 {
00753
00754 $_GET["sort"] = array("title" => "ASC");
00755 }
00756 $table = $this->object->getQuestionsTable($_GET["sort"], $_POST["filter_text"], $_POST["sel_filter_type"], $startrow);
00757 $colors = array("tblrow1", "tblrow2");
00758 $counter = 0;
00759 $last_questionblock_id = 0;
00760 $editable = $rbacsystem->checkAccess('write', $this->ref_id);
00761 foreach ($table["rows"] as $data)
00762 {
00763 $this->tpl->setCurrentBlock("checkable");
00764 $this->tpl->setVariable("QUESTION_ID", $data["question_id"]);
00765 $this->tpl->parseCurrentBlock();
00766 if ($data["complete"] == 0)
00767 {
00768 $this->tpl->setCurrentBlock("qpl_warning");
00769 $this->tpl->setVariable("IMAGE_WARNING", ilUtil::getImagePath("warning.png"));
00770 $this->tpl->setVariable("ALT_WARNING", $this->lng->txt("warning_question_not_complete"));
00771 $this->tpl->setVariable("TITLE_WARNING", $this->lng->txt("warning_question_not_complete"));
00772 $this->tpl->parseCurrentBlock();
00773 }
00774 $this->tpl->setCurrentBlock("QTab");
00775
00776 $class = strtolower(SurveyQuestionGUI::_getGUIClassNameForId($data["question_id"]));
00777 $this->ctrl->setParameterByClass($class, "q_id", $data["question_id"]);
00778 $sel_question_types = "";
00779 switch ($class)
00780 {
00781 case "surveynominalquestiongui":
00782 $sel_question_types = "qt_nominal";
00783 break;
00784 case "surveyordinalquestiongui":
00785 $sel_question_types = "qt_ordinal";
00786 break;
00787 case "surveymetricquestiongui":
00788 $sel_question_types = "qt_metric";
00789 break;
00790 case "surveytextquestiongui":
00791 $sel_question_types = "qt_text";
00792 break;
00793 }
00794 $this->ctrl->setParameterByClass($class, "sel_question_types", $sel_question_types);
00795 if ($editable)
00796 {
00797 $this->tpl->setVariable("EDIT", "[<a href=\"" . $this->ctrl->getLinkTargetByClass($class, "editQuestion") . "\">" . $this->lng->txt("edit") . "</a>]");
00798 }
00799 $this->tpl->setVariable("QUESTION_TITLE", "<strong>" . $data["title"] . "</strong>");
00800
00801 $this->tpl->setVariable("PREVIEW", "[<a href=\"" . $this->ctrl->getLinkTargetByClass($class, "preview") . "\">" . $this->lng->txt("preview") . "</a>]");
00802 $this->tpl->setVariable("QUESTION_DESCRIPTION", $data["description"]);
00803 $this->tpl->setVariable("QUESTION_PREVIEW", $this->lng->txt("preview"));
00804 $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt($data["type_tag"]));
00805 $this->tpl->setVariable("QUESTION_AUTHOR", $data["author"]);
00806 $this->tpl->setVariable("QUESTION_CREATED", ilFormat::formatDate(ilFormat::ftimestamp2dateDB($data["created"]), "date"));
00807 $this->tpl->setVariable("QUESTION_UPDATED", ilFormat::formatDate(ilFormat::ftimestamp2dateDB($data["TIMESTAMP"]), "date"));
00808 $this->tpl->setVariable("COLOR_CLASS", $colors[$counter % 2]);
00809 $this->tpl->parseCurrentBlock();
00810 $counter++;
00811 }
00812
00813 if ($table["rowcount"] > count($table["rows"]))
00814 {
00815 $nextstep = $table["nextrow"] + $table["step"];
00816 if ($nextstep > $table["rowcount"])
00817 {
00818 $nextstep = $table["rowcount"];
00819 }
00820 $sort = "";
00821 if (is_array($_GET["sort"]))
00822 {
00823 $key = key($_GET["sort"]);
00824 $sort = "&sort[$key]=" . $_GET["sort"]["$key"];
00825 }
00826 $counter = 1;
00827 for ($i = 0; $i < $table["rowcount"]; $i += $table["step"])
00828 {
00829 $this->tpl->setCurrentBlock("pages");
00830 if ($table["startrow"] == $i)
00831 {
00832 $this->tpl->setVariable("PAGE_NUMBER", "<span class=\"inactivepage\">$counter</span>");
00833 }
00834 else
00835 {
00836 $this->tpl->setVariable("PAGE_NUMBER", "<a href=\"" . $this->ctrl->getFormAction($this) . "$sort&nextrow=$i" . "\">$counter</a>");
00837 }
00838 $this->tpl->parseCurrentBlock();
00839 $counter++;
00840 }
00841 $this->tpl->setCurrentBlock("navigation_bottom");
00842 $this->tpl->setVariable("TEXT_ITEM", $this->lng->txt("item"));
00843 $this->tpl->setVariable("TEXT_ITEM_START", $table["startrow"] + 1);
00844 $end = $table["startrow"] + $table["step"];
00845 if ($end > $table["rowcount"])
00846 {
00847 $end = $table["rowcount"];
00848 }
00849 $this->tpl->setVariable("TEXT_ITEM_END", $end);
00850 $this->tpl->setVariable("TEXT_OF", strtolower($this->lng->txt("of")));
00851 $this->tpl->setVariable("TEXT_ITEM_COUNT", $table["rowcount"]);
00852 $this->tpl->setVariable("TEXT_PREVIOUS", $this->lng->txt("previous"));
00853 $this->tpl->setVariable("TEXT_NEXT", $this->lng->txt("next"));
00854 $this->tpl->setVariable("HREF_PREV_ROWS", $this->ctrl->getFormAction($this) . "$sort&prevrow=" . $table["prevrow"]);
00855 $this->tpl->setVariable("HREF_NEXT_ROWS", $this->ctrl->getFormAction($this) . "$sort&nextrow=" . $table["nextrow"]);
00856 $this->tpl->parseCurrentBlock();
00857 }
00858
00859
00860 if ($counter == 0) {
00861 $this->tpl->setCurrentBlock("Emptytable");
00862 $this->tpl->setVariable("TEXT_EMPTYTABLE", $this->lng->txt("no_questions_available"));
00863 $this->tpl->parseCurrentBlock();
00864 }
00865
00866 if ($rbacsystem->checkAccess('write', $this->ref_id)) {
00867
00868 $this->tpl->setCurrentBlock("QTypes");
00869 $query = "SELECT * FROM survey_questiontype ORDER BY questiontype_id";
00870 $query_result = $this->ilias->db->query($query);
00871 while ($data = $query_result->fetchRow(DB_FETCHMODE_OBJECT))
00872 {
00873 $this->tpl->setVariable("QUESTION_TYPE_ID", $data->type_tag);
00874 $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt($data->type_tag));
00875 $this->tpl->parseCurrentBlock();
00876 }
00877 $this->tpl->setCurrentBlock("CreateQuestion");
00878 $this->tpl->setVariable("QUESTION_ADD", $this->lng->txt("create"));
00879 $this->tpl->setVariable("QUESTION_IMPORT", $this->lng->txt("import"));
00880 $this->tpl->setVariable("ACTION_QUESTION_ADD", $this->ctrl->getFormAction($this));
00881 $this->tpl->parseCurrentBlock();
00882 }
00883
00884 $sortcolumns = array(
00885 "title" => $_GET["sort"]["title"],
00886 "description" => $_GET["sort"]["description"],
00887 "type" => $_GET["sort"]["type"],
00888 "author" => $_GET["sort"]["author"],
00889 "created" => $_GET["sort"]["created"],
00890 "updated" => $_GET["sort"]["updated"]
00891 );
00892 foreach ($sortcolumns as $key => $value) {
00893 if (strcmp($value, "ASC") == 0) {
00894 $sortcolumns[$key] = "DESC";
00895 } else {
00896 $sortcolumns[$key] = "ASC";
00897 }
00898 }
00899
00900 $this->tpl->setCurrentBlock("adm_content");
00901
00902 $this->ctrl->setParameterByClass(get_class($this), "startrow", $table["startrow"]);
00903 $this->tpl->setVariable("QUESTION_TITLE", "<a href=\"" . $this->ctrl->getFormAction($this) . "&sort[title]=" . $sortcolumns["title"] . "\">" . $this->lng->txt("title") . "</a>" . $table["images"]["title"]);
00904 $this->tpl->setVariable("QUESTION_DESCRIPTION", "<a href=\"" . $this->ctrl->getFormAction($this) . "&sort[description]=" . $sortcolumns["description"] . "\">" . $this->lng->txt("description") . "</a>". $table["images"]["description"]);
00905 $this->tpl->setVariable("QUESTION_TYPE", "<a href=\"" . $this->ctrl->getFormAction($this) . "&sort[type]=" . $sortcolumns["type"] . "\">" . $this->lng->txt("question_type") . "</a>" . $table["images"]["type"]);
00906 $this->tpl->setVariable("QUESTION_AUTHOR", "<a href=\"" . $this->ctrl->getFormAction($this) . "&sort[author]=" . $sortcolumns["author"] . "\">" . $this->lng->txt("author") . "</a>" . $table["images"]["author"]);
00907 $this->tpl->setVariable("QUESTION_CREATED", "<a href=\"" . $this->ctrl->getFormAction($this) . "&sort[created]=" . $sortcolumns["created"] . "\">" . $this->lng->txt("create_date") . "</a>" . $table["images"]["created"]);
00908 $this->tpl->setVariable("QUESTION_UPDATED", "<a href=\"" . $this->ctrl->getFormAction($this) . "&sort[updated]=" . $sortcolumns["updated"] . "\">" . $this->lng->txt("last_update") . "</a>" . $table["images"]["updated"]);
00909 $this->tpl->setVariable("BUTTON_CANCEL", $this->lng->txt("cancel"));
00910 $this->tpl->setVariable("ACTION_QUESTION_FORM", $this->ctrl->getFormAction($this));
00911 $this->tpl->parseCurrentBlock();
00912 unset($_SESSION["calling_survey"]);
00913 }
00914
00915 function editMetaObject()
00916 {
00917 $meta_gui =& new ilMetaDataGUI();
00918 $meta_gui->setObject($this->object);
00919 $meta_gui->edit("ADM_CONTENT", "adm_content",
00920 "$this->defaultscript?ref_id=".$_GET["ref_id"]."&cmd=saveMeta");
00921 }
00922
00923 function saveMetaObject()
00924 {
00925 global $rbacsystem;
00926
00927 if (!$rbacsystem->checkAccess("write", $this->object->getRefId()))
00928 {
00929 sendInfo($this->lng->txt("cannot_save_metaobject"));
00930 $this->editMetaObject();
00931 return;
00932 }
00933 else
00934 {
00935 $meta_gui =& new ilMetaDataGUI();
00936 $meta_gui->setObject($this->object);
00937 $meta_gui->save($_POST["meta_section"]);
00938 }
00939 $this->ctrl->redirect($this, "editMeta");
00940 }
00941
00942
00943 function chooseMetaSectionObject($a_script = "",
00944 $a_templ_var = "ADM_CONTENT", $a_templ_block = "adm_content")
00945 {
00946 if ($a_script == "")
00947 {
00948 $a_script = "$this->defaultscript?ref_id=".$_GET["ref_id"];
00949 }
00950 $meta_gui =& new ilMetaDataGUI();
00951 $meta_gui->setObject($this->object);
00952 $meta_gui->edit($a_templ_var, $a_templ_block, $a_script, $_REQUEST["meta_section"]);
00953 }
00954
00955
00956 function chooseMetaSection()
00957 {
00958 $this->chooseMetaSectionObject("$this->defaultscript?ref_id=".
00959 $this->object->getRefId());
00960 }
00961
00962 function addMetaObject($a_script = "",
00963 $a_templ_var = "ADM_CONTENT", $a_templ_block = "adm_content")
00964 {
00965 if ($a_script == "")
00966 {
00967 $a_script = "$this->defaultscript?ref_id=".$_GET["ref_id"];
00968 }
00969 $meta_gui =& new ilMetaDataGUI();
00970 $meta_gui->setObject($this->object);
00971 $meta_name = $_POST["meta_name"] ? $_POST["meta_name"] : $_GET["meta_name"];
00972 $meta_index = $_POST["meta_index"] ? $_POST["meta_index"] : $_GET["meta_index"];
00973 if ($meta_index == "")
00974 $meta_index = 0;
00975 $meta_path = $_POST["meta_path"] ? $_POST["meta_path"] : $_GET["meta_path"];
00976 $meta_section = $_POST["meta_section"] ? $_POST["meta_section"] : $_GET["meta_section"];
00977 if ($meta_name != "")
00978 {
00979 $meta_gui->meta_obj->add($meta_name, $meta_path, $meta_index);
00980 }
00981 else
00982 {
00983 sendInfo($this->lng->txt("meta_choose_element"), true);
00984 }
00985 $meta_gui->edit($a_templ_var, $a_templ_block, $a_script, $meta_section);
00986 }
00987
00988 function addMeta()
00989 {
00990 $this->addMetaObject("$this->defaultscript?ref_id=".
00991 $this->object->getRefId());
00992 }
00993
00994 function deleteMetaObject($a_script = "",
00995 $a_templ_var = "ADM_CONTENT", $a_templ_block = "adm_content")
00996 {
00997 if ($a_script == "")
00998 {
00999 $a_script = "$this->defaultscript?ref_id=".$_GET["ref_id"];
01000 }
01001 $meta_gui =& new ilMetaDataGUI();
01002 $meta_gui->setObject($this->object);
01003 $meta_index = $_POST["meta_index"] ? $_POST["meta_index"] : $_GET["meta_index"];
01004 $meta_gui->meta_obj->delete($_GET["meta_name"], $_GET["meta_path"], $meta_index);
01005 $meta_gui->edit($a_templ_var, $a_templ_block, $a_script, $_GET["meta_section"]);
01006 }
01007
01008 function deleteMeta()
01009 {
01010 $this->deleteMetaObject("$this->defaultscript?ref_id=".
01011 $this->object->getRefId());
01012 }
01013
01014 function updateObject() {
01015 $this->update = $this->object->updateMetaData();
01016 sendInfo($this->lng->txt("msg_obj_modified"), true);
01017 }
01018
01027 function setLocator($a_tree = "", $a_id = "", $scriptname="repository.php", $question_title = "")
01028 {
01029 $ilias_locator = new ilLocatorGUI(false);
01030 if (!is_object($a_tree))
01031 {
01032 $a_tree =& $this->tree;
01033 }
01034 if (!($a_id))
01035 {
01036 $a_id = $_GET["ref_id"];
01037 }
01038 if (!($scriptname))
01039 {
01040 $scriptname = "repository.php";
01041 }
01042 $path = $a_tree->getPathFull($a_id);
01043
01044
01045 if ($a_parent_parent)
01046 {
01047
01048 $subObj =& $this->ilias->obj_factory->getInstanceByRefId($a_ref_id);
01049
01050 $path[] = array(
01051 "id" => $a_ref_id,
01052 "title" => $this->lng->txt($subObj->getTitle())
01053 );
01054 }
01055
01056
01057 $modifier = 1;
01058
01059 if (isset($_GET["obj_id"]))
01060 {
01061 $modifier = 0;
01062 }
01063
01064
01065 $i = 1;
01066
01067 if (!defined("ILIAS_MODULE")) {
01068 foreach ($path as $key => $row)
01069 {
01070 $ilias_locator->navigate($i++, $row["title"], ilUtil::removeTrailingPathSeparators(ILIAS_HTTP_PATH) . "/adm_object.php?ref_id=".$row["child"], "");
01071 }
01072 } else {
01073 foreach ($path as $key => $row)
01074 {
01075 if (strcmp($row["title"], "ILIAS") == 0) {
01076 $row["title"] = $this->lng->txt("repository");
01077 }
01078 if ($this->ref_id == $row["child"]) {
01079 $param = "&cmd=questions";
01080 $ilias_locator->navigate($i++, $row["title"], ilUtil::removeTrailingPathSeparators(ILIAS_HTTP_PATH) . "/survey/questionpool.php" . "?ref_id=".$row["child"] . $param,"target=\"bottom\"");
01081 switch ($_GET["cmd"]) {
01082 case "questions":
01083 $id = $_GET["edit"];
01084 if (!$id) {
01085 $id = $_POST["id"];
01086 }
01087 if ($question_title) {
01088 if ($id > 0)
01089 {
01090 $ilias_locator->navigate($i++, $question_title, ilUtil::removeTrailingPathSeparators(ILIAS_HTTP_PATH) . "/survey/questionpool.php" . "?ref_id=".$row["child"] . "&cmd=questions&edit=$id","target=\"bottom\"");
01091 }
01092 }
01093 break;
01094 }
01095 } else {
01096 $ilias_locator->navigate($i++, $row["title"], ilUtil::removeTrailingPathSeparators(ILIAS_HTTP_PATH) . "/" . $scriptname."?ref_id=".$row["child"],"target=\"bottom\"");
01097 }
01098 }
01099
01100 if (isset($_GET["obj_id"]))
01101 {
01102 $obj_data =& $this->ilias->obj_factory->getInstanceByObjId($_GET["obj_id"]);
01103 $ilias_locator->navigate($i++,$obj_data->getTitle(),$scriptname."?ref_id=".$_GET["ref_id"]."&obj_id=".$_GET["obj_id"],"target=\"bottom\"");
01104 }
01105 }
01106 $ilias_locator->output(true);
01107 }
01108
01114 function permObject()
01115 {
01116 global $rbacsystem, $rbacreview;
01117
01118 static $num = 0;
01119
01120 if (!$rbacsystem->checkAccess("edit_permission", $this->object->getRefId()))
01121 {
01122 $this->ilias->raiseError($this->lng->txt("msg_no_perm_perm"),$this->ilias->error_obj->MESSAGE);
01123 exit();
01124 }
01125
01126
01127 $parentRoles = $rbacreview->getParentRoleIds($this->object->getRefId());
01128
01129 $data = array();
01130
01131
01132 $role_folder = $rbacreview->getRoleFolderOfObject($this->object->getRefId());
01133
01134 $local_roles = array();
01135
01136 if ($role_folder)
01137 {
01138 $local_roles = $rbacreview->getRolesOfRoleFolder($role_folder["ref_id"]);
01139 }
01140
01141 foreach ($parentRoles as $key => $r)
01142 {
01143 if ($r["obj_id"] == SYSTEM_ROLE_ID)
01144 {
01145 unset($parentRoles[$key]);
01146 continue;
01147 }
01148
01149 if (!in_array($r["obj_id"],$local_roles))
01150 {
01151 $data["check_inherit"][] = ilUtil::formCheckBox(0,"stop_inherit[]",$r["obj_id"]);
01152 }
01153 else
01154 {
01155 $r["link"] = true;
01156
01157
01158 if ($rbacreview->isAssignable($r["obj_id"],$role_folder["ref_id"]))
01159 {
01160 $data["check_inherit"][] = " ";
01161 }
01162 else
01163 {
01164
01165 $data["check_inherit"][] = ilUtil::formCheckBox(1,"stop_inherit[]",$r["obj_id"]);
01166 }
01167 }
01168
01169 $data["roles"][] = $r;
01170 }
01171
01172 $ope_list = getOperationList($this->object->getType());
01173
01174
01175 foreach ($ope_list as $key => $operation)
01176 {
01177 $opdata = array();
01178
01179 $opdata["name"] = $operation["operation"];
01180
01181 $colspan = count($parentRoles) + 1;
01182
01183 foreach ($parentRoles as $role)
01184 {
01185 $checked = $rbacsystem->checkPermission($this->object->getRefId(), $role["obj_id"],$operation["operation"],$_GET["parent"]);
01186 $disabled = false;
01187
01188
01189 $box = ilUtil::formCheckBox($checked,"perm[".$role["obj_id"]."][]",$operation["ops_id"],$disabled);
01190 $opdata["values"][] = $box;
01191 }
01192
01193 $data["permission"][] = $opdata;
01194 }
01195
01197
01199
01200 $this->getTemplateFile("perm");
01201 $this->tpl->setCurrentBlock("tableheader");
01202 $this->tpl->setVariable("TXT_TITLE", $this->lng->txt("permission_settings"));
01203 $this->tpl->setVariable("COLSPAN", $colspan);
01204 $this->tpl->setVariable("TXT_OPERATION", $this->lng->txt("operation"));
01205 $this->tpl->setVariable("TXT_ROLES", $this->lng->txt("roles"));
01206 $this->tpl->parseCurrentBlock();
01207
01208 $num = 0;
01209
01210 foreach($data["roles"] as $role)
01211 {
01212
01213 if ($role["link"])
01214 {
01215 $this->tpl->setCurrentBlock("ROLELINK_OPEN");
01216 $this->tpl->setVariable("LINK_ROLE_RULESET","$this->defaultscript?ref_id=".$role_folder["ref_id"]."&obj_id=".$role["obj_id"]."&cmd=perm");
01217 $this->tpl->setVariable("TXT_ROLE_RULESET",$this->lng->txt("edit_perm_ruleset"));
01218 $this->tpl->parseCurrentBlock();
01219
01220 $this->tpl->touchBlock("ROLELINK_CLOSE");
01221 }
01222
01223 $this->tpl->setCurrentBlock("ROLENAMES");
01224 $this->tpl->setVariable("ROLE_NAME",$role["title"]);
01225 $this->tpl->parseCurrentBlock();
01226
01227
01228 if ($this->objDefinition->stopInheritance($this->type))
01229 {
01230 $this->tpl->setCurrentBLock("CHECK_INHERIT");
01231 $this->tpl->setVariable("CHECK_INHERITANCE",$data["check_inherit"][$num]);
01232 $this->tpl->parseCurrentBlock();
01233 }
01234
01235 $num++;
01236 }
01237
01238
01239 $colspan = $num + 1;
01240 $num = 0;
01241
01242
01243 if ($this->objDefinition->stopInheritance($this->type))
01244 {
01245 $this->tpl->setCurrentBLock("STOP_INHERIT");
01246 $this->tpl->setVariable("TXT_STOP_INHERITANCE", $this->lng->txt("stop_inheritance"));
01247 $this->tpl->parseCurrentBlock();
01248 }
01249
01250 foreach ($data["permission"] as $ar_perm)
01251 {
01252 foreach ($ar_perm["values"] as $box)
01253 {
01254
01255 $this->tpl->setCurrentBlock("CHECK_PERM");
01256 $this->tpl->setVariable("CHECK_PERMISSION",$box);
01257 $this->tpl->parseCurrentBlock();
01258
01259 }
01260
01261
01262 $this->tpl->setCurrentBlock("TABLE_DATA_OUTER");
01263 $css_row = ilUtil::switchColor($num++, "tblrow1", "tblrow2");
01264 $this->tpl->setVariable("CSS_ROW",$css_row);
01265 $this->tpl->setVariable("PERMISSION", $this->lng->txt($this->object->getType()."_".$ar_perm["name"]));
01266 $this->tpl->parseCurrentBlock();
01267
01268 }
01269
01270
01271 if (false)
01272
01273 {
01274 $this->tpl->setCurrentBlock("LOCAL_ROLE");
01275
01276
01277 $data = array();
01278 $data["fields"] = array();
01279 $data["fields"]["title"] = $_SESSION["error_post_vars"]["Fobject"]["title"];
01280 $data["fields"]["desc"] = $_SESSION["error_post_vars"]["Fobject"]["desc"];
01281
01282 foreach ($data["fields"] as $key => $val)
01283 {
01284 $this->tpl->setVariable("TXT_".strtoupper($key), $this->lng->txt($key));
01285 $this->tpl->setVariable(strtoupper($key), $val);
01286 }
01287
01288 $this->tpl->setVariable("FORMACTION_LR",$this->getFormAction("addRole", "$this->defaultscript?ref_id=".$_GET["ref_id"]."&cmd=addRole"));
01289 $this->tpl->setVariable("TXT_HEADER", $this->lng->txt("you_may_add_local_roles"));
01290 $this->tpl->setVariable("TXT_ADD", $this->lng->txt("role_add_local"));
01291 $this->tpl->setVariable("TARGET", $this->getTargetFrame("addRole"));
01292 $this->tpl->setVariable("TXT_REQUIRED_FLD", $this->lng->txt("required_field"));
01293 $this->tpl->parseCurrentBlock();
01294 }
01295
01296
01297 $this->tpl->setCurrentBlock("adm_content");
01298 $this->tpl->setVariable("FORMACTION", $this->getFormAction("permSave","$this->defaultscript?".$this->link_params."&cmd=permSave"));
01299 $this->tpl->setVariable("TXT_SAVE", $this->lng->txt("save"));
01300 $this->tpl->setVariable("COL_ANZ",$colspan);
01301 $this->tpl->parseCurrentBlock();
01302 }
01303
01309 function permSaveObject()
01310 {
01311 global $rbacsystem, $rbacreview, $rbacadmin;
01312
01313
01314 $rbacadmin->revokePermission($this->ref_id);
01315
01316 if (is_array($_POST["perm"]))
01317 {
01318 foreach ($_POST["perm"] as $key => $new_role_perms)
01319 {
01320
01321 $rbacadmin->grantPermission($key,$new_role_perms,$this->ref_id);
01322 }
01323 }
01324
01325
01326 $this->object->update();
01327
01328
01329 $rolf_data = $rbacreview->getRoleFolderOfObject($this->ref_id);
01330 $rolf_id = $rolf_data["child"];
01331
01332 if ($_POST["stop_inherit"])
01333 {
01334
01335 if (empty($rolf_id))
01336 {
01337
01338 $rfoldObj = $this->object->createRoleFolder();
01339
01340
01341 $rolf_id = $rfoldObj->getRefId();
01342 }
01343
01344
01345 if (!$rbacsystem->checkAccess("write",$rolf_id))
01346 {
01347 $this->ilias->raiseError($this->lng->txt("msg_no_perm_write"),$this->ilias->error_obj->WARNING);
01348 }
01349
01350 foreach ($_POST["stop_inherit"] as $stop_inherit)
01351 {
01352 $roles_of_folder = $rbacreview->getRolesOfRoleFolder($rolf_id);
01353
01354
01355 if (!in_array($stop_inherit,$roles_of_folder))
01356 {
01357 $parentRoles = $rbacreview->getParentRoleIds($rolf_id);
01358 $rbacadmin->copyRolePermission($stop_inherit,$parentRoles[$stop_inherit]["parent"],
01359 $rolf_id,$stop_inherit);
01360 $rbacadmin->assignRoleToFolder($stop_inherit,$rolf_id,'n');
01361 }
01362 }
01363 }
01364 elseif (!empty($rolf_id))
01365 {
01366
01367
01368
01369
01370
01371
01372
01373
01374
01375
01376
01377 }
01378
01379 sendinfo($this->lng->txt("saved_successfully"),true);
01380 ilUtil::redirect($this->getReturnLocation("permSave","$this->defaultscript?ref_id=".$_GET["ref_id"]."&cmd=perm"));
01381 }
01382
01383
01384
01385
01386 function exportObject()
01387 {
01388 global $tree;
01389
01390
01391
01392
01393 $this->tpl->addBlockfile("BUTTONS", "buttons", "tpl.buttons.html");
01394
01395
01396 $this->tpl->setCurrentBlock("btn_cell");
01397 $this->tpl->setVariable("BTN_LINK", $this->ctrl->getLinkTarget($this, "createExportFile"));
01398 $this->tpl->setVariable("BTN_TXT", $this->lng->txt("svy_create_export_file"));
01399 $this->tpl->parseCurrentBlock();
01400
01401 $export_dir = $this->object->getExportDirectory();
01402 $export_files = $this->object->getExportFiles($export_dir);
01403
01404
01405 require_once("classes/class.ilTableGUI.php");
01406 $tbl = new ilTableGUI();
01407
01408
01409 $this->tpl->addBlockfile("ADM_CONTENT", "adm_content", "tpl.table.html");
01410
01411
01412 $this->tpl->addBlockfile("TBL_CONTENT", "tbl_content", "tpl.export_file_row.html", true);
01413
01414 $num = 0;
01415
01416 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
01417
01418 $tbl->setTitle($this->lng->txt("svy_export_files"));
01419
01420 $tbl->setHeaderNames(array("<input type=\"checkbox\" name=\"chb_check_all\" value=\"1\" onclick=\"setCheckboxes('ObjectItems', 'file', document.ObjectItems.chb_check_all.checked);\" />", $this->lng->txt("svy_file"),
01421 $this->lng->txt("svy_size"), $this->lng->txt("date") ));
01422
01423 $tbl->enabled["sort"] = false;
01424 $tbl->setColumnWidth(array("1%", "49%", "25%", "25%"));
01425
01426
01427 $tbl->setOrderColumn($_GET["sort_by"]);
01428 $tbl->setOrderDirection($_GET["sort_order"]);
01429 $tbl->setLimit($_GET["limit"]);
01430 $tbl->setOffset($_GET["offset"]);
01431 $tbl->setMaxCount($this->maxcount);
01432
01433 $this->tpl->setVariable("COLUMN_COUNTS", 4);
01434
01435
01436 $this->tpl->setVariable("IMG_ARROW", ilUtil::getImagePath("arrow_downright.gif"));
01437 $this->tpl->setCurrentBlock("tbl_action_btn");
01438 $this->tpl->setVariable("BTN_NAME", "confirmDeleteExportFile");
01439 $this->tpl->setVariable("BTN_VALUE", $this->lng->txt("delete"));
01440 $this->tpl->parseCurrentBlock();
01441
01442 $this->tpl->setCurrentBlock("tbl_action_btn");
01443 $this->tpl->setVariable("BTN_NAME", "downloadExportFile");
01444 $this->tpl->setVariable("BTN_VALUE", $this->lng->txt("download"));
01445 $this->tpl->parseCurrentBlock();
01446
01447
01448 $tbl->setFooter("tblfooter",$this->lng->txt("previous"),$this->lng->txt("next"));
01449
01450
01451 $tbl->setMaxCount(count($export_files));
01452 $export_files = array_slice($export_files, $_GET["offset"], $_GET["limit"]);
01453
01454 $tbl->render();
01455 if(count($export_files) > 0)
01456 {
01457 $i=0;
01458 foreach($export_files as $exp_file)
01459 {
01460 $this->tpl->setCurrentBlock("tbl_content");
01461 $this->tpl->setVariable("TXT_FILENAME", $exp_file);
01462
01463 $css_row = ilUtil::switchColor($i++, "tblrow1", "tblrow2");
01464 $this->tpl->setVariable("CSS_ROW", $css_row);
01465
01466 $this->tpl->setVariable("TXT_SIZE", filesize($export_dir."/".$exp_file));
01467 $this->tpl->setVariable("CHECKBOX_ID", $exp_file);
01468
01469 $file_arr = explode("__", $exp_file);
01470 $this->tpl->setVariable("TXT_DATE", date("Y-m-d H:i:s",$file_arr[0]));
01471
01472 $this->tpl->parseCurrentBlock();
01473 }
01474 }
01475 else
01476 {
01477 $this->tpl->setCurrentBlock("notfound");
01478 $this->tpl->setVariable("TXT_OBJECT_NOT_FOUND", $this->lng->txt("obj_not_found"));
01479 $this->tpl->setVariable("NUM_COLS", 3);
01480 $this->tpl->parseCurrentBlock();
01481 }
01482
01483 $this->tpl->parseCurrentBlock();
01484 }
01485
01489 function createExportFileObject($questions)
01490 {
01491 global $rbacsystem;
01492
01493 if ($rbacsystem->checkAccess("write", $this->ref_id))
01494 {
01495 require_once("./survey/classes/class.ilSurveyQuestionpoolExport.php");
01496 $survey_exp = new ilSurveyQuestionpoolExport($this->object);
01497 $survey_exp->buildExportFile($questions);
01498 ilUtil::redirect("questionpool.php?cmd=export&ref_id=".$_GET["ref_id"]);
01499
01500 }
01501 else
01502 {
01503 sendInfo("cannot_export_questionpool");
01504 }
01505 }
01506
01510 function downloadExportFileObject()
01511 {
01512 if(!isset($_POST["file"]))
01513 {
01514 $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
01515 }
01516
01517 if (count($_POST["file"]) > 1)
01518 {
01519 $this->ilias->raiseError($this->lng->txt("select_max_one_item"),$this->ilias->error_obj->MESSAGE);
01520 }
01521
01522
01523 $export_dir = $this->object->getExportDirectory();
01524 ilUtil::deliverFile($export_dir."/".$_POST["file"][0],
01525 $_POST["file"][0]);
01526 }
01527
01531 function confirmDeleteExportFileObject()
01532 {
01533 if(!isset($_POST["file"]))
01534 {
01535 $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
01536 }
01537
01538
01539
01540
01541 $_SESSION["ilExportFiles"] = $_POST["file"];
01542
01543 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.confirm_deletion.html", true);
01544
01545 sendInfo($this->lng->txt("info_delete_sure"));
01546
01547 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
01548
01549
01550 $this->tpl->setCurrentBlock("table_header");
01551 $this->tpl->setVariable("TEXT",$this->lng->txt("objects"));
01552 $this->tpl->parseCurrentBlock();
01553
01554
01555 $counter = 0;
01556 foreach($_POST["file"] as $file)
01557 {
01558 $this->tpl->setCurrentBlock("table_row");
01559 $this->tpl->setVariable("CSS_ROW",ilUtil::switchColor(++$counter,"tblrow1","tblrow2"));
01560 $this->tpl->setVariable("TEXT_CONTENT", $file);
01561 $this->tpl->parseCurrentBlock();
01562 }
01563
01564
01565 $this->tpl->setVariable("IMG_ARROW",ilUtil::getImagePath("arrow_downright.gif"));
01566 $buttons = array( "cancelDeleteExportFile" => $this->lng->txt("cancel"),
01567 "deleteExportFile" => $this->lng->txt("confirm"));
01568 foreach ($buttons as $name => $value)
01569 {
01570 $this->tpl->setCurrentBlock("operation_btn");
01571 $this->tpl->setVariable("BTN_NAME",$name);
01572 $this->tpl->setVariable("BTN_VALUE",$value);
01573 $this->tpl->parseCurrentBlock();
01574 }
01575 }
01576
01577
01581 function cancelDeleteExportFileObject()
01582 {
01583 session_unregister("ilExportFiles");
01584 $this->ctrl->redirect($this, "export");
01585 }
01586
01587
01591 function deleteExportFileObject()
01592 {
01593 $export_dir = $this->object->getExportDirectory();
01594 foreach($_SESSION["ilExportFiles"] as $file)
01595 {
01596 $exp_file = $export_dir."/".$file;
01597 $exp_dir = $export_dir."/".substr($file, 0, strlen($file) - 4);
01598 if (@is_file($exp_file))
01599 {
01600 unlink($exp_file);
01601 }
01602 if (@is_dir($exp_dir))
01603 {
01604 ilUtil::delDir($exp_dir);
01605 }
01606 }
01607 $this->ctrl->redirect($this, "export");
01608 }
01609
01615 function importObject()
01616 {
01617 $this->getTemplateFile("import", "spl");
01618 $this->tpl->setVariable("FORMACTION", "adm_object.php?&ref_id=".$_GET["ref_id"]."&cmd=gateway&new_type=".$this->type);
01619 $this->tpl->setVariable("BTN_NAME", "uploadSpl");
01620 $this->tpl->setVariable("TXT_UPLOAD", $this->lng->txt("upload"));
01621 $this->tpl->setVariable("TXT_IMPORT_SPL", $this->lng->txt("import_spl"));
01622 $this->tpl->setVariable("TXT_SELECT_MODE", $this->lng->txt("select_mode"));
01623 $this->tpl->setVariable("TXT_SELECT_FILE", $this->lng->txt("select_file"));
01624 }
01625
01629 function uploadSplObject($redirect = true)
01630 {
01631 if ($_FILES["xmldoc"]["error"] > UPLOAD_ERR_OK)
01632 {
01633 sendInfo($this->lng->txt("spl_select_file_for_import"));
01634 $this->importObject();
01635 return;
01636 }
01637 require_once "./survey/classes/class.ilObjSurveyQuestionpool.php";
01638
01639 $newObj = new ilObjSurveyQuestionpool();
01640
01641 $newObj->setType($_GET["new_type"]);
01642
01643 $newObj->setTitle("dummy");
01644
01645
01646
01647 $newObj->create(true);
01648
01649 $newObj->createReference();
01650
01651 $newObj->putInTree($_GET["ref_id"]);
01652
01653 $newObj->setPermissions($_GET["ref_id"]);
01654
01655 $newObj->notify("new",$_GET["ref_id"],$_GET["parent_non_rbac_id"],$_GET["ref_id"],$newObj->getRefId());
01656
01657
01658 $newObj->createImportDirectory();
01659
01660
01661 $file = pathinfo($_FILES["xmldoc"]["name"]);
01662 $full_path = $newObj->getImportDirectory()."/".$_FILES["xmldoc"]["name"];
01663 ilUtil::moveUploadedFile($_FILES["xmldoc"]["tmp_name"],
01664 $_FILES["xmldoc"]["name"], $full_path);
01665
01666
01667
01668 $qtiresult = $newObj->importObject($full_path);
01669
01670 if (is_object($newObj->meta_data))
01671 {
01672
01673 $meta_data =& new ilMetaData($newObj->getType(), $newObj->getId());
01674 $newObj->meta_data = $meta_data;
01675 $newObj->setTitle($newObj->meta_data->getTitle());
01676 $newObj->setDescription($newObj->meta_data->getDescription());
01677 ilObject::_writeTitle($newObj->getID(), $newObj->getTitle());
01678 ilObject::_writeDescription($newObj->getID(), $newObj->getDescription());
01679 }
01680
01681 if ($redirect)
01682 {
01683 ilUtil::redirect("adm_object.php?".$this->link_params);
01684 }
01685 }
01686
01690 function createObject()
01691 {
01692 global $rbacsystem;
01693 $new_type = $_POST["new_type"] ? $_POST["new_type"] : $_GET["new_type"];
01694 if (!$rbacsystem->checkAccess("create", $_GET["ref_id"], $new_type))
01695 {
01696 $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
01697 }
01698 else
01699 {
01700 $this->getTemplateFile("create", $new_type);
01701
01702 require_once("./survey/classes/class.ilObjSurvey.php");
01703
01704
01705 $data = array();
01706 $data["fields"] = array();
01707 $data["fields"]["title"] = ilUtil::prepareFormOutput($_SESSION["error_post_vars"]["Fobject"]["title"],true);
01708 $data["fields"]["desc"] = ilUtil::prepareFormOutput($_SESSION["error_post_vars"]["Fobject"]["desc"]);
01709
01710 foreach ($data["fields"] as $key => $val)
01711 {
01712 $this->tpl->setVariable("TXT_".strtoupper($key), $this->lng->txt($key));
01713 $this->tpl->setVariable(strtoupper($key), $val);
01714
01715 if ($this->prepare_output)
01716 {
01717 $this->tpl->parseCurrentBlock();
01718 }
01719 }
01720
01721 $this->tpl->setVariable("FORMACTION", $this->getFormAction("save","adm_object.php?cmd=gateway&ref_id=".
01722 $_GET["ref_id"]."&new_type=".$new_type));
01723 $this->tpl->setVariable("TXT_HEADER", $this->lng->txt($new_type."_new"));
01724 $this->tpl->setVariable("TXT_CANCEL", $this->lng->txt("cancel"));
01725 $this->tpl->setVariable("TXT_SUBMIT", $this->lng->txt($new_type."_add"));
01726 $this->tpl->setVariable("CMD_SUBMIT", "save");
01727 $this->tpl->setVariable("TARGET", $this->getTargetFrame("save"));
01728 $this->tpl->setVariable("TXT_REQUIRED_FLD", $this->lng->txt("required_field"));
01729
01730 $this->tpl->setVariable("TXT_IMPORT_SPL", $this->lng->txt("import_spl"));
01731 $this->tpl->setVariable("TXT_SPL_FILE", $this->lng->txt("spl_upload_file"));
01732 $this->tpl->setVariable("TXT_IMPORT", $this->lng->txt("import"));
01733 }
01734 }
01735
01739 function importFileObject()
01740 {
01741 if (strcmp($_FILES["xmldoc"]["tmp_name"], "") == 0)
01742 {
01743 sendInfo($this->lng->txt("spl_select_file_for_import"));
01744 $this->createObject();
01745 return;
01746 }
01747 $this->uploadSplObject(false);
01748 ilUtil::redirect($this->getReturnLocation("importFile",$this->ctrl->getTargetScript()."?".$this->link_params));
01749
01750 }
01751
01755 function &executeCommand()
01756 {
01757 $cmd = $this->ctrl->getCmd("questions");
01758 $next_class = $this->ctrl->getNextClass($this);
01759 $this->ctrl->setReturn($this, "questions");
01760 $q_type = ($_POST["sel_question_types"] != "")
01761 ? $_POST["sel_question_types"]
01762 : $_GET["sel_question_types"];
01763
01764
01765 switch($next_class)
01766 {
01767 case "surveynominalquestiongui":
01768 $this->ctrl->setParameterByClass("surveynominalquestiongui", "sel_question_types", $q_type);
01769 $q_gui =& SurveyQuestionGUI::_getQuestionGUI($q_type, $_GET["q_id"]);
01770 $q_gui->object->setObjId($this->object->getId());
01771 $q_gui->setQuestionTabs();
01772 $ret =& $this->ctrl->forwardCommand($q_gui);
01773 break;
01774
01775 case "surveyordinalquestiongui":
01776 $this->ctrl->setParameterByClass("surveyordinalquestiongui", "sel_question_types", $q_type);
01777 $q_gui =& SurveyQuestionGUI::_getQuestionGUI($q_type, $_GET["q_id"]);
01778 $q_gui->object->setObjId($this->object->getId());
01779 $q_gui->setQuestionTabs();
01780 $ret =& $this->ctrl->forwardCommand($q_gui);
01781 break;
01782
01783 case "surveymetricquestiongui":
01784 $this->ctrl->setParameterByClass("surveymetricquestiongui", "sel_question_types", $q_type);
01785 $q_gui =& SurveyQuestionGUI::_getQuestionGUI($q_type, $_GET["q_id"]);
01786 $q_gui->object->setObjId($this->object->getId());
01787 $q_gui->setQuestionTabs();
01788 $ret =& $this->ctrl->forwardCommand($q_gui);
01789 break;
01790
01791 case "surveytextquestiongui":
01792 $this->ctrl->setParameterByClass("surveytextquestiongui", "sel_question_types", $q_type);
01793 $q_gui =& SurveyQuestionGUI::_getQuestionGUI($q_type, $_GET["q_id"]);
01794 $q_gui->object->setObjId($this->object->getId());
01795 $q_gui->setQuestionTabs();
01796 $ret =& $this->ctrl->forwardCommand($q_gui);
01797 break;
01798
01799 default:
01800 if (($cmd != "createQuestion") and (!$_GET["calling_survey"]) and (!$_GET["new_for_survey"]))
01801 {
01802 $this->setAdminTabs();
01803 }
01804 $cmd.= "Object";
01805 $ret =& $this->$cmd();
01806 break;
01807 }
01808 }
01809
01813 function &createQuestionObject()
01814 {
01815 $q_gui =& SurveyQuestionGUI::_getQuestionGUI($_POST["sel_question_types"]);
01816 $q_gui->object->setObjId($this->object->getId());
01817 $this->ctrl->setCmdClass(get_class($q_gui));
01818 $this->ctrl->setCmd("editQuestion");
01819
01820 $ret =& $this->executeCommand();
01821 return $ret;
01822 }
01823
01824 function prepareOutput()
01825 {
01826 $this->tpl->addBlockFile("CONTENT", "content", "tpl.adm_content.html");
01827 $this->tpl->addBlockFile("STATUSLINE", "statusline", "tpl.statusline.html");
01828 $title = $this->object->getTitle();
01829
01830
01831 sendInfo();
01832
01833 if (!empty($title))
01834 {
01835 $this->tpl->setVariable("HEADER", $title);
01836 }
01837 if (!defined("ILIAS_MODULE"))
01838 {
01839 $this->setAdminTabs($_POST["new_type"]);
01840 }
01841 $this->setLocator();
01842
01843 }
01844
01848 function &editQuestionForSurveyObject()
01849 {
01850
01851 $q_gui =& SurveyQuestionGUI::_getQuestionGUI("", $_GET["q_id"]);
01852 $this->ctrl->setParameterByClass(get_class($q_gui), "sel_question_types", $q_gui->getQuestionType());
01853 $this->ctrl->setParameterByClass(get_class($q_gui), "q_id", $_GET["q_id"]);
01854 $this->ctrl->setCmdClass(get_class($q_gui));
01855 $this->ctrl->setCmd("editQuestion");
01856 $ret =& $this->executeCommand();
01857 return $ret;
01858 }
01859
01863 function &createQuestionForSurveyObject()
01864 {
01865
01866 $q_gui =& SurveyQuestionGUI::_getQuestionGUI($_GET["sel_question_types"]);
01867 $this->ctrl->setParameterByClass(get_class($q_gui), "sel_question_types", $q_gui->getQuestionType());
01868 $this->ctrl->setCmdClass(get_class($q_gui));
01869 $this->ctrl->setCmd("editQuestion");
01870 $ret =& $this->executeCommand();
01871 return $ret;
01872 }
01873
01877 function &previewObject()
01878 {
01879 $q_gui =& SurveyQuestionGUI::_getQuestionGUI("", $_GET["preview"]);
01880 $_GET["q_id"] = $_GET["preview"];
01881 $this->ctrl->setParameterByClass(get_class($q_gui), "sel_question_types", $q_gui->getQuestionType());
01882 $this->ctrl->setParameterByClass(get_class($q_gui), "q_id", $_GET["preview"]);
01883 $this->ctrl->setCmdClass(get_class($q_gui));
01884 $this->ctrl->setCmd("preview");
01885 $ret =& $this->executeCommand();
01886 return $ret;
01887 }
01888
01889 }
01890 ?>