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

content/classes/class.ilObjSAHSLearningModuleGUI.php

Go to the documentation of this file.
00001 <?php
00002 /*
00003         +-----------------------------------------------------------------------------+
00004         | ILIAS open source                                                           |
00005         +-----------------------------------------------------------------------------+
00006         | Copyright (c) 1998-2005 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 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                         //add template for view button
00133                         $this->tpl->addBlockfile("BUTTONS", "buttons", "tpl.buttons.html");
00134         
00135                         // view button
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                         // view button
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=\"bottom\" ");
00146                         $this->tpl->setVariable("BTN_TXT",$this->lng->txt("edit"));
00147                         $this->tpl->parseCurrentBlock();
00148                 }
00149         }
00150 
00154         function properties()
00155         {
00156         }
00157 
00161         function saveProperties()
00162         {
00163         }
00164 
00165 
00169         function createObject()
00170         {
00171                 $this->importObject();
00172         }
00173 
00179         function importObject()
00180         {
00181                 // display import form
00182                 // print_r($this->lng);
00183                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.slm_import.html");
00184                 $this->ctrl->setParameter($this, "new_type", "sahs");
00185                 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
00186                 //$this->tpl->setVariable("FORMACTION", $this->getFormAction("save","adm_object.php?cmd=gateway&ref_id=".
00187                 //      $_GET["ref_id"]."&new_type=sahs"));
00188 
00189                 $this->tpl->setVariable("BTN_NAME", "save");
00190                 $this->tpl->setVariable("TARGET", ' target="'.
00191                         ilFrameTargetInfo::_getFrame("MainContent").'" ');
00192 
00193                 $this->tpl->setVariable("TXT_SELECT_LMTYPE", $this->lng->txt("type"));
00194                 $this->tpl->setVariable("TXT_TYPE_AICC", $this->lng->txt("lm_type_aicc"));
00195                 $this->tpl->setVariable("TXT_TYPE_HACP", $this->lng->txt("lm_type_hacp"));
00196                 $this->tpl->setVariable("TXT_TYPE_SCORM", $this->lng->txt("lm_type_scorm"));
00197 
00198                 $this->tpl->setVariable("TXT_UPLOAD", $this->lng->txt("upload"));
00199                 $this->tpl->setVariable("TXT_IMPORT_LM", $this->lng->txt("import_lm"));
00200                 $this->tpl->setVariable("TXT_SELECT_FILE", $this->lng->txt("select_file"));
00201                 $this->tpl->setVariable("TXT_VALIDATE_FILE", $this->lng->txt("cont_validate_file"));
00202 
00203                 // get the value for the maximal uploadable filesize from the php.ini (if available)
00204                 $umf=get_cfg_var("upload_max_filesize");
00205                 // get the value for the maximal post data from the php.ini (if available)
00206                 $pms=get_cfg_var("post_max_size");
00207 
00208                 // use the smaller one as limit
00209                 $max_filesize=min($umf, $pms);
00210                 if (!$max_filesize) $max_filesize=max($umf, $pms);
00211                 // gives out the limit as a littel notice :)
00212                 $this->tpl->setVariable("TXT_FILE_INFO", $this->lng->txt("file_notice")." $max_filesize.");
00213         }
00214 
00221         function uploadObject()
00222         {
00223                 global $_FILES, $rbacsystem;
00224 
00225                 // check if file was uploaded
00226                 $source = $_FILES["scormfile"]["tmp_name"];
00227                 if (($source == 'none') || (!$source))
00228                 {
00229                         $this->ilias->raiseError("No file selected!",$this->ilias->error_obj->MESSAGE);
00230                 }
00231                 // check create permission
00232                 if (!$rbacsystem->checkAccess("create", $_GET["ref_id"], "sahs"))
00233                 {
00234                         $this->ilias->raiseError($this->lng->txt("no_create_permission"), $this->ilias->error_obj->WARNING);
00235                 }
00236                 // get_cfg_var("upload_max_filesize"); // get the may filesize form t he php.ini
00237                 switch ($__FILES["scormfile"]["error"])
00238                 {
00239                         case UPLOAD_ERR_INI_SIZE:
00240                                 $this->ilias->raiseError($this->lng->txt("err_max_file_size_exceeds"),$this->ilias->error_obj->MESSAGE);
00241                                 break;
00242 
00243                         case UPLOAD_ERR_FORM_SIZE:
00244                                 $this->ilias->raiseError($this->lng->txt("err_max_file_size_exceeds"),$this->ilias->error_obj->MESSAGE);
00245                                 break;
00246 
00247                         case UPLOAD_ERR_PARTIAL:
00248                                 $this->ilias->raiseError($this->lng->txt("err_partial_file_upload"),$this->ilias->error_obj->MESSAGE);
00249                                 break;
00250 
00251                         case UPLOAD_ERR_NO_FILE:
00252                                 $this->ilias->raiseError($this->lng->txt("err_no_file_uploaded"),$this->ilias->error_obj->MESSAGE);
00253                                 break;
00254                 }
00255 
00256                 $file = pathinfo($_FILES["scormfile"]["name"]);
00257                 $name = substr($file["basename"], 0, strlen($file["basename"]) - strlen($file["extension"]) - 1);
00258                 if ($name == "")
00259                 {
00260                         $name = $this->lng->txt("no_title");
00261                 }
00262 
00263                 // create and insert object in objecttree
00264                 switch ($_POST["sub_type"])
00265                 {
00266                         case "scorm":
00267                                 include_once("content/classes/class.ilObjSCORMLearningModule.php");
00268                                 $newObj = new ilObjSCORMLearningModule();
00269                                 break;
00270 
00271                         case "aicc":
00272                                 include_once("content/classes/class.ilObjAICCLearningModule.php");
00273                                 $newObj = new ilObjAICCLearningModule();
00274                                 break;
00275 
00276                         case "hacp":
00277                                 include_once("content/classes/class.ilObjHACPLearningModule.php");
00278                                 $newObj = new ilObjHACPLearningModule();
00279                                 break;
00280                 }
00281 
00282                 //$newObj->setType("slm");
00283                 //$dummy_meta =& new ilMetaData();
00284                 //$dummy_meta->setObject($newObj);
00285                 //$newObj->assignMetaData($dummy_meta);
00286                 $newObj->setTitle($name);
00287                 $newObj->setSubType($_POST["sub_type"]);
00288                 $newObj->setDescription("");
00289                 $newObj->create();
00290                 $newObj->createReference();
00291                 $newObj->putInTree($_GET["ref_id"]);
00292                 $newObj->setPermissions($_GET["ref_id"]);
00293                 $newObj->notify("new",$_GET["ref_id"],$_GET["parent_non_rbac_id"],$_GET["ref_id"],$newObj->getRefId());
00294 
00295                 // create data directory, copy file to directory
00296                 $newObj->createDataDirectory();
00297 
00298                 // copy uploaded file to data directory
00299                 $file_path = $newObj->getDataDirectory()."/".$_FILES["scormfile"]["name"];
00300                 
00301                 ilUtil::moveUploadedFile($_FILES["scormfile"]["tmp_name"],
00302                         $_FILES["scormfile"]["name"], $file_path);
00303 
00304                 //move_uploaded_file($_FILES["scormfile"]["tmp_name"], $file_path);
00305 
00306                 ilUtil::unzip($file_path);
00307                 ilUtil::renameExecutables($newObj->getDataDirectory());
00308 
00309                 $newObj->readObject();
00310                 
00311                 sendInfo( $this->lng->txt($newObj->getType()."_added"), true);
00312                 ilUtil::redirect("content/sahs_edit.php?ref_id=".$newObj->getRefId());
00313         }
00314 
00315         function upload()
00316         {
00317                 $this->uploadObject();
00318         }
00319 
00323         function saveObject()
00324         {
00325                 global $rbacadmin;
00326 
00327                 $this->uploadObject();
00328         }
00329 
00333         function perm()
00334         {
00335                 $this->setFormAction("permSave", "sahs_edit.php?cmd=permSave&ref_id=".$_GET["ref_id"].
00336                         "&obj_id=".$_GET["obj_id"]);
00337                 $this->setFormAction("addRole", "sahs_edit.php?ref_id=".$_GET["ref_id"].
00338                         "&obj_id=".$_GET["obj_id"]."&cmd=addRole");
00339                 $this->permObject();
00340         }
00341 
00345         function info()
00346         {
00347                 $this->infoObject();
00348         }
00349 
00353         function permSave()
00354         {
00355                 $this->setReturnLocation("permSave",
00356                         "sahs_edit.php?ref_id=".$_GET["ref_id"]."&obj_id=".$_GET["obj_id"]."&cmd=perm");
00357                 $this->permSaveObject();
00358         }
00359 
00363         function addRole()
00364         {
00365                 $this->setReturnLocation("addRole",
00366                         "sahs_edit.php?ref_id=".$_GET["ref_id"]."&obj_id=".$_GET["obj_id"]."&cmd=perm");
00367                 $this->addRoleObject();
00368         }
00369 
00373         function owner()
00374         {
00375                 $this->ownerObject();
00376         }
00377 
00381         function getTemplate()
00382         {
00383                 global $lng;
00384 
00385                 $this->tpl->addBlockFile("CONTENT", "content", "tpl.adm_content.html");
00386                 //$this->tpl->setVariable("HEADER", $a_header_title);
00387                 $this->tpl->addBlockFile("STATUSLINE", "statusline", "tpl.statusline.html");
00388                 //$this->tpl->setVariable("TXT_LOCATOR",$this->lng->txt("locator"));
00389         }
00390 
00391 
00397         function frameset()
00398         {
00399                 $this->tpl = new ilTemplate("tpl.sahs_edit_frameset.html", false, false, "content");
00400                 $this->tpl->setVariable("REF_ID",$this->ref_id);
00401                 $this->tpl->show();
00402         }
00403 
00407         function setLocator($a_tree = "", $a_id = "", $scriptname="adm_object.php")
00408         {
00409                 global $ilias_locator, $tree;
00410                 if (!defined("ILIAS_MODULE"))
00411                 {
00412                         parent::setLocator();
00413                 }
00414                 else
00415                 {
00416                         $a_tree =& $tree;
00417                         $a_id = $_GET["ref_id"];
00418 
00419                         $this->tpl->addBlockFile("LOCATOR", "locator", "tpl.locator.html");
00420 
00421                         $path = $a_tree->getPathFull($a_id);
00422 
00423                         // this is a stupid workaround for a bug in PEAR:IT
00424                         $modifier = 1;
00425 
00426                         if (!empty($_GET["obj_id"]))
00427                         {
00428                                 $modifier = 0;
00429                         }
00430 
00431                         // ### AA 03.11.10 added new locator GUI class ###
00432                         $i = 1;
00433 
00434                         if ($this->object->getType() != "grp" && ($_GET["cmd"] == "delete" || $_GET["cmd"] == "edit"))
00435                         {
00436                                 unset($path[count($path) - 1]);
00437                         }
00438 
00439                         foreach ($path as $key => $row)
00440                         {
00441 
00442                                 if ($key < count($path) - $modifier)
00443                                 {
00444                                         $this->tpl->touchBlock("locator_separator");
00445                                 }
00446 
00447                                 $this->tpl->setCurrentBlock("locator_item");
00448                                 if ($row["child"] != $a_tree->getRootId())
00449                                 {
00450                                         $this->tpl->setVariable("ITEM", $row["title"]);
00451                                 }
00452                                 else
00453                                 {
00454                                         $this->tpl->setVariable("ITEM", $this->lng->txt("repository"));
00455                                 }
00456                                 if($row["type"] == "sahs")
00457                                 {
00458                                         $this->tpl->setVariable("LINK_ITEM", "sahs_edit.php?ref_id=".$row["child"]."&type=".$row["type"]);
00459                                 }
00460                                 else
00461                                 {
00462                                         $this->tpl->setVariable("LINK_ITEM", "../repository.php?cmd=frameset&ref_id=".$row["child"]);
00463                                         $t_frame = ilFrameTargetInfo::_getFrame("MainContent");
00464                                         $this->tpl->setVariable("LINK_TARGET", " target=\"$t_frame\" ");
00465                                 }
00466                                 //$this->tpl->setVariable("LINK_TARGET", " target=\"bottom\" ");
00467 
00468                                 $this->tpl->parseCurrentBlock();
00469 
00470                                 $this->tpl->setCurrentBlock("locator");
00471 
00472                                 // ### AA 03.11.10 added new locator GUI class ###
00473                                 // navigate locator
00474                                 if ($row["child"] != $a_tree->getRootId())
00475                                 {
00476                                         $ilias_locator->navigate($i++,$row["title"],"../repository.php?ref_id=".$row["child"],"bottom");
00477                                 }
00478                                 else
00479                                 {
00480                                         $ilias_locator->navigate($i++,$this->lng->txt("repository"),"../repository.php?ref_id=".$row["child"],"bottom");
00481                                 }
00482                         }
00483 
00484                         $this->tpl->setVariable("TXT_LOCATOR",$debug.$this->lng->txt("locator"));
00485                         $this->tpl->parseCurrentBlock();
00486                 }
00487 
00488         }
00489 
00490 
00494         function setTabs()
00495         {
00496                 $this->tpl->setCurrentBlock("header_image");
00497                 $this->tpl->setVariable("IMG_HEADER", ilUtil::getImagePath("icon_lm_b.gif"));
00498                 $this->tpl->parseCurrentBlock();
00499 
00500                 $this->getTabs($this->tabs_gui);
00501                 #$this->tpl->setVariable("TABS", $this->tabs_gui->getHTML());
00502                 $this->tpl->setVariable("HEADER", $this->object->getTitle());
00503         }
00504 
00510         function getTabs(&$tabs_gui)
00511         {
00512                 global $rbacsystem;
00513                 
00514                 if ($this->ctrl->getCmd() == "delete")
00515                 {
00516                         return;
00517                 }
00518 
00519                 // properties
00520                 $tabs_gui->addTarget("properties",
00521                         $this->ctrl->getLinkTarget($this, "properties"), "properties",
00522                         get_class($this));
00523 
00524                 // file system gui tabs
00525                 // properties
00526                 $tabs_gui->addTarget("cont_list_files",
00527                         $this->ctrl->getLinkTargetByClass("ilfilesystemgui", "listFiles"), "",
00528                         "ilfilesystemgui");
00529 
00530                 // tracking data
00531                 $tabs_gui->addTarget("cont_tracking_data",
00532                         $this->ctrl->getLinkTarget($this, "showTrackingItems"), "showTrackingItems",
00533                         get_class($this));
00534 
00535                 // edit meta
00536 /*
00537                 $tabs_gui->addTarget("meta_data",
00538                         $this->ctrl->getLinkTarget($this, "editMeta"), "editMeta",
00539                         get_class($this));
00540 */
00541                 $tabs_gui->addTarget("meta_data",
00542                          $this->ctrl->getLinkTargetByClass('ilmdeditorgui',''),
00543                          "", "ilmdeditorgui");
00544 
00545                 // learning progress
00546                 include_once("Services/Tracking/classes/class.ilObjUserTracking.php");
00547                 if(ilObjUserTracking::_enabledLearningProgress())
00548                 {
00549                         $tabs_gui->addTarget('learning_progress',
00550                                                                  $this->ctrl->getLinkTargetByClass(array('illearningprogressgui'),''),
00551                                                                  '',
00552                                                                  array('illplistofobjectsgui','illplistofsettingsgui','illearningprogressgui','illplistofprogressgui'));
00553                 }
00554                 // perm
00555                 if ($rbacsystem->checkAccess('edit_permission',$this->object->getRefId()))
00556                 {
00557                         $tabs_gui->addTarget("perm_settings",
00558                                 $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm"), array("perm","info","owner"), 'ilpermissiongui');
00559                 }
00560 
00561                 // owner
00562 /*
00563                 $tabs_gui->addTarget("owner",
00564                         $this->ctrl->getLinkTarget($this, "owner"), "owner",
00565                         get_class($this));
00566 */
00567         }
00568 
00569 
00570 
00571 } // END class.ilObjSAHSLearningModule
00572 ?>

Generated on Fri Dec 13 2013 11:57:57 for ILIAS Release_3_6_x_branch .rev 46809 by  doxygen 1.7.1