ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilOrgUnitExporter Class Reference

Class ilOrgUnitExporter. More...

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

Public Member Functions

 simpleExport ($orgu_ref_id)
 
 simpleExportExcel ($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

 getExternalId ($orgu_ref_id)
 
 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 50 of file class.ilOrgUnitExporter.php.

51 {
52 return "orgu_" . CLIENT_ID . "_" . $orgu_ref_id;
53 }

Referenced by getExternalId().

+ Here is the caller graph for this function:

◆ getAttributesForOrgu()

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

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

165 {
166 global $DIC;
167 $tree = $DIC['tree'];
168 $parent_ref = $tree->getParentId($orgu->getRefId());
169 if ($parent_ref != ilObjOrgUnit::getRootOrgRefId()) {
170 $ou_parent_id = $this->getExternalId($parent_ref);
171 } else {
172 $ou_parent_id = "__ILIAS";
173 }
174 // Only the ref id is guaranteed to be unique.
175 $ref_id = $orgu->getRefId();
176 $attr = array("ou_id" => $this->getExternalId($ref_id), "ou_id_type" => "external_id", "ou_parent_id" => $ou_parent_id, "ou_parent_id_type" => "external_id", "action" => "create");
177 return $attr;
178 }
static getRootOrgRefId()
global $DIC
Definition: saml.php:7

References $DIC, $tree, getExternalId(), and ilObjOrgUnit\getRootOrgRefId().

Referenced by simpleExport(), and simpleExportExcel().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getExternalId()

ilOrgUnitExporter::getExternalId (   $orgu_ref_id)
protected
Parameters
$orgu_ref_id
Returns
string

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

41 {
42 $import_id = ilObjOrgunit::_lookupImportId(ilObjOrgUnit::_lookupObjectId($orgu_ref_id));
43 return $import_id ?: $this->buildExternalId($orgu_ref_id);
44 }
static _lookupObjectId($a_ref_id)
lookup object id

References ilObject\_lookupObjectId(), and buildExternalId().

Referenced by getAttributesForOrgu(), and 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 142 of file class.ilOrgUnitExporter.php.

143 {
144 global $DIC;
145 $tree = $DIC['tree'];
146 $open = array($root_node_ref);
147 $closed = array();
148 while (count($open)) {
149 $current = array_shift($open);
150 $closed[] = $current;
151 foreach ($tree->getChildsByType($current, "orgu") as $new) {
152 if (!in_array($new["child"], $closed) && !in_array($new["child"], $open)) {
153 $open[] = $new["child"];
154 }
155 }
156 }
157 return $closed;
158 }

References $current, $DIC, and $tree.

Referenced by simpleExport(), and simpleExportExcel().

+ Here is the caller graph for this function:

◆ sendAndCreateSimpleExportFile()

ilOrgUnitExporter::sendAndCreateSimpleExportFile ( )

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

100 {
101 $orgu_id = ilObjOrgUnit::getRootOrgId();
102 $orgu_ref_id = ilObjOrgUnit::getRootOrgRefId();
103
104 ilExport::_createExportDirectory($orgu_id, "xml", "orgu");
105 $export_dir = ilExport::_getExportDirectory($orgu_id, "xml", "orgu");
106 $ts = time();
107
108 // Workaround for test assessment
109 $sub_dir = $ts . '__' . IL_INST_ID . '__' . "orgu" . '_' . $orgu_id . "";
110 $new_file = $sub_dir . '.zip';
111
112 $export_run_dir = $export_dir . "/" . $sub_dir;
113 ilUtil::makeDirParents($export_run_dir);
114
115 $writer = $this->simpleExport($orgu_ref_id);
116 $writer->xmlDumpFile($export_run_dir . "/manifest.xml", false);
117
118 // zip the file
119 ilUtil::zip($export_run_dir, $export_dir . "/" . $new_file);
120 ilUtil::delDir($export_run_dir);
121
122 // Store info about export
123 $exp = new ilExportFileInfo($orgu_id);
124 $exp->setVersion(ILIAS_VERSION_NUMERIC);
125 $exp->setCreationDate(new ilDateTime($ts, IL_CAL_UNIX));
126 $exp->setExportType('xml');
127 $exp->setFilename($new_file);
128 $exp->create();
129
131 $export_dir . "/" . $new_file,
132 $new_file
133 );
134
135 return array(
136 "success" => true,
137 "file" => $new_file,
138 "directory" => $export_dir
139 );
140 }
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.
static _createExportDirectory($a_obj_id, $a_export_type="xml", $a_obj_type="")
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)
zips given directory/file into given zip.file
static deliverFile( $a_file, $a_filename, $a_mime='', $isInline=false, $removeAfterDelivery=false, $a_exit_after=true)
deliver file for download via browser.
static makeDirParents($a_dir)
Create a new directory and all parent directories.
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 12 of file class.ilOrgUnitExporter.php.

13 {
14 $nodes = $this->getStructure($orgu_ref_id);
15 $writer = new ilXmlWriter();
16 $writer->xmlHeader();
17 $writer->xmlStartTag("OrgUnits");
18 foreach ($nodes as $orgu_ref_id) {
19 $orgu = new ilObjOrgUnit($orgu_ref_id);
20 if ($orgu->getRefId() == ilObjOrgUnit::getRootOrgRefId()) {
21 continue;
22 }
23 $attributes = $this->getAttributesForOrgu($orgu);
24 $writer->xmlStartTag("OrgUnit", $attributes);
25 $writer->xmlElement("external_id", null, $this->getExternalId($orgu_ref_id));
26 $writer->xmlElement("title", null, $orgu->getTitle());
27 $writer->xmlElement("description", null, $orgu->getDescription());
28 $writer->xmlEndTag("OrgUnit");
29 }
30 $writer->xmlEndTag("OrgUnits");
31 return $writer;
32 }
Class ilObjOrgUnit.
XML writer class.
if(array_key_exists('yes', $_REQUEST)) $attributes
Definition: getconsent.php:85

References $attributes, $nodes, getAttributesForOrgu(), getExternalId(), ilObjOrgUnit\getRootOrgRefId(), and getStructure().

Referenced by sendAndCreateSimpleExportFile().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ simpleExportExcel()

ilOrgUnitExporter::simpleExportExcel (   $orgu_ref_id)
Parameters
$orgu_ref_id

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

60 {
61 // New File and Sheet
62 $file_name = "org_unit_export_" . $orgu_ref_id;
63 $worksheet = new ilExcel();
64 $worksheet->addSheet('org_units');
65 $row = 1;
66
67 // Headers
68 $worksheet->setCell($row, 0, "ou_id");
69 $worksheet->setCell($row, 1, "ou_id_type");
70 $worksheet->setCell($row, 2, "ou_parent_id");
71 $worksheet->setCell($row, 3, "ou_parent_id_type");
72 $worksheet->setCell($row, 4, "reference_id");
73 $worksheet->setCell($row, 5, "title");
74 $worksheet->setCell($row, 6, "description");
75 $worksheet->setCell($row, 7, "action");
76
77 // Rows
78 $nodes = $this->getStructure($orgu_ref_id);
79
80 foreach ($nodes as $node) {
81 $orgu = new ilObjOrgUnit($node);
82 if ($orgu->getRefId() == ilObjOrgUnit::getRootOrgRefId()) {
83 continue;
84 }
85 $row++;
86 $attrs = $this->getAttributesForOrgu($orgu);
87 $worksheet->setCell($row, 0, $attrs["ou_id"]);
88 $worksheet->setCell($row, 1, $attrs["ou_id_type"]);
89 $worksheet->setCell($row, 2, $attrs["ou_parent_id"]);
90 $worksheet->setCell($row, 3, $attrs["ou_parent_id_type"]);
91 $worksheet->setCell($row, 4, $orgu->getRefId());
92 $worksheet->setCell($row, 5, $orgu->getTitle());
93 $worksheet->setCell($row, 6, $orgu->getDescription());
94 $worksheet->setCell($row, 7, "create");
95 }
96 $worksheet->sendToClient($file_name);
97 }
$row

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

+ Here is the call graph for this function:

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