ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 require_once('./Services/Export/classes/class.ilXmlImporter.php');
4 
13 
17  public $errors;
21  public $warnings;
25  public $stats;
26 
27 
34  protected function buildRef($id, $type) {
35  if ($type == 'reference_id') {
36  if (!ilObjOrgUnit::_exists($id, true)) {
37  return false;
38  }
39 
40  return $id;
41  } elseif ($type == 'external_id') {
42  $obj_id = ilObject::_lookupObjIdByImportId($id);
43 
44  if (!ilObject::_hasUntrashedReference($obj_id)) {
45  return false;
46  }
47 
48  $ref_ids = ilObject::_getAllReferences($obj_id);
49 
50  if (!count($ref_ids)) {
51  return false;
52  }
53 
54  foreach($ref_ids as $ref_id) {
55  if(!ilObject::_isInTrash($ref_id))
56  return $ref_id;
57  }
58  return false;
59  } else {
60  return false;
61  }
62  }
63 
64 
68  public function hasErrors() {
69  return count($this->errors) != 0;
70  }
71 
72 
76  public function hasWarnings() {
77  return count($this->warnings) != 0;
78  }
79 
80 
86  public function addWarning($lang_var, $import_id, $action = NULL) {
87  $this->warnings[] = array( 'lang_var' => $lang_var, 'import_id' => $import_id, 'action' => $action );
88  }
89 
90 
96  public function addError($lang_var, $import_id, $action = NULL) {
97  $this->errors[] = array( 'lang_var' => $lang_var, 'import_id' => $import_id, 'action' => $action );
98  }
99 
100 
104  public function getErrors() {
105  return $this->errors;
106  }
107 
108 
112  public function getWarnings() {
113  return $this->warnings;
114  }
115 
116 
120  public function getStats() {
121  return $this->stats;
122  }
123 
124 
135  public function importXmlRepresentation($a_entity, $a_id, $a_xml, $a_mapping) {
136  $container_mappings = $a_mapping->getMappingsOfEntity("Services/Container", "objs");
137  foreach($container_mappings as $old => $new) {
138  echo ilObject2::_lookupType($new);if (ilObject2::_lookupType($new) == "orgu") {
139  $a_mapping->addMapping("Modules/OrgUnit", "orgu", $old, $new);
140  }
141  }
142  }
143 }
144 
145 ?>
static _hasUntrashedReference($a_obj_id)
checks wether an object has at least one reference that is not in trash
static _exists($a_id, $a_reference=false, $type="orgu")
static _isInTrash($a_ref_id)
checks wether object is in trash
static _getAllReferences($a_id)
get all reference ids of object
Class ilOrgUnitImporter.
importXmlRepresentation($a_entity, $a_id, $a_xml, $a_mapping)
$old
Create styles array
The data for the language used.
addError($lang_var, $import_id, $action=NULL)
addWarning($lang_var, $import_id, $action=NULL)
static _lookupType($a_id, $a_reference=false)
$ref_id
Definition: sahs_server.php:39
static _lookupObjIdByImportId($a_import_id)
Xml importer class.