ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
ilOrgUnitImporter Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

+ Inheritance diagram for ilOrgUnitImporter:
+ Collaboration diagram for ilOrgUnitImporter:

Public Member Functions

 __construct ()
 
 hasMoreThanOneMatch (string $external_id)
 
 hasErrors ()
 
 hasWarnings ()
 
 addWarning (string $lang_var, string $import_id, ?string $action=null)
 
 addError (string $lang_var, string $import_id, ?string $action=null)
 
 getErrors ()
 
 getWarnings ()
 
 getStats ()
 
 importXmlRepresentation (string $a_entity, string $a_id, string $a_xml, ilImportMapping $a_mapping)
 
- Public Member Functions inherited from ilXmlImporter
 __construct ()
 
 setImport (ilImport $a_val)
 
 getImport ()
 
 init ()
 
 setInstallId (string $a_val)
 
 getInstallId ()
 
 setInstallUrl (string $a_val)
 
 getInstallUrl ()
 
 setSchemaVersion (string $a_val)
 
 getSchemaVersion ()
 
 setImportDirectory (string $a_val)
 
 getImportDirectory ()
 
 setSkipEntities (array $a_val)
 
 getSkipEntities ()
 
 exportedFromSameInstallation ()
 
 importXmlRepresentation (string $a_entity, string $a_id, string $a_xml, ilImportMapping $a_mapping)
 
 finalProcessing (ilImportMapping $a_mapping)
 
 afterContainerImportProcessing (ilImportMapping $mapping)
 

Data Fields

array $errors = []
 
array $warnings = []
 
array $stats
 

Protected Member Functions

 buildRef ($id, string $type)
 

Private Attributes

ilDBInterface $database
 

Additional Inherited Members

- Protected Attributes inherited from ilXmlImporter
array $skip_entities = array()
 
ilImport $imp
 
string $install_id
 
string $install_url
 
string $schema_version
 
string $import_directory
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning Class ilOrgUnitImporter

Author
Oskar Truffer ot@st.nosp@m.uder.nosp@m.-raim.nosp@m.ann..nosp@m.ch
Martin Studer ms@st.nosp@m.uder.nosp@m.-raim.nosp@m.ann..nosp@m.ch
Fabian Schmid fs@st.nosp@m.uder.nosp@m.-raim.nosp@m.ann..nosp@m.ch

Definition at line 26 of file class.ilOrgUnitImporter.php.

Constructor & Destructor Documentation

◆ __construct()

ilOrgUnitImporter::__construct ( )

Definition at line 36 of file class.ilOrgUnitImporter.php.

References $DIC.

37  {
38  global $DIC;
39  $this->database = $DIC->database();
40  }
global $DIC
Definition: shib_login.php:25

Member Function Documentation

◆ addError()

ilOrgUnitImporter::addError ( string  $lang_var,
string  $import_id,
?string  $action = null 
)

Definition at line 118 of file class.ilOrgUnitImporter.php.

Referenced by ilOrgUnitSimpleImport\simpleImport(), ilOrgUnitSimpleImport\simpleImportElement(), ilOrgUnitSimpleUserImport\simpleUserImport(), and ilOrgUnitSimpleUserImport\simpleUserImportElement().

118  : void
119  {
120  $this->errors[] = array('lang_var' => $lang_var, 'import_id' => $import_id, 'action' => $action);
121  }
+ Here is the caller graph for this function:

◆ addWarning()

ilOrgUnitImporter::addWarning ( string  $lang_var,
string  $import_id,
?string  $action = null 
)

Definition at line 113 of file class.ilOrgUnitImporter.php.

Referenced by ilOrgUnitSimpleImport\moveObject(), and ilOrgUnitSimpleImport\simpleImportElement().

113  : void
114  {
115  $this->warnings[] = array('lang_var' => $lang_var, 'import_id' => $import_id, 'action' => $action);
116  }
+ Here is the caller graph for this function:

◆ buildRef()

ilOrgUnitImporter::buildRef (   $id,
string  $type 
)
protected
Parameters
$idint|string
Returns
bool|int

Definition at line 46 of file class.ilOrgUnitImporter.php.

References $id, $ref_id, ilObjOrgUnit\_exists(), ilObject\_getAllReferences(), ilObject\_hasUntrashedReference(), ilObject\_isInTrash(), ilObject\_lookupObjIdByImportId(), and ilObject\_lookupType().

Referenced by ilOrgUnitSimpleImport\simpleImportElement(), and ilOrgUnitSimpleUserImport\simpleUserImportElement().

47  {
48  if (!is_int($id) && !is_string($id)) {
49  throw new \InvalidArgumentException("Expected int or string as \$id, got: " . gettype($id));
50  }
51 
52  if ($type === 'reference_id') {
53  if (!ilObjOrgUnit::_exists((int) $id, true)) {
54  return false;
55  }
56 
57  return $id;
58  } elseif ($type === 'external_id') {
60 
61  if (ilObject::_lookupType($obj_id) !== 'orgu') {
62  return false;
63  }
64 
65  if (!ilObject::_hasUntrashedReference($obj_id)) {
66  return false;
67  }
68 
69  $ref_ids = ilObject::_getAllReferences($obj_id);
70 
71  if (!count($ref_ids)) {
72  return false;
73  }
74 
75  foreach ($ref_ids as $ref_id) {
76  if (!ilObject::_isInTrash($ref_id)) {
77  return $ref_id;
78  }
79  }
80 
81  return false;
82  } else {
83  return false;
84  }
85  }
static _lookupObjIdByImportId(string $import_id)
Get (latest) object id for an import id.
static _getAllReferences(int $id)
get all reference ids for object ID
static _hasUntrashedReference(int $obj_id)
checks whether an object has at least one reference that is not in trash
static _exists(int $id, bool $isReference=false, ?string $type="orgu")
$ref_id
Definition: ltiauth.php:66
static _isInTrash(int $ref_id)
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:24
static _lookupType(int $id, bool $reference=false)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getErrors()

ilOrgUnitImporter::getErrors ( )

Definition at line 123 of file class.ilOrgUnitImporter.php.

References $errors.

Referenced by ilOrgUnitSimpleUserImportGUI\displayImportResults().

123  : array
124  {
125  return $this->errors;
126  }
+ Here is the caller graph for this function:

◆ getStats()

ilOrgUnitImporter::getStats ( )

Definition at line 133 of file class.ilOrgUnitImporter.php.

References $stats.

Referenced by ilOrgUnitSimpleUserImportGUI\displayImportResults().

133  : array
134  {
135  return $this->stats;
136  }
+ Here is the caller graph for this function:

◆ getWarnings()

ilOrgUnitImporter::getWarnings ( )

Definition at line 128 of file class.ilOrgUnitImporter.php.

References $warnings.

Referenced by ilOrgUnitSimpleUserImportGUI\displayImportResults().

128  : array
129  {
130  return $this->warnings;
131  }
+ Here is the caller graph for this function:

◆ hasErrors()

ilOrgUnitImporter::hasErrors ( )

Definition at line 103 of file class.ilOrgUnitImporter.php.

Referenced by ilOrgUnitSimpleUserImportGUI\displayImportResults().

103  : bool
104  {
105  return count($this->errors) != 0;
106  }
+ Here is the caller graph for this function:

◆ hasMoreThanOneMatch()

ilOrgUnitImporter::hasMoreThanOneMatch ( string  $external_id)

Definition at line 87 of file class.ilOrgUnitImporter.php.

References $res.

Referenced by ilOrgUnitSimpleImport\simpleImportElement().

87  : bool
88  {
89  $query = "SELECT * FROM object_data " .
90  "INNER JOIN object_reference as ref on ref.obj_id = object_data.obj_id and ref.deleted is null " .
91  'WHERE object_data.type = "orgu" and import_id = ' . $this->database->quote($external_id, "text") . " " .
92  "ORDER BY create_date DESC";
93 
94  $res = $this->database->query($query);
95 
96  if ($this->database->numRows($res) > 1) {
97  return true;
98  } else {
99  return false;
100  }
101  }
$res
Definition: ltiservices.php:69
+ Here is the caller graph for this function:

◆ hasWarnings()

ilOrgUnitImporter::hasWarnings ( )

Definition at line 108 of file class.ilOrgUnitImporter.php.

Referenced by ilOrgUnitSimpleUserImportGUI\displayImportResults().

108  : bool
109  {
110  return count($this->warnings) != 0;
111  }
+ Here is the caller graph for this function:

◆ importXmlRepresentation()

ilOrgUnitImporter::importXmlRepresentation ( string  $a_entity,
string  $a_id,
string  $a_xml,
ilImportMapping  $a_mapping 
)
Deprecated:

Definition at line 139 of file class.ilOrgUnitImporter.php.

References ilObject\_lookupType(), ilImportMapping\addMapping(), and ilImportMapping\getMappingsOfEntity().

144  : void {
145  $container_mappings = $a_mapping->getMappingsOfEntity("components/ILIAS/Container", "objs");
146  foreach ($container_mappings as $old => $new) {
147  if (ilObject2::_lookupType($new) === 'orgu') {
148  $a_mapping->addMapping('components/ILIAS/OrgUnit', 'orgu', $old, $new);
149  }
150  }
151  }
addMapping(string $a_comp, string $a_entity, string $a_old_id, string $a_new_id)
getMappingsOfEntity(string $a_comp, string $a_entity)
static _lookupType(int $id, bool $reference=false)
+ Here is the call graph for this function:

Field Documentation

◆ $database

ilDBInterface ilOrgUnitImporter::$database
private

Definition at line 34 of file class.ilOrgUnitImporter.php.

◆ $errors

array ilOrgUnitImporter::$errors = []

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

Referenced by getErrors().

◆ $stats

array ilOrgUnitImporter::$stats

Definition at line 33 of file class.ilOrgUnitImporter.php.

Referenced by getStats().

◆ $warnings

array ilOrgUnitImporter::$warnings = []

Definition at line 31 of file class.ilOrgUnitImporter.php.

Referenced by getWarnings().


The documentation for this class was generated from the following file: