ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilOrgUnitImporter.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
3
12{
13
17 public $errors;
21 public $warnings;
25 public $stats;
26
27
34 protected function buildRef($id, $type)
35 {
36 if ($type == 'reference_id') {
37 if (!ilObjOrgUnit::_exists($id, true)) {
38 return false;
39 }
40
41 return $id;
42 } elseif ($type == 'external_id') {
44
46 return false;
47 }
48
49 $ref_ids = ilObject::_getAllReferences($obj_id);
50
51 if (!count($ref_ids)) {
52 return false;
53 }
54
55 foreach ($ref_ids as $ref_id) {
56 if (!ilObject::_isInTrash($ref_id)) {
57 return $ref_id;
58 }
59 }
60 return false;
61 } else {
62 return false;
63 }
64 }
65
66
70 public function hasErrors()
71 {
72 return count($this->errors) != 0;
73 }
74
75
79 public function hasWarnings()
80 {
81 return count($this->warnings) != 0;
82 }
83
84
90 public function addWarning($lang_var, $import_id, $action = null)
91 {
92 $this->warnings[] = array( 'lang_var' => $lang_var, 'import_id' => $import_id, 'action' => $action );
93 }
94
95
101 public function addError($lang_var, $import_id, $action = null)
102 {
103 $this->errors[] = array( 'lang_var' => $lang_var, 'import_id' => $import_id, 'action' => $action );
104 }
105
106
110 public function getErrors()
111 {
112 return $this->errors;
113 }
114
115
119 public function getWarnings()
120 {
121 return $this->warnings;
122 }
123
124
128 public function getStats()
129 {
130 return $this->stats;
131 }
132
133
144 public function importXmlRepresentation($a_entity, $a_id, $a_xml, $a_mapping)
145 {
146 $container_mappings = $a_mapping->getMappingsOfEntity("Services/Container", "objs");
147 foreach ($container_mappings as $old => $new) {
149 if (ilObject2::_lookupType($new) == "orgu") {
150 $a_mapping->addMapping("Modules/OrgUnit", "orgu", $old, $new);
151 }
152 }
153 }
154}
An exception for terminatinating execution or to throw for unit testing.
static _exists($a_id, $a_reference=false, $type="orgu")
static _lookupType($a_id, $a_reference=false)
lookup object type
static _getAllReferences($a_id)
get all reference ids of object
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 _isInTrash($a_ref_id)
checks wether object is in trash
Class ilOrgUnitImporter.
importXmlRepresentation($a_entity, $a_id, $a_xml, $a_mapping)
addError($lang_var, $import_id, $action=null)
addWarning($lang_var, $import_id, $action=null)
Xml importer class.
$action
if(!array_key_exists('StateId', $_REQUEST)) $id
$type
$old