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

Modules/ScormAicc/classes/class.ilObjSAHSLearningModuleGUI.php

Go to the documentation of this file.
00001 <?php
00002 /*
00003         +-----------------------------------------------------------------------------+
00004         | ILIAS open source                                                           |
00005         +-----------------------------------------------------------------------------+
00006         | Copyright (c) 1998-2006 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 
00038 class ilObjSAHSLearningModuleGUI extends ilObjectGUI
00039 {
00045         function ilObjSAHSLearningModuleGUI($a_data,$a_id,$a_call_by_reference, $a_prepare_output = true)
00046         {
00047                 global $lng;
00048 
00049                 $lng->loadLanguageModule("content");
00050                 $this->type = "sahs";
00051                 $this->ilObjectGUI($a_data,$a_id,$a_call_by_reference,false);
00052                 #$this->tabs_gui =& new ilTabsGUI();
00053 
00054         }
00055 
00059         function &executeCommand()
00060         {
00061                 global $ilAccess;
00062                 
00063                 if (strtolower($_GET["baseClass"]) == "iladministrationgui" ||
00064                         $this->getCreationMode() == true)
00065                 {
00066                         $this->prepareOutput();
00067                 }
00068                 else
00069                 {
00070                         $this->getTemplate();
00071                         $this->setLocator();
00072                         $this->setTabs();
00073                 }
00074 
00075                 $next_class = $this->ctrl->getNextClass($this);
00076                 $cmd = $this->ctrl->getCmd();
00077 
00078                 switch($next_class)
00079                 {
00080                         case 'ilmdeditorgui':
00081 
00082                                 include_once 'Services/MetaData/classes/class.ilMDEditorGUI.php';
00083 
00084                                 $md_gui =& new ilMDEditorGUI($this->object->getId(), 0, $this->object->getType());
00085                                 $md_gui->addObserver($this->object,'MDUpdateListener','General');
00086 
00087                                 $this->ctrl->forwardCommand($md_gui);
00088                                 break;
00089                                 
00090                         case 'ilpermissiongui':
00091                                 include_once("./classes/class.ilPermissionGUI.php");
00092                                 $perm_gui =& new ilPermissionGUI($this);
00093                                 $ret =& $this->ctrl->forwardCommand($perm_gui);
00094                                 break;
00095 
00096                         case "ilfilesystemgui":
00097                                 $this->fs_gui =& new ilFileSystemGUI($this->object->getDataDirectory());
00098                                 $ret =& $this->ctrl->forwardCommand($this->fs_gui);
00099                                 break;
00100 
00101                         case "illearningprogressgui":
00102                                 include_once './Services/Tracking/classes/class.ilLearningProgressGUI.php';
00103 
00104                                 $new_gui =& new ilLearningProgressGUI(LP_MODE_REPOSITORY,$this->object->getRefId());
00105                                 $this->ctrl->forwardCommand($new_gui);
00106 
00107                                 break;
00108 
00109                         case "ilinfoscreengui":
00110                                 include_once("./Services/InfoScreen/classes/class.ilInfoScreenGUI.php");
00111 
00112                                 $info = new ilInfoScreenGUI($this);
00113                                 $info->enablePrivateNotes();
00114                                 $info->enableLearningProgress();
00115                                 
00116                                 // add read / back button
00117                                 if ($ilAccess->checkAccess("read", "", $_GET["ref_id"]))
00118                                 {
00119                                         $info->addButton($this->lng->txt("view"),
00120                                                 "ilias.php?baseClass=ilSAHSPresentationGUI&amp;ref_id=".$this->object->getRefID(),
00121                                                 ' target="ilContObj'.$this->object->getId().'" ');
00122                                 }
00123 
00124                                 $info->enableNews();
00125                                 if ($ilAccess->checkAccess("write", "", $_GET["ref_id"]))
00126                                 {
00127                                         $info->enableNewsEditing();
00128                                         $news_set = new ilSetting("news");
00129                                         $enable_internal_rss = $news_set->get("enable_rss_for_internal");
00130                                         if ($enable_internal_rss)
00131                                         {
00132                                                 $info->setBlockProperty("news", "settings", true);
00133                                         }
00134                                 }
00135                                 // show standard meta data section
00136                                 $info->addMetaDataSections($this->object->getId(),0, $this->object->getType());
00137                 
00138                                 // forward the command
00139                                 $this->ctrl->forwardCommand($info);
00140                                 break;
00141 
00142                         default:
00143                                 $cmd = $this->ctrl->getCmd("frameset");
00144                                 if ((strtolower($_GET["baseClass"]) == "iladministrationgui" ||
00145                                         $this->getCreationMode() == true) &&
00146                                         $cmd != "frameset")
00147                                 {
00148                                         $cmd.= "Object";
00149                                 }
00150 
00151                                 $ret =& $this->$cmd();
00152                                 break;
00153                 }
00154         }
00155 
00156 
00157         function viewObject()
00158         {
00159                 if (strtolower($_GET["baseClass"]) == "iladministrationgui")
00160                 {
00161                         parent::viewObject();
00162                 }
00163                 else
00164                 {
00165                 }
00166         }
00167 
00171         function properties()
00172         {
00173         }
00174 
00178         function saveProperties()
00179         {
00180         }
00181 
00182 
00186         function createObject()
00187         {
00188                 $this->importObject();
00189         }
00190 
00196         function importObject()
00197         {
00198                 // display import form
00199                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.slm_import.html", "Modules/ScormAicc");
00200                 
00201                 $this->tpl->setVariable("TYPE_IMG",ilUtil::getImagePath('icon_slm.gif'));
00202                 $this->tpl->setVariable("ALT_IMG", $this->lng->txt("obj_sahs"));
00203                 
00204                 $this->ctrl->setParameter($this, "new_type", "sahs");
00205                 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
00206 
00207                 $this->tpl->setVariable("BTN_NAME", "save");
00208                 $this->tpl->setVariable("TARGET", ' target="'.
00209                         ilFrameTargetInfo::_getFrame("MainContent").'" ');
00210 
00211                 $this->tpl->setVariable("TXT_SELECT_LMTYPE", $this->lng->txt("type"));
00212                 $this->tpl->setVariable("TXT_TYPE_AICC", $this->lng->txt("lm_type_aicc"));
00213                 $this->tpl->setVariable("TXT_TYPE_HACP", $this->lng->txt("lm_type_hacp"));
00214                 $this->tpl->setVariable("TXT_TYPE_SCORM", $this->lng->txt("lm_type_scorm"));
00215 
00216                 $this->tpl->setVariable("TXT_TYPE_SCORM2004", $this->lng->txt("lm_type_scorm2004"));
00217                 
00218                 $this->tpl->setVariable("TXT_UPLOAD", $this->lng->txt("upload"));
00219                 $this->tpl->setVariable("TXT_CANCEL", $this->lng->txt("cancel"));
00220                 $this->tpl->setVariable("TXT_IMPORT_LM", $this->lng->txt("import_sahs"));
00221                 $this->tpl->setVariable("TXT_SELECT_FILE", $this->lng->txt("select_file"));
00222                 $this->tpl->setVariable("TXT_VALIDATE_FILE", $this->lng->txt("cont_validate_file"));
00223 
00224                 // get the value for the maximal uploadable filesize from the php.ini (if available)
00225                 $umf=get_cfg_var("upload_max_filesize");
00226                 // get the value for the maximal post data from the php.ini (if available)
00227                 $pms=get_cfg_var("post_max_size");
00228                 
00229                 //convert from short-string representation to "real" bytes
00230                 $multiplier_a=array("K"=>1024, "M"=>1024*1024, "G"=>1024*1024*1024);
00231                 
00232                 $umf_parts=preg_split("/(\d+)([K|G|M])/", $umf, -1, PREG_SPLIT_DELIM_CAPTURE|PREG_SPLIT_NO_EMPTY);
00233         $pms_parts=preg_split("/(\d+)([K|G|M])/", $pms, -1, PREG_SPLIT_DELIM_CAPTURE|PREG_SPLIT_NO_EMPTY);
00234         
00235         if (count($umf_parts) == 2) { $umf = $umf_parts[0]*$multiplier_a[$umf_parts[1]]; }
00236         if (count($pms_parts) == 2) { $pms = $pms_parts[0]*$multiplier_a[$pms_parts[1]]; }
00237         
00238         // use the smaller one as limit
00239                 $max_filesize=min($umf, $pms);
00240 
00241                 if (!$max_filesize) $max_filesize=max($umf, $pms);
00242         
00243         //format for display in mega-bytes
00244                 $max_filesize=sprintf("%.1f MB",$max_filesize/1024/1024);
00245 
00246                 // gives out the limit as a little notice
00247                 $this->tpl->setVariable("TXT_FILE_INFO", $this->lng->txt("file_notice")." $max_filesize");
00248         }
00249 
00256         function uploadObject()
00257         {
00258                 global $_FILES, $rbacsystem;
00259 
00260                 // check if file was uploaded
00261                 $source = $_FILES["scormfile"]["tmp_name"];
00262                 if (($source == 'none') || (!$source))
00263                 {
00264                         $this->ilias->raiseError("No file selected!",$this->ilias->error_obj->MESSAGE);
00265                 }
00266                 // check create permission
00267                 if (!$rbacsystem->checkAccess("create", $_GET["ref_id"], "sahs"))
00268                 {
00269                         $this->ilias->raiseError($this->lng->txt("no_create_permission"), $this->ilias->error_obj->WARNING);
00270                 }
00271                 // get_cfg_var("upload_max_filesize"); // get the may filesize form t he php.ini
00272                 switch ($__FILES["scormfile"]["error"])
00273                 {
00274                         case UPLOAD_ERR_INI_SIZE:
00275                                 $this->ilias->raiseError($this->lng->txt("err_max_file_size_exceeds"),$this->ilias->error_obj->MESSAGE);
00276                                 break;
00277 
00278                         case UPLOAD_ERR_FORM_SIZE:
00279                                 $this->ilias->raiseError($this->lng->txt("err_max_file_size_exceeds"),$this->ilias->error_obj->MESSAGE);
00280                                 break;
00281 
00282                         case UPLOAD_ERR_PARTIAL:
00283                                 $this->ilias->raiseError($this->lng->txt("err_partial_file_upload"),$this->ilias->error_obj->MESSAGE);
00284                                 break;
00285 
00286                         case UPLOAD_ERR_NO_FILE:
00287                                 $this->ilias->raiseError($this->lng->txt("err_no_file_uploaded"),$this->ilias->error_obj->MESSAGE);
00288                                 break;
00289                 }
00290 
00291                 $file = pathinfo($_FILES["scormfile"]["name"]);
00292                 $name = substr($file["basename"], 0, strlen($file["basename"]) - strlen($file["extension"]) - 1);
00293                 if ($name == "")
00294                 {
00295                         $name = $this->lng->txt("no_title");
00296                 }
00297 
00298                 // create and insert object in objecttree
00299                 switch ($_POST["sub_type"])
00300                 {
00301                         
00302                         case "scorm2004":
00303                                 include_once("./Modules/Scorm2004/classes/class.ilObjSCORM2004LearningModule.php");
00304                                 $newObj = new ilObjSCORM2004LearningModule();
00305                                 break;
00306 
00307                         case "scorm":
00308                                 include_once("./Modules/ScormAicc/classes/class.ilObjSCORMLearningModule.php");
00309                                 $newObj = new ilObjSCORMLearningModule();
00310                                 break;
00311 
00312                         case "aicc":
00313                                 include_once("./Modules/ScormAicc/classes/class.ilObjAICCLearningModule.php");
00314                                 $newObj = new ilObjAICCLearningModule();
00315                                 break;
00316 
00317                         case "hacp":
00318                                 include_once("./Modules/ScormAicc/classes/class.ilObjHACPLearningModule.php");
00319                                 $newObj = new ilObjHACPLearningModule();
00320                                 break;
00321                 }
00322 
00323                 $newObj->setTitle($name);
00324                 $newObj->setSubType($_POST["sub_type"]);
00325                 $newObj->setDescription("");
00326                 $newObj->create();
00327                 $newObj->createReference();
00328                 $newObj->putInTree($_GET["ref_id"]);
00329                 $newObj->setPermissions($_GET["ref_id"]);
00330                 $newObj->notify("new",$_GET["ref_id"],$_GET["parent_non_rbac_id"],$_GET["ref_id"],$newObj->getRefId());
00331 
00332                 // create data directory, copy file to directory
00333                 $newObj->createDataDirectory();
00334 
00335                 // copy uploaded file to data directory
00336                 $file_path = $newObj->getDataDirectory()."/".$_FILES["scormfile"]["name"];
00337                 
00338                 ilUtil::moveUploadedFile($_FILES["scormfile"]["tmp_name"],
00339                         $_FILES["scormfile"]["name"], $file_path);
00340 
00341                 //move_uploaded_file($_FILES["scormfile"]["tmp_name"], $file_path);
00342 
00343                 ilUtil::unzip($file_path);
00344                 ilUtil::renameExecutables($newObj->getDataDirectory());
00345 
00346                 $title = $newObj->readObject();         
00347                 if ($title != "")
00348                 {
00349                         ilObject::_writeTitle($newObj->getId(), $title);
00350                         $md = new ilMD($newObj->getId(),0, $newObj->getType());
00351                         if(is_object($md_gen = $md->getGeneral()))
00352                         {
00353                                 $md_gen->setTitle($title);
00354                                 $md_gen->update();
00355                         }
00356                 }
00357                 
00358                 ilUtil::sendInfo( $this->lng->txt($newObj->getType()."_added"), true);
00359                 ilUtil::redirect("ilias.php?baseClass=ilSAHSEditGUI&ref_id=".$newObj->getRefId());
00360         }
00361 
00362         function upload()
00363         {
00364                 $this->uploadObject();
00365         }
00366 
00370         function saveObject()
00371         {
00372                 global $rbacadmin;
00373 
00374                 $this->uploadObject();
00375         }
00376 
00377 
00381         function info()
00382         {
00383                 $this->infoObject();
00384         }
00385 
00389         function owner()
00390         {
00391                 $this->ownerObject();
00392         }
00393 
00397         function getTemplate()
00398         {
00399                 global $lng;
00400 
00401                 $this->tpl->addBlockFile("CONTENT", "content", "tpl.adm_content.html");
00402                 //$this->tpl->setVariable("HEADER", $a_header_title);
00403                 $this->tpl->addBlockFile("STATUSLINE", "statusline", "tpl.statusline.html");
00404                 //$this->tpl->setVariable("TXT_LOCATOR",$this->lng->txt("locator"));
00405         }
00406 
00407 
00413         function frameset()
00414         {
00415                 $this->tpl = new ilTemplate("tpl.sahs_edit_frameset.html", false, false, "Modules/ScormAicc");
00416                 $this->tpl->setVariable("SRC",
00417                         $this->ctrl->getLinkTarget($this, "properties"));
00418                 $this->tpl->show("DEFAULT", false);
00419                 exit;
00420         }
00421 
00425         function setTabs()
00426         {
00427                 $this->tpl->setCurrentBlock("header_image");
00428                 $this->tpl->setVariable("IMG_HEADER", ilUtil::getImagePath("icon_lm_b.gif"));
00429                 $this->tpl->parseCurrentBlock();
00430 
00431                 $this->getTabs($this->tabs_gui);
00432                 #$this->tpl->setVariable("TABS", $this->tabs_gui->getHTML());
00433                 $this->tpl->setVariable("HEADER", $this->object->getTitle());
00434         }
00435 
00441         function getTabs(&$tabs_gui)
00442         {
00443                 global $rbacsystem,$ilUser;
00444                 
00445                 if ($this->ctrl->getCmd() == "delete")
00446                 {
00447                         return;
00448                 }
00449 
00450                 // info screen
00451                 $force_active = ($this->ctrl->getNextClass() == "ilinfoscreengui")
00452                         ? true
00453                         : false;
00454                 $tabs_gui->addTarget("info_short",
00455                         $this->ctrl->getLinkTargetByClass("ilinfoscreengui", "showSummary"), "",
00456                         "ilinfoscreengui", "", $force_active);
00457                         
00458                 // properties
00459                 $tabs_gui->addTarget("properties",
00460                         $this->ctrl->getLinkTarget($this, "properties"), "properties",
00461                         get_class($this));
00462 
00463                 // file system gui tabs
00464                 // properties
00465                 $tabs_gui->addTarget("cont_list_files",
00466                         $this->ctrl->getLinkTargetByClass("ilfilesystemgui", "listFiles"), "",
00467                         "ilfilesystemgui");
00468 
00469                 // tracking data
00470                 $tabs_gui->addTarget("cont_tracking_data",
00471                         $this->ctrl->getLinkTarget($this, "showTrackingItems"), "showTrackingItems",
00472                         get_class($this));
00473 
00474                 // edit meta
00475 /*
00476                 $tabs_gui->addTarget("meta_data",
00477                         $this->ctrl->getLinkTarget($this, "editMeta"), "editMeta",
00478                         get_class($this));
00479 */
00480                 $tabs_gui->addTarget("meta_data",
00481                          $this->ctrl->getLinkTargetByClass('ilmdeditorgui',''),
00482                          "", "ilmdeditorgui");
00483 
00484                 // learning progress
00485                 include_once("Services/Tracking/classes/class.ilObjUserTracking.php");
00486                 if(ilObjUserTracking::_enabledLearningProgress() and $ilUser->getId() != ANONYMOUS_USER_ID)
00487                 {
00488                         $tabs_gui->addTarget('learning_progress',
00489                                                                  $this->ctrl->getLinkTargetByClass(array('illearningprogressgui'),''),
00490                                                                  '',
00491                                                                  array('illplistofobjectsgui','illplistofsettingsgui','illearningprogressgui','illplistofprogressgui'));
00492                 }
00493                 // perm
00494                 if ($rbacsystem->checkAccess('edit_permission',$this->object->getRefId()))
00495                 {
00496                         $tabs_gui->addTarget("perm_settings",
00497                                 $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm"), array("perm","info","owner"), 'ilpermissiongui');
00498                 }
00499 
00500                 // owner
00501 /*
00502                 $tabs_gui->addTarget("owner",
00503                         $this->ctrl->getLinkTarget($this, "owner"), "owner",
00504                         get_class($this));
00505 */
00506         }
00507 
00511         function _goto($a_target)
00512         {
00513                 global $ilAccess, $ilErr, $lng;
00514 
00515                 // to do: force flat view
00516                 if ($ilAccess->checkAccess("visible", "", $a_target))
00517                 {
00518                         $_GET["cmd"] = "infoScreen";
00519                         $_GET["baseClass"] = "ilSAHSPresentationGUI";
00520                         $_GET["ref_id"] = $a_target;
00521                         include("ilias.php");
00522                         exit;
00523                 }
00524                 else
00525                 {
00526                         if ($ilAccess->checkAccess("read", "", ROOT_FOLDER_ID))
00527                         {
00528                                 $_GET["cmd"] = "frameset";
00529                                 $_GET["target"] = "";
00530                                 $_GET["ref_id"] = ROOT_FOLDER_ID;
00531                                 ilUtil::sendInfo(sprintf($lng->txt("msg_no_perm_read_item"),
00532                                         ilObject::_lookupTitle(ilObject::_lookupObjId($a_target))), true);
00533                                 include("repository.php");
00534                                 exit;
00535                         }
00536                 }
00537 
00538                 $ilErr->raiseError($lng->txt("msg_no_perm_read"), $ilErr->FATAL);
00539         }
00540 
00541         function addLocatorItems()
00542         {
00543                 global $ilLocator;
00544                 
00545                 if (is_object($this->object))
00546                 {
00547                         $ilLocator->addItem($this->object->getTitle(),
00548                                 $this->ctrl->getLinkTargetByClass("ilinfoscreengui", "showSummary"), "", $_GET["ref_id"]);
00549                 }
00550         }
00551 
00552 } // END class.ilObjSAHSLearningModule
00553 ?>

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