ILIAS  Release_4_4_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilOrgUnitSimpleImport Class Reference

Class ilOrgUnitSimpleImport. More...

+ Inheritance diagram for ilOrgUnitSimpleImport:
+ Collaboration diagram for ilOrgUnitSimpleImport:

Public Member Functions

 simpleImport ($file_path)
 simpleImportElement (SimpleXMLElement $o)
- Public Member Functions inherited from ilOrgUnitImporter
 hasErrors ()
 hasWarnings ()
 addWarning ($lang_var, $import_id, $action=null)
 addError ($lang_var, $import_id, $action=null)
 getErrors ()
 getWarnings ()
 getStats ()
 importXmlRepresentation ($a_entity, $a_id, $a_xml, $a_mapping)
 Import XML.
- Public Member Functions inherited from ilXmlImporter
 __construct ()
 Constructor.
 init ()
 Init.
 setInstallId ($a_val)
 Set installation id.
 getInstallId ()
 Get installation id.
 setInstallUrl ($a_val)
 Set installation url.
 getInstallUrl ()
 Get installation url.
 setSchemaVersion ($a_val)
 Set schema version.
 getSchemaVersion ()
 Get schema version.
 setImportDirectory ($a_val)
 Set import directory.
 getImportDirectory ()
 Get import directory.
 setSkipEntities ($a_val)
 Set skip entities.
 getSkipEntities ()
 Get skip entities.
 finalProcessing ($a_mapping)
 Final processing.

Additional Inherited Members

- Data Fields inherited from ilOrgUnitImporter
 $errors
 $warnings
 $stats
- Protected Member Functions inherited from ilOrgUnitImporter
 buildRef ($id, $type)
- Protected Attributes inherited from ilXmlImporter
 $skip_entities = array()

Detailed Description

Member Function Documentation

ilOrgUnitSimpleImport::simpleImport (   $file_path)

Definition at line 13 of file class.ilOrgUnitSimpleImport.php.

References $lng, ilOrgUnitImporter\addError(), and simpleImportElement().

{
global $lng;
$this->stats = array("created" => 0, "updated" => 0, "deleted" => 0);
$a = file_get_contents($file_path, "r");
$xml = new SimpleXMLElement($a);
if(!count($xml->OrgUnit)) {
$this->addError("no_orgunit",null,null);
return;
}
foreach($xml->OrgUnit as $o){
$this->simpleImportElement($o);
}
}

+ Here is the call graph for this function:

ilOrgUnitSimpleImport::simpleImportElement ( SimpleXMLElement  $o)

Definition at line 29 of file class.ilOrgUnitSimpleImport.php.

References $ilLog, $ilUser, $ref_id, $tpl, ilObject\_lookupObjIdByImportId(), ilOrgUnitImporter\addError(), ilOrgUnitImporter\addWarning(), ilOrgUnitImporter\buildRef(), and ilObjOrgUnit\getRootOrgRefId().

Referenced by simpleImport().

{
global $tree, $tpl, $ilUser;
$title = $o->title;
$description = $o->description;
$external_id = $o->external_id;
$create_mode = true;
$attributes = $o->attributes();
$action = (string)$attributes->action;
$ou_id = (string)$attributes->ou_id;
$ou_id_type = (string)$attributes->ou_id_type;
$ou_parent_id = (string)$attributes->ou_parent_id;
$ou_parent_id_type = (string)$attributes->ou_parent_id_type;
$this->addWarning("cannot_change_root_node", $ou_id, $action);
return;
}
if($ou_parent_id == "__ILIAS"){
$ou_parent_id = ilObjOrgUnit::getRootOrgRefId();
$ou_parent_id_type = "reference_id";
}
$ref_id = $this->buildRef($ou_id, $ou_id_type);
$parent_ref_id = $this->buildRef($ou_parent_id, $ou_parent_id_type);
if($action == "delete"){
if(!$parent_ref_id){
$this->addError("ou_parent_id_not_valid", $ou_id, $action);
return;
}
if(!$ref_id){
$this->addError("ou_id_not_valid", $ou_id, $action);
return;
}
include_once("./Services/Repository/classes/class.ilRepUtil.php");
$ru = new ilRepUtil($this);
try{
$ru->deleteObjects($parent_ref_id, array($ref_id)) !== false;
$this->stats["deleted"]++;
}catch(Excpetion $e){
$this->addWarning("orgu_already_deleted", $ou_id, $action);
}
return;
}elseif($action == "update"){
if(!$parent_ref_id){
$this->addError("ou_parent_id_not_valid", $ou_id, $action);
return;
}
if(!$ref_id){
$this->addError("ou_id_not_valid", $ou_id, $action);
return;
}
$object = new ilObjOrgUnit($ref_id);
$object->setTitle($title);
$arrTranslations = $object->getTranslations();
$object->updateTranslation($title,$description,$ilUser->getLanguage(),"");
$object->setDescription($description);
$object->update();
$object->setImportId($external_id);
if($parent_ref_id != $tree->getParentId($ref_id)){
try{
$tree->moveTree($ref_id, $parent_ref_id);
}catch(Exception $e){
global $ilLog;
$this->addWarning("not_movable", $ou_id, $action);
$ilLog->write($e->getMessage()."\\n".$e->getTraceAsString());
}
}
$this->stats["updated"]++;
}elseif($action == "create"){
if(!$parent_ref_id){
$this->addError("ou_parent_id_not_valid", $ou_id, $action);
return;
}
if($external_id){
{
$this->addError("ou_external_id_exists", $ou_id, $action);
return;
}
}
$object = new ilObjOrgUnit();
$object->setTitle($title);
$object->setDescription($description);
$object->setImportId($external_id);
$object->create();
$object->createReference();
$object->putInTree($parent_ref_id);
$object->setPermissions($ou_parent_id);
$this->stats["created"]++;
}else{
$this->addError("no_valid_action_given", $ou_id, $action);
}
}

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