3 require_once(
"./Modules/OrgUnit/classes/class.ilOrgUnitImporter.php");
14 $this->stats = array(
"created" => 0,
"removed" => 0);
15 $a = file_get_contents($file_path,
"r");
16 $xml =
new SimpleXMLElement($a);
18 if(!count($xml->Assignment)) {
19 $this->
addError(
"no_assignment",null,null);
23 foreach($xml->Assignment as $a){
31 $attributes = $a->attributes();
32 $action = $attributes->action;
33 $user_id_type = $a->User->attributes()->id_type;
34 $user_id = (string) $a->User;
35 $org_unit_id_type = $a->OrgUnit->attributes()->id_type;
36 $org_unit_id = (string) $a->OrgUnit;
37 $role = (
string) $a->Role;
39 if(!$user_id = $this->
buildUserId($user_id, $user_id_type)){
40 $this->
addError(
"user_not_found", $a->User);
44 if(!$org_unit_id = $this->
buildRef($org_unit_id, $org_unit_id_type)){
45 $this->
addError(
"org_unit_not_found", $a->OrgUnit);
50 if($role ==
"employee"){
51 $role_id = $org_unit->getEmployeeRole();
52 }elseif($role ==
"superior")
53 $role_id = $org_unit->getSuperiorRole();
55 $this->
addError(
"not_a_valid_role", $user_id);
61 $rbacadmin->assignUser($role_id, $user_id);
62 $this->stats[
"created"]++;
63 }elseif($action ==
"remove"){
64 $rbacadmin->deassignUser($role_id, $user_id);
65 $this->stats[
"removed"]++;
67 $this->
addError(
"not_a_valid_action", $user_id);
73 if($type ==
"ilias_login"){
75 return $user_id?$user_id:
false;
76 }elseif($type ==
"external_id"){
78 return $user_id?$user_id:
false;
79 }elseif($type ==
"email"){
80 $q =
"SELECT usr_id FROM usr_data WHERE email = ".$ilDB->quote($id,
"text");
81 $set = $ilDB->query($q);
82 $user_id = $ilDB->fetchAssoc($set);
83 return $user_id?$user_id:
false;
84 }elseif($type ==
"user_id"){
Class ilOrgUnitSimpleUserImport.
static _lookupId($a_user_str)
lookup id by login
addError($lang_var, $import_id, $action=null)
simpleUserImportElement(SimpleXMLElement $a)
simpleUserImport($file_path)
static _lookupObjIdByImportId($a_import_id)