ILIAS  trunk Revision v11.0_alpha-1761-g6dbbfa7b760
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
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 25 of file class.ilOrgUnitImporter.php.

Constructor & Destructor Documentation

◆ __construct()

ilOrgUnitImporter::__construct ( )

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

References $DIC.

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

Member Function Documentation

◆ addError()

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

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

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

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

◆ addWarning()

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

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

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

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

◆ buildRef()

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

Definition at line 45 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().

46  {
47  if (!is_int($id) && !is_string($id)) {
48  throw new \InvalidArgumentException("Expected int or string as \$id, got: " . gettype($id));
49  }
50 
51  if ($type === 'reference_id') {
52  if (!ilObjOrgUnit::_exists((int) $id, true)) {
53  return false;
54  }
55 
56  return $id;
57  } elseif ($type === 'external_id') {
59 
60  if (ilObject::_lookupType($obj_id) !== 'orgu') {
61  return false;
62  }
63 
64  if (!ilObject::_hasUntrashedReference($obj_id)) {
65  return false;
66  }
67 
68  $ref_ids = ilObject::_getAllReferences($obj_id);
69 
70  if (!count($ref_ids)) {
71  return false;
72  }
73 
74  foreach ($ref_ids as $ref_id) {
75  if (!ilObject::_isInTrash($ref_id)) {
76  return $ref_id;
77  }
78  }
79 
80  return false;
81  } else {
82  return false;
83  }
84  }
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:65
static _isInTrash(int $ref_id)
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
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 122 of file class.ilOrgUnitImporter.php.

References $errors.

Referenced by ilOrgUnitSimpleUserImportGUI\displayImportResults().

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

◆ getStats()

ilOrgUnitImporter::getStats ( )

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

References $stats.

Referenced by ilOrgUnitSimpleUserImportGUI\displayImportResults().

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

◆ getWarnings()

ilOrgUnitImporter::getWarnings ( )

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

References $warnings.

Referenced by ilOrgUnitSimpleUserImportGUI\displayImportResults().

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

◆ hasErrors()

ilOrgUnitImporter::hasErrors ( )

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

Referenced by ilOrgUnitSimpleUserImportGUI\displayImportResults().

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

◆ hasMoreThanOneMatch()

ilOrgUnitImporter::hasMoreThanOneMatch ( string  $external_id)

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

References $res.

Referenced by ilOrgUnitSimpleImport\simpleImportElement().

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

◆ hasWarnings()

ilOrgUnitImporter::hasWarnings ( )

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

Referenced by ilOrgUnitSimpleUserImportGUI\displayImportResults().

107  : bool
108  {
109  return count($this->warnings) != 0;
110  }
+ 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 138 of file class.ilOrgUnitImporter.php.

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

143  : void {
144  $container_mappings = $a_mapping->getMappingsOfEntity("components/ILIAS/Container", "objs");
145  foreach ($container_mappings as $old => $new) {
146  if (ilObject2::_lookupType($new) === 'orgu') {
147  $a_mapping->addMapping('components/ILIAS/OrgUnit', 'orgu', $old, $new);
148  }
149  }
150  }
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 33 of file class.ilOrgUnitImporter.php.

◆ $errors

array ilOrgUnitImporter::$errors = []

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

Referenced by getErrors().

◆ $stats

array ilOrgUnitImporter::$stats

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

Referenced by getStats().

◆ $warnings

array ilOrgUnitImporter::$warnings = []

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

Referenced by getWarnings().


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