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,false);
00053 #$this->tabs_gui =& new ilTabsGUI();
00054
00055 }
00056
00060 function &executeCommand()
00061 {
00062 if (strtolower($_GET["baseClass"]) == "iladministrationgui" ||
00063 $this->getCreationMode() == true)
00064 {
00065 $this->prepareOutput();
00066 }
00067 else
00068 {
00069 $this->getTemplate();
00070 $this->setLocator();
00071 $this->setTabs();
00072 }
00073
00074 $next_class = $this->ctrl->getNextClass($this);
00075 $cmd = $this->ctrl->getCmd();
00076
00077 switch($next_class)
00078 {
00079 case 'ilmdeditorgui':
00080
00081 include_once 'Services/MetaData/classes/class.ilMDEditorGUI.php';
00082
00083 $md_gui =& new ilMDEditorGUI($this->object->getId(), 0, $this->object->getType());
00084 $md_gui->addObserver($this->object,'MDUpdateListener','General');
00085
00086 $this->ctrl->forwardCommand($md_gui);
00087 break;
00088
00089 case 'ilpermissiongui':
00090 include_once("./classes/class.ilPermissionGUI.php");
00091 $perm_gui =& new ilPermissionGUI($this);
00092 $ret =& $this->ctrl->forwardCommand($perm_gui);
00093 break;
00094
00095 case "ilfilesystemgui":
00096 $this->fs_gui =& new ilFileSystemGUI($this->object->getDataDirectory());
00097 $ret =& $this->ctrl->forwardCommand($this->fs_gui);
00098 break;
00099
00100 case "illearningprogressgui":
00101 include_once './Services/Tracking/classes/class.ilLearningProgressGUI.php';
00102
00103 $new_gui =& new ilLearningProgressGUI(LP_MODE_REPOSITORY,$this->object->getRefId());
00104 $this->ctrl->forwardCommand($new_gui);
00105
00106 break;
00107
00108
00109 default:
00110 $cmd = $this->ctrl->getCmd("frameset");
00111 if ((strtolower($_GET["baseClass"]) == "iladministrationgui" ||
00112 $this->getCreationMode() == true) &&
00113 $cmd != "frameset")
00114 {
00115 $cmd.= "Object";
00116 }
00117 $ret =& $this->$cmd();
00118 break;
00119 }
00120 }
00121
00122
00123 function viewObject()
00124 {
00125 if (strtolower($_GET["baseClass"]) == "iladministrationgui")
00126 {
00127 parent::viewObject();
00128 }
00129 else
00130 {
00131
00132
00133 $this->tpl->addBlockfile("BUTTONS", "buttons", "tpl.buttons.html");
00134
00135
00136 $this->tpl->setCurrentBlock("btn_cell");
00137 $this->tpl->setVariable("BTN_LINK","content/sahs_presentation.php?ref_id=".$this->object->getRefID());
00138 $this->tpl->setVariable("BTN_TARGET"," target=\"ilContObj".$this->object->getID()."\" ");
00139 $this->tpl->setVariable("BTN_TXT",$this->lng->txt("view"));
00140 $this->tpl->parseCurrentBlock();
00141
00142
00143 $this->tpl->setCurrentBlock("btn_cell");
00144 $this->tpl->setVariable("BTN_LINK","content/sahs_edit.php?ref_id=".$this->object->getRefID());
00145 $this->tpl->setVariable("BTN_TARGET"," target=\"".
00146 ilFrameTargetInfo::_getFrame("MainContent")."\" ");
00147 $this->tpl->setVariable("BTN_TXT",$this->lng->txt("edit"));
00148 $this->tpl->parseCurrentBlock();
00149 }
00150 }
00151
00155 function properties()
00156 {
00157 }
00158
00162 function saveProperties()
00163 {
00164 }
00165
00166
00170 function createObject()
00171 {
00172 $this->importObject();
00173 }
00174
00180 function importObject()
00181 {
00182
00183 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.slm_import.html");
00184
00185 $this->tpl->setVariable("TYPE_IMG",ilUtil::getImagePath('icon_slm.gif'));
00186 $this->tpl->setVariable("ALT_IMG", $this->lng->txt("obj_sahs"));
00187
00188 $this->ctrl->setParameter($this, "new_type", "sahs");
00189 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
00190
00191 $this->tpl->setVariable("BTN_NAME", "save");
00192 $this->tpl->setVariable("TARGET", ' target="'.
00193 ilFrameTargetInfo::_getFrame("MainContent").'" ');
00194
00195 $this->tpl->setVariable("TXT_SELECT_LMTYPE", $this->lng->txt("type"));
00196 $this->tpl->setVariable("TXT_TYPE_AICC", $this->lng->txt("lm_type_aicc"));
00197 $this->tpl->setVariable("TXT_TYPE_HACP", $this->lng->txt("lm_type_hacp"));
00198 $this->tpl->setVariable("TXT_TYPE_SCORM", $this->lng->txt("lm_type_scorm"));
00199
00200 $this->tpl->setVariable("TXT_UPLOAD", $this->lng->txt("upload"));
00201 $this->tpl->setVariable("TXT_CANCEL", $this->lng->txt("cancel"));
00202 $this->tpl->setVariable("TXT_IMPORT_LM", $this->lng->txt("import_sahs"));
00203 $this->tpl->setVariable("TXT_SELECT_FILE", $this->lng->txt("select_file"));
00204 $this->tpl->setVariable("TXT_VALIDATE_FILE", $this->lng->txt("cont_validate_file"));
00205
00206
00207 $umf=get_cfg_var("upload_max_filesize");
00208
00209 $pms=get_cfg_var("post_max_size");
00210
00211
00212 $max_filesize=min($umf, $pms);
00213 if (!$max_filesize) $max_filesize=max($umf, $pms);
00214
00215 $this->tpl->setVariable("TXT_FILE_INFO", $this->lng->txt("file_notice")." $max_filesize.");
00216 }
00217
00224 function uploadObject()
00225 {
00226 global $_FILES, $rbacsystem;
00227
00228
00229 $source = $_FILES["scormfile"]["tmp_name"];
00230 if (($source == 'none') || (!$source))
00231 {
00232 $this->ilias->raiseError("No file selected!",$this->ilias->error_obj->MESSAGE);
00233 }
00234
00235 if (!$rbacsystem->checkAccess("create", $_GET["ref_id"], "sahs"))
00236 {
00237 $this->ilias->raiseError($this->lng->txt("no_create_permission"), $this->ilias->error_obj->WARNING);
00238 }
00239
00240 switch ($__FILES["scormfile"]["error"])
00241 {
00242 case UPLOAD_ERR_INI_SIZE:
00243 $this->ilias->raiseError($this->lng->txt("err_max_file_size_exceeds"),$this->ilias->error_obj->MESSAGE);
00244 break;
00245
00246 case UPLOAD_ERR_FORM_SIZE:
00247 $this->ilias->raiseError($this->lng->txt("err_max_file_size_exceeds"),$this->ilias->error_obj->MESSAGE);
00248 break;
00249
00250 case UPLOAD_ERR_PARTIAL:
00251 $this->ilias->raiseError($this->lng->txt("err_partial_file_upload"),$this->ilias->error_obj->MESSAGE);
00252 break;
00253
00254 case UPLOAD_ERR_NO_FILE:
00255 $this->ilias->raiseError($this->lng->txt("err_no_file_uploaded"),$this->ilias->error_obj->MESSAGE);
00256 break;
00257 }
00258
00259 $file = pathinfo($_FILES["scormfile"]["name"]);
00260 $name = substr($file["basename"], 0, strlen($file["basename"]) - strlen($file["extension"]) - 1);
00261 if ($name == "")
00262 {
00263 $name = $this->lng->txt("no_title");
00264 }
00265
00266
00267 switch ($_POST["sub_type"])
00268 {
00269 case "scorm":
00270 include_once("content/classes/class.ilObjSCORMLearningModule.php");
00271 $newObj = new ilObjSCORMLearningModule();
00272 break;
00273
00274 case "aicc":
00275 include_once("content/classes/class.ilObjAICCLearningModule.php");
00276 $newObj = new ilObjAICCLearningModule();
00277 break;
00278
00279 case "hacp":
00280 include_once("content/classes/class.ilObjHACPLearningModule.php");
00281 $newObj = new ilObjHACPLearningModule();
00282 break;
00283 }
00284
00285
00286
00287
00288
00289 $newObj->setTitle($name);
00290 $newObj->setSubType($_POST["sub_type"]);
00291 $newObj->setDescription("");
00292 $newObj->create();
00293 $newObj->createReference();
00294 $newObj->putInTree($_GET["ref_id"]);
00295 $newObj->setPermissions($_GET["ref_id"]);
00296 $newObj->notify("new",$_GET["ref_id"],$_GET["parent_non_rbac_id"],$_GET["ref_id"],$newObj->getRefId());
00297
00298
00299 $newObj->createDataDirectory();
00300
00301
00302 $file_path = $newObj->getDataDirectory()."/".$_FILES["scormfile"]["name"];
00303
00304 ilUtil::moveUploadedFile($_FILES["scormfile"]["tmp_name"],
00305 $_FILES["scormfile"]["name"], $file_path);
00306
00307
00308
00309 ilUtil::unzip($file_path);
00310 ilUtil::renameExecutables($newObj->getDataDirectory());
00311
00312 $title = $newObj->readObject();
00313 if ($title != "")
00314 {
00315 ilObject::_writeTitle($newObj->getId(), $title);
00316 $md = new ilMD($newObj->getId(),0, $newObj->getType());
00317 if(is_object($md_gen = $md->getGeneral()))
00318 {
00319 $md_gen->setTitle($title);
00320 $md_gen->update();
00321 }
00322 }
00323
00324 sendInfo( $this->lng->txt($newObj->getType()."_added"), true);
00325 ilUtil::redirect("content/sahs_edit.php?ref_id=".$newObj->getRefId());
00326 }
00327
00328 function upload()
00329 {
00330 $this->uploadObject();
00331 }
00332
00336 function saveObject()
00337 {
00338 global $rbacadmin;
00339
00340 $this->uploadObject();
00341 }
00342
00346 function perm()
00347 {
00348 $this->setFormAction("permSave", "sahs_edit.php?cmd=permSave&ref_id=".$_GET["ref_id"].
00349 "&obj_id=".$_GET["obj_id"]);
00350 $this->setFormAction("addRole", "sahs_edit.php?ref_id=".$_GET["ref_id"].
00351 "&obj_id=".$_GET["obj_id"]."&cmd=addRole");
00352 $this->permObject();
00353 }
00354
00358 function info()
00359 {
00360 $this->infoObject();
00361 }
00362
00366 function permSave()
00367 {
00368 $this->setReturnLocation("permSave",
00369 "sahs_edit.php?ref_id=".$_GET["ref_id"]."&obj_id=".$_GET["obj_id"]."&cmd=perm");
00370 $this->permSaveObject();
00371 }
00372
00376 function addRole()
00377 {
00378 $this->setReturnLocation("addRole",
00379 "sahs_edit.php?ref_id=".$_GET["ref_id"]."&obj_id=".$_GET["obj_id"]."&cmd=perm");
00380 $this->addRoleObject();
00381 }
00382
00386 function owner()
00387 {
00388 $this->ownerObject();
00389 }
00390
00394 function getTemplate()
00395 {
00396 global $lng;
00397
00398 $this->tpl->addBlockFile("CONTENT", "content", "tpl.adm_content.html");
00399
00400 $this->tpl->addBlockFile("STATUSLINE", "statusline", "tpl.statusline.html");
00401
00402 }
00403
00404
00410 function frameset()
00411 {
00412 $this->tpl = new ilTemplate("tpl.sahs_edit_frameset.html", false, false, "content");
00413 $this->tpl->setVariable("REF_ID",$this->ref_id);
00414 $this->tpl->show("DEFAULT", false);
00415 exit;
00416 }
00417
00421 function setLocator($a_tree = "", $a_id = "", $scriptname="adm_object.php")
00422 {
00423 global $ilias_locator, $tree;
00424 if (!defined("ILIAS_MODULE"))
00425 {
00426 parent::setLocator();
00427 }
00428 else
00429 {
00430 $a_tree =& $tree;
00431 $a_id = $_GET["ref_id"];
00432
00433 $this->tpl->addBlockFile("LOCATOR", "locator", "tpl.locator.html");
00434
00435 $path = $a_tree->getPathFull($a_id);
00436
00437
00438 $modifier = 1;
00439
00440 if (!empty($_GET["obj_id"]))
00441 {
00442 $modifier = 0;
00443 }
00444
00445
00446 $i = 1;
00447
00448 if ($this->object->getType() != "grp" && ($_GET["cmd"] == "delete" || $_GET["cmd"] == "edit"))
00449 {
00450 unset($path[count($path) - 1]);
00451 }
00452
00453 foreach ($path as $key => $row)
00454 {
00455
00456 if ($key < count($path) - $modifier)
00457 {
00458 $this->tpl->touchBlock("locator_separator");
00459 }
00460
00461 $this->tpl->setCurrentBlock("locator_item");
00462 if ($row["child"] != $a_tree->getRootId())
00463 {
00464 $this->tpl->setVariable("ITEM", $row["title"]);
00465 }
00466 else
00467 {
00468 $this->tpl->setVariable("ITEM", $this->lng->txt("repository"));
00469 }
00470 if($row["type"] == "sahs")
00471 {
00472 $this->tpl->setVariable("LINK_ITEM", "sahs_edit.php?ref_id=".$row["child"]."&type=".$row["type"]);
00473 }
00474 else
00475 {
00476 $this->tpl->setVariable("LINK_ITEM", "../repository.php?cmd=frameset&ref_id=".$row["child"]);
00477 $t_frame = ilFrameTargetInfo::_getFrame("MainContent");
00478 $this->tpl->setVariable("LINK_TARGET", " target=\"$t_frame\" ");
00479 }
00480
00481
00482 $this->tpl->parseCurrentBlock();
00483
00484 $this->tpl->setCurrentBlock("locator");
00485
00486
00487
00488 if ($row["child"] != $a_tree->getRootId())
00489 {
00490 $ilias_locator->navigate($i++,$row["title"],"../repository.php?ref_id=".$row["child"],
00491 ilFrameTargetInfo::_getFrame("MainContent"));
00492 }
00493 else
00494 {
00495 $ilias_locator->navigate($i++,$this->lng->txt("repository"),"../repository.php?ref_id=".$row["child"],
00496 ilFrameTargetInfo::_getFrame("MainContent"));
00497 }
00498 }
00499
00500 $this->tpl->setVariable("TXT_LOCATOR",$debug.$this->lng->txt("locator"));
00501 $this->tpl->parseCurrentBlock();
00502 }
00503
00504 }
00505
00506
00510 function setTabs()
00511 {
00512 $this->tpl->setCurrentBlock("header_image");
00513 $this->tpl->setVariable("IMG_HEADER", ilUtil::getImagePath("icon_lm_b.gif"));
00514 $this->tpl->parseCurrentBlock();
00515
00516 $this->getTabs($this->tabs_gui);
00517 #$this->tpl->setVariable("TABS", $this->tabs_gui->getHTML());
00518 $this->tpl->setVariable("HEADER", $this->object->getTitle());
00519 }
00520
00526 function getTabs(&$tabs_gui)
00527 {
00528 global $rbacsystem;
00529
00530 if ($this->ctrl->getCmd() == "delete")
00531 {
00532 return;
00533 }
00534
00535
00536 $tabs_gui->addTarget("properties",
00537 $this->ctrl->getLinkTarget($this, "properties"), "properties",
00538 get_class($this));
00539
00540
00541
00542 $tabs_gui->addTarget("cont_list_files",
00543 $this->ctrl->getLinkTargetByClass("ilfilesystemgui", "listFiles"), "",
00544 "ilfilesystemgui");
00545
00546
00547 $tabs_gui->addTarget("cont_tracking_data",
00548 $this->ctrl->getLinkTarget($this, "showTrackingItems"), "showTrackingItems",
00549 get_class($this));
00550
00551
00552
00553
00554
00555
00556
00557 $tabs_gui->addTarget("meta_data",
00558 $this->ctrl->getLinkTargetByClass('ilmdeditorgui',''),
00559 "", "ilmdeditorgui");
00560
00561
00562 include_once("Services/Tracking/classes/class.ilObjUserTracking.php");
00563 if(ilObjUserTracking::_enabledLearningProgress())
00564 {
00565 $tabs_gui->addTarget('learning_progress',
00566 $this->ctrl->getLinkTargetByClass(array('illearningprogressgui'),''),
00567 '',
00568 array('illplistofobjectsgui','illplistofsettingsgui','illearningprogressgui','illplistofprogressgui'));
00569 }
00570
00571 if ($rbacsystem->checkAccess('edit_permission',$this->object->getRefId()))
00572 {
00573 $tabs_gui->addTarget("perm_settings",
00574 $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm"), array("perm","info","owner"), 'ilpermissiongui');
00575 }
00576
00577
00578
00579
00580
00581
00582
00583 }
00584
00588 function _goto($a_target)
00589 {
00590 global $ilAccess, $ilErr, $lng;
00591
00592
00593 if ($ilAccess->checkAccess("visible", "", $a_target))
00594 {
00595 $_GET["cmd"] = "infoScreen";
00596 $_GET["baseClass"] = "ilSAHSPresentationGUI";
00597 $_GET["ref_id"] = $a_target;
00598 include("ilias.php");
00599 exit;
00600 }
00601 else
00602 {
00603 if ($ilAccess->checkAccess("read", "", ROOT_FOLDER_ID))
00604 {
00605 $_GET["cmd"] = "frameset";
00606 $_GET["target"] = "";
00607 $_GET["ref_id"] = ROOT_FOLDER_ID;
00608 sendInfo(sprintf($lng->txt("msg_no_perm_read_item"),
00609 ilObject::_lookupTitle(ilObject::_lookupObjId($a_target))), true);
00610 include("repository.php");
00611 exit;
00612 }
00613 }
00614
00615 $ilErr->raiseError($lng->txt("msg_no_perm_read"), $ilErr->FATAL);
00616 }
00617
00618
00619 }
00620 ?>