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);
 }
Example #2
0
 /**
  * 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);
 }