33 $this->stats = array(
'created' => 0,
'removed' => 0);
34 $a = file_get_contents($file_path,
'r');
35 $xml =
new SimpleXMLElement(
$a);
37 if (!count(
$xml->children())) {
38 $this->
addError(
'no_assignment', null, null);
43 foreach (
$xml->children() as
$a) {
55 $user_id_type = $a->User->attributes()->id_type;
56 $user_id = (string) $a->User;
57 $org_unit_id_type = $a->OrgUnit->attributes()->id_type;
58 $org_unit_id = (string) $a->OrgUnit;
59 $role = (
string) $a->Role;
61 if (!$user_id = $this->
buildUserId($user_id, $user_id_type)) {
62 $this->
addError(
'user_not_found', $a->User);
67 if (!$org_unit_id = $this->
buildRef($org_unit_id, $org_unit_id_type)) {
68 $this->
addError(
'org_unit_not_found', $a->OrgUnit);
74 if ($role ===
'employee') {
76 } elseif ($role ===
'superior') {
82 $position_id = $position->getId();
84 $this->
addError(
'not_a_valid_role', $user_id);
89 if ($action ==
'add') {
93 $this->stats[
'created']++;
94 } elseif ($action ==
'remove') {
96 $assignment->delete();
97 $this->stats[
'removed']++;
99 $this->
addError(
'not_a_valid_action', $user_id);
111 $ilDB = $DIC[
'ilDB'];
112 if (
$type ==
'ilias_login') {
115 return $user_id ? $user_id :
false;
116 } elseif (
$type ==
'external_id') {
119 return $user_id ? $user_id :
false;
120 } elseif (
$type ==
'email') {
121 $q =
'SELECT usr_id FROM usr_data WHERE email = ' .
$ilDB->quote(
$id,
'text');
122 $set =
$ilDB->query($q);
123 $user_id =
$ilDB->fetchAssoc($set);
125 return $user_id ? $user_id :
false;
126 } elseif (
$type ==
'user_id') {
static _lookupObjIdByImportId(string $import_id)
Get (latest) object id for an import id.
static findOrCreateAssignment(int $user_id, int $position_id, int $orgu_id)
const CORE_POSITION_EMPLOYEE
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _lookupId($a_user_str)
static where($where, $operator=null)
buildRef($id, string $type)
simpleUserImportElement(SimpleXMLElement $a)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
const CORE_POSITION_SUPERIOR
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples
simpleUserImport($file_path)
addError(string $lang_var, string $import_id, ?string $action=null)