ILIAS  release_4-4 Revision
All Data Structures Namespaces Files Functions Variables Modules Pages
ilOrgUnitSimpleUserImport Class Reference

Class ilOrgUnitSimpleUserImport. More...

+ Inheritance diagram for ilOrgUnitSimpleUserImport:
+ Collaboration diagram for ilOrgUnitSimpleUserImport:

Public Member Functions

 simpleUserImport ($file_path)
 
 simpleUserImportElement (SimpleXMLElement $a)
 
- Public Member Functions inherited from ilOrgUnitImporter
 hasErrors ()
 
 hasWarnings ()
 
 addWarning ($lang_var, $import_id, $action=null)
 
 addError ($lang_var, $import_id, $action=null)
 
 getErrors ()
 
 getWarnings ()
 
 getStats ()
 
 importXmlRepresentation ($a_entity, $a_id, $a_xml, $a_mapping)
 Import XML. More...
 
- Public Member Functions inherited from ilXmlImporter
 __construct ()
 Constructor. More...
 
 init ()
 Init. More...
 
 setInstallId ($a_val)
 Set installation id. More...
 
 getInstallId ()
 Get installation id. More...
 
 setInstallUrl ($a_val)
 Set installation url. More...
 
 getInstallUrl ()
 Get installation url. More...
 
 setSchemaVersion ($a_val)
 Set schema version. More...
 
 getSchemaVersion ()
 Get schema version. More...
 
 setImportDirectory ($a_val)
 Set import directory. More...
 
 getImportDirectory ()
 Get import directory. More...
 
 setSkipEntities ($a_val)
 Set skip entities. More...
 
 getSkipEntities ()
 Get skip entities. More...
 
 importXmlRepresentation ($a_entity, $a_id, $a_xml, $a_mapping)
 Import xml representation. More...
 
 finalProcessing ($a_mapping)
 Final processing. More...
 

Private Member Functions

 buildUserId ($id, $type)
 

Additional Inherited Members

- Data Fields inherited from ilOrgUnitImporter
 $errors
 
 $warnings
 
 $stats
 
- Protected Member Functions inherited from ilOrgUnitImporter
 buildRef ($id, $type)
 
- Protected Attributes inherited from ilXmlImporter
 $skip_entities = array()
 

Detailed Description

Member Function Documentation

◆ buildUserId()

ilOrgUnitSimpleUserImport::buildUserId (   $id,
  $type 
)
private

Definition at line 71 of file class.ilOrgUnitSimpleUserImport.php.

References ilObjUser\_lookupId(), and ilObject\_lookupObjIdByImportId().

Referenced by simpleUserImportElement().

71  {
72  global $ilDB;
73  if($type == "ilias_login"){
74  $user_id = ilObjUser::_lookupId($id);
75  return $user_id?$user_id:false;
76  }elseif($type == "external_id"){
77  $user_id = ilObjUser::_lookupObjIdByImportId($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"){
85  return $id;
86  }else
87  return false;
88  }
static _lookupId($a_user_str)
lookup id by login
static _lookupObjIdByImportId($a_import_id)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ simpleUserImport()

ilOrgUnitSimpleUserImport::simpleUserImport (   $file_path)

Definition at line 13 of file class.ilOrgUnitSimpleUserImport.php.

References ilOrgUnitImporter\addError(), and simpleUserImportElement().

13  {
14  $this->stats = array("created" => 0, "removed" => 0);
15  $a = file_get_contents($file_path, "r");
16  $xml = new SimpleXMLElement($a);
17 
18  if(!count($xml->Assignment)) {
19  $this->addError("no_assignment",null,null);
20  return;
21  }
22 
23  foreach($xml->Assignment as $a){
24  $this->simpleUserImportElement($a);
25  }
26  }
addError($lang_var, $import_id, $action=null)
+ Here is the call graph for this function:

◆ simpleUserImportElement()

ilOrgUnitSimpleUserImport::simpleUserImportElement ( SimpleXMLElement  $a)

Definition at line 28 of file class.ilOrgUnitSimpleUserImport.php.

References ilOrgUnitImporter\addError(), ilOrgUnitImporter\buildRef(), and buildUserId().

Referenced by simpleUserImport().

28  {
29  global $rbacadmin;
30 
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;
38 
39  if(!$user_id = $this->buildUserId($user_id, $user_id_type)){
40  $this->addError("user_not_found", $a->User);
41  return;
42  }
43 
44  if(!$org_unit_id = $this->buildRef($org_unit_id, $org_unit_id_type)){
45  $this->addError("org_unit_not_found", $a->OrgUnit);
46  return;
47  }
48  $org_unit = new ilObjOrgUnit($org_unit_id);
49 
50  if($role == "employee"){
51  $role_id = $org_unit->getEmployeeRole();
52  }elseif($role == "superior")
53  $role_id = $org_unit->getSuperiorRole();
54  else{
55  $this->addError("not_a_valid_role", $user_id);
56  return;
57  }
58 
59 
60  if($action == "add"){
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"]++;
66  }else{
67  $this->addError("not_a_valid_action", $user_id);
68  }
69  }
addError($lang_var, $import_id, $action=null)
Class ilObjOrgUnit.
if( $out) else
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

The documentation for this class was generated from the following file: