function preview() { global $ilias; $export = new ilScorm2004Export($this->object, 'SCORM 2004 3rd'); $zipfile = $export->buildExportFile(); $zipPathinfo = pathinfo($zipfile); $file_path = $this->object->getDataDirectory() . "/" . $zipPathinfo["basename"]; copy($zipfile, $file_path); unlink($zipfile); ilUtil::unzip($file_path, true); ilUtil::renameExecutables($this->object->getDataDirectory()); unlink($file_path); include_once "./Modules/Scorm2004/classes/ilSCORM13Package.php"; $rte_pkg = new ilSCORM13Package(); $rte_pkg->il_import($this->object->getDataDirectory(), $this->object->getId(), $ilias, false, true); //increase module version is it necessary? //$this->object->setModuleVersion($module_version+1); //$this->object->update(); //redirect to view player ilUtil::redirect("ilias.php?baseClass=ilSAHSPresentationGUI&ref_id=" . $this->object->getRefID() . "&envEditor=1"); }
function importSave() { global $_FILES, $rbacsystem; global $ilias, $lng; // check if file was uploaded $source = $_FILES["scormfile"]["tmp_name"]; if ($source == 'none' || !$source) { $ilias->raiseError("No file selected!", $ilias->error_obj->MESSAGE); } // check create permission if (!$rbacsystem->checkAccess("create", $_GET["ref_id"], "sahs")) { $ilias->raiseError($lng->txt("no_create_permission"), $ilias->error_obj->WARNING); } // get_cfg_var("upload_max_filesize"); // get the may filesize form t he php.ini switch ($__FILES["scormfile"]["error"]) { case UPLOAD_ERR_INI_SIZE: $ilias->raiseError($lng->txt("err_max_file_size_exceeds"), $ilias->error_obj->MESSAGE); break; case UPLOAD_ERR_FORM_SIZE: $ilias->raiseError($lng->txt("err_max_file_size_exceeds"), $ilias->error_obj->MESSAGE); break; case UPLOAD_ERR_PARTIAL: $ilias->raiseError($lng->txt("err_partial_file_upload"), $ilias->error_obj->MESSAGE); break; case UPLOAD_ERR_NO_FILE: $ilias->raiseError($lng->txt("err_no_file_uploaded"), $ilias->error_obj->MESSAGE); break; } $file = pathinfo($_FILES["scormfile"]["name"]); $name = substr($file["basename"], 0, strlen($file["basename"]) - strlen($file["extension"]) - 1); $file_path = $this->slm_object->getDataDirectory() . "/" . $this->node_object->getId() . "/" . $_FILES["scormfile"]["name"]; ilUtil::createDirectory($this->slm_object->getDataDirectory() . "/" . $this->node_object->getId()); ilUtil::moveUploadedFile($_FILES["scormfile"]["tmp_name"], $_FILES["scormfile"]["name"], $file_path); ilUtil::unzip($file_path); ilUtil::renameExecutables($this->slm_object->getDataDirectory() . "/" . $this->node_object->getId()); include_once "./Modules/Scorm2004/classes/ilSCORM13Package.php"; $newPack = new ilSCORM13Package(); $newPack->il_importSco($this->slm_object->getId(), $this->node_object->getId(), $this->slm_object->getDataDirectory() . "/" . $this->node_object->getId()); $this->ctrl->redirect($this, "showOrganization"); }
/** * deletes a user * @access public * @param integer user_id */ function delete() { global $rbacadmin, $ilDB; // deassign from ldap groups include_once 'Services/LDAP/classes/class.ilLDAPRoleGroupMapping.php'; $mapping = ilLDAPRoleGroupMapping::_getInstance(); $mapping->deleteUser($this->getId()); // remove mailbox / update sent mails include_once "Services/Mail/classes/class.ilMailbox.php"; $mailbox = new ilMailbox($this->getId()); $mailbox->delete(); $mailbox->updateMailsOfDeletedUser($this->getLogin()); // delete feed blocks on personal desktop include_once "./Services/Block/classes/class.ilCustomBlock.php"; $costum_block = new ilCustomBlock(); $costum_block->setContextObjId($this->getId()); $costum_block->setContextObjType("user"); $c_blocks = $costum_block->queryBlocksForContext(); include_once "./Services/Feeds/classes/class.ilPDExternalFeedBlock.php"; foreach ($c_blocks as $c_block) { if ($c_block["type"] == "pdfeed") { $fb = new ilPDExternalFeedBlock($c_block["id"]); $fb->delete(); } } // delete block settings include_once "./Services/Block/classes/class.ilBlockSetting.php"; ilBlockSetting::_deleteSettingsOfUser($this->getId()); // delete user_account $ilDB->manipulateF("DELETE FROM usr_data WHERE usr_id = %s", array("integer"), array($this->getId())); // delete user_prefs ilObjUser::_deleteAllPref($this->getId()); // delete user_session include_once "./Services/Authentication/classes/class.ilSession.php"; ilSession::_destroyByUserId($this->getId()); // remove user from rbac $rbacadmin->removeUser($this->getId()); // remove bookmarks // TODO: move this to class.ilBookmarkFolder $q = "DELETE FROM bookmark_tree WHERE tree = " . $ilDB->quote($this->getId(), "integer"); $ilDB->manipulate($q); $q = "DELETE FROM bookmark_data WHERE user_id = " . $ilDB->quote($this->getId(), "integer"); $ilDB->manipulate($q); // DELETE FORUM ENTRIES (not complete in the moment) include_once './Modules/Forum/classes/class.ilObjForum.php'; ilObjForum::_deleteUser($this->getId()); // Delete link check notify entries include_once './Services/LinkChecker/classes/class.ilLinkCheckNotify.php'; ilLinkCheckNotify::_deleteUser($this->getId()); // Delete crs entries include_once './Modules/Course/classes/class.ilObjCourse.php'; ilObjCourse::_deleteUser($this->getId()); // Delete user tracking include_once './Services/Tracking/classes/class.ilObjUserTracking.php'; ilObjUserTracking::_deleteUser($this->getId()); include_once 'Modules/Session/classes/class.ilEventParticipants.php'; ilEventParticipants::_deleteByUser($this->getId()); // Delete Tracking data SCORM 2004 RTE include_once 'Modules/Scorm2004/classes/ilSCORM13Package.php'; ilSCORM13Package::_removeTrackingDataForUser($this->getId()); // Delete Tracking data SCORM 1.2 RTE include_once 'Modules/ScormAicc/classes/class.ilObjSCORMLearningModule.php'; ilObjSCORMLearningModule::_removeTrackingDataForUser($this->getId()); // remove all notifications include_once "./Services/Notification/classes/class.ilNotification.php"; ilNotification::removeForUser($this->getId()); // remove portfolios include_once "./Modules/Portfolio/classes/class.ilObjPortfolio.php"; ilObjPortfolio::deleteUserPortfolios($this->getId()); // remove workspace include_once "./Services/PersonalWorkspace/classes/class.ilWorkspaceTree.php"; $tree = new ilWorkspaceTree($this->getId()); $tree->cascadingDelete(); // remove disk quota entries include_once "./Services/DiskQuota/classes/class.ilDiskQuotaHandler.php"; ilDiskQuotaHandler::deleteByOwner($this->getId()); // Delete user defined field entries $this->deleteUserDefinedFieldEntries(); // Delete clipboard entries $this->clipboardDeleteAll(); // Reset owner $this->resetOwner(); // Trigger deleteUser Event global $ilAppEventHandler; $ilAppEventHandler->raise('Services/User', 'deleteUser', array('usr_id' => $this->getId())); // delete object data parent::delete(); return true; }
/** * read manifest file * @access public */ function readObject() { global $ilias, $lng, $ilDB; //check for MYSQL 4.1 and json_encode,json_decode if (!function_exists('json_encode') || !function_exists('json_decode') || $ilDB->getDBType() == 'mysql' && !$ilDB->isMysql4_1OrHigher()) { $ilias->raiseError($lng->txt('scplayer_phpmysqlcheck'), $ilias->error_obj->WARNING); } $needs_convert = false; // convert imsmanifest.xml file in iso to utf8 if needed $manifest_file = $this->getDataDirectory() . "/imsmanifest.xml"; // check if manifestfile exists and space left on device... $check_for_manifest_file = is_file($manifest_file); // if no manifestfile if (!$check_for_manifest_file) { $this->ilias->raiseError($this->lng->txt("Manifestfile {$manifest_file} not found!"), $this->ilias->error_obj->MESSAGE); return; } if ($check_for_manifest_file) { $manifest_file_array = file($manifest_file); foreach ($manifest_file_array as $mfa) { // if (seems_not_utf8($mfa)) if (@iconv('UTF-8', 'UTF-8', $mfa) != $mfa) { $needs_convert = true; break; } } // to copy the file we need some extraspace, counted in bytes *2 ... we need 2 copies.... $estimated_manifest_filesize = filesize($manifest_file) * 2; // i deactivated this, because it seems to fail on some windows systems (see bug #1795) //$check_disc_free = disk_free_space($this->getDataDirectory()) - $estimated_manifest_filesize; $check_disc_free = 2; } // if $manifest_file needs to be converted to UTF8 if ($needs_convert) { // if file exists and enough space left on device if ($check_for_manifest_file && $check_disc_free > 1) { // create backup from original if (!copy($manifest_file, $manifest_file . ".old")) { echo "Failed to copy {$manifest_file}...<br>\n"; } // read backupfile, convert each line to utf8, write line to new file // php < 4.3 style $f_write_handler = fopen($manifest_file . ".new", "w"); $f_read_handler = fopen($manifest_file . ".old", "r"); while (!feof($f_read_handler)) { $zeile = fgets($f_read_handler); //echo mb_detect_encoding($zeile); fputs($f_write_handler, utf8_encode($zeile)); } fclose($f_read_handler); fclose($f_write_handler); // copy new utf8-file to imsmanifest.xml if (!copy($manifest_file . ".new", $manifest_file)) { echo "Failed to copy {$manifest_file}...<br>\n"; } if (!@is_file($manifest_file)) { $this->ilias->raiseError($this->lng->txt("cont_no_manifest"), $this->ilias->error_obj->WARNING); } } else { // gives out the specific error if (!($check_disc_free > 1)) { $this->ilias->raiseError($this->lng->txt("Not enough space left on device!"), $this->ilias->error_obj->MESSAGE); } return; } } else { // check whether file starts with BOM (that confuses some sax parsers, see bug #1795) $hmani = fopen($manifest_file, "r"); $start = fread($hmani, 3); if (strtolower(bin2hex($start)) == "efbbbf") { $f_write_handler = fopen($manifest_file . ".new", "w"); while (!feof($hmani)) { $n = fread($hmani, 900); fputs($f_write_handler, $n); } fclose($f_write_handler); fclose($hmani); // copy new utf8-file to imsmanifest.xml if (!copy($manifest_file . ".new", $manifest_file)) { echo "Failed to copy {$manifest_file}...<br>\n"; } } else { fclose($hmani); } } //validate the XML-Files in the SCORM-Package if ($_POST["validate"] == "y") { if (!$this->validate($this->getDataDirectory())) { $this->ilias->raiseError("<b>Validation Error(s):</b><br>" . $this->getValidationSummary(), $this->ilias->error_obj->WARNING); } } //check for SCORM 1.2 $this->convert_1_2_to_2004($manifest_file); // start SCORM 2004 package parser/importer include_once "./Modules/Scorm2004/classes/ilSCORM13Package.php"; $newPack = new ilSCORM13Package(); if ($this->getEditable()) { return $newPack->il_importLM($this, $this->getDataDirectory(), $this->getImportSequencing()); } else { return $newPack->il_import($this->getDataDirectory(), $this->getId(), $this->ilias, $_POST["validate"]); } }
function dbImportLM($node, $parent_id = "", $a_import_sequencing = false) { switch ($node->getName()) { case "manifest": $this->slm_tree =& new ilTree($this->slm->getId()); $this->slm_tree->setTreeTablePK("slm_id"); $this->slm_tree->setTableNames('sahs_sc13_tree', 'sahs_sc13_tree_node'); $this->slm_tree->addTree($this->slm->getId(), 1); //add seqinfo for rootNode include_once "./Modules/Scorm2004/classes/seq_editor/class.ilSCORM2004Sequencing.php"; $seq_info = new ilSCORM2004Sequencing($this->slm->getId(), true); // get original sequencing information $r = $this->mani_xpath->query("/d:manifest/d:organizations/d:organization/imsss:sequencing"); $this->imsmanifest->formatOutput = false; if ($r) { $this->setSequencingInfo($r->item(0), $seq_info, $a_import_sequencing); if ($a_import_sequencing) { $seq_info->initDom(); } } $seq_info->insert(); if (file_exists($this->packageFolder . '/' . 'index.xml')) { $doc = simplexml_load_file($this->packageFolder . '/' . 'index.xml'); $l = $doc->xpath("/ContentObject/MetaData"); if ($l[0]) { include_once 'Services/MetaData/classes/class.ilMDXMLCopier.php'; $mdxml =& new ilMDXMLCopier($l[0]->asXML(), $this->slm->getId(), $this->slm->getId(), $this->slm->getType()); $mdxml->startParsing(); $mdxml->getMDObject()->update(); } } break; case "organization": $this->slm->title = $node->title; break; case "item": $a = $node->attributes(); if (preg_match("/il_\\d+_chap_\\d+/", $a['identifier'])) { $chap =& new ilSCORM2004Chapter($this->slm); $chap->setTitle($node->title); $chap->setSLMId($this->slm->getId()); $chap->create(true); // save sequencing information $r = $this->mani_xpath->query("//d:item[@identifier='" . $a['identifier'] . "']/imsss:sequencing"); if ($r) { $seq_info = new ilSCORM2004Sequencing($chap->getId()); $this->setSequencingInfo($r->item(0), $seq_info, $a_import_sequencing); $seq_info->initDom(); $seq_info->insert(); } ilSCORM2004Node::putInTree($chap, $parent_id, ""); $parent_id = $chap->getId(); $doc = simplexml_load_file($this->packageFolder . '/' . 'index.xml'); $l = $doc->xpath("/ContentObject/StructureObject/MetaData[General/Identifier/@Entry='" . $a['identifier'] . "']"); if ($l[0]) { include_once 'Services/MetaData/classes/class.ilMDXMLCopier.php'; $mdxml =& new ilMDXMLCopier($l[0]->asXML(), $this->slm->getId(), $chap->getId(), $chap->getType()); $mdxml->startParsing(); $mdxml->getMDObject()->update(); } } if (preg_match("/il_\\d+_sco_(\\d+)/", $a['identifier'], $match)) { $sco = new ilSCORM2004Sco($this->slm); $sco->setTitle($node->title); $sco->setSLMId($this->slm->getId()); $sco->create(true); // save sequencing information $r = $this->mani_xpath->query("//d:item[@identifier='" . $a['identifier'] . "']/imsss:sequencing"); if ($r) { $seq_info = new ilSCORM2004Sequencing($sco->getId()); $this->setSequencingInfo($r->item(0), $seq_info, $a_import_sequencing, "local_obj_" . $sco->getID() . "_0"); $seq_info->initDom(); $seq_info->insert(); } ilSCORM2004Node::putInTree($sco, $parent_id, ""); $newPack = new ilSCORM13Package(); $newPack->il_importSco($this->slm->getId(), $sco->getId(), $this->packageFolder . "/" . $match[1]); $parent_id = $sco->getId(); } if (preg_match("/il_\\d+_ass_(\\d+)/", $a['identifier'], $match)) { $ass = new ilSCORM2004Asset($this->slm); $ass->setTitle($node->title); $ass->setSLMId($this->slm->getId()); $ass->create(true); // save sequencing information $r = $this->mani_xpath->query("//d:item[@identifier='" . $a['identifier'] . "']/imsss:sequencing"); if ($r) { $seq_info = new ilSCORM2004Sequencing($ass->getId()); $this->setSequencingInfo($r->item(0), $seq_info, $a_import_sequencing, "local_obj_" . $ass->getID() . "_0"); $seq_info->initDom(); $seq_info->insert(); } ilSCORM2004Node::putInTree($ass, $parent_id, ""); $newPack = new ilSCORM13Package(); $newPack->il_importAss($this->slm->getId(), $ass->getId(), $this->packageFolder . "/" . $match[1]); $parent_id = $ass->getId(); } break; } foreach ($node->children() as $child) { $this->dbImportLM($child, $parent_id, $a_import_sequencing); } }