/** * Add subitems * @param object $a_id * @param object $a_type * @return */ protected function addSubitems($a_id, $a_type, $a_target_release) { $GLOBALS['ilLog']->write(__METHOD__); $set_number = 1; foreach ($this->eo->getSubitemsForExport() as $ref_id) { // get last export file $obj_id = ilObject::_lookupObjId($ref_id); $expi = ilExportFileInfo::lookupLastExport($obj_id, 'xml', $a_target_release); if (!$expi instanceof ilExportFileInfo) { $GLOBALS['ilLog']->write(__METHOD__ . ': Cannot find export file for refId ' . $ref_id . ', type ' . ilObject::_lookupType($a_id)); continue; } $exp_dir = ilExport::_getExportDirectory($obj_id, 'xml', ilObject::_lookupType($obj_id)); $exp_full = $exp_dir . DIRECTORY_SEPARATOR . $expi->getFilename(); $GLOBALS['ilLog']->write(__METHOD__ . ': zip path ' . $exp_full); // Unzip ilUtil::unzip($exp_full, true, false); // create set directory ilUtil::makeDirParents($this->cont_export_dir . DIRECTORY_SEPARATOR . 'set_' . $set_number); // cut .zip $new_path_rel = 'set_' . $set_number . DIRECTORY_SEPARATOR . $expi->getBasename(); $new_path_abs = $this->cont_export_dir . DIRECTORY_SEPARATOR . $new_path_rel; $GLOBALS['ilLog']->write(__METHOD__ . ': ' . $new_path_rel . ' ' . $new_path_abs); // Move export rename($exp_dir . DIRECTORY_SEPARATOR . $expi->getBasename(), $new_path_abs); $GLOBALS['ilLog']->write($exp_dir . DIRECTORY_SEPARATOR . $expi->getBasename() . ' -> ' . $new_path_abs); // Delete latest container xml of source if ($a_id == $obj_id) { $expi->delete(); if (file_exists($exp_full)) { $GLOBALS['ilLog']->write(__METHOD__ . ': Deleting' . $exp_full); unlink($exp_full); } } $this->cont_manifest_writer->xmlElement('ExportSet', array('Path' => $new_path_rel, 'Type' => ilObject::_lookupType($obj_id))); ++$set_number; } }
/** * Delete files */ function delete() { global $ilCtrl; foreach ($_POST["file"] as $file) { $file = explode(":", $file); include_once "./Services/Export/classes/class.ilExport.php"; $export_dir = ilExport::_getExportDirectory($this->obj->getId(), str_replace("..", "", $file[0]), $this->obj->getType()); $exp_file = $export_dir . "/" . str_replace("..", "", $file[1]); $exp_dir = $export_dir . "/" . substr($file[1], 0, strlen($file[1]) - 4); if (@is_file($exp_file)) { unlink($exp_file); } if (@is_dir($exp_dir)) { ilUtil::delDir($exp_dir); } // delete entry in database include_once './Services/Export/classes/class.ilExportFileInfo.php'; $info = new ilExportFileInfo($this->obj->getId(), $file[0], $file[1]); $info->delete(); } $ilCtrl->redirect($this, "listExportFiles"); }
public function sendAndCreateSimpleExportFile() { $orgu_id = ilObjOrgUnit::getRootOrgId(); $orgu_ref_id = ilObjOrgUnit::getRootOrgRefId(); ilExport::_createExportDirectory($orgu_id, "xml", "orgu"); $export_dir = ilExport::_getExportDirectory($orgu_id, "xml", "orgu"); $ts = time(); // Workaround for test assessment $sub_dir = $ts . '__' . IL_INST_ID . '__' . "orgu" . '_' . $orgu_id . ""; $new_file = $sub_dir . '.zip'; $export_run_dir = $export_dir . "/" . $sub_dir; ilUtil::makeDirParents($export_run_dir); $writer = $this->simpleExport($orgu_ref_id); $writer->xmlDumpFile($export_run_dir . "/manifest.xml", false); // zip the file ilUtil::zip($export_run_dir, $export_dir . "/" . $new_file); ilUtil::delDir($export_run_dir); // Store info about export include_once './Services/Export/classes/class.ilExportFileInfo.php'; $exp = new ilExportFileInfo($orgu_id); $exp->setVersion(ILIAS_VERSION_NUMERIC); $exp->setCreationDate(new ilDateTime($ts, IL_CAL_UNIX)); $exp->setExportType('xml'); $exp->setFilename($new_file); $exp->create(); ilUtil::deliverFile($export_dir . "/" . $new_file, $new_file); return array("success" => true, "file" => $new_file, "directory" => $export_dir); }
/** * parse tree * @param object $a_source * @return */ public function parseContainer($a_source) { global $tree, $objDefinition, $ilAccess; $first = true; foreach ($tree->getSubTree($root = $tree->getNodeData($a_source)) as $node) { if ($node['type'] == 'rolf') { continue; } if (!$objDefinition->allowExport($node['type'])) { #continue; } include_once "./Modules/File/classes/class.ilObjFileAccess.php"; if ($node['type'] == "file" && ilObjFileAccess::_isFileHidden($node['title'])) { continue; } $r = array(); if ($last = ilExportFileInfo::lookupLastExport($node['obj_id'], 'xml')) { $r['last_export'] = $last->getCreationDate()->get(IL_CAL_UNIX); } else { $r['last_export'] = 0; } $r['last'] = false; $r['source'] = $first; $r['ref_id'] = $node['child']; $r['depth'] = $node['depth'] - $root['depth']; $r['type'] = $node['type']; $r['title'] = $node['title']; $r['export'] = $objDefinition->allowExport($node['type']); $r['perm_export'] = $ilAccess->checkAccess('write', '', $node['child']); $rows[] = $r; $first = false; } $rows[] = array('last' => true); $this->setData((array) $rows); }
/** * Export an ILIAS object (the object type must be known by objDefinition) * * @param string $a_type repository object type * @param int $a_id id of object or entity that shoudl be exported * @param string $a_target_release target release * * @return array success and info array */ function exportObject($a_type, $a_id, $a_target_release) { global $objDefinition, $tpl; $comp = $objDefinition->getComponentForType($a_type); $c = explode("/", $comp); $class = "il" . $c[1] . "Exporter"; // manifest writer include_once "./Services/Xml/classes/class.ilXmlWriter.php"; $this->manifest_writer = new ilXmlWriter(); $this->manifest_writer->xmlHeader(); $this->manifest_writer->xmlStartTag('Manifest', array("MainEntity" => $a_type, "Title" => ilObject::_lookupTitle($a_id), "TargetRelease" => $a_target_release, "InstallationId" => IL_INST_ID, "InstallationUrl" => ILIAS_HTTP_PATH)); // get export class ilExport::_createExportDirectory($a_id, "xml", $a_type); $export_dir = ilExport::_getExportDirectory($a_id, "xml", $a_type); $ts = time(); // Workaround for test assessment $sub_dir = $ts . '__' . IL_INST_ID . '__' . $a_type . '_' . $a_id; $new_file = $sub_dir . '.zip'; $this->export_run_dir = $export_dir . "/" . $sub_dir; ilUtil::makeDirParents($this->export_run_dir); $this->cnt = array(); $success = $this->processExporter($comp, $class, $a_type, $a_target_release, $a_id); $this->manifest_writer->xmlEndTag('Manifest'); $this->manifest_writer->xmlDumpFile($this->export_run_dir . "/manifest.xml", false); // zip the file ilUtil::zip($this->export_run_dir, $export_dir . "/" . $new_file); ilUtil::delDir($this->export_run_dir); // Store info about export if ($success) { include_once './Services/Export/classes/class.ilExportFileInfo.php'; $exp = new ilExportFileInfo($a_id); $exp->setVersion($a_target_release); $exp->setCreationDate(new ilDateTime($ts, IL_CAL_UNIX)); $exp->setExportType('xml'); $exp->setFilename($new_file); $exp->create(); } return array("success" => $success, "file" => $new_file, "directory" => $export_dir); }