ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ImportOrgUnitTree.php
Go to the documentation of this file.
1<?php
2
20
22
28{
29 public const ORG_UNIT_TREE = 'OrgUnitTree';
30
36 protected function run(array $params): bool
37 {
38 global $DIC;
39 $DIC->language()->loadLanguageModule('orgu');
40
41 $importer = new ilOrgUnitSimpleImport();
42
43 $xml = simplexml_load_string($params['OrgUnitTree']);
44
45 if ($xml) {
46 foreach ($xml->children() as $ou_id => $node) {
47 $importer->simpleImportElement(simplexml_load_string($node->asXML()));
48 }
49 } else {
50 throw new \ilSoapPluginException("Could not Read the XML File");
51 }
52
53 if (count($importer->getErrors()) || count($importer->getWarnings())) {
54 $arr_msg = [];
55 if ($importer->hasWarnings()) {
56 $arr_msg[] = $DIC->language()->txt("import_terminated_with_warnings");
57 foreach ($importer->getWarnings() as $warning) {
58 $arr_msg[$warning["import_id"]] = $DIC->language()->txt($warning["lang_var"]) . " (Import ID: " . $warning["import_id"] . ")";
59 }
60 }
61 if ($importer->hasErrors()) {
62 $arr_msg[] = $DIC->language()->txt("import_terminated_with_errors");
63 foreach ($importer->getErrors() as $error) {
64 $arr_msg[$error["import_id"]] = $DIC->language()->txt($error["lang_var"]) . " (Import ID: " . $error["import_id"] . ")";
65 }
66 }
67
68 throw new \ilSoapPluginException(implode(" / ", $arr_msg));
69 }
70
71 return true;
72 }
73
74 public function getName(): string
75 {
76 return "importOrgUnitsSimpleXML";
77 }
78
79 protected function getAdditionalInputParams(): array
80 {
81 return array(self::ORG_UNIT_TREE => Base::TYPE_STRING);
82 }
83
84 public function getOutputParams(): array
85 {
86 return [];
87 }
88
89 public function getDocumentation(): string
90 {
91 return "Imports ILIAS Organisational Units (SimpleXML)";
92 }
93}
getOutputParams()
Get the output parameters in the same format as the input parameters.
getDocumentation()
Get the documentation of this method.
ilErrorHandling $error
Definition: class.ilias.php:69
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
if(! $DIC->user() ->getId()||!ilLTIConsumerAccess::hasCustomProviderCreationAccess()) $params
Definition: ltiregstart.php:31
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
global $DIC
Definition: shib_login.php:26