ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups 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.
 getXmlExportTailDependencies ($a_entity, $a_target_release, $a_ids)
 Get tail dependencies.
 getXmlRepresentation ($a_entity, $a_schema_version, $a_id)
 Get xml.
 getValidSchemaVersions ($a_entity)
 Returns schema versions that the component can export to.
 init ()
 Init method.
- Public Member Functions inherited from ilXmlExporter
 __construct ()
 Constructor.
 setExportDirectories ($a_dir_relative, $a_dir_absolute)
 Export directories.
 getRelativeExportDirectory ()
 Get relative export directory.
 getAbsoluteExportDirectory ()
 Get absolute export directory.
 determineSchemaVersion ($a_entity, $a_target_release)
 Determine schema version.

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
- Protected Attributes inherited from ilXmlExporter
 $dir_relative
 $dir_absolute

Detailed Description

Member Function Documentation

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

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

Referenced by getAttributesForOrgu(), and simpleExport().

{
return "orgu_".CLIENT_ID."_".$orgu_ref_id;
}

+ Here is the caller graph for this function:

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 simpleExport().

{
global $tree;
$parent_ref = $tree->getParentId($orgu->getRefId());
if($parent_ref != ilObjOrgUnit::getRootOrgRefId()){
$ou_parent_id = $this->buildExternalId($parent_ref);
} else {
$ou_parent_id = "__ILIAS";
}
// Only the ref id is guaranteed to be unique.
$ref_id = $orgu->getRefId();
$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");
return $attr;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilOrgUnitExporter::getStructure (   $root_node_ref)
private

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

Referenced by simpleExport().

{
global $tree;
$open = array($root_node_ref);
$closed = array();
while(count($open)){
$current = array_shift($open);
$closed[] = $current;
foreach($tree->getChildsByType($current, "orgu") as $new){
if(!in_array($new["child"], $closed) && !in_array($new["child"], $open))
$open[] = $new["child"];
}
}
return $closed;
}

+ Here is the caller graph for this function:

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().

{
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
);
}

+ Here is the call graph for this function:

ilOrgUnitExporter::simpleExport (   $orgu_ref_id)

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

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

Referenced by sendAndCreateSimpleExportFile().

{
$nodes = $this->getStructure($orgu_ref_id);
$writer = new ilXmlWriter();
$writer->xmlStartTag("OrgUnits");
foreach($nodes as $orgu_ref_id){
$orgu = new ilObjOrgUnit($orgu_ref_id);
if($orgu->getRefId() == ilObjOrgUnit::getRootOrgRefId())
continue;
$attributes = $this->getAttributesForOrgu($orgu);
$writer->xmlStartTag("OrgUnit", $attributes);
$writer->xmlElement("external_id", null, $this->buildExternalId($orgu_ref_id));
$writer->xmlElement("title", null, $orgu->getTitle());
$writer->xmlElement("description", null, $orgu->getDescription());
$writer->xmlEndTag("OrgUnit");
}
$writer->xmlEndTag("OrgUnits");
return $writer;
}

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