ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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...
 
 setExport (ilExport $a_exp)
 Set export object. More...
 
 getExport ()
 Get export. 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
 
 $exp
 

Detailed Description

Member Function Documentation

◆ buildExternalId()

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

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

41 {
42 return "orgu_".CLIENT_ID."_".$orgu_ref_id;
43 }

Referenced by getAttributesForOrgu(), and simpleExport().

+ Here is the caller graph for this function:

◆ getAttributesForOrgu()

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

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

147 {
148 global $tree;
149 $parent_ref = $tree->getParentId($orgu->getRefId());
150 if($parent_ref != ilObjOrgUnit::getRootOrgRefId()){
151 $ou_parent_id = $this->buildExternalId($parent_ref);
152 } else {
153 $ou_parent_id = "__ILIAS";
154 }
155 // Only the ref id is guaranteed to be unique.
156 $ref_id = $orgu->getRefId();
157 $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");
158 return $attr;
159 }
static getRootOrgRefId()
$ref_id
Definition: sahs_server.php:39

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

Referenced by simpleExport().

+ 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 128 of file class.ilOrgUnitExporter.php.

128 {
129 global $tree;
130 $open = array($root_node_ref);
131 $closed = array();
132 while(count($open)){
133 $current = array_shift($open);
134 $closed[] = $current;
135 foreach($tree->getChildsByType($current, "orgu") as $new){
136 if(!in_array($new["child"], $closed) && !in_array($new["child"], $open))
137 $open[] = $new["child"];
138 }
139 }
140 return $closed;
141 }

Referenced by simpleExport().

+ Here is the caller graph for this function:

◆ sendAndCreateSimpleExportFile()

ilOrgUnitExporter::sendAndCreateSimpleExportFile ( )

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

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

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

+ Here is the call graph for this function:

◆ simpleExport()

ilOrgUnitExporter::simpleExport (   $orgu_ref_id)

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

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

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

Referenced by sendAndCreateSimpleExportFile().

+ 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: