ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups 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)
- Public Member Functions inherited from ilXmlImporter
 __construct ()
 Constructor.
 init ()
 Init.
 setInstallId ($a_val)
 Set installation id.
 getInstallId ()
 Get installation id.
 setInstallUrl ($a_val)
 Set installation url.
 getInstallUrl ()
 Get installation url.
 setSchemaVersion ($a_val)
 Set schema version.
 getSchemaVersion ()
 Get schema version.
 setImportDirectory ($a_val)
 Set import directory.
 getImportDirectory ()
 Get import directory.
 setSkipEntities ($a_val)
 Set skip entities.
 getSkipEntities ()
 Get skip entities.
 finalProcessing ($a_mapping)
 Final processing.

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

ilOrgUnitSimpleUserImport::buildUserId (   $id,
  $type 
)
private
Parameters
$id
$type
Returns
bool

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

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

Referenced by simpleUserImportElement().

{
global $ilDB;
if ($type == 'ilias_login') {
$user_id = ilObjUser::_lookupId($id);
return $user_id ? $user_id : false;
} elseif ($type == 'external_id') {
return $user_id ? $user_id : false;
} elseif ($type == 'email') {
$q = 'SELECT usr_id FROM usr_data WHERE email = ' . $ilDB->quote($id, 'text');
$set = $ilDB->query($q);
$user_id = $ilDB->fetchAssoc($set);
return $user_id ? $user_id : false;
} elseif ($type == 'user_id') {
return $id;
} else {
return false;
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilOrgUnitSimpleUserImport::simpleUserImport (   $file_path)
Parameters
$file_path

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

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

{
$this->stats = array( 'created' => 0, 'removed' => 0 );
$a = file_get_contents($file_path, 'r');
$xml = new SimpleXMLElement($a);
if (!count($xml->Assignment)) {
$this->addError('no_assignment', NULL, NULL);
return;
}
foreach ($xml->Assignment as $a) {
}
}

+ Here is the call graph for this function:

ilOrgUnitSimpleUserImport::simpleUserImportElement ( SimpleXMLElement  $a)
Parameters
SimpleXMLElement$a

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

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

Referenced by simpleUserImport().

{
global $rbacadmin;
$attributes = $a->attributes();
$action = $attributes->action;
$user_id_type = $a->User->attributes()->id_type;
$user_id = (string)$a->User;
$org_unit_id_type = $a->OrgUnit->attributes()->id_type;
$org_unit_id = (string)$a->OrgUnit;
$role = (string)$a->Role;
if (!$user_id = $this->buildUserId($user_id, $user_id_type)) {
$this->addError('user_not_found', $a->User);
return;
}
if (!$org_unit_id = $this->buildRef($org_unit_id, $org_unit_id_type)) {
$this->addError('org_unit_not_found', $a->OrgUnit);
return;
}
$org_unit = new ilObjOrgUnit($org_unit_id);
if ($role == 'employee') {
$role_id = $org_unit->getEmployeeRole();
} elseif ($role == 'superior') {
$role_id = $org_unit->getSuperiorRole();
} else {
$this->addError('not_a_valid_role', $user_id);
return;
}
if ($action == 'add') {
$rbacadmin->assignUser($role_id, $user_id);
$this->stats['created'] ++;
} elseif ($action == 'remove') {
$rbacadmin->deassignUser($role_id, $user_id);
$this->stats['removed'] ++;
} else {
$this->addError('not_a_valid_action', $user_id);
}
}

+ 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: