16 $this->stats = array(
"created" => 0,
"updated" => 0,
"deleted" => 0);
17 $a = file_get_contents($file_path,
"r");
20 if (!count(
$xml->OrgUnit)) {
21 $this->
addError(
"no_orgunit", null, null);
25 foreach (
$xml->OrgUnit as $o) {
36 $title = (string) $o->title;
38 $external_id = (string) $o->external_id;
45 $ou_parent_id_type = (string)
$attributes->ou_parent_id_type;
48 $this->
addWarning(
"cannot_change_root_node", $ou_id?$ou_id:$external_id,
$action);
52 if ($ou_parent_id ==
"__ILIAS") {
54 $ou_parent_id_type =
"reference_id";
58 if ($ou_id_type ==
'external_id') {
60 if(strlen($external_id) == 0) {
61 $external_id = $ou_id;
70 $ref_id = $this->
buildRef($ou_id, $ou_id_type);
71 $parent_ref_id = $this->
buildRef($ou_parent_id, $ou_parent_id_type);
74 if (!$parent_ref_id) {
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);
84 $ru->deleteObjects($parent_ref_id, array($ref_id)) !==
false;
85 $this->stats[
"deleted"]++;
90 } elseif (
$action ==
"update") {
91 if (!$parent_ref_id) {
92 $this->
addError(
"ou_parent_id_not_valid", $ou_id?$ou_id:$external_id,
$action);
96 $this->
addError(
"ou_id_not_valid", $ou_id?$ou_id:$external_id,
$action);
100 $object->setTitle(
$title);
102 $arrTranslations = $object->getTranslations();
107 $object->setImportId($external_id);
108 $this->
moveObject($ref_id, $parent_ref_id, $ou_id, $external_id);
110 $this->stats[
"updated"]++;
111 } elseif (
$action ==
"create") {
112 if (!$parent_ref_id) {
113 $this->
addError(
"ou_parent_id_not_valid", $ou_id?$ou_id:$external_id,
$action);
119 $this->
addError(
"ou_external_id_exists", $ou_id?$ou_id:$external_id,
$action);
124 $object->setTitle(
$title);
126 $object->setImportId($external_id);
128 $object->createReference();
129 $object->putInTree($parent_ref_id);
130 $object->setPermissions($ou_parent_id);
131 $this->stats[
"created"]++;
143 protected function moveObject($ref_id, $parent_ref_id, $ou_id, $external_id)
146 $tree = $DIC[
'tree'];
147 if ($parent_ref_id !=
$tree->getParentId($ref_id)) {
150 if (in_array($ref_id,
$path)) {
151 $this->
addWarning(
"not_movable_to_subtree", $ou_id?$ou_id:$external_id,
"update");
153 $tree->moveTree($ref_id, $parent_ref_id);
158 $this->
addWarning(
"not_movable", $ou_id?$ou_id:$external_id,
"update");
159 $ilLog->write($e->getMessage() .
"\\n" . $e->getTraceAsString());
160 error_log($e->getMessage() .
"\\n" . $e->getTraceAsString());
hasMoreThanOneMatch($external_id)
static _hasUntrashedReference($a_obj_id)
checks wether an object has at least one reference that is not in trash
Repository Utilities (application layer, put GUI related stuff into ilRepUtilGUI) ...
moveObject($ref_id, $parent_ref_id, $ou_id, $external_id)
addWarning($lang_var, $import_id, $action=null)
addError($lang_var, $import_id, $action=null)
if(!file_exists(getcwd() . '/ilias.ini.php'))
registration confirmation script for ilias
if(array_key_exists('yes', $_REQUEST)) $attributes
static _lookupType($a_id, $a_reference=false)
lookup object type
Class ilOrgUnitSimpleImport.
simpleImportElement(SimpleXMLElement $o)
static _lookupObjIdByImportId($a_import_id)