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) {
41 $attributes = $a->attributes();
42 $action = $attributes->action;
43 $user_id_type = $a->User->attributes()->id_type;
44 $user_id = (string)$a->User;
45 $org_unit_id_type = $a->OrgUnit->attributes()->id_type;
46 $org_unit_id = (string)$a->OrgUnit;
47 $role = (
string)$a->Role;
49 if (!$user_id = $this->
buildUserId($user_id, $user_id_type)) {
50 $this->
addError(
'user_not_found', $a->User);
55 if (!$org_unit_id = $this->
buildRef($org_unit_id, $org_unit_id_type)) {
56 $this->
addError(
'org_unit_not_found', $a->OrgUnit);
62 if ($role ==
'employee') {
63 $role_id = $org_unit->getEmployeeRole();
64 } elseif ($role ==
'superior') {
65 $role_id = $org_unit->getSuperiorRole();
67 $this->
addError(
'not_a_valid_role', $user_id);
72 if ($action ==
'add') {
73 $rbacadmin->assignUser($role_id, $user_id);
74 $this->stats[
'created'] ++;
75 } elseif ($action ==
'remove') {
76 $rbacadmin->deassignUser($role_id, $user_id);
77 $this->stats[
'removed'] ++;
79 $this->
addError(
'not_a_valid_action', $user_id);
92 if ($type ==
'ilias_login') {
95 return $user_id ? $user_id :
false;
96 } elseif ($type ==
'external_id') {
99 return $user_id ? $user_id :
false;
100 } elseif ($type ==
'email') {
101 $q =
'SELECT usr_id FROM usr_data WHERE email = ' . $ilDB->quote($id,
'text');
102 $set = $ilDB->query($q);
103 $user_id = $ilDB->fetchAssoc($set);
105 return $user_id ? $user_id :
false;
106 } elseif ($type ==
'user_id') {
Class ilOrgUnitSimpleUserImport.
static _lookupId($a_user_str)
Lookup id by login.
simpleUserImportElement(SimpleXMLElement $a)
addError($lang_var, $import_id, $action=NULL)
simpleUserImport($file_path)
static _lookupObjIdByImportId($a_import_id)