3 require_once(
'./Modules/OrgUnit/classes/class.ilOrgUnitImporter.php');
19 $this->stats =
array(
'created' => 0,
'removed' => 0 );
20 $a = file_get_contents($file_path,
'r');
23 if (!count($xml->Assignment)) {
24 $this->
addError(
'no_assignment', NULL, NULL);
29 foreach ($xml->Assignment as $a) {
40 $rbacadmin = $DIC[
'rbacadmin'];
42 $attributes = $a->attributes();
43 $action = $attributes->action;
44 $user_id_type = $a->User->attributes()->id_type;
45 $user_id = (
string)$a->User;
46 $org_unit_id_type = $a->OrgUnit->attributes()->id_type;
47 $org_unit_id = (
string)$a->OrgUnit;
48 $role = (
string)$a->Role;
50 if (!$user_id = $this->
buildUserId($user_id, $user_id_type)) {
51 $this->
addError(
'user_not_found', $a->User);
56 if (!$org_unit_id = $this->
buildRef($org_unit_id, $org_unit_id_type)) {
57 $this->
addError(
'org_unit_not_found', $a->OrgUnit);
63 if ($role ==
'employee') {
64 $role_id = $org_unit->getEmployeeRole();
65 } elseif ($role ==
'superior') {
66 $role_id = $org_unit->getSuperiorRole();
68 $this->
addError(
'not_a_valid_role', $user_id);
73 if ($action ==
'add') {
74 $rbacadmin->assignUser($role_id, $user_id);
75 $this->stats[
'created'] ++;
76 } elseif ($action ==
'remove') {
77 $rbacadmin->deassignUser($role_id, $user_id);
78 $this->stats[
'removed'] ++;
80 $this->
addError(
'not_a_valid_action', $user_id);
94 if ($type ==
'ilias_login') {
97 return $user_id ? $user_id :
false;
98 } elseif ($type ==
'external_id') {
101 return $user_id ? $user_id :
false;
102 } elseif ($type ==
'email') {
103 $q =
'SELECT usr_id FROM usr_data WHERE email = ' .
$ilDB->quote($id,
'text');
104 $set =
$ilDB->query($q);
105 $user_id =
$ilDB->fetchAssoc($set);
107 return $user_id ? $user_id :
false;
108 } elseif ($type ==
'user_id') {
Class ilOrgUnitSimpleUserImport.
static _lookupId($a_user_str)
Lookup id by login.
Add rich text string
The name of the decorator.
simpleUserImportElement(SimpleXMLElement $a)
Create styles array
The data for the language used.
addError($lang_var, $import_id, $action=NULL)
simpleUserImport($file_path)
static _lookupObjIdByImportId($a_import_id)