ILIAS  Release_5_0_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)
- 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.

Protected Member Functions

 moveObject ($ref_id, $parent_ref_id, $ou_id, $external_id)
- Protected Member Functions inherited from ilOrgUnitImporter
 buildRef ($id, $type)

Additional Inherited Members

- Data Fields inherited from ilOrgUnitImporter
 $errors
 $warnings
 $stats
- Protected Attributes inherited from ilXmlImporter
 $skip_entities = array()

Detailed Description

Member Function Documentation

ilOrgUnitSimpleImport::moveObject (   $ref_id,
  $parent_ref_id,
  $ou_id,
  $external_id 
)
protected
Parameters
$ref_idint
$parent_ref_idint
$ou_idmixed This is only needed for displaying the warning.
$external_idmixed This is only needed for displaying the warning.

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

References $ilLog, $path, $ref_id, and ilOrgUnitImporter\addWarning().

Referenced by simpleImportElement().

{
global $tree;
if($parent_ref_id != $tree->getParentId($ref_id)){
try{
$path = $tree->getPathId($parent_ref_id);
if(in_array($ref_id, $path)) {
$this->addWarning("not_movable_to_subtree", $ou_id?$ou_id:$external_id, "update");
} else {
$tree->moveTree($ref_id, $parent_ref_id);
}
}catch(Exception $e){
global $ilLog;
$this->addWarning("not_movable", $ou_id?$ou_id:$external_id, "update");
$ilLog->write($e->getMessage()."\\n".$e->getTraceAsString());
error_log($e->getMessage()."\\n".$e->getTraceAsString());
}
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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 $ilUser, $ref_id, $tpl, ilObject\_hasUntrashedReference(), ilObject\_lookupObjIdByImportId(), ilOrgUnitImporter\addError(), ilOrgUnitImporter\addWarning(), ilOrgUnitImporter\buildRef(), ilObjOrgUnit\getRootOrgRefId(), and moveObject().

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?$ou_id:$external_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?$ou_id:$external_id, $action);
return;
}
if(!$ref_id){
$this->addError("ou_id_not_valid", $ou_id?$ou_id:$external_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?$ou_id:$external_id, $action);
}
return;
}elseif($action == "update"){
if(!$parent_ref_id){
$this->addError("ou_parent_id_not_valid", $ou_id?$ou_id:$external_id, $action);
return;
}
if(!$ref_id){
$this->addError("ou_id_not_valid", $ou_id?$ou_id:$external_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);
$this->moveObject($ref_id, $parent_ref_id, $ou_id, $external_id);
$this->stats["updated"]++;
}elseif($action == "create"){
if(!$parent_ref_id){
$this->addError("ou_parent_id_not_valid", $ou_id?$ou_id:$external_id, $action);
return;
}
if($external_id){
$obj_id = ilObject::_lookupObjIdByImportId($external_id);
{
$this->addError("ou_external_id_exists", $ou_id?$ou_id:$external_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: