ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
All Data Structures Namespaces Files Functions Variables Modules Pages
ilOrgUnitExporter Class Reference

Class ilOrgUnitExporter. More...

+ Inheritance diagram for ilOrgUnitExporter:
+ Collaboration diagram for ilOrgUnitExporter:

Public Member Functions

 simpleExport ($orgu_ref_id)
 
 sendAndCreateSimpleExportFile ()
 
- Public Member Functions inherited from ilCategoryExporter
 getXmlExportHeadDependencies ($a_entity, $a_target_release, $a_ids)
 Get head dependencies. More...
 
 getXmlExportTailDependencies ($a_entity, $a_target_release, $a_ids)
 Get tail dependencies. More...
 
 getXmlRepresentation ($a_entity, $a_schema_version, $a_id)
 Get xml. More...
 
 getValidSchemaVersions ($a_entity)
 Returns schema versions that the component can export to. More...
 
 init ()
 Init method. More...
 
- Public Member Functions inherited from ilXmlExporter
 __construct ()
 Constructor. More...
 
 getXmlRepresentation ($a_entity, $a_schema_version, $a_id)
 Get xml representation. More...
 
 init ()
 
 setExportDirectories ($a_dir_relative, $a_dir_absolute)
 Export directories. More...
 
 getRelativeExportDirectory ()
 Get relative export directory. More...
 
 getAbsoluteExportDirectory ()
 Get absolute export directory. More...
 
 getXmlExportHeadDependencies ($a_entity, $a_target_release, $a_ids)
 Get head dependencies. More...
 
 getXmlExportTailDependencies ($a_entity, $a_target_release, $a_ids)
 Get tail dependencies. More...
 
 getValidSchemaVersions ($a_entity)
 Returns schema versions that the component can export to. More...
 
 determineSchemaVersion ($a_entity, $a_target_release)
 Determine schema version. More...
 

Protected Member Functions

 buildExternalId ($orgu_ref_id)
 

Private Member Functions

 getStructure ($root_node_ref)
 
 getAttributesForOrgu ($orgu)
 

Additional Inherited Members

- Static Public Member Functions inherited from ilXmlExporter
static lookupExportDirectory ($a_obj_type, $a_obj_id, $a_export_type='xml', $a_entity="")
 export directory lookup More...
 
- Protected Attributes inherited from ilXmlExporter
 $dir_relative
 
 $dir_absolute
 

Detailed Description

Member Function Documentation

◆ buildExternalId()

ilOrgUnitExporter::buildExternalId (   $orgu_ref_id)
protected
Parameters
$orgu_ref_idint
Returns
string

Definition at line 40 of file class.ilOrgUnitExporter.php.

References $row, getAttributesForOrgu(), ilObjOrgUnit\getRootOrgRefId(), and getStructure().

Referenced by getAttributesForOrgu(), and simpleExport().

40  {
41  return "orgu_".CLIENT_ID."_".$orgu_ref_id;
42  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getAttributesForOrgu()

ilOrgUnitExporter::getAttributesForOrgu (   $orgu)
private
Parameters
$orguilObjOrgUnit
Returns
array

Definition at line 146 of file class.ilOrgUnitExporter.php.

References $ref_id, buildExternalId(), and ilObjOrgUnit\getRootOrgRefId().

Referenced by buildExternalId(), and simpleExport().

146  {
147  global $tree;
148  $parent_ref = $tree->getParentId($orgu->getRefId());
149  if($parent_ref != ilObjOrgUnit::getRootOrgRefId()){
150  $ou_parent_id = $this->buildExternalId($parent_ref);
151  } else {
152  $ou_parent_id = "__ILIAS";
153  }
154  // Only the ref id is guaranteed to be unique.
155  $ref_id = $orgu->getRefId();
156  $attr = array("ou_id" => $this->buildExternalId($ref_id), "ou_id_type" => "external_id", "ou_parent_id" => $ou_parent_id, "ou_parent_id_type" => "external_id", "action" => "create");
157  return $attr;
158  }
static getRootOrgRefId()
$ref_id
Definition: sahs_server.php:39
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getStructure()

ilOrgUnitExporter::getStructure (   $root_node_ref)
private

Definition at line 127 of file class.ilOrgUnitExporter.php.

Referenced by buildExternalId(), and simpleExport().

127  {
128  global $tree;
129  $open = array($root_node_ref);
130  $closed = array();
131  while(count($open)){
132  $current = array_shift($open);
133  $closed[] = $current;
134  foreach($tree->getChildsByType($current, "orgu") as $new){
135  if(!in_array($new["child"], $closed) && !in_array($new["child"], $open))
136  $open[] = $new["child"];
137  }
138  }
139  return $closed;
140  }
+ Here is the caller graph for this function:

◆ sendAndCreateSimpleExportFile()

ilOrgUnitExporter::sendAndCreateSimpleExportFile ( )

Definition at line 86 of file class.ilOrgUnitExporter.php.

References ilExport\_createExportDirectory(), ilExport\_getExportDirectory(), ilUtil\delDir(), ilUtil\deliverFile(), ilObjOrgUnit\getRootOrgId(), ilObjOrgUnit\getRootOrgRefId(), IL_CAL_UNIX, ILIAS_VERSION_NUMERIC, ilUtil\makeDirParents(), simpleExport(), and ilUtil\zip().

86  {
87  $orgu_id = ilObjOrgUnit::getRootOrgId();
88  $orgu_ref_id = ilObjOrgUnit::getRootOrgRefId();
89 
90  ilExport::_createExportDirectory($orgu_id, "xml", "orgu");
91  $export_dir = ilExport::_getExportDirectory($orgu_id, "xml", "orgu");
92  $ts = time();
93 
94  // Workaround for test assessment
95  $sub_dir = $ts.'__'.IL_INST_ID.'__'."orgu".'_'.$orgu_id."";
96  $new_file = $sub_dir.'.zip';
97 
98  $export_run_dir = $export_dir."/".$sub_dir;
99  ilUtil::makeDirParents($export_run_dir);
100 
101  $writer = $this->simpleExport($orgu_ref_id);
102  $writer->xmlDumpFile($export_run_dir."/manifest.xml", false);
103 
104  // zip the file
105  ilUtil::zip($export_run_dir , $export_dir."/".$new_file);
106  ilUtil::delDir($export_run_dir );
107 
108  // Store info about export
109  include_once './Services/Export/classes/class.ilExportFileInfo.php';
110  $exp = new ilExportFileInfo($orgu_id);
111  $exp->setVersion(ILIAS_VERSION_NUMERIC);
112  $exp->setCreationDate(new ilDateTime($ts,IL_CAL_UNIX));
113  $exp->setExportType('xml');
114  $exp->setFilename($new_file);
115  $exp->create();
116 
117  ilUtil::deliverFile($export_dir."/".$new_file,
118  $new_file);
119 
120  return array(
121  "success" => true,
122  "file" => $new_file,
123  "directory" => $export_dir
124  );
125  }
static makeDirParents($a_dir)
Create a new directory and all parent directories.
const ILIAS_VERSION_NUMERIC
_createExportDirectory($a_obj_id, $a_export_type="xml", $a_obj_type="")
Create export directory.
const IL_CAL_UNIX
Stores information of creation date and versions of export files
Date and time handling
static deliverFile($a_file, $a_filename, $a_mime='', $isInline=false, $removeAfterDelivery=false, $a_exit_after=true)
deliver file for download via browser.
static zip($a_dir, $a_file, $compress_content=false)
zips given directory/file into given zip.file
static getRootOrgRefId()
static _getExportDirectory($a_obj_id, $a_type="xml", $a_obj_type="", $a_entity="")
Get export directory for an repository object.
static delDir($a_dir, $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
+ Here is the call graph for this function:

◆ simpleExport()

ilOrgUnitExporter::simpleExport (   $orgu_ref_id)

Definition at line 17 of file class.ilOrgUnitExporter.php.

References buildExternalId(), getAttributesForOrgu(), ilObjOrgUnit\getRootOrgRefId(), and getStructure().

Referenced by sendAndCreateSimpleExportFile().

17  {
18  $nodes = $this->getStructure($orgu_ref_id);
19  $writer = new ilXmlWriter();
20  $writer->xmlStartTag("OrgUnits");
21  foreach($nodes as $orgu_ref_id){
22  $orgu = new ilObjOrgUnit($orgu_ref_id);
23  if($orgu->getRefId() == ilObjOrgUnit::getRootOrgRefId())
24  continue;
25  $attributes = $this->getAttributesForOrgu($orgu);
26  $writer->xmlStartTag("OrgUnit", $attributes);
27  $writer->xmlElement("external_id", null, $this->buildExternalId($orgu_ref_id));
28  $writer->xmlElement("title", null, $orgu->getTitle());
29  $writer->xmlElement("description", null, $orgu->getDescription());
30  $writer->xmlEndTag("OrgUnit");
31  }
32  $writer->xmlEndTag("OrgUnits");
33  return $writer;
34  }
XML writer class.
Class ilObjOrgUnit.
static getRootOrgRefId()
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

The documentation for this class was generated from the following file: