3 require_once(
"./Modules/OrgUnit/classes/class.ilOrgUnitImporter.php");
15 $this->stats = array(
"created" => 0,
"updated" => 0,
"deleted" => 0);
16 $a = file_get_contents($file_path,
"r");
17 $xml =
new SimpleXMLElement($a);
19 if(!count($xml->OrgUnit)) {
20 $this->
addError(
"no_orgunit",null,null);
24 foreach($xml->OrgUnit as $o){
32 $description = $o->description;
33 $external_id = $o->external_id;
35 $attributes = $o->attributes();
36 $action = (string)$attributes->action;
37 $ou_id = (
string)$attributes->ou_id;
38 $ou_id_type = (string)$attributes->ou_id_type;
39 $ou_parent_id = (
string)$attributes->ou_parent_id;
40 $ou_parent_id_type = (string)$attributes->ou_parent_id_type;
43 $this->
addWarning(
"cannot_change_root_node", $ou_id?$ou_id:$external_id, $action);
47 if($ou_parent_id ==
"__ILIAS"){
49 $ou_parent_id_type =
"reference_id";
53 $parent_ref_id = $this->
buildRef($ou_parent_id, $ou_parent_id_type);
55 if($action ==
"delete"){
57 $this->
addError(
"ou_parent_id_not_valid", $ou_id?$ou_id:$external_id, $action);
61 $this->
addError(
"ou_id_not_valid", $ou_id?$ou_id:$external_id, $action);
64 include_once(
"./Services/Repository/classes/class.ilRepUtil.php");
67 $ru->deleteObjects($parent_ref_id, array(
$ref_id)) !==
false;
68 $this->stats[
"deleted"]++;
70 $this->
addWarning(
"orgu_already_deleted", $ou_id?$ou_id:$external_id, $action);
73 }elseif($action ==
"update"){
75 $this->
addError(
"ou_parent_id_not_valid", $ou_id?$ou_id:$external_id, $action);
79 $this->
addError(
"ou_id_not_valid", $ou_id?$ou_id:$external_id, $action);
83 $object->setTitle($title);
85 $arrTranslations = $object->getTranslations();
86 $object->updateTranslation($title,$description,$ilUser->getLanguage(),
"");
88 $object->setDescription($description);
90 $object->setImportId($external_id);
93 $this->stats[
"updated"]++;
94 }elseif($action ==
"create"){
96 $this->
addError(
"ou_parent_id_not_valid", $ou_id?$ou_id:$external_id, $action);
103 $this->
addError(
"ou_external_id_exists", $ou_id?$ou_id:$external_id, $action);
108 $object->setTitle($title);
109 $object->setDescription($description);
110 $object->setImportId($external_id);
112 $object->createReference();
113 $object->putInTree($parent_ref_id);
114 $object->setPermissions($ou_parent_id);
115 $this->stats[
"created"]++;
117 $this->
addError(
"no_valid_action_given", $ou_id, $action);
129 if($parent_ref_id != $tree->getParentId(
$ref_id)){
131 $path = $tree->getPathId($parent_ref_id);
133 $this->
addWarning(
"not_movable_to_subtree", $ou_id?$ou_id:$external_id,
"update");
135 $tree->moveTree(
$ref_id, $parent_ref_id);
139 $this->
addWarning(
"not_movable", $ou_id?$ou_id:$external_id,
"update");
140 $ilLog->write($e->getMessage().
"\\n".$e->getTraceAsString());
141 error_log($e->getMessage().
"\\n".$e->getTraceAsString());
Repository Utilities (application layer, put GUI related stuff into ilRepUtilGUI) ...
moveObject($ref_id, $parent_ref_id, $ou_id, $external_id)
addError($lang_var, $import_id, $action=NULL)
Class ilOrgUnitSimpleImport.
addWarning($lang_var, $import_id, $action=NULL)
_hasUntrashedReference($a_obj_id)
checks wether an object has at least one reference that is not in trash
simpleImportElement(SimpleXMLElement $o)
static _lookupObjIdByImportId($a_import_id)