Ejemplo n.º 1
0
 /**
  * execute command
  */
 function executeCommand()
 {
     global $ilUser, $ilLocator, $ilTabs;
     $next_class = $this->ctrl->getNextClass($this);
     $cmd = $this->ctrl->getCmd();
     if (strtolower($_GET["baseClass"]) == "iladministrationgui" || $this->getCreationMode() == true) {
         $this->prepareOutput();
     } else {
         if (!in_array($cmd, array("", "framset")) || $next_class != "") {
             $this->getTemplate();
             $this->setLocator();
             $this->setTabs();
         }
     }
     if (!$this->getCreationMode()) {
         if (IS_PAYMENT_ENABLED) {
             include_once 'Services/Payment/classes/class.ilPaymentObject.php';
             if (ilPaymentObject::_requiresPurchaseToAccess($_GET['ref_id'], $type = isset($_GET['purchasetype']) ? $_GET['purchasetype'] : NULL)) {
                 $this->tpl->getStandardTemplate();
                 include_once 'Services/Payment/classes/class.ilShopPurchaseGUI.php';
                 $pp = new ilShopPurchaseGUI((int) $_GET['ref_id']);
                 $ret = $this->ctrl->forwardCommand($pp);
                 return true;
             }
         }
     }
     switch ($next_class) {
         case 'ilmdeditorgui':
             $this->checkPermission("write");
             $ilTabs->activateTab('id_meta_data');
             include_once 'Services/MetaData/classes/class.ilMDEditorGUI.php';
             $md_gui =& new ilMDEditorGUI($this->object->getId(), 0, $this->object->getType());
             $md_gui->addObserver($this->object, 'MDUpdateListener', 'General');
             $this->ctrl->forwardCommand($md_gui);
             break;
         case "ilfilesystemgui":
             $this->checkPermission("write");
             $ilTabs->activateTab('id_list_files');
             $fs_gui = new ilFileSystemGUI($this->object->getDataDirectory());
             $fs_gui->activateLabels(true, $this->lng->txt("cont_purpose"));
             $fs_gui->setUseUploadDirectory(true);
             $fs_gui->setTableId("htlmfs" . $this->object->getId());
             if ($this->object->getStartFile() != "") {
                 $fs_gui->labelFile($this->object->getStartFile(), $this->lng->txt("cont_startfile"));
             }
             $fs_gui->addCommand($this, "setStartFile", $this->lng->txt("cont_set_start_file"));
             $this->ctrl->forwardCommand($fs_gui);
             // try to set start file automatically
             require_once "./Modules/HTMLLearningModule/classes/class.ilObjFileBasedLMAccess.php";
             if (!ilObjFileBasedLMAccess::_determineStartUrl($this->object->getId())) {
                 $do_update = false;
                 $pcommand = $fs_gui->getLastPerformedCommand();
                 if (is_array($pcommand)) {
                     $valid = array("index.htm", "index.html", "start.htm", "start.html");
                     if ($pcommand["cmd"] == "create_file") {
                         $file = strtolower(basename($pcommand["name"]));
                         if (in_array($file, $valid)) {
                             $this->object->setStartFile($pcommand["name"]);
                             $do_update = $pcommand["name"];
                         }
                     } else {
                         if ($pcommand["cmd"] == "unzip_file") {
                             $zip_file = strtolower(basename($pcommand["name"]));
                             $suffix = strrpos($zip_file, ".");
                             if ($suffix) {
                                 $zip_file = substr($zip_file, 0, $suffix);
                             }
                             foreach ($pcommand["added"] as $file) {
                                 $chk_file = null;
                                 if (stristr($file, ".htm")) {
                                     $chk_file = strtolower(basename($file));
                                     $suffix = strrpos($chk_file, ".");
                                     if ($suffix) {
                                         $chk_file = substr($chk_file, 0, $suffix);
                                     }
                                 }
                                 if (in_array(basename($file), $valid) || $zip_file && $chk_file && $chk_file == $zip_file) {
                                     $this->object->setStartFile($file);
                                     $do_update = $file;
                                     break;
                                 }
                             }
                         }
                     }
                 }
                 if ($do_update) {
                     ilUtil::sendInfo(sprintf($this->lng->txt("cont_start_file_set_to"), $do_update), true);
                     $this->object->update();
                     $this->ctrl->redirectByClass("ilfilesystemgui", "listFiles");
                 }
             }
             break;
         case "ilinfoscreengui":
             $ret =& $this->outputInfoScreen();
             break;
         case "illearningprogressgui":
             $ilTabs->activateTab('id_learning_progress');
             include_once './Services/Tracking/classes/class.ilLearningProgressGUI.php';
             $new_gui =& new ilLearningProgressGUI(ilLearningProgressGUI::LP_CONTEXT_REPOSITORY, $this->object->getRefId(), $_GET['user_id'] ? $_GET['user_id'] : $ilUser->getId());
             $this->ctrl->forwardCommand($new_gui);
             break;
         case 'ilpermissiongui':
             $ilTabs->activateTab('id_permissions');
             include_once "Services/AccessControl/classes/class.ilPermissionGUI.php";
             $perm_gui =& new ilPermissionGUI($this);
             $ret =& $this->ctrl->forwardCommand($perm_gui);
             break;
         case 'illicensegui':
             $ilTabs->activateTab('id_license');
             include_once "./Services/License/classes/class.ilLicenseGUI.php";
             $license_gui =& new ilLicenseGUI($this);
             $ret =& $this->ctrl->forwardCommand($license_gui);
             break;
         case "ilexportgui":
             $ilTabs->activateTab("export");
             include_once "./Services/Export/classes/class.ilExportGUI.php";
             $exp_gui = new ilExportGUI($this);
             $exp_gui->addFormat("xml");
             $exp_gui->addFormat("html", "", $this, "exportHTML");
             $ret = $this->ctrl->forwardCommand($exp_gui);
             //				$this->tpl->show();
             break;
         case "ilcommonactiondispatchergui":
             include_once "Services/Object/classes/class.ilCommonActionDispatcherGUI.php";
             $gui = ilCommonActionDispatcherGUI::getInstanceFromAjaxCall();
             $this->ctrl->forwardCommand($gui);
             break;
         default:
             $cmd = $this->ctrl->getCmd("frameset");
             if (strtolower($_GET["baseClass"]) == "iladministrationgui" || $this->getCreationMode() == true) {
                 $cmd .= "Object";
             }
             $ret =& $this->{$cmd}();
             break;
     }
     $this->addHeaderAction();
 }