• Main Page
  • Related Pages
  • Modules
  • Namespaces
  • Data Structures
  • Files
  • File List
  • Globals

Modules/SurveyQuestionPool/classes/class.ilObjSurveyQuestionPoolGUI.php

Go to the documentation of this file.
00001 <?php
00002 /*
00003         +-----------------------------------------------------------------------------+
00004         | ILIAS open source                                                           |
00005         +-----------------------------------------------------------------------------+
00006         | Copyright (c) 1998-2001 ILIAS open source, University of Cologne            |
00007         |                                                                             |
00008         | This program is free software; you can redistribute it and/or               |
00009         | modify it under the terms of the GNU General Public License                 |
00010         | as published by the Free Software Foundation; either version 2              |
00011         | of the License, or (at your option) any later version.                      |
00012         |                                                                             |
00013         | This program is distributed in the hope that it will be useful,             |
00014         | but WITHOUT ANY WARRANTY; without even the implied warranty of              |
00015         | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               |
00016         | GNU General Public License for more details.                                |
00017         |                                                                             |
00018         | You should have received a copy of the GNU General Public License           |
00019         | along with this program; if not, write to the Free Software                 |
00020         | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. |
00021         +-----------------------------------------------------------------------------+
00022 */
00023 
00024 include_once "./classes/class.ilObjectGUI.php";
00025 include_once "./Modules/Survey/classes/inc.SurveyConstants.php";
00026 
00042 class ilObjSurveyQuestionPoolGUI extends ilObjectGUI
00043 {
00044         var $defaultscript;
00045         
00050         function ilObjSurveyQuestionPoolGUI()
00051         {
00052     global $lng, $ilCtrl;
00053 
00054                 $this->type = "spl";
00055                 $lng->loadLanguageModule("survey");
00056                 $this->ctrl =& $ilCtrl;
00057                 $this->ctrl->saveParameter($this, array("ref_id", "calling_survey", "new_for_survey"));
00058 
00059                 $this->ilObjectGUI("",$_GET["ref_id"], true, false);
00060         }
00061 
00065         function &executeCommand()
00066         {
00067                 global $ilAccess, $ilNavigationHistory;
00068                 
00069                 // add entry to navigation history
00070                 if (!$this->getCreationMode() &&
00071                         $ilAccess->checkAccess("read", "", $_GET["ref_id"]))
00072                 {
00073                         $ilNavigationHistory->addItem($_GET["ref_id"],
00074                                 "ilias.php?baseClass=ilObjSurveyQuestionPoolGUI&cmd=questions&ref_id=".$_GET["ref_id"], "spl");
00075                 }
00076 
00077                 $this->prepareOutput();
00078                 $cmd = $this->ctrl->getCmd("questions");
00079                 $next_class = $this->ctrl->getNextClass($this);
00080                 $this->ctrl->setReturn($this, "questions");
00081                 if ($_GET["q_id"] < 1)
00082                 {
00083                         $q_type = ($_POST["sel_question_types"] != "")
00084                                 ? $_POST["sel_question_types"]
00085                                 : $_GET["sel_question_types"];
00086                 }
00087                 switch($next_class)
00088                 {
00089                         case 'ilmdeditorgui':
00090                                 include_once "./Services/MetaData/classes/class.ilMDEditorGUI.php";
00091                                 $md_gui =& new ilMDEditorGUI($this->object->getId(), 0, $this->object->getType());
00092                                 $md_gui->addObserver($this->object,'MDUpdateListener','General');
00093 
00094                                 $this->ctrl->forwardCommand($md_gui);
00095                                 break;
00096 
00097                         case 'ilpermissiongui':
00098                                 include_once("./classes/class.ilPermissionGUI.php");
00099                                 $perm_gui =& new ilPermissionGUI($this);
00100                                 $ret =& $this->ctrl->forwardCommand($perm_gui);
00101                                 break;
00102                                 
00103                         case "ilsurveyphrasesgui":
00104                                 include_once("./Modules/SurveyQuestionPool/classes/class.ilSurveyPhrasesGUI.php");
00105                                 $phrases_gui =& new ilSurveyPhrasesGUI($this);
00106                                 $ret =& $this->ctrl->forwardCommand($phrases_gui);
00107                                 break;
00108 
00109                         case "":
00110                                 $cmd.= "Object";
00111                                 $ret =& $this->$cmd();
00112                                 break;
00113                                 
00114                         default:
00115                                 if (strlen($q_type))
00116                                 {
00117                                         $question_type_gui = $q_type . "GUI";
00118                                 }
00119                                 else
00120                                 {
00121                                         include_once "./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
00122                                         $question_type_gui = SurveyQuestion::_getQuestionType($_GET["q_id"]) . "GUI";
00123                                 }
00124                                 include_once "./Modules/SurveyQuestionPool/classes/class.$question_type_gui" . ".php";
00125                                 $q_gui = new $question_type_gui($_GET["q_id"]);
00126                                 $q_gui->object->setObjId($this->object->getId());
00127                                 $q_gui->setQuestionTabs();
00128                                 $ret =& $this->ctrl->forwardCommand($q_gui);
00129                                 break;
00130                 }
00131                 if (strtolower($_GET["baseClass"]) != "iladministrationgui" &&
00132                         $this->getCreationMode() != true)
00133                 {
00134                         $this->tpl->show();
00135                 }
00136         }
00137 
00143         function cancelObject()
00144         {
00145                 ilUtil::sendInfo($this->lng->txt("msg_cancel"),true);
00146                 ilUtil::redirect("repository.php?cmd=frameset&ref_id=".$_GET["ref_id"]);
00147         }
00148 
00149 
00154         function saveObject()
00155         {
00156                 global $rbacadmin;
00157 
00158                 // create and insert forum in objecttree
00159                 $newObj = parent::saveObject();
00160 
00161                 // always send a message
00162                 ilUtil::sendInfo($this->lng->txt("object_added"),true);
00163 
00164                 ilUtil::redirect("ilias.php?ref_id=".$newObj->getRefId().
00165                         "&baseClass=ilObjSurveyQuestionPoolGUI");
00166         }
00167         
00176         function cancelAction($question_id = "") 
00177         {
00178                 $this->ctrl->redirect($this, "questions");
00179         }
00180 
00184         function propertiesObject()
00185         {
00186                 global $rbacsystem;
00187                 
00188                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_svy_qpl_properties.html", "Modules/SurveyQuestionPool");
00189                 $this->tpl->setCurrentBlock("adm_content");
00190                 $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
00191                 $this->tpl->setVariable("HEADING_GENERAL", $this->lng->txt("spl_general_properties"));
00192                 $this->tpl->setVariable("PROPERTY_ONLINE", $this->lng->txt("spl_online_property"));
00193                 $this->tpl->setVariable("PROPERTY_ONLINE_DESCRIPTION", $this->lng->txt("spl_online_property_description"));
00194                 if ($this->object->getOnline() == 1)
00195                 {
00196                         $this->tpl->setVariable("PROPERTY_ONLINE_CHECKED", " checked=\"checked\"");
00197                 }
00198                 if ($rbacsystem->checkAccess('write', $this->ref_id)) 
00199                 {
00200                         $this->tpl->setVariable("SAVE", $this->lng->txt("save"));
00201                 }
00202                 else
00203                 {
00204                         $this->tpl->setVariable("PROPERTY_ONLINE_DISABLED", " disabled=\"disabled\"");
00205                 }
00206                 $this->tpl->parseCurrentBlock();
00207         }
00208         
00212         function savePropertiesObject()
00213         {
00214                 $qpl_online = $_POST["online"];
00215                 if (strlen($qpl_online) == 0) $qpl_online = "0";
00216                 $this->object->setOnline($qpl_online);
00217                 $this->object->saveToDb();
00218                 ilUtil::sendInfo($this->lng->txt("saved_successfully"), true);
00219                 $this->ctrl->redirect($this, "properties");
00220         }
00221         
00222 
00230         function copyObject()
00231         {
00232     // create an array of all checked checkboxes
00233     $checked_questions = array();
00234     foreach ($_POST as $key => $value) 
00235                 {
00236       if (preg_match("/cb_(\d+)/", $key, $matches)) 
00237                         {
00238         array_push($checked_questions, $matches[1]);
00239       }
00240     }
00241                 
00242                 // copy button was pressed
00243                 if (count($checked_questions) > 0) 
00244                 {
00245                         $_SESSION["spl_copied_questions"] = join($checked_questions, ",");
00246                 } 
00247                 else if (count($checked_questions) == 0) 
00248                 {
00249                         ilUtil::sendInfo($this->lng->txt("qpl_copy_select_none"));
00250                         $_SESSION["spl_copied_questions"] = "";
00251                 }
00252                 $this->questionsObject();
00253         }       
00254         
00262         function duplicateObject()
00263         {
00264     // create an array of all checked checkboxes
00265     $checked_questions = array();
00266     foreach ($_POST as $key => $value) {
00267       if (preg_match("/cb_(\d+)/", $key, $matches)) {
00268         array_push($checked_questions, $matches[1]);
00269       }
00270     }
00271                 
00272                 if (count($checked_questions) > 0) {
00273                         foreach ($checked_questions as $key => $value) {
00274                                 $this->object->duplicateQuestion($value);
00275                         }
00276                 } elseif (count($checked_questions) == 0) {
00277                         ilUtil::sendInfo($this->lng->txt("qpl_duplicate_select_none"));
00278                 }
00279                 $this->questionsObject();
00280         }
00281 
00285         function exportQuestionsObject()
00286         {
00287                 // create an array of all checked checkboxes
00288                 $checked_questions = array();
00289                 foreach ($_POST as $key => $value) {
00290                         if (preg_match("/cb_(\d+)/", $key, $matches)) {
00291                                 array_push($checked_questions, $matches[1]);
00292                         }
00293                 }
00294                 
00295                 // export button was pressed
00296                 if (count($checked_questions) > 0)
00297                 {
00298                         $this->createExportFileObject($checked_questions);
00299                 }
00300                 else
00301                 {
00302                         ilUtil::sendInfo($this->lng->txt("qpl_export_select_none"));
00303                         $this->questionsObject();
00304                 }
00305         }
00306         
00314         function deleteQuestionsObject()
00315         {
00316                 global $rbacsystem;
00317                 
00318                 ilUtil::sendInfo();
00319                 // create an array of all checked checkboxes
00320                 $checked_questions = array();
00321                 foreach ($_POST as $key => $value) 
00322                 {
00323                         if (preg_match("/cb_(\d+)/", $key, $matches)) 
00324                         {
00325                                 array_push($checked_questions, $matches[1]);
00326                         }
00327                 }
00328                 
00329                 if (count($checked_questions) > 0) 
00330                 {
00331                         if ($rbacsystem->checkAccess('write', $this->ref_id)) 
00332                         {
00333                                 ilUtil::sendInfo($this->lng->txt("qpl_confirm_delete_questions"));
00334                         } 
00335                         else 
00336                         {
00337                                 ilUtil::sendInfo($this->lng->txt("qpl_delete_rbac_error"));
00338                                 $this->questionsObject();
00339                                 return;
00340                         }
00341                 } 
00342                 elseif (count($checked_questions) == 0) 
00343                 {
00344                         ilUtil::sendInfo($this->lng->txt("qpl_delete_select_none"));
00345                         $this->questionsObject();
00346                         return;
00347                 }
00348                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_svy_qpl_confirm_delete_questions.html", "Modules/SurveyQuestionPool");
00349                 $whereclause = join($checked_questions, " OR survey_question.question_id = ");
00350                 $whereclause = " AND (survey_question.question_id = " . $whereclause . ")";
00351                 $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";
00352                 $query_result = $this->ilias->db->query($query);
00353                 $colors = array("tblrow1", "tblrow2");
00354                 $counter = 0;
00355                 if ($query_result->numRows() > 0)
00356                 {
00357                         while ($data = $query_result->fetchRow(DB_FETCHMODE_OBJECT))
00358                         {
00359                                 if (in_array($data->question_id, $checked_questions))
00360                                 {
00361                                         $this->tpl->setCurrentBlock("row");
00362                                         $this->tpl->setVariable("COLOR_CLASS", $colors[$counter % 2]);
00363                                         $this->tpl->setVariable("TXT_TITLE", $data->title);
00364                                         $this->tpl->setVariable("TXT_DESCRIPTION", $data->description);
00365                                         $this->tpl->setVariable("TXT_TYPE", $this->lng->txt($data->type_tag));
00366                                         $this->tpl->parseCurrentBlock();
00367                                         $counter++;
00368                                 }
00369                         }
00370                 }
00371                 foreach ($checked_questions as $id)
00372                 {
00373                         $this->tpl->setCurrentBlock("hidden");
00374                         $this->tpl->setVariable("HIDDEN_NAME", "id_$id");
00375                         $this->tpl->setVariable("HIDDEN_VALUE", "1");
00376                         $this->tpl->parseCurrentBlock();
00377                 }
00378 
00379                 $this->tpl->setCurrentBlock("adm_content");
00380                 $this->tpl->setVariable("TXT_TITLE", $this->lng->txt("title"));
00381                 $this->tpl->setVariable("TXT_DESCRIPTION", $this->lng->txt("description"));
00382                 $this->tpl->setVariable("TXT_TYPE", $this->lng->txt("question_type"));
00383                 $this->tpl->setVariable("BTN_CONFIRM", $this->lng->txt("confirm"));
00384                 $this->tpl->setVariable("BTN_CANCEL", $this->lng->txt("cancel"));
00385                 $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
00386                 $this->tpl->parseCurrentBlock();
00387         }
00388 
00392         function confirmDeleteQuestionsObject()
00393         {
00394                 // delete questions after confirmation
00395                 ilUtil::sendInfo($this->lng->txt("qpl_questions_deleted"), true);
00396                 $checked_questions = array();
00397                 foreach ($_POST as $key => $value) {
00398                         if (preg_match("/id_(\d+)/", $key, $matches)) {
00399                                 array_push($checked_questions, $matches[1]);
00400                         }
00401                 }
00402 
00403                 foreach ($checked_questions as $key => $value) {
00404                         $this->object->removeQuestion($value);
00405                 }
00406                 $this->ctrl->redirect($this, "questions");
00407         }
00408         
00412         function cancelDeleteQuestionsObject()
00413         {
00414                 // delete questions after confirmation
00415                 $this->ctrl->redirect($this, "questions");
00416         }
00417         
00425         function pasteObject()
00426         {
00427                 ilUtil::sendInfo();
00428 
00429     // create an array of all checked checkboxes
00430     $checked_questions = array();
00431     foreach ($_POST as $key => $value) {
00432       if (preg_match("/cb_(\d+)/", $key, $matches)) {
00433         array_push($checked_questions, $matches[1]);
00434       }
00435     }
00436                 
00437                 // paste button was pressed
00438                 if (strcmp($_SESSION["spl_copied_questions"], "") != 0)
00439                 {
00440                         $copied_questions = split("/,/", $_SESSION["spl_copied_questions"]);
00441                         ilUtil::sendInfo($this->lng->txt("qpl_past_questions_confirmation"));
00442                 }
00443                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_svy_qpl_confirm_paste_questions.html", "Modules/SurveyQuestionPool");
00444                 $questions_info =& $this->object->getQuestionsInfo($copied_questions);
00445                 $colors = array("tblrow1", "tblrow2");
00446                 $counter = 0;
00447                 foreach ($questions_info as $data)
00448                 {
00449                         $this->tpl->setCurrentBlock("row");
00450                         $this->tpl->setVariable("COLOR_CLASS", $colors[$counter % 2]);
00451                         $this->tpl->setVariable("TXT_TITLE", $data->title);
00452                         $this->tpl->setVariable("TXT_DESCRIPTION", $data->description);
00453                         $this->tpl->setVariable("TXT_TYPE", $this->lng->txt($data->type_tag));
00454                         $this->tpl->parseCurrentBlock();
00455                         $counter++;
00456                 }
00457                 foreach ($questions_info as $data)
00458                 {
00459                         $this->tpl->setCurrentBlock("hidden");
00460                         $this->tpl->setVariable("HIDDEN_NAME", "id_$data->question_id");
00461                         $this->tpl->setVariable("HIDDEN_VALUE", $data->question_id);
00462                         $this->tpl->parseCurrentBlock();
00463                 }
00464 
00465                 $this->tpl->setCurrentBlock("adm_content");
00466                 $this->tpl->setVariable("TXT_TITLE", $this->lng->txt("title"));
00467                 $this->tpl->setVariable("TXT_DESCRIPTION", $this->lng->txt("description"));
00468                 $this->tpl->setVariable("TXT_TYPE", $this->lng->txt("question_type"));
00469                 $this->tpl->setVariable("BTN_CONFIRM", $this->lng->txt("confirm"));
00470                 $this->tpl->setVariable("BTN_CANCEL", $this->lng->txt("cancel"));
00471                 $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
00472                 $this->tpl->parseCurrentBlock();
00473         }
00474 
00478         function confirmPasteQuestionsObject()
00479         {
00480                 // paste questions after confirmation
00481                 ilUtil::sendInfo($this->lng->txt("qpl_questions_pasted"), true);
00482                 $checked_questions = array();
00483                 foreach ($_POST as $key => $value) {
00484                         if (preg_match("/id_(\d+)/", $key, $matches)) {
00485                                 array_push($checked_questions, $matches[1]);
00486                         }
00487                 }
00488                 foreach ($checked_questions as $key => $value) {
00489                         $this->object->paste($value);
00490                 }
00491                 
00492                 $this->ctrl->redirect($this, "questions");
00493         }
00494         
00498         function cancelPasteQuestionsObject()
00499         {
00500                 // delete questions after confirmation
00501                 $this->ctrl->redirect($this, "questions");
00502         }
00503         
00507         function importQuestionsObject()
00508         {
00509                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_svy_import_question.html", "Modules/SurveyQuestionPool");
00510                 $this->tpl->setCurrentBlock("adm_content");
00511                 $this->tpl->setVariable("TEXT_IMPORT_QUESTION", $this->lng->txt("import_question"));
00512                 $this->tpl->setVariable("TEXT_SELECT_FILE", $this->lng->txt("select_file"));
00513                 $this->tpl->setVariable("TEXT_UPLOAD", $this->lng->txt("upload"));
00514                 $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
00515                 $this->tpl->parseCurrentBlock();
00516         }
00517 
00521         function uploadQuestionsObject()
00522         {
00523                 // check if file was uploaded
00524                 $source = $_FILES["qtidoc"]["tmp_name"];
00525                 $error = 0;
00526                 if (($source == 'none') || (!$source) || $_FILES["qtidoc"]["error"] > UPLOAD_ERR_OK)
00527                 {
00528 //                      $this->ilias->raiseError("No file selected!",$this->ilias->error_obj->MESSAGE);
00529                         $error = 1;
00530                 }
00531                 // check correct file type
00532                 if (strpos("xml", $_FILES["qtidoc"]["type"]) !== FALSE)
00533                 {
00534 //                      $this->ilias->raiseError("Wrong file type!",$this->ilias->error_obj->MESSAGE);
00535                         $error = 1;
00536                 }
00537                 if (!$error)
00538                 {
00539                         // import file into questionpool
00540                         // create import directory
00541                         $this->object->createImportDirectory();
00542 
00543                         // copy uploaded file to import directory
00544                         $full_path = $this->object->getImportDirectory()."/".$_FILES["qtidoc"]["name"];
00545 
00546                         include_once "./Services/Utilities/classes/class.ilUtil.php";
00547                         ilUtil::moveUploadedFile($_FILES["qtidoc"]["tmp_name"], 
00548                                 $_FILES["qtidoc"]["name"], $full_path);
00549                         //move_uploaded_file($_FILES["qtidoc"]["tmp_name"], $full_path);
00550                         $source = $full_path;
00551                         $this->object->importObject($source, TRUE);
00552                         unlink($source);
00553                 }
00554                 $this->ctrl->redirect($this, "questions");
00555         }
00556         
00557         function filterObject()
00558         {
00559                 $this->questionsObject();
00560         }
00561         
00562         function resetObject()
00563         {
00564                 $this->questionsObject();
00565         }
00566         
00571         function questionsObject()
00572         {
00573                 global $rbacsystem;
00574                 global $ilUser;
00575 
00576                 $lastquestiontype = $ilUser->getPref("svy_lastquestiontype");
00577                 $filter_text = "";
00578                 $filter_type = "";
00579                 if (count($_POST))
00580                 {
00581                         $filter_text = $_POST["filter_text"];
00582                         $filter_type = $_POST["sel_filter_type"];
00583                 }
00584                 else
00585                 {
00586                         $filter_text = $_GET["filter_text"];
00587                         $filter_type = $_GET["sel_filter_type"];
00588                 }
00589                 
00590                 if (strcmp($this->ctrl->getCmd(), "reset") == 0)
00591                 {
00592                         $filter_text = "";
00593                         $filter_type = "";
00594                 }
00595                 else
00596                 {
00597                         $this->ctrl->setParameter($this, "filter_text", $filter_text);
00598                         $this->ctrl->setParameter($this, "sel_filter_type", $filter_type);
00599                 }
00600 
00601                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_svy_qpl_questions.html", "Modules/SurveyQuestionPool");
00602                 if ($rbacsystem->checkAccess("write", $this->ref_id)) 
00603                 {
00604                         $this->tpl->addBlockFile("CREATE_QUESTION", "create_question", "tpl.il_svy_qpl_create_new_question.html", "Modules/SurveyQuestionPool");
00605                 }
00606                 $this->tpl->addBlockFile("A_BUTTONS", "a_buttons", "tpl.il_svy_qpl_action_buttons.html", "Modules/SurveyQuestionPool");
00607                 $this->tpl->addBlockFile("FILTER_QUESTION_MANAGER", "filter_questions", "tpl.il_svy_qpl_filter_questions.html", "Modules/SurveyQuestionPool");
00608 
00609                 // create filter form
00610                 $filter_fields = array(
00611                         "title" => $this->lng->txt("title"),
00612                         "description" => $this->lng->txt("description"),
00613                         "author" => $this->lng->txt("author"),
00614                 );
00615                 $this->tpl->setCurrentBlock("filterrow");
00616                 foreach ($filter_fields as $key => $value) 
00617                 {
00618                         $this->tpl->setVariable("VALUE_FILTER_TYPE", "$key");
00619                         $this->tpl->setVariable("NAME_FILTER_TYPE", "$value");
00620                         if (!$_POST["cmd"]["reset"]) 
00621                         {
00622                                 if (strcmp($filter_type, $key) == 0) 
00623                                 {
00624                                         $this->tpl->setVariable("VALUE_FILTER_SELECTED", " selected=\"selected\"");
00625                                 }
00626                         }
00627                         $this->tpl->parseCurrentBlock();
00628                 }
00629 
00630                 $this->tpl->setCurrentBlock("filter_questions");
00631                 $this->tpl->setVariable("FILTER_TEXT", $this->lng->txt("filter"));
00632                 $this->tpl->setVariable("TEXT_FILTER_BY", $this->lng->txt("by"));
00633                 if (strcmp($this->ctrl->getCmd(), "reset") != 0)
00634                 {
00635                         $this->tpl->setVariable("VALUE_FILTER_TEXT", $filter_text);
00636                 }
00637                 $this->tpl->setVariable("VALUE_SUBMIT_FILTER", $this->lng->txt("set_filter"));
00638                 $this->tpl->setVariable("VALUE_RESET_FILTER", $this->lng->txt("reset_filter"));
00639                 $this->tpl->parseCurrentBlock();
00640     
00641                 $startrow = 0;
00642                 if ($_GET["prevrow"])
00643                 {
00644                         $startrow = $_GET["prevrow"];
00645                 }               
00646                 if ($_GET["nextrow"])
00647                 {
00648                         $startrow = $_GET["nextrow"];
00649                 }
00650                 if ($_GET["startrow"])
00651                 {
00652                         $startrow = $_GET["startrow"];
00653                 }
00654                 if (!$_GET["sort"])
00655                 {
00656                         // default sort order
00657                         $_GET["sort"] = array("title" => "ASC");
00658                 }
00659                 $sort = ($_GET["sort"]) ? $_GET["sort"] : "title";
00660                 $sortorder = ($_GET["sortorder"]) ? $_GET["sortorder"] : "ASC";
00661                 $this->ctrl->setParameter($this, "sort", $sort);
00662                 $this->ctrl->setParameter($this, "sortorder", $sortorder);
00663                 $table = $this->object->getQuestionsTable($sort, $sortorder, $filter_text, $filter_type, $startrow);
00664                 $colors = array("tblrow1", "tblrow2");
00665                 $counter = 0;
00666                 $last_questionblock_id = 0;
00667                 $editable = $rbacsystem->checkAccess('write', $this->ref_id);
00668                 foreach ($table["rows"] as $data)
00669                 {
00670                         $this->tpl->setCurrentBlock("checkable");
00671                         $this->tpl->setVariable("QUESTION_ID", $data["question_id"]);
00672                         $this->tpl->parseCurrentBlock();
00673                         if ($data["complete"] == 0)
00674                         {
00675                                 $this->tpl->setCurrentBlock("qpl_warning");
00676                                 include_once "./Services/Utilities/classes/class.ilUtil.php";
00677                                 $this->tpl->setVariable("IMAGE_WARNING", ilUtil::getImagePath("warning.gif"));
00678                                 $this->tpl->setVariable("ALT_WARNING", $this->lng->txt("warning_question_not_complete"));
00679                                 $this->tpl->setVariable("TITLE_WARNING", $this->lng->txt("warning_question_not_complete"));
00680                                 $this->tpl->parseCurrentBlock();
00681                         }
00682                         include_once "./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
00683                         $classname = SurveyQuestion::_getQuestionType($data["question_id"]);
00684                         $classnamegui = $classname . "GUI";
00685                         $sel_question_types = $classname; 
00686                         $this->ctrl->setParameterByClass(strtolower($classnamegui), "q_id", $data["question_id"]);
00687                         $this->ctrl->setParameterByClass(strtolower($classnamegui), "sel_question_types", $sel_question_types);
00688                         if ($editable)
00689                         {
00690                                 $this->tpl->setCurrentBlock("url_edit");
00691                                 $this->tpl->setVariable("URL_EDIT", $this->ctrl->getLinkTargetByClass(strtolower($classnamegui), "editQuestion"));
00692                                 $this->tpl->setVariable("TEXT_EDIT", $this->lng->txt("edit"));
00693                                 $this->tpl->parseCurrentBlock();
00694                         }
00695                         $this->tpl->setCurrentBlock("QTab");
00696                         $this->tpl->setVariable("QUESTION_TITLE", "<strong>" . $data["title"] . "</strong>");
00697                         $this->tpl->setVariable("URL_PREVIEW", $this->ctrl->getLinkTargetByClass(strtolower($classnamegui), "preview"));
00698                         $this->tpl->setVariable("TEXT_PREVIEW", $this->lng->txt("preview"));
00699                         $this->tpl->setVariable("QUESTION_DESCRIPTION", $data["description"]);
00700                         $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt($data["type_tag"]));
00701                         $this->tpl->setVariable("QUESTION_AUTHOR", $data["author"]);
00702                         include_once "./classes/class.ilFormat.php";
00703                         $this->tpl->setVariable("QUESTION_CREATED", ilFormat::formatDate(ilFormat::ftimestamp2dateDB($data["created"]), "date"));
00704                         $this->tpl->setVariable("QUESTION_UPDATED", ilFormat::formatDate(ilFormat::ftimestamp2dateDB($data["TIMESTAMP14"]), "date"));
00705                         $this->tpl->setVariable("QUESTION_ID", $data["question_id"]);
00706                         $this->tpl->setVariable("COLOR_CLASS", $colors[$counter % 2]);
00707                         $this->tpl->parseCurrentBlock();
00708                         $counter++;
00709     }
00710 
00711                 if ($table["rowcount"] > count($table["rows"]))
00712                 {
00713                         $nextstep = $table["nextrow"] + $table["step"];
00714                         if ($nextstep > $table["rowcount"])
00715                         {
00716                                 $nextstep = $table["rowcount"];
00717                         }
00718                         $counter = 1;
00719                         for ($i = 0; $i < $table["rowcount"]; $i += $table["step"])
00720                         {
00721                                 $this->tpl->setCurrentBlock("pages");
00722                                 if ($table["startrow"] == $i)
00723                                 {
00724                                         $this->tpl->setVariable("PAGE_NUMBER", "<span class=\"inactivepage\">$counter</span>");
00725                                 }
00726                                 else
00727                                 {
00728                                         $this->tpl->setVariable("PAGE_NUMBER", "<a href=\"" . $this->ctrl->getLinkTarget($this, "questions") . "&nextrow=$i" . "\">$counter</a>");
00729                                 }
00730                                 $this->tpl->parseCurrentBlock();
00731                                 $counter++;
00732                         }
00733                         $this->tpl->setCurrentBlock("navigation_bottom");
00734                         $this->tpl->setVariable("TEXT_ITEM", $this->lng->txt("item"));
00735                         $this->tpl->setVariable("TEXT_ITEM_START", $table["startrow"] + 1);
00736                         $end = $table["startrow"] + $table["step"];
00737                         if ($end > $table["rowcount"])
00738                         {
00739                                 $end = $table["rowcount"];
00740                         }
00741                         $this->tpl->setVariable("TEXT_ITEM_END", $end);
00742                         $this->tpl->setVariable("TEXT_OF", strtolower($this->lng->txt("of")));
00743                         $this->tpl->setVariable("TEXT_ITEM_COUNT", $table["rowcount"]);
00744                         $this->tpl->setVariable("TEXT_PREVIOUS", $this->lng->txt("previous"));
00745                         $this->tpl->setVariable("TEXT_NEXT", $this->lng->txt("next"));
00746                         $this->tpl->setVariable("HREF_PREV_ROWS", $this->ctrl->getLinkTarget($this, "questions") . "&prevrow=" . $table["prevrow"]);
00747                         $this->tpl->setVariable("HREF_NEXT_ROWS", $this->ctrl->getLinkTarget($this, "questions") . "&nextrow=" . $table["nextrow"]);
00748                         $this->tpl->parseCurrentBlock();
00749                 }
00750 
00751                 // if there are no questions, display a message
00752                 if ($counter == 0) 
00753                 {
00754                         $this->tpl->setCurrentBlock("Emptytable");
00755                         $this->tpl->setVariable("TEXT_EMPTYTABLE", $this->lng->txt("no_questions_available"));
00756                         $this->tpl->parseCurrentBlock();
00757                 }
00758                 if ($counter > 0) 
00759                 {
00760                         $this->tpl->setCurrentBlock("selectall");
00761                         $this->tpl->setVariable("SELECT_ALL", $this->lng->txt("select_all"));
00762                         $counter++;
00763                         $this->tpl->setVariable("COLOR_CLASS", $colors[$counter % 2]);
00764                         $this->tpl->parseCurrentBlock();
00765                 }
00766 
00767                 include_once "./Services/Utilities/classes/class.ilUtil.php";
00768                 $this->tpl->setVariable("ARROW", "<img src=\"" . ilUtil::getImagePath("arrow_downright.gif") . "\" alt=\"".$this->lng->txt("arrow_downright")."\">");
00769                 $this->tpl->setCurrentBlock("copy");
00770                 $this->tpl->setVariable("COPY", $this->lng->txt("copy"));
00771                 $this->tpl->parseCurrentBlock();
00772                 $this->tpl->setCurrentBlock("exportquestions");
00773                 $this->tpl->setVariable("EXPORT", $this->lng->txt("export"));
00774                 $this->tpl->parseCurrentBlock();
00775 
00776                 // create edit buttons & table footer
00777                 if ($rbacsystem->checkAccess("write", $this->ref_id))
00778                 {
00779                         $this->tpl->setVariable("DELETE", $this->lng->txt("delete"));
00780                         $this->tpl->setVariable("DUPLICATE", $this->lng->txt("duplicate_question"));
00781                         $this->tpl->setVariable("PASTE", $this->lng->txt("paste"));
00782                         if (strcmp($_SESSION["spl_copied_questions"], "") == 0)
00783                         {
00784                                 $this->tpl->setVariable("PASTE_DISABLED", " disabled=\"disabled\"");
00785                         }
00786                 }
00787     
00788                 if ($rbacsystem->checkAccess("write", $this->ref_id)) 
00789                 {
00790                         // "create question" form
00791                         $questiontypes =& $this->object->_getQuestiontypes();
00792                         $this->tpl->setCurrentBlock("QTypes");
00793                         foreach ($questiontypes as $questiontype)
00794                         {
00795                                 if (strcmp($lastquestiontype, $questiontype) == 0)
00796                                 {
00797                                         $this->tpl->setVariable("QUESTION_TYPE_SELECTED", " selected=\"selected\"");
00798                                 }
00799                                 $this->tpl->setVariable("QUESTION_TYPE_ID", $questiontype);
00800                                 $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt($questiontype));
00801                                 $this->tpl->parseCurrentBlock();
00802                         }
00803                         $this->tpl->setCurrentBlock("CreateQuestion");
00804                         $this->tpl->setVariable("QUESTION_ADD", $this->lng->txt("create"));
00805                         $this->tpl->setVariable("QUESTION_IMPORT", $this->lng->txt("import"));
00806                         $this->tpl->setVariable("ACTION_QUESTION_ADD", $this->ctrl->getFormAction($this));
00807                         $this->tpl->parseCurrentBlock();
00808                 }
00809                 // define the sort column parameters
00810                 $sortarray = array(
00811                         "title" => (strcmp($sort, "title") == 0) ? $sortorder : "",
00812                         "description" => (strcmp($sort, "description") == 0) ? $sortorder : "",
00813                         "type" => (strcmp($sort, "type") == 0) ? $sortorder : "",
00814                         "author" => (strcmp($sort, "author") == 0) ? $sortorder : "",
00815                         "created" => (strcmp($sort, "created") == 0) ? $sortorder : "",
00816                         "updated" => (strcmp($sort, "updated") == 0) ? $sortorder : ""
00817                 );
00818                 foreach ($sortarray as $key => $value) 
00819                 {
00820                         if (strcmp($value, "ASC") == 0) 
00821                         {
00822                                 $sortarray[$key] = "DESC";
00823                         } 
00824                         else 
00825                         {
00826                                 $sortarray[$key] = "ASC";
00827                         }
00828                 }
00829     
00830                 $this->tpl->setCurrentBlock("adm_content");
00831                 // create table header
00832                 $this->ctrl->setParameterByClass(get_class($this), "startrow", $table["startrow"]);
00833                 $this->ctrl->setParameter($this, "sort", "title");
00834                 $this->ctrl->setParameter($this, "sortorder", $sortarray["title"]);
00835                 $this->tpl->setVariable("QUESTION_TITLE", "<a href=\"" . $this->ctrl->getLinkTarget($this, "questions") . "\">" . $this->lng->txt("title") . "</a>" . $table["images"]["title"]);
00836                 $this->ctrl->setParameter($this, "sort", "description");
00837                 $this->ctrl->setParameter($this, "sortorder", $sortarray["description"]);
00838                 $this->tpl->setVariable("QUESTION_DESCRIPTION", "<a href=\"" . $this->ctrl->getLinkTarget($this, "questions") . "\">" . $this->lng->txt("description") . "</a>". $table["images"]["description"]);
00839                 $this->ctrl->setParameter($this, "sort", "type");
00840                 $this->ctrl->setParameter($this, "sortorder", $sortarray["type"]);
00841                 $this->tpl->setVariable("QUESTION_TYPE", "<a href=\"" . $this->ctrl->getLinkTarget($this, "questions") . "\">" . $this->lng->txt("question_type") . "</a>" . $table["images"]["type"]);
00842                 $this->ctrl->setParameter($this, "sort", "author");
00843                 $this->ctrl->setParameter($this, "sortorder", $sortarray["author"]);
00844                 $this->tpl->setVariable("QUESTION_AUTHOR", "<a href=\"" . $this->ctrl->getLinkTarget($this, "questions") . "\">" . $this->lng->txt("author") . "</a>" . $table["images"]["author"]);
00845                 $this->ctrl->setParameter($this, "sort", "created");
00846                 $this->ctrl->setParameter($this, "sortorder", $sortarray["created"]);
00847                 $this->tpl->setVariable("QUESTION_CREATED", "<a href=\"" . $this->ctrl->getLinkTarget($this, "questions") . "\">" . $this->lng->txt("create_date") . "</a>" . $table["images"]["created"]);
00848                 $this->ctrl->setParameter($this, "sort", "updated");
00849                 $this->ctrl->setParameter($this, "sortorder", $sortarray["updated"]);
00850                 $this->tpl->setVariable("QUESTION_UPDATED", "<a href=\"" . $this->ctrl->getLinkTarget($this, "questions") . "\">" . $this->lng->txt("last_update") . "</a>" . $table["images"]["updated"]);
00851                 $this->tpl->setVariable("BUTTON_CANCEL", $this->lng->txt("cancel"));
00852                 $this->ctrl->setParameter($this, "sort", $sort);
00853                 $this->ctrl->setParameter($this, "sortorder", $sortorder);
00854                 $this->tpl->setVariable("ACTION_QUESTION_FORM", $this->ctrl->getFormAction($this));
00855                 $this->tpl->parseCurrentBlock();
00856                 unset($_SESSION["calling_survey"]);
00857   }
00858 
00859 
00860         function updateObject() 
00861         {
00862                 $this->update = $this->object->update();
00863                 ilUtil::sendInfo($this->lng->txt("msg_obj_modified"), true);
00864         }
00865 
00866         /*
00867         * list all export files
00868         */
00869         function exportObject()
00870         {
00871                 global $tree;
00872 
00873                 //$this->setTabs();
00874 
00875                 //add template for view button
00876                 $this->tpl->addBlockfile("BUTTONS", "buttons", "tpl.buttons.html");
00877 
00878                 // create export file button
00879                 $this->tpl->setCurrentBlock("btn_cell");
00880                 $this->tpl->setVariable("BTN_LINK", $this->ctrl->getLinkTarget($this, "createExportFile"));
00881                 $this->tpl->setVariable("BTN_TXT", $this->lng->txt("svy_create_export_file"));
00882                 $this->tpl->parseCurrentBlock();
00883 
00884                 $export_dir = $this->object->getExportDirectory();
00885                 $export_files = $this->object->getExportFiles($export_dir);
00886 
00887                 // create table
00888                 include_once("./Services/Table/classes/class.ilTableGUI.php");
00889                 $tbl = new ilTableGUI();
00890 
00891                 // load files templates
00892                 $this->tpl->addBlockfile("ADM_CONTENT", "adm_content", "tpl.table.html");
00893 
00894                 // load template for table content data
00895                 $this->tpl->addBlockfile("TBL_CONTENT", "tbl_content", "tpl.export_file_row.html", "Modules/SurveyQuestionPool");
00896 
00897                 $num = 0;
00898 
00899                 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
00900 
00901                 $tbl->setTitle($this->lng->txt("svy_export_files"));
00902 
00903                 $tbl->setHeaderNames(array("", $this->lng->txt("svy_file"),
00904                         $this->lng->txt("svy_size"), $this->lng->txt("date") ));
00905 
00906                 $tbl->enabled["sort"] = false;
00907                 $tbl->setColumnWidth(array("1%", "49%", "25%", "25%"));
00908 
00909                 // control
00910                 $tbl->setOrderColumn($_GET["sort_by"]);
00911                 $tbl->setOrderDirection($_GET["sort_order"]);
00912                 $tbl->setLimit($_GET["limit"]);
00913                 $tbl->setOffset($_GET["offset"]);
00914                 $tbl->setMaxCount($this->maxcount);             // ???
00915                 $header_params = $this->ctrl->getParameterArray($this, "export");
00916                 $tbl->setHeaderVars(array("", "file", "size", "date"), $header_params);
00917 
00918                 // delete button
00919                 include_once "./Services/Utilities/classes/class.ilUtil.php";
00920 
00921                 // footer
00922                 $tbl->setFooter("tblfooter",$this->lng->txt("previous"),$this->lng->txt("next"));
00923                 //$tbl->disable("footer");
00924 
00925                 $tbl->setMaxCount(count($export_files));
00926                 $export_files = array_slice($export_files, $_GET["offset"], $_GET["limit"]);
00927 
00928                 $tbl->render();
00929                 if(count($export_files) > 0)
00930                 {
00931                         $this->tpl->setVariable("COLUMN_COUNTS", 4);
00932 
00933                         $i=0;
00934                         foreach($export_files as $exp_file)
00935                         {
00936                                 $this->tpl->setCurrentBlock("tbl_content");
00937                                 $this->tpl->setVariable("TXT_FILENAME", $exp_file);
00938 
00939                                 $css_row = ilUtil::switchColor($i++, "tblrow1", "tblrow2");
00940                                 $this->tpl->setVariable("CSS_ROW", $css_row);
00941 
00942                                 $this->tpl->setVariable("TXT_SIZE", filesize($export_dir."/".$exp_file));
00943                                 $this->tpl->setVariable("CHECKBOX_ID", $exp_file);
00944 
00945                                 $file_arr = explode("__", $exp_file);
00946                                 $this->tpl->setVariable("TXT_DATE", date("Y-m-d H:i:s",$file_arr[0]));
00947 
00948                                 $this->tpl->parseCurrentBlock();
00949                         }
00950                         $this->tpl->setCurrentBlock("selectall");
00951                         $this->tpl->setVariable("SELECT_ALL", $this->lng->txt("select_all"));
00952                         $this->tpl->setVariable("CSS_ROW", $css_row);
00953                         $this->tpl->parseCurrentBlock();
00954                         $this->tpl->setVariable("IMG_ARROW", ilUtil::getImagePath("arrow_downright.gif"));
00955                         $this->tpl->setCurrentBlock("tbl_action_btn");
00956                         $this->tpl->setVariable("BTN_NAME", "confirmDeleteExportFile");
00957                         $this->tpl->setVariable("BTN_VALUE", $this->lng->txt("delete"));
00958                         $this->tpl->parseCurrentBlock();
00959         
00960                         $this->tpl->setCurrentBlock("tbl_action_btn");
00961                         $this->tpl->setVariable("BTN_NAME", "downloadExportFile");
00962                         $this->tpl->setVariable("BTN_VALUE", $this->lng->txt("download"));
00963                         $this->tpl->parseCurrentBlock();
00964                 } //if is_array
00965                 else
00966                 {
00967                         $this->tpl->setCurrentBlock("notfound");
00968                         $this->tpl->setVariable("TXT_OBJECT_NOT_FOUND", $this->lng->txt("obj_not_found"));
00969                         $this->tpl->setVariable("NUM_COLS", 3);
00970                         $this->tpl->parseCurrentBlock();
00971                 }
00972 
00973                 $this->tpl->parseCurrentBlock();
00974         }
00975 
00979         function createExportFileObject($questions = null)
00980         {
00981                 global $rbacsystem;
00982                 
00983                 if ($rbacsystem->checkAccess("write", $this->ref_id))
00984                 {
00985                         include_once("./Modules/SurveyQuestionPool/classes/class.ilSurveyQuestionpoolExport.php");
00986                         $survey_exp = new ilSurveyQuestionpoolExport($this->object);
00987                         $survey_exp->buildExportFile($questions);
00988                         $this->ctrl->redirect($this, "export");
00989                 }
00990                 else
00991                 {
00992                         ilUtil::sendInfo("cannot_export_questionpool");
00993                 }
00994         }
00995         
00999         function downloadExportFileObject()
01000         {
01001                 if(!isset($_POST["file"]))
01002                 {
01003                         ilUtil::sendInfo($this->lng->txt("no_checkbox"), true);
01004                         $this->ctrl->redirect($this, "export");
01005                 }
01006 
01007                 if (count($_POST["file"]) > 1)
01008                 {
01009                         ilUtil::sendInfo($this->lng->txt("select_max_one_item"),true);
01010                         $this->ctrl->redirect($this, "export");
01011                 }
01012 
01013 
01014                 $export_dir = $this->object->getExportDirectory();
01015                 include_once "./Services/Utilities/classes/class.ilUtil.php";
01016                 ilUtil::deliverFile($export_dir."/".$_POST["file"][0],
01017                         $_POST["file"][0]);
01018         }
01019 
01023         function confirmDeleteExportFileObject()
01024         {
01025                 if(!isset($_POST["file"]))
01026                 {
01027                         ilUtil::sendInfo($this->lng->txt("no_checkbox"),true);
01028                         $this->ctrl->redirect($this, "export");
01029                 }
01030 
01031                 //$this->setTabs();
01032 
01033                 // SAVE POST VALUES
01034                 $_SESSION["ilExportFiles"] = $_POST["file"];
01035 
01036                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.confirm_deletion.html", "Modules/SurveyQuestionPool");
01037 
01038                 ilUtil::sendInfo($this->lng->txt("info_delete_sure"));
01039 
01040                 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
01041 
01042                 // BEGIN TABLE HEADER
01043                 $this->tpl->setCurrentBlock("table_header");
01044                 $this->tpl->setVariable("TEXT",$this->lng->txt("objects"));
01045                 $this->tpl->parseCurrentBlock();
01046 
01047                 // BEGIN TABLE DATA
01048                 $counter = 0;
01049                 include_once "./Services/Utilities/classes/class.ilUtil.php";
01050                 foreach($_POST["file"] as $file)
01051                 {
01052                                 $this->tpl->setCurrentBlock("table_row");
01053                                 $this->tpl->setVariable("IMG_OBJ", ilUtil::getImagePath("icon_file.gif"));
01054                                 $this->tpl->setVariable("TEXT_IMG_OBJ", $this->lng->txt("file_icon"));
01055                                 $this->tpl->setVariable("CSS_ROW",ilUtil::switchColor(++$counter,"tblrow1","tblrow2"));
01056                                 $this->tpl->setVariable("TEXT_CONTENT", $file);
01057                                 $this->tpl->parseCurrentBlock();
01058                 }
01059 
01060                 // cancel/confirm button
01061                 $this->tpl->setVariable("IMG_ARROW",ilUtil::getImagePath("arrow_downright.gif"));
01062                 $buttons = array( 
01063                         "deleteExportFile"  => $this->lng->txt("confirm"),
01064                         "cancelDeleteExportFile"  => $this->lng->txt("cancel")
01065                         );
01066                 foreach ($buttons as $name => $value)
01067                 {
01068                         $this->tpl->setCurrentBlock("operation_btn");
01069                         $this->tpl->setVariable("BTN_NAME",$name);
01070                         $this->tpl->setVariable("BTN_VALUE",$value);
01071                         $this->tpl->parseCurrentBlock();
01072                 }
01073         }
01074 
01075 
01079         function cancelDeleteExportFileObject()
01080         {
01081                 session_unregister("ilExportFiles");
01082                 $this->ctrl->redirect($this, "export");
01083         }
01084 
01085 
01089         function deleteExportFileObject()
01090         {
01091                 $export_dir = $this->object->getExportDirectory();
01092                 foreach($_SESSION["ilExportFiles"] as $file)
01093                 {
01094                         $exp_file = $export_dir."/".$file;
01095                         $exp_dir = $export_dir."/".substr($file, 0, strlen($file) - 4);
01096                         if (@is_file($exp_file))
01097                         {
01098                                 unlink($exp_file);
01099                         }
01100                         if (@is_dir($exp_dir))
01101                         {
01102                                 include_once "./Services/Utilities/classes/class.ilUtil.php";
01103                                 ilUtil::delDir($exp_dir);
01104                         }
01105                 }
01106                 $this->ctrl->redirect($this, "export");
01107         }
01108 
01114         function importObject()
01115         {
01116                 global $rbacsystem;
01117                 if (!$rbacsystem->checkAccess("create", $_GET["ref_id"]))
01118                 {
01119                         $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
01120                 }
01121                 $this->getTemplateFile("import", "spl");
01122                 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
01123                 $this->tpl->setVariable("BTN_NAME", "uploadSpl");
01124                 $this->tpl->setVariable("TXT_UPLOAD", $this->lng->txt("upload"));
01125                 $this->tpl->setVariable("TXT_IMPORT_SPL", $this->lng->txt("import_spl"));
01126                 $this->tpl->setVariable("TXT_SELECT_MODE", $this->lng->txt("select_mode"));
01127                 $this->tpl->setVariable("TXT_SELECT_FILE", $this->lng->txt("select_file"));
01128         }
01129 
01133         function uploadSplObject($redirect = true)
01134         {
01135                 if ($_FILES["xmldoc"]["error"] > UPLOAD_ERR_OK)
01136                 {
01137                         ilUtil::sendInfo($this->lng->txt("spl_select_file_for_import"));
01138                         $this->importObject();
01139                         return;
01140                 }
01141                 include_once "./Modules/SurveyQuestionPool/classes/class.ilObjSurveyQuestionPool.php";
01142                 // create new questionpool object
01143                 $newObj = new ilObjSurveyQuestionPool();
01144                 // set type of questionpool object
01145                 $newObj->setType($_GET["new_type"]);
01146                 // set title of questionpool object to "dummy"
01147                 $newObj->setTitle("dummy");
01148                 // set description of questionpool object to "dummy"
01149                 //$newObj->setDescription("dummy");
01150                 // create the questionpool class in the ILIAS database (object_data table)
01151                 $newObj->create(true);
01152                 // create a reference for the questionpool object in the ILIAS database (object_reference table)
01153                 $newObj->createReference();
01154                 // put the questionpool object in the administration tree
01155                 $newObj->putInTree($_GET["ref_id"]);
01156                 // get default permissions and set the permissions for the questionpool object
01157                 $newObj->setPermissions($_GET["ref_id"]);
01158                 // notify the questionpool object and all its parent objects that a "new" object was created
01159                 $newObj->notify("new",$_GET["ref_id"],$_GET["parent_non_rbac_id"],$_GET["ref_id"],$newObj->getRefId());
01160 
01161                 // create import directory
01162                 $newObj->createImportDirectory();
01163 
01164                 // copy uploaded file to import directory
01165                 $file = pathinfo($_FILES["xmldoc"]["name"]);
01166                 $full_path = $newObj->getImportDirectory()."/".$_FILES["xmldoc"]["name"];
01167                 include_once "./Services/Utilities/classes/class.ilUtil.php";
01168                 ilUtil::moveUploadedFile($_FILES["xmldoc"]["tmp_name"], 
01169                         $_FILES["xmldoc"]["name"], $full_path);
01170                 //move_uploaded_file($_FILES["xmldoc"]["tmp_name"], $full_path);
01171 
01172                 // import qti data
01173                 $qtiresult = $newObj->importObject($full_path);
01174 
01175                 if ($redirect)
01176                 {
01177                         $this->ctrl->redirect($this, "cancel");
01178 //                      ilUtil::redirect("adm_object.php?".$this->link_params);
01179                 }
01180                 return $newObj->getRefId();
01181         }
01182 
01186         function createObject()
01187         {
01188                 global $rbacsystem;
01189                 $new_type = $_POST["new_type"] ? $_POST["new_type"] : $_GET["new_type"];
01190                 if (!$rbacsystem->checkAccess("create", $_GET["ref_id"], $new_type))
01191                 {
01192                         $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
01193                 }
01194                 else
01195                 {
01196                         $this->getTemplateFile("create", $new_type);
01197 
01198                         include_once("./Modules/Survey/classes/class.ilObjSurvey.php");
01199                         $this->fillCloneTemplate('DUPLICATE','spl');
01200                         $this->tpl->setCurrentBlock("adm_content");
01201 
01202                         // fill in saved values in case of error
01203                         $data = array();
01204                         $data["fields"] = array();
01205                         include_once "./Services/Utilities/classes/class.ilUtil.php";
01206                         $data["fields"]["title"] = ilUtil::prepareFormOutput($_SESSION["error_post_vars"]["Fobject"]["title"],true);
01207                         $data["fields"]["desc"] = ilUtil::prepareFormOutput($_SESSION["error_post_vars"]["Fobject"]["desc"]);
01208 
01209                         foreach ($data["fields"] as $key => $val)
01210                         {
01211                                 $this->tpl->setVariable("TXT_".strtoupper($key), $this->lng->txt($key));
01212                                 $this->tpl->setVariable(strtoupper($key), $val);
01213 
01214                                 if ($this->prepare_output)
01215                                 {
01216                                         $this->tpl->parseCurrentBlock();
01217                                 }
01218                         }
01219 
01220                         $this->ctrl->setParameter($this, "new_type", $this->type);
01221                         $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
01222                         $this->tpl->setVariable("TXT_HEADER", $this->lng->txt($new_type."_new"));
01223                         $this->tpl->setVariable("TXT_CANCEL", $this->lng->txt("cancel"));
01224                         $this->tpl->setVariable("TXT_SUBMIT", $this->lng->txt($new_type."_add"));
01225                         $this->tpl->setVariable("CMD_SUBMIT", "save");
01226                         $this->tpl->setVariable("TARGET", ' target="'.
01227                                 ilFrameTargetInfo::_getFrame("MainContent").'" ');
01228                         $this->tpl->setVariable("TXT_REQUIRED_FLD", $this->lng->txt("required_field"));
01229 
01230                         $this->tpl->setVariable("TXT_IMPORT_SPL", $this->lng->txt("import_spl"));
01231                         $this->tpl->setVariable("TXT_SPL_FILE", $this->lng->txt("spl_upload_file"));
01232                         $this->tpl->setVariable("NEW_TYPE", $this->type);
01233                         $this->tpl->setVariable("TXT_IMPORT", $this->lng->txt("import"));
01234 
01235                         $this->tpl->setVariable("TYPE_IMG", ilUtil::getImagePath('icon_spl.gif'));
01236                         $this->tpl->setVariable("ALT_IMG",$this->lng->txt("obj_spl"));
01237                         $this->tpl->setVariable("TYPE_IMG2", ilUtil::getImagePath('icon_spl.gif'));
01238                         $this->tpl->setVariable("ALT_IMG2",$this->lng->txt("obj_spl"));
01239 
01240                         $this->tpl->parseCurrentBlock();
01241                 }
01242         }
01243 
01247         function importFileObject()
01248         {
01249                 if (strcmp($_FILES["xmldoc"]["tmp_name"], "") == 0)
01250                 {
01251                         ilUtil::sendInfo($this->lng->txt("spl_select_file_for_import"));
01252                         $this->createObject();
01253                         return;
01254                 }
01255                 $this->ctrl->setParameter($this, "new_type", $this->type);
01256                 $ref_id = $this->uploadSplObject(false);
01257                 // always send a message
01258                 ilUtil::sendInfo($this->lng->txt("object_imported"),true);
01259 
01260                 ilUtil::redirect("ilias.php?ref_id=".$ref_id.
01261                         "&baseClass=ilObjSurveyQuestionPoolGUI");
01262         }
01263 
01267         function &createQuestionObject()
01268         {
01269                 global $ilUser;
01270                 $ilUser->writePref("svy_lastquestiontype", $_POST["sel_question_types"]);
01271                 include_once "./Modules/SurveyQuestionPool/classes/class.SurveyQuestionGUI.php";
01272                 $q_gui =& SurveyQuestionGUI::_getQuestionGUI($_POST["sel_question_types"]);
01273                 $q_gui->object->setObjId($this->object->getId());
01274                 $this->ctrl->setParameter($this, "sel_question_types", $_POST["sel_question_types"]);
01275                 $this->ctrl->redirectByClass(get_class($q_gui), "editQuestion");
01276         }
01277 
01281         function &editQuestionForSurveyObject()
01282         {
01283                 include_once "./Modules/SurveyQuestionPool/classes/class.SurveyQuestionGUI.php";
01284                 $q_gui =& SurveyQuestionGUI::_getQuestionGUI("", $_GET["q_id"]);
01285                 $this->ctrl->setParameterByClass(get_class($q_gui), "sel_question_types", $q_gui->getQuestionType());
01286                 $this->ctrl->setParameterByClass(get_class($q_gui), "q_id", $_GET["q_id"]);
01287                 $this->ctrl->redirectByClass(get_class($q_gui), "editQuestion");
01288         }
01289 
01293         function &createQuestionForSurveyObject()
01294         {
01295                 include_once "./Modules/SurveyQuestionPool/classes/class.SurveyQuestionGUI.php";
01296                 $q_gui =& SurveyQuestionGUI::_getQuestionGUI($_GET["sel_question_types"]);
01297                 $this->ctrl->setParameterByClass(get_class($q_gui), "sel_question_types", $q_gui->getQuestionType());
01298                 $this->ctrl->redirectByClass(get_class($q_gui), "editQuestion");
01299         }
01300 
01304         function &previewObject()
01305         {
01306                 include_once "./Modules/SurveyQuestionPool/classes/class.SurveyQuestionGUI.php";
01307                 $q_gui =& SurveyQuestionGUI::_getQuestionGUI("", $_GET["preview"]);
01308                 $this->ctrl->setParameterByClass(get_class($q_gui), "sel_question_types", $q_gui->getQuestionType());
01309                 $this->ctrl->setParameterByClass(get_class($q_gui), "q_id", $_GET["preview"]);
01310                 $this->ctrl->redirectByClass(get_class($q_gui), "preview");
01311         }
01312 
01313         function addLocatorItems()
01314         {
01315                 global $ilLocator;
01316                 switch ($this->ctrl->getCmd())
01317                 {
01318                         case "create":
01319                         case "importFile":
01320                         case "cancel":
01321                                 break;
01322                         default:
01323                         $ilLocator->addItem($this->object->getTitle(), $this->ctrl->getLinkTarget($this, ""), "", $_GET["ref_id"]);
01324                                 break;
01325                 }
01326                 if ($_GET["q_id"] > 0)
01327                 {
01328                         include_once "./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
01329                         $q_type = SurveyQuestion::_getQuestionType($_GET["q_id"]) . "GUI";
01330                         $this->ctrl->setParameterByClass($q_type, "q_id", $_GET["q_id"]);
01331                         $ilLocator->addItem(SurveyQuestion::_getTitle($_GET["q_id"]), $this->ctrl->getLinkTargetByClass($q_type, "editQuestion"));
01332                 }
01333         }
01334         
01340         function getTabs(&$tabs_gui)
01341         {
01342                 $next_class = $this->ctrl->getNextClass($this);
01343                 switch ($next_class)
01344                 {
01345                         case "":
01346                         case "ilpermissiongui":
01347                         case "ilmdeditorgui":
01348                         case "ilsurveyphrasesgui":
01349                                 break;
01350                         default:
01351                                 return;
01352                                 break;
01353                 }
01354                 if (($_GET["calling_survey"] > 0) || ($_GET["new_for_survey"] > 0)) return;
01355                 // properties
01356                 $tabs_gui->addTarget("properties",
01357                          $this->ctrl->getLinkTarget($this,'properties'),
01358                          "properties", 
01359                          "", "");
01360                 // questions
01361                 $force_active = ($this->ctrl->getCmdClass() == "" ||
01362                         $this->ctrl->getCmd() == "")
01363                         ? true
01364                         : false;
01365                 if (!$force_active)
01366                 {
01367                         if (is_array($_GET["sort"]))
01368                         {
01369                                 $force_active = true;
01370                         }
01371                 }
01372                 $tabs_gui->addTarget("survey_questions",
01373                          $this->ctrl->getLinkTarget($this,'questions'),
01374                          array("questions", "filter", "reset", "createQuestion", 
01375                          "importQuestions", "deleteQuestions", "duplicate", "copy", "paste", 
01376                          "exportQuestions", "confirmDeleteQuestions", "cancelDeleteQuestions",
01377                          "confirmPasteQuestions", "cancelPasteQuestions", "uploadQuestions",
01378                          "editQuestion", "addMaterial", "removeMaterial", "save", "cancel",
01379                          "cancelExplorer", "linkChilds", "addGIT", "addST", "addPG", "preview",
01380                          "moveCategory", "deleteCategory", "addPhrase", "addCategory", "savePhrase",
01381                          "addSelectedPhrase", "cancelViewPhrase", "confirmSavePhrase", "cancelSavePhrase",
01382                          "insertBeforeCategory", "insertAfterCategory", "confirmDeleteCategory",
01383                          "cancelDeleteCategory", "categories", "saveCategories", 
01384                          "savePhrase", "addPhrase"
01385                          ),
01386                          array("ilobjsurveyquestionpoolgui", "ilsurveyphrasesgui"), "", $force_active);
01387 
01388                 global $rbacsystem;
01389                 global $ilAccess;
01390                 if ($rbacsystem->checkAccess('write', $this->ref_id))
01391                 {
01392                         // meta data
01393                         $tabs_gui->addTarget("meta_data",
01394                                  $this->ctrl->getLinkTargetByClass('ilmdeditorgui','listSection'),
01395                                  "", "ilmdeditorgui");
01396 
01397                         // manage phrases
01398                         $tabs_gui->addTarget("manage_phrases",
01399                                  $this->ctrl->getLinkTargetByClass("ilsurveyphrasesgui", "phrases"),
01400                                  array("phrases", "deletePhrase", "confirmDeletePhrase", "cancelDeletePhrase"),
01401                                  "ilsurveyphrasesgui", "");
01402                 }
01403 
01404                 // export
01405                 $tabs_gui->addTarget("export",
01406                          $this->ctrl->getLinkTarget($this,'export'),
01407                          array("export", "createExportFile", "confirmDeleteExportFile", 
01408                          "downloadExportFile", "cancelDeleteExportFile", "deleteExportFile"),
01409                          "", "");
01410 
01411                 if ($ilAccess->checkAccess("edit_permission", "", $this->ref_id))
01412                 {
01413                                 $tabs_gui->addTarget("perm_settings",
01414                                 $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm"), array("perm","info","owner"), 'ilpermissiongui');
01415                 }
01416         }
01417 
01426         function _goto($a_target)
01427         {
01428                 global $ilAccess, $ilErr, $lng;
01429                 if ($ilAccess->checkAccess("write", "", $a_target))
01430                 {
01431                         $_GET["baseClass"] = "ilObjSurveyQuestionPoolGUI";
01432                         $_GET["cmd"] = "questions";
01433                         $_GET["ref_id"] = $a_target;
01434                         include_once("ilias.php");
01435                         exit;
01436                 }
01437                 else if ($ilAccess->checkAccess("read", "", ROOT_FOLDER_ID))
01438                 {
01439                         $_GET["cmd"] = "frameset";
01440                         $_GET["target"] = "";
01441                         $_GET["ref_id"] = ROOT_FOLDER_ID;
01442                         ilUtil::sendInfo(sprintf($lng->txt("msg_no_perm_read_item"),
01443                                 ilObject::_lookupTitle(ilObject::_lookupObjId($a_target))), true);
01444                         include("repository.php");
01445                         exit;
01446                 }
01447                 $ilErr->raiseError($lng->txt("msg_no_perm_read_lm"), $ilErr->FATAL);
01448         }       
01449 } // END class.ilObjSurveyQuestionPoolGUI
01450 ?>

Generated on Fri Dec 13 2013 17:56:52 for ILIAS Release_3_9_x_branch .rev 46835 by  doxygen 1.7.1