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 "classes/class.ilObjectGUI.php";
00025 require_once("classes/class.ilFileSystemGUI.php");
00026 require_once("classes/class.ilTabsGUI.php");
00027
00039 class ilObjSAHSLearningModuleGUI extends ilObjectGUI
00040 {
00046 function ilObjSAHSLearningModuleGUI($a_data,$a_id,$a_call_by_reference, $a_prepare_output = true)
00047 {
00048 global $lng;
00049
00050 $lng->loadLanguageModule("content");
00051 $this->type = "sahs";
00052 $this->ilObjectGUI($a_data,$a_id,$a_call_by_reference,$a_prepare_output);
00053 $this->tabs_gui =& new ilTabsGUI();
00054
00055 }
00056
00060 function executeCommand()
00061 {
00062 $this->fs_gui =& new ilFileSystemGUI($this->object->getDataDirectory());
00063 $this->getTemplate();
00064 $this->setLocator();
00065 $this->setTabs();
00066
00067 $next_class = $this->ctrl->getNextClass($this);
00068 $cmd = $this->ctrl->getCmd();
00069
00070 switch($next_class)
00071 {
00072 case "ilfilesystemgui":
00073
00074 $ret =& $this->ctrl->forwardCommand($this->fs_gui);
00075 break;
00076
00077 default:
00078 $cmd = $this->ctrl->getCmd("frameset");
00079 $ret =& $this->$cmd();
00080 break;
00081 }
00082 $this->tpl->show();
00083 }
00084
00085
00086 function viewObject()
00087 {
00088
00089 $this->tpl->addBlockfile("BUTTONS", "buttons", "tpl.buttons.html");
00090
00091
00092 $this->tpl->setCurrentBlock("btn_cell");
00093 $this->tpl->setVariable("BTN_LINK","content/sahs_presentation.php?ref_id=".$this->object->getRefID());
00094 $this->tpl->setVariable("BTN_TARGET"," target=\"ilContObj".$this->object->getID()."\" ");
00095 $this->tpl->setVariable("BTN_TXT",$this->lng->txt("view"));
00096 $this->tpl->parseCurrentBlock();
00097
00098
00099 $this->tpl->setCurrentBlock("btn_cell");
00100 $this->tpl->setVariable("BTN_LINK","content/sahs_edit.php?ref_id=".$this->object->getRefID());
00101 $this->tpl->setVariable("BTN_TARGET"," target=\"bottom\" ");
00102 $this->tpl->setVariable("BTN_TXT",$this->lng->txt("edit"));
00103 $this->tpl->parseCurrentBlock();
00104 }
00105
00109 function properties()
00110 {
00111 }
00112
00116 function saveProperties()
00117 {
00118 }
00119
00120
00124 function createObject()
00125 {
00126 $this->importObject();
00127 }
00128
00134 function importObject()
00135 {
00136
00137
00138 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.slm_import.html");
00139 $this->tpl->setVariable("FORMACTION", $this->getFormAction("save","adm_object.php?cmd=gateway&ref_id=".
00140 $_GET["ref_id"]."&new_type=sahs"));
00141
00142 $this->tpl->setVariable("BTN_NAME", "save");
00143
00144 $this->tpl->setVariable("TXT_SELECT_LMTYPE", $this->lng->txt("type"));
00145 $this->tpl->setVariable("TXT_TYPE_AICC", $this->lng->txt("lm_type_aicc"));
00146 $this->tpl->setVariable("TXT_TYPE_HACP", $this->lng->txt("lm_type_hacp"));
00147 $this->tpl->setVariable("TXT_TYPE_SCORM", $this->lng->txt("lm_type_scorm"));
00148
00149 $this->tpl->setVariable("TXT_UPLOAD", $this->lng->txt("upload"));
00150 $this->tpl->setVariable("TXT_IMPORT_LM", $this->lng->txt("import_lm"));
00151 $this->tpl->setVariable("TXT_SELECT_FILE", $this->lng->txt("select_file"));
00152 $this->tpl->setVariable("TXT_VALIDATE_FILE", $this->lng->txt("cont_validate_file"));
00153
00154
00155 $umf=get_cfg_var("upload_max_filesize");
00156
00157 $pms=get_cfg_var("post_max_size");
00158
00159
00160 $max_filesize=min($umf, $pms);
00161 if (!$max_filesize) $max_filesize=max($umf, $pms);
00162
00163 $this->tpl->setVariable("TXT_FILE_INFO", $this->lng->txt("file_notice")." $max_filesize.");
00164 }
00165
00172 function uploadObject()
00173 {
00174 global $_FILES, $rbacsystem;
00175
00176
00177 $source = $_FILES["scormfile"]["tmp_name"];
00178 if (($source == 'none') || (!$source))
00179 {
00180 $this->ilias->raiseError("No file selected!",$this->ilias->error_obj->MESSAGE);
00181 }
00182
00183 if (!$rbacsystem->checkAccess("create", $_GET["ref_id"], "sahs"))
00184 {
00185 $this->ilias->raiseError($this->lng->txt("no_create_permission"), $this->ilias->error_obj->WARNING);
00186 }
00187
00188 switch ($__FILES["scormfile"]["error"])
00189 {
00190 case UPLOAD_ERR_INI_SIZE:
00191 $this->ilias->raiseError($this->lng->txt("err_max_file_size_exceeds"),$this->ilias->error_obj->MESSAGE);
00192 break;
00193
00194 case UPLOAD_ERR_FORM_SIZE:
00195 $this->ilias->raiseError($this->lng->txt("err_max_file_size_exceeds"),$this->ilias->error_obj->MESSAGE);
00196 break;
00197
00198 case UPLOAD_ERR_PARTIAL:
00199 $this->ilias->raiseError($this->lng->txt("err_partial_file_upload"),$this->ilias->error_obj->MESSAGE);
00200 break;
00201
00202 case UPLOAD_ERR_NO_FILE:
00203 $this->ilias->raiseError($this->lng->txt("err_no_file_uploaded"),$this->ilias->error_obj->MESSAGE);
00204 break;
00205 }
00206
00207 $file = pathinfo($_FILES["scormfile"]["name"]);
00208 $name = substr($file["basename"], 0, strlen($file["basename"]) - strlen($file["extension"]) - 1);
00209 if ($name == "")
00210 {
00211 $name = $this->lng->txt("no_title");
00212 }
00213
00214
00215 switch ($_POST["sub_type"])
00216 {
00217 case "scorm":
00218 include_once("content/classes/class.ilObjSCORMLearningModule.php");
00219 $newObj = new ilObjSCORMLearningModule();
00220 break;
00221
00222 case "aicc":
00223 include_once("content/classes/class.ilObjAICCLearningModule.php");
00224 $newObj = new ilObjAICCLearningModule();
00225 break;
00226
00227 case "hacp":
00228 include_once("content/classes/class.ilObjHACPLearningModule.php");
00229 $newObj = new ilObjHACPLearningModule();
00230 break;
00231 }
00232
00233
00234
00235
00236
00237 $newObj->setTitle($name);
00238 $newObj->setSubType($_POST["sub_type"]);
00239 $newObj->setDescription("");
00240 $newObj->create();
00241 $newObj->createReference();
00242 $newObj->putInTree($_GET["ref_id"]);
00243 $newObj->setPermissions($_GET["ref_id"]);
00244 $newObj->notify("new",$_GET["ref_id"],$_GET["parent_non_rbac_id"],$_GET["ref_id"],$newObj->getRefId());
00245
00246
00247 $newObj->createDataDirectory();
00248
00249
00250 $file_path = $newObj->getDataDirectory()."/".$_FILES["scormfile"]["name"];
00251
00252 ilUtil::moveUploadedFile($_FILES["scormfile"]["tmp_name"],
00253 $_FILES["scormfile"]["name"], $file_path);
00254
00255
00256
00257 ilUtil::unzip($file_path);
00258 ilUtil::renameExecutables($newObj->getDataDirectory());
00259
00260 $newObj->readObject();
00261
00262 }
00263
00264 function upload()
00265 {
00266 $this->uploadObject();
00267 }
00268
00272 function saveObject()
00273 {
00274 global $rbacadmin;
00275
00276 $this->uploadObject();
00277
00278 sendInfo( $this->lng->txt("lm_added"), true);
00279 ilUtil::redirect($this->getReturnLocation("save","adm_object.php?".$this->link_params));
00280
00281 }
00282
00286 function perm()
00287 {
00288 $this->setFormAction("permSave", "sahs_edit.php?cmd=permSave&ref_id=".$_GET["ref_id"].
00289 "&obj_id=".$_GET["obj_id"]);
00290 $this->setFormAction("addRole", "sahs_edit.php?ref_id=".$_GET["ref_id"].
00291 "&obj_id=".$_GET["obj_id"]."&cmd=addRole");
00292 $this->permObject();
00293 }
00294
00298 function permSave()
00299 {
00300 $this->setReturnLocation("permSave",
00301 "sahs_edit.php?ref_id=".$_GET["ref_id"]."&obj_id=".$_GET["obj_id"]."&cmd=perm");
00302 $this->permSaveObject();
00303 }
00304
00308 function addRole()
00309 {
00310 $this->setReturnLocation("addRole",
00311 "sahs_edit.php?ref_id=".$_GET["ref_id"]."&obj_id=".$_GET["obj_id"]."&cmd=perm");
00312 $this->addRoleObject();
00313 }
00314
00318 function owner()
00319 {
00320 $this->ownerObject();
00321 }
00322
00327 function chooseMetaSectionObject($a_target = "")
00328 {
00329 if ($a_target == "")
00330 {
00331 $a_target = "adm_object.php?ref_id=".$this->object->getRefId();
00332 }
00333
00334 include_once "classes/class.ilMetaDataGUI.php";
00335 $meta_gui =& new ilMetaDataGUI();
00336 $meta_gui->setObject($this->object);
00337 $meta_gui->edit("ADM_CONTENT", "adm_content",
00338 $a_target, $_REQUEST["meta_section"]);
00339 }
00340
00345 function chooseMetaSection()
00346 {
00347 $this->chooseMetaSectionObject($this->ctrl->getLinkTarget($this));
00348 }
00349
00354 function addMetaObject($a_target = "")
00355 {
00356 if ($a_target == "")
00357 {
00358 $a_target = "adm_object.php?ref_id=".$this->object->getRefId();
00359 }
00360
00361 include_once "classes/class.ilMetaDataGUI.php";
00362 $meta_gui =& new ilMetaDataGUI();
00363 $meta_gui->setObject($this->object);
00364 $meta_name = $_POST["meta_name"] ? $_POST["meta_name"] : $_GET["meta_name"];
00365 $meta_index = $_POST["meta_index"] ? $_POST["meta_index"] : $_GET["meta_index"];
00366 if ($meta_index == "")
00367 $meta_index = 0;
00368 $meta_path = $_POST["meta_path"] ? $_POST["meta_path"] : $_GET["meta_path"];
00369 $meta_section = $_POST["meta_section"] ? $_POST["meta_section"] : $_GET["meta_section"];
00370 if ($meta_name != "")
00371 {
00372 $meta_gui->meta_obj->add($meta_name, $meta_path, $meta_index);
00373 }
00374 else
00375 {
00376 sendInfo($this->lng->txt("meta_choose_element"), true);
00377 }
00378 $meta_gui->edit("ADM_CONTENT", "adm_content", $a_target, $meta_section);
00379 }
00380
00385 function addMeta()
00386 {
00387 $this->addMetaObject($this->ctrl->getLinkTarget($this));
00388 }
00389
00390
00395 function deleteMetaObject($a_target = "")
00396 {
00397 if ($a_target == "")
00398 {
00399 $a_target = "adm_object.php?ref_id=".$this->object->getRefId();
00400 }
00401
00402 include_once "classes/class.ilMetaDataGUI.php";
00403 $meta_gui =& new ilMetaDataGUI();
00404 $meta_gui->setObject($this->object);
00405 $meta_index = $_POST["meta_index"] ? $_POST["meta_index"] : $_GET["meta_index"];
00406 $meta_gui->meta_obj->delete($_GET["meta_name"], $_GET["meta_path"], $meta_index);
00407 $meta_gui->edit("ADM_CONTENT", "adm_content", $a_target, $_GET["meta_section"]);
00408 }
00409
00414 function deleteMeta()
00415 {
00416 $this->deleteMetaObject($this->ctrl->getLinkTarget($this));
00417 }
00418
00423 function editMetaObject($a_target = "")
00424 {
00425 if ($a_target == "")
00426 {
00427 $a_target = "adm_object.php?ref_id=".$this->object->getRefId();
00428 }
00429
00430 include_once "classes/class.ilMetaDataGUI.php";
00431 $meta_gui =& new ilMetaDataGUI();
00432 $meta_gui->setObject($this->object);
00433 $meta_gui->edit("ADM_CONTENT", "adm_content", $a_target, $_GET["meta_section"]);
00434 }
00435
00440 function editMeta()
00441 {
00442 $this->editMetaObject($this->ctrl->getLinkTarget($this));
00443 }
00444
00449 function saveMetaObject($a_target = "")
00450 {
00451 if ($a_target == "")
00452 {
00453 $a_target = "adm_object.php?cmd=editMeta&ref_id=".$this->object->getRefId();
00454 }
00455
00456 include_once "classes/class.ilMetaDataGUI.php";
00457 $meta_gui =& new ilMetaDataGUI();
00458 $meta_gui->setObject($this->object);
00459 $meta_gui->save($_POST["meta_section"]);
00460 ilUtil::redirect(ilUtil::appendUrlParameterString($a_target,
00461 "meta_section=" . $_POST["meta_section"]));
00462 }
00463
00468 function saveMeta()
00469 {
00470 $this->saveMetaObject($this->ctrl->getLinkTarget($this, "editMeta"));
00471 }
00472
00473
00477 function getTemplate()
00478 {
00479 global $lng;
00480
00481 $this->tpl->addBlockFile("CONTENT", "content", "tpl.adm_content.html");
00482
00483 $this->tpl->addBlockFile("STATUSLINE", "statusline", "tpl.statusline.html");
00484
00485 }
00486
00487
00493 function frameset()
00494 {
00495 $this->tpl = new ilTemplate("tpl.sahs_edit_frameset.html", false, false, "content");
00496 $this->tpl->setVariable("REF_ID",$this->ref_id);
00497 $this->tpl->show();
00498 }
00499
00503 function setLocator($a_tree = "", $a_id = "", $scriptname="adm_object.php")
00504 {
00505 global $ilias_locator, $tree;
00506 if (!defined("ILIAS_MODULE"))
00507 {
00508 parent::setLocator();
00509 }
00510 else
00511 {
00512 $a_tree =& $tree;
00513 $a_id = $_GET["ref_id"];
00514
00515 $this->tpl->addBlockFile("LOCATOR", "locator", "tpl.locator.html");
00516
00517 $path = $a_tree->getPathFull($a_id);
00518
00519
00520 $modifier = 1;
00521
00522 if (!empty($_GET["obj_id"]))
00523 {
00524 $modifier = 0;
00525 }
00526
00527
00528 $i = 1;
00529
00530 if ($this->object->getType() != "grp" && ($_GET["cmd"] == "delete" || $_GET["cmd"] == "edit"))
00531 {
00532 unset($path[count($path) - 1]);
00533 }
00534
00535 foreach ($path as $key => $row)
00536 {
00537
00538 if ($key < count($path) - $modifier)
00539 {
00540 $this->tpl->touchBlock("locator_separator");
00541 }
00542
00543 $this->tpl->setCurrentBlock("locator_item");
00544 if ($row["child"] != $a_tree->getRootId())
00545 {
00546 $this->tpl->setVariable("ITEM", $row["title"]);
00547 }
00548 else
00549 {
00550 $this->tpl->setVariable("ITEM", $this->lng->txt("repository"));
00551 }
00552 if($row["type"] == "sahs")
00553 {
00554 $this->tpl->setVariable("LINK_ITEM", "sahs_edit.php?ref_id=".$row["child"]."&type=".$row["type"]);
00555 }
00556 else
00557 {
00558 $this->tpl->setVariable("LINK_ITEM", "../repository.php?cmd=frameset&ref_id=".$row["child"]);
00559 $t_frame = ilFrameTargetInfo::_getFrame("MainContent");
00560 $this->tpl->setVariable("LINK_TARGET", " target=\"$t_frame\" ");
00561 }
00562
00563
00564 $this->tpl->parseCurrentBlock();
00565
00566 $this->tpl->setCurrentBlock("locator");
00567
00568
00569
00570 if ($row["child"] != $a_tree->getRootId())
00571 {
00572 $ilias_locator->navigate($i++,$row["title"],"../repository.php?ref_id=".$row["child"],"bottom");
00573 }
00574 else
00575 {
00576 $ilias_locator->navigate($i++,$this->lng->txt("repository"),"../repository.php?ref_id=".$row["child"],"bottom");
00577 }
00578 }
00579
00580 $this->tpl->setVariable("TXT_LOCATOR",$debug.$this->lng->txt("locator"));
00581 $this->tpl->parseCurrentBlock();
00582 }
00583
00584 }
00585
00586
00590 function setTabs()
00591 {
00592 $this->getTabs($this->tabs_gui);
00593 $this->tpl->setVariable("TABS", $this->tabs_gui->getHTML());
00594 $this->tpl->setVariable("HEADER", $this->object->getTitle());
00595 }
00596
00602 function getTabs(&$tabs_gui)
00603 {
00604 if ($this->ctrl->getCmd() == "delete")
00605 {
00606 return;
00607 }
00608
00609
00610 $tabs_gui->addTarget("properties",
00611 $this->ctrl->getLinkTarget($this, "properties"), "properties",
00612 get_class($this));
00613
00614
00615 if (is_object($this->fs_gui))
00616 {
00617 $this->fs_gui->getTabs($tabs_gui);
00618 }
00619
00620
00621 $tabs_gui->addTarget("cont_tracking_data",
00622 $this->ctrl->getLinkTarget($this, "showTrackingItems"), "showTrackingItems",
00623 get_class($this));
00624
00625
00626 $tabs_gui->addTarget("meta_data",
00627 $this->ctrl->getLinkTarget($this, "editMeta"), "editMeta",
00628 get_class($this));
00629
00630
00631 $tabs_gui->addTarget("perm_settings",
00632 $this->ctrl->getLinkTarget($this, "perm"), "perm",
00633 get_class($this));
00634
00635
00636 $tabs_gui->addTarget("owner",
00637 $this->ctrl->getLinkTarget($this, "owner"), "owner",
00638 get_class($this));
00639 }
00640
00641
00642
00643 }
00644 ?>