34 $this->positionRepo =
$dic[
"repo.Positions"];
35 $this->assignmentRepo =
$dic[
"repo.UserAssignments"];
43 $this->stats = array(
'created' => 0,
'removed' => 0);
44 $a = file_get_contents($file_path,
'r');
47 if (!count($xml->children())) {
48 $this->
addError(
'no_assignment', null, null);
53 foreach ($xml->children() as
$a) {
63 $attributes = $a->attributes();
64 $action = $attributes->action;
65 $user_id_type = $a->User->attributes()->id_type;
67 $org_unit_id_type = $a->OrgUnit->attributes()->id_type;
68 $org_unit_id = (string) $a->OrgUnit;
69 $role = (
string) $a->Role;
72 $this->
addError(
'user_not_found', $a->User);
77 if (!$org_unit_id = $this->
buildRef($org_unit_id, $org_unit_id_type)) {
78 $this->
addError(
'org_unit_not_found', $a->OrgUnit);
84 if ($role ===
'employee') {
85 $position_id = $this->positionRepo
88 } elseif ($role ===
'superior') {
89 $position_id = $this->positionRepo
94 $position = $this->positionRepo->getSingle($role,
'title');
96 $position_id = $position->getId();
103 if ($action ==
'add') {
104 $assignment = $this->assignmentRepo->get(
$user_id, $position_id, $org_unit_id);
105 $this->stats[
'created']++;
106 } elseif ($action ==
'remove') {
107 $assignment = $this->assignmentRepo->find(
$user_id, $position_id, $org_unit_id);
109 $this->assignmentRepo->delete($assignment);
110 $this->stats[
'removed']++;
125 $ilDB = $DIC[
'ilDB'];
126 if ($type ==
'ilias_login') {
130 } elseif ($type ==
'external_id') {
134 } elseif ($type ==
'email') {
135 $q =
'SELECT usr_id FROM usr_data WHERE email = ' .
$ilDB->quote(
$id,
'text');
140 } elseif ($type ==
'user_id') {
static _lookupObjIdByImportId(string $import_id)
Get (latest) object id for an import id.
ilOrgUnitPositionDBRepository $positionRepo
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)
ilOrgUnitUserAssignmentDBRepository $assignmentRepo
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...
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
const CORE_POSITION_SUPERIOR
$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)