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
00037 class ilObjSAHSLearningModuleGUI extends ilObjectGUI
00038 {
00044 function ilObjSAHSLearningModuleGUI($a_data,$a_id,$a_call_by_reference, $a_prepare_output = true)
00045 {
00046 global $lng;
00047
00048 $lng->loadLanguageModule("content");
00049 $this->type = "sahs";
00050 $this->ilObjectGUI($a_data,$a_id,$a_call_by_reference,$a_prepare_output);
00051 $this->tabs_gui =& new ilTabsGUI();
00052
00053 }
00054
00058 function executeCommand()
00059 {
00060 $this->fs_gui =& new ilFileSystemGUI($this->object->getDataDirectory());
00061 $this->getTemplate();
00062 $this->setLocator();
00063 $this->setTabs();
00064
00065 $next_class = $this->ctrl->getNextClass($this);
00066 $cmd = $this->ctrl->getCmd();
00067
00068 switch($next_class)
00069 {
00070 case 'ilmdeditorgui':
00071
00072 include_once 'Services/MetaData/classes/class.ilMDEditorGUI.php';
00073
00074 $md_gui =& new ilMDEditorGUI($this->object->getId(), 0, $this->object->getType());
00075 $md_gui->addObserver($this->object,'MDUpdateListener','General');
00076
00077 $this->ctrl->forwardCommand($md_gui);
00078 break;
00079
00080 case "ilfilesystemgui":
00081
00082 $ret =& $this->ctrl->forwardCommand($this->fs_gui);
00083 break;
00084
00085 default:
00086 $cmd = $this->ctrl->getCmd("frameset");
00087 $ret =& $this->$cmd();
00088 break;
00089 }
00090 $this->tpl->show();
00091 }
00092
00093
00094 function viewObject()
00095 {
00096
00097 $this->tpl->addBlockfile("BUTTONS", "buttons", "tpl.buttons.html");
00098
00099
00100 $this->tpl->setCurrentBlock("btn_cell");
00101 $this->tpl->setVariable("BTN_LINK","content/sahs_presentation.php?ref_id=".$this->object->getRefID());
00102 $this->tpl->setVariable("BTN_TARGET"," target=\"ilContObj".$this->object->getID()."\" ");
00103 $this->tpl->setVariable("BTN_TXT",$this->lng->txt("view"));
00104 $this->tpl->parseCurrentBlock();
00105
00106
00107 $this->tpl->setCurrentBlock("btn_cell");
00108 $this->tpl->setVariable("BTN_LINK","content/sahs_edit.php?ref_id=".$this->object->getRefID());
00109 $this->tpl->setVariable("BTN_TARGET"," target=\"bottom\" ");
00110 $this->tpl->setVariable("BTN_TXT",$this->lng->txt("edit"));
00111 $this->tpl->parseCurrentBlock();
00112 }
00113
00117 function properties()
00118 {
00119 }
00120
00124 function saveProperties()
00125 {
00126 }
00127
00128
00132 function createObject()
00133 {
00134 $this->importObject();
00135 }
00136
00142 function importObject()
00143 {
00144
00145
00146 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.slm_import.html");
00147 $this->tpl->setVariable("FORMACTION", $this->getFormAction("save","adm_object.php?cmd=gateway&ref_id=".
00148 $_GET["ref_id"]."&new_type=sahs"));
00149
00150 $this->tpl->setVariable("BTN_NAME", "save");
00151
00152 $this->tpl->setVariable("TXT_SELECT_LMTYPE", $this->lng->txt("type"));
00153 $this->tpl->setVariable("TXT_TYPE_AICC", $this->lng->txt("lm_type_aicc"));
00154 $this->tpl->setVariable("TXT_TYPE_HACP", $this->lng->txt("lm_type_hacp"));
00155 $this->tpl->setVariable("TXT_TYPE_SCORM", $this->lng->txt("lm_type_scorm"));
00156
00157 $this->tpl->setVariable("TXT_UPLOAD", $this->lng->txt("upload"));
00158 $this->tpl->setVariable("TXT_IMPORT_LM", $this->lng->txt("import_lm"));
00159 $this->tpl->setVariable("TXT_SELECT_FILE", $this->lng->txt("select_file"));
00160 $this->tpl->setVariable("TXT_VALIDATE_FILE", $this->lng->txt("cont_validate_file"));
00161
00162
00163 $umf=get_cfg_var("upload_max_filesize");
00164
00165 $pms=get_cfg_var("post_max_size");
00166
00167
00168 $max_filesize=min($umf, $pms);
00169 if (!$max_filesize) $max_filesize=max($umf, $pms);
00170
00171 $this->tpl->setVariable("TXT_FILE_INFO", $this->lng->txt("file_notice")." $max_filesize.");
00172 }
00173
00180 function uploadObject()
00181 {
00182 global $_FILES, $rbacsystem;
00183
00184
00185 $source = $_FILES["scormfile"]["tmp_name"];
00186 if (($source == 'none') || (!$source))
00187 {
00188 $this->ilias->raiseError("No file selected!",$this->ilias->error_obj->MESSAGE);
00189 }
00190
00191 if (!$rbacsystem->checkAccess("create", $_GET["ref_id"], "sahs"))
00192 {
00193 $this->ilias->raiseError($this->lng->txt("no_create_permission"), $this->ilias->error_obj->WARNING);
00194 }
00195
00196 switch ($__FILES["scormfile"]["error"])
00197 {
00198 case UPLOAD_ERR_INI_SIZE:
00199 $this->ilias->raiseError($this->lng->txt("err_max_file_size_exceeds"),$this->ilias->error_obj->MESSAGE);
00200 break;
00201
00202 case UPLOAD_ERR_FORM_SIZE:
00203 $this->ilias->raiseError($this->lng->txt("err_max_file_size_exceeds"),$this->ilias->error_obj->MESSAGE);
00204 break;
00205
00206 case UPLOAD_ERR_PARTIAL:
00207 $this->ilias->raiseError($this->lng->txt("err_partial_file_upload"),$this->ilias->error_obj->MESSAGE);
00208 break;
00209
00210 case UPLOAD_ERR_NO_FILE:
00211 $this->ilias->raiseError($this->lng->txt("err_no_file_uploaded"),$this->ilias->error_obj->MESSAGE);
00212 break;
00213 }
00214
00215 $file = pathinfo($_FILES["scormfile"]["name"]);
00216 $name = substr($file["basename"], 0, strlen($file["basename"]) - strlen($file["extension"]) - 1);
00217 if ($name == "")
00218 {
00219 $name = $this->lng->txt("no_title");
00220 }
00221
00222
00223 switch ($_POST["sub_type"])
00224 {
00225 case "scorm":
00226 include_once("content/classes/class.ilObjSCORMLearningModule.php");
00227 $newObj = new ilObjSCORMLearningModule();
00228 break;
00229
00230 case "aicc":
00231 include_once("content/classes/class.ilObjAICCLearningModule.php");
00232 $newObj = new ilObjAICCLearningModule();
00233 break;
00234
00235 case "hacp":
00236 include_once("content/classes/class.ilObjHACPLearningModule.php");
00237 $newObj = new ilObjHACPLearningModule();
00238 break;
00239 }
00240
00241
00242
00243
00244
00245 $newObj->setTitle($name);
00246 $newObj->setSubType($_POST["sub_type"]);
00247 $newObj->setDescription("");
00248 $newObj->create();
00249 $newObj->createReference();
00250 $newObj->putInTree($_GET["ref_id"]);
00251 $newObj->setPermissions($_GET["ref_id"]);
00252 $newObj->notify("new",$_GET["ref_id"],$_GET["parent_non_rbac_id"],$_GET["ref_id"],$newObj->getRefId());
00253
00254
00255 $newObj->createDataDirectory();
00256
00257
00258 $file_path = $newObj->getDataDirectory()."/".$_FILES["scormfile"]["name"];
00259
00260 ilUtil::moveUploadedFile($_FILES["scormfile"]["tmp_name"],
00261 $_FILES["scormfile"]["name"], $file_path);
00262
00263
00264
00265 ilUtil::unzip($file_path);
00266 ilUtil::renameExecutables($newObj->getDataDirectory());
00267
00268 $newObj->readObject();
00269
00270 }
00271
00272 function upload()
00273 {
00274 $this->uploadObject();
00275 }
00276
00280 function saveObject()
00281 {
00282 global $rbacadmin;
00283
00284 $this->uploadObject();
00285
00286 sendInfo( $this->lng->txt("lm_added"), true);
00287 ilUtil::redirect($this->getReturnLocation("save","adm_object.php?".$this->link_params));
00288
00289 }
00290
00294 function perm()
00295 {
00296 $this->setFormAction("permSave", "sahs_edit.php?cmd=permSave&ref_id=".$_GET["ref_id"].
00297 "&obj_id=".$_GET["obj_id"]);
00298 $this->setFormAction("addRole", "sahs_edit.php?ref_id=".$_GET["ref_id"].
00299 "&obj_id=".$_GET["obj_id"]."&cmd=addRole");
00300 $this->permObject();
00301 }
00302
00306 function info()
00307 {
00308 $this->infoObject();
00309 }
00310
00314 function permSave()
00315 {
00316 $this->setReturnLocation("permSave",
00317 "sahs_edit.php?ref_id=".$_GET["ref_id"]."&obj_id=".$_GET["obj_id"]."&cmd=perm");
00318 $this->permSaveObject();
00319 }
00320
00324 function addRole()
00325 {
00326 $this->setReturnLocation("addRole",
00327 "sahs_edit.php?ref_id=".$_GET["ref_id"]."&obj_id=".$_GET["obj_id"]."&cmd=perm");
00328 $this->addRoleObject();
00329 }
00330
00334 function owner()
00335 {
00336 $this->ownerObject();
00337 }
00338
00343
00344
00345
00346
00347
00348
00349
00350
00351
00352
00353
00354
00355
00356
00357
00362
00363
00364
00365
00366
00367
00368
00373
00374
00375
00376
00377
00378
00379
00380
00381
00382
00383
00384
00385
00386
00387
00388
00389
00390
00391
00392
00393
00394
00395
00396
00397
00398
00399
00400
00401
00406
00407
00408
00409
00410
00411
00412
00417
00418
00419
00420
00421
00422
00423
00424
00425
00426
00427
00428
00429
00430
00431
00432
00433
00438
00439
00440
00441
00442
00443
00444
00449
00450
00451
00452
00453
00454
00455
00456
00457
00458
00459
00460
00461
00462
00463
00468
00469
00470
00471
00472
00473
00474
00479
00480
00481
00482
00483
00484
00485
00486
00487
00488
00489
00490
00491
00492
00493
00494
00495
00500
00501
00502
00503
00504
00505
00506
00507
00511 function getTemplate()
00512 {
00513 global $lng;
00514
00515 $this->tpl->addBlockFile("CONTENT", "content", "tpl.adm_content.html");
00516
00517 $this->tpl->addBlockFile("STATUSLINE", "statusline", "tpl.statusline.html");
00518
00519 }
00520
00521
00527 function frameset()
00528 {
00529 $this->tpl = new ilTemplate("tpl.sahs_edit_frameset.html", false, false, "content");
00530 $this->tpl->setVariable("REF_ID",$this->ref_id);
00531 $this->tpl->show();
00532 }
00533
00537 function setLocator($a_tree = "", $a_id = "", $scriptname="adm_object.php")
00538 {
00539 global $ilias_locator, $tree;
00540 if (!defined("ILIAS_MODULE"))
00541 {
00542 parent::setLocator();
00543 }
00544 else
00545 {
00546 $a_tree =& $tree;
00547 $a_id = $_GET["ref_id"];
00548
00549 $this->tpl->addBlockFile("LOCATOR", "locator", "tpl.locator.html");
00550
00551 $path = $a_tree->getPathFull($a_id);
00552
00553
00554 $modifier = 1;
00555
00556 if (!empty($_GET["obj_id"]))
00557 {
00558 $modifier = 0;
00559 }
00560
00561
00562 $i = 1;
00563
00564 if ($this->object->getType() != "grp" && ($_GET["cmd"] == "delete" || $_GET["cmd"] == "edit"))
00565 {
00566 unset($path[count($path) - 1]);
00567 }
00568
00569 foreach ($path as $key => $row)
00570 {
00571
00572 if ($key < count($path) - $modifier)
00573 {
00574 $this->tpl->touchBlock("locator_separator");
00575 }
00576
00577 $this->tpl->setCurrentBlock("locator_item");
00578 if ($row["child"] != $a_tree->getRootId())
00579 {
00580 $this->tpl->setVariable("ITEM", $row["title"]);
00581 }
00582 else
00583 {
00584 $this->tpl->setVariable("ITEM", $this->lng->txt("repository"));
00585 }
00586 if($row["type"] == "sahs")
00587 {
00588 $this->tpl->setVariable("LINK_ITEM", "sahs_edit.php?ref_id=".$row["child"]."&type=".$row["type"]);
00589 }
00590 else
00591 {
00592 $this->tpl->setVariable("LINK_ITEM", "../repository.php?cmd=frameset&ref_id=".$row["child"]);
00593 $t_frame = ilFrameTargetInfo::_getFrame("MainContent");
00594 $this->tpl->setVariable("LINK_TARGET", " target=\"$t_frame\" ");
00595 }
00596
00597
00598 $this->tpl->parseCurrentBlock();
00599
00600 $this->tpl->setCurrentBlock("locator");
00601
00602
00603
00604 if ($row["child"] != $a_tree->getRootId())
00605 {
00606 $ilias_locator->navigate($i++,$row["title"],"../repository.php?ref_id=".$row["child"],"bottom");
00607 }
00608 else
00609 {
00610 $ilias_locator->navigate($i++,$this->lng->txt("repository"),"../repository.php?ref_id=".$row["child"],"bottom");
00611 }
00612 }
00613
00614 $this->tpl->setVariable("TXT_LOCATOR",$debug.$this->lng->txt("locator"));
00615 $this->tpl->parseCurrentBlock();
00616 }
00617
00618 }
00619
00620
00624 function setTabs()
00625 {
00626 $this->getTabs($this->tabs_gui);
00627 $this->tpl->setVariable("TABS", $this->tabs_gui->getHTML());
00628 $this->tpl->setVariable("HEADER", $this->object->getTitle());
00629 }
00630
00636 function getTabs(&$tabs_gui)
00637 {
00638 global $rbacsystem;
00639
00640 if ($this->ctrl->getCmd() == "delete")
00641 {
00642 return;
00643 }
00644
00645
00646 $tabs_gui->addTarget("properties",
00647 $this->ctrl->getLinkTarget($this, "properties"), "properties",
00648 get_class($this));
00649
00650
00651 if (is_object($this->fs_gui))
00652 {
00653 $this->fs_gui->getTabs($tabs_gui);
00654 }
00655
00656
00657 $tabs_gui->addTarget("cont_tracking_data",
00658 $this->ctrl->getLinkTarget($this, "showTrackingItems"), "showTrackingItems",
00659 get_class($this));
00660
00661
00662
00663
00664
00665
00666
00667 $tabs_gui->addTarget("meta_data",
00668 $this->ctrl->getLinkTargetByClass('ilmdeditorgui',''),
00669 "meta_data", get_class($this));
00670
00671
00672 if ($rbacsystem->checkAccess('edit_permission',$this->object->getRefId()))
00673 {
00674 $tabs_gui->addTarget("perm_settings",
00675 $this->ctrl->getLinkTarget($this, "perm"), array("perm", "info"),
00676 get_class($this));
00677 }
00678
00679
00680
00681
00682
00683
00684
00685 }
00686
00687
00688
00689 }
00690 ?>