3require_once(
"./Modules/OrgUnit/classes/class.ilOrgUnitImporter.php");
 
   16                $this->stats = array(
"created" => 0, 
"updated" => 0, 
"deleted" => 0);
 
   17                $a = file_get_contents($file_path, 
"r");
 
   18                $xml = 
new SimpleXMLElement($a);
 
   20                if(!count($xml->OrgUnit)) {
 
   21                        $this->
addError(
"no_orgunit",
null,
null);
 
   25                foreach($xml->OrgUnit as $o){
 
   36                $description = $o->description;
 
   37                $external_id = $o->external_id;
 
   39                $attributes = $o->attributes();
 
   40                $action = (string)$attributes->action;
 
   41                $ou_id = (
string)$attributes->ou_id;
 
   42                $ou_id_type = (string)$attributes->ou_id_type;
 
   43                $ou_parent_id = (
string)$attributes->ou_parent_id;
 
   44                $ou_parent_id_type = (string)$attributes->ou_parent_id_type;
 
   47                        $this->
addWarning(
"cannot_change_root_node", $ou_id?$ou_id:$external_id, $action);
 
   51                if($ou_parent_id == 
"__ILIAS"){
 
   53                        $ou_parent_id_type = 
"reference_id";
 
   57                $parent_ref_id = $this->
buildRef($ou_parent_id, $ou_parent_id_type);
 
   59                if($action == 
"delete"){
 
   61                                $this->
addError(
"ou_parent_id_not_valid", $ou_id?$ou_id:$external_id, $action);
 
   65                                $this->
addError(
"ou_id_not_valid", $ou_id?$ou_id:$external_id, $action);
 
   68                        include_once(
"./Services/Repository/classes/class.ilRepUtil.php");
 
   71                                $ru->deleteObjects($parent_ref_id, array(
$ref_id)) !== 
false;
 
   72                                $this->stats[
"deleted"]++;
 
   74                                $this->
addWarning(
"orgu_already_deleted", $ou_id?$ou_id:$external_id, $action);
 
   77                }elseif($action == 
"update"){
 
   79                                $this->
addError(
"ou_parent_id_not_valid", $ou_id?$ou_id:$external_id, $action);
 
   83                                $this->
addError(
"ou_id_not_valid", $ou_id?$ou_id:$external_id, $action);
 
   89                        $arrTranslations = $object->getTranslations();
 
   90                        $object->updateTranslation(
$title,$description,
$ilUser->getLanguage(),
"");
 
   92                        $object->setDescription($description);
 
   94                        $object->setImportId($external_id);
 
   97                        $this->stats[
"updated"]++;
 
   98                }elseif($action == 
"create"){
 
  100                                $this->
addError(
"ou_parent_id_not_valid", $ou_id?$ou_id:$external_id, $action);
 
  107                                        $this->
addError(
"ou_external_id_exists", $ou_id?$ou_id:$external_id, $action);
 
  112                        $object->setTitle(
$title);
 
  113                        $object->setDescription($description);
 
  114                        $object->setImportId($external_id);
 
  116                        $object->createReference();
 
  117                        $object->putInTree($parent_ref_id);
 
  118                        $object->setPermissions($ou_parent_id);
 
  119                        $this->stats[
"created"]++;
 
  121                        $this->
addError(
"no_valid_action_given", $ou_id, $action);
 
  133                $tree = 
$DIC[
'tree'];
 
  134                if($parent_ref_id != $tree->getParentId(
$ref_id)){
 
  136                                $path = $tree->getPathId($parent_ref_id);
 
  138                                        $this->
addWarning(
"not_movable_to_subtree", $ou_id?$ou_id:$external_id, 
"update");
 
  140                                        $tree->moveTree(
$ref_id, $parent_ref_id);
 
  142                        }
catch(Exception $e){
 
  145                                $this->
addWarning(
"not_movable", $ou_id?$ou_id:$external_id, 
"update");
 
  146                                $ilLog->write($e->getMessage().
"\\n".$e->getTraceAsString());
 
  147                                error_log($e->getMessage().
"\\n".$e->getTraceAsString());
 
An exception for terminatinating execution or to throw for unit testing.
static _hasUntrashedReference($a_obj_id)
checks wether an object has at least one reference that is not in trash
static _lookupObjIdByImportId($a_import_id)
static _lookupType($a_id, $a_reference=false)
lookup object type
addWarning($lang_var, $import_id, $action=NULL)
addError($lang_var, $import_id, $action=NULL)
Class ilOrgUnitSimpleImport.
simpleImportElement(SimpleXMLElement $o)
moveObject($ref_id, $parent_ref_id, $ou_id, $external_id)
Repository Utilities (application layer, put GUI related stuff into ilRepUtilGUI)