ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
ilUserImportParser Class Reference

User Import Parser. More...

+ Inheritance diagram for ilUserImportParser:
+ Collaboration diagram for ilUserImportParser:

Public Member Functions

 __construct ($a_xml_file='', $a_mode=IL_USER_IMPORT, $a_conflict_rule=IL_FAIL_ON_CONFLICT)
 Constructor. More...
 
 setFolderId ($a_folder_id)
 assign users to this folder (normally the usr_folder) But if called from local admin => the ref_id of the category public More...
 
 getFolderId ()
 
 setHandlers ($a_xml_parser)
 set event handler should be overwritten by inherited class private More...
 
 startParsing ()
 start the parser More...
 
 setRoleAssignment ($a_assign)
 set import to local role assignemt More...
 
 buildTag ($type, $name, $attr="")
 generate a tag with given name and attributes More...
 
 handlerBeginTag ($a_xml_parser, $a_name, $a_attribs)
 handler for begin of element More...
 
 extractRolesBeginTag ($a_xml_parser, $a_name, $a_attribs)
 handler for begin of element in extract roles mode More...
 
 importBeginTag ($a_xml_parser, $a_name, $a_attribs)
 handler for begin of element in user import mode More...
 
 verifyBeginTag ($a_xml_parser, $a_name, $a_attribs)
 handler for begin of element More...
 
 handlerEndTag ($a_xml_parser, $a_name)
 handler for end of element More...
 
 extractRolesEndTag ($a_xml_parser, $a_name)
 handler for end of element when in extract roles mode. More...
 
 getRoleObject ($a_role_id)
 Returns the parent object of the role folder object which contains the specified role. More...
 
 getCourseMembersObjectForRole ($a_role_id)
 Returns the parent object of the role folder object which contains the specified role. More...
 
 assignToRole ($a_user_obj, $a_role_id)
 Assigns a user to a role. More...
 
 getParentRoleIds ($a_role_id)
 Get array of parent role ids from cache. More...
 
 assignToRoleWithParents ($a_user_obj, $a_role_id)
 Assigns a user to a role and to all parent roles. More...
 
 detachFromRole ($a_user_obj, $a_role_id)
 Detachs a user from a role. More...
 
 importEndTag ($a_xml_parser, $a_name)
 handler for end of element when in import user mode. More...
 
 saveTempImage ($image_data, $filename)
 Saves binary image data to a temporary image file and returns the name of the image file on success. More...
 
 verifyEndTag ($a_xml_parser, $a_name)
 handler for end of element when in verify mode. More...
 
 handlerCharacterData ($a_xml_parser, $a_data)
 handler for character data More...
 
 getCollectedRoles ()
 get collected roles More...
 
 getUserCount ()
 get count of User elements More...
 
 logWarning ($aLogin, $aMessage)
 Writes a warning log message to the protocol. More...
 
 logFailure ($aLogin, $aMessage)
 Writes a failure log message to the protocol. More...
 
 logSuccess ($aLogin, $userid, $action)
 Writes a success log message to the protocol. More...
 
 getProtocol ()
 Returns the protocol. More...
 
 getProtocolAsHTML ($a_log_title)
 Returns the protocol as a HTML table. More...
 
 isSuccess ()
 Returns true, if the import was successful. More...
 
 getErrorLevel ()
 Returns the error level. More...
 
 getUserMapping ()
 returns a map user_id <=> login More...
 
 sendAccountMail ()
 send account mail More...
 
 setSendMail ($value)
 write access to property send mail More...
 
 isSendMail ()
 read access to property send mail More...
 
 setUserMappingMode ($value)
 write access to user mapping mode More...
 
 getUserMappingMode ()
 read access to user mapping mode More...
 
- Public Member Functions inherited from ilSaxParser
 __construct ($a_xml_file='', $throwException=false)
 Constructor setup ILIAS global object public. More...
 
 setXMLContent ($a_xml_content)
 
 getXMLContent ()
 
 getInputType ()
 
 startParsing ()
 stores xml data in array More...
 
 createParser ()
 create parser More...
 
 setOptions ($a_xml_parser)
 set parser options More...
 
 setHandlers ($a_xml_parser)
 set event handler should be overwritten by inherited class private More...
 
 openXMLFile ()
 open xml file More...
 
 parse ($a_xml_parser, $a_fp=null)
 parse xml file More...
 
 freeParser ($a_xml_parser)
 free xml parser handle More...
 
 setThrowException ($throwException)
 set error handling More...
 
- Public Member Functions inherited from PEAR
 __construct ($error_class=null)
 Constructor. More...
 
 _PEAR ()
 Destructor (the emulated type of...). More...
 
 registerShutdownFunc ($func, $args=array())
 Use this function to register a shutdown method for static classes. More...
 
 isError ($data, $code=null)
 Tell whether a value is a PEAR error. More...
 
 expectError ($code=' *')
 This method is used to tell which errors you expect to get. More...
 
 popExpect ()
 This method pops one element off the expected error codes stack. More...
 
 _checkDelExpect ($error_code)
 This method checks unsets an error code if available. More...
 
 delExpect ($error_code)
 This method deletes all occurences of the specified element from the expected error codes stack. More...
 
raiseError ($message=null, $code=null, $mode=null, $options=null, $userinfo=null, $error_class=null, $skipmsg=false)
 This method is a wrapper that returns an instance of the configured error class with this object's default error handling applied. More...
 
throwError ($message=null, $code=null, $userinfo=null)
 Simpler form of raiseError with fewer options. More...
 
 staticPushErrorHandling ($mode, $options=null)
 
 staticPopErrorHandling ()
 
 pushErrorHandling ($mode, $options=null)
 Push a new error handler on top of the error handler options stack. More...
 
 popErrorHandling ()
 Pop the last error handler used. More...
 
 loadExtension ($ext)
 OS independant PHP extension load. More...
 

Data Fields

 $approve_date_set = false
 
 $time_limit_set = false
 
 $time_limit_owner_set = false
 
 $updateLookAndSkin = false
 boolean to determine if look and skin should be updated More...
 
 $folder_id
 
 $roles
 
 $action
 The Action attribute determines what to do for the current User element. More...
 
 $protocol
 The variable holds the protocol of the import. More...
 
 $logins
 This variable is used to collect each login that we encounter in the import data. More...
 
 $conflict_rule
 Conflict handling rule. More...
 
 $send_mail
 
 $error_level
 This variable is used to report the error level of the validation process or the importing process. More...
 
 $currPasswordType
 The password type of the current user. More...
 
 $currPassword
 The password of the current user. More...
 
 $currActive
 The active state of the current user. More...
 
 $userCount
 The count of user elements in the XML file. More...
 
 $user_mapping
 
 $mapping_mode
 
 $localRoleCache
 Cached local roles. More...
 
 $personalPicture
 Cached personal picture of the actual user This is used because the ilObjUser object has no field for the personal picture. More...
 
 $parentRolesCache
 Cached parent roles. More...
 
 $skin
 ILIAS skin. More...
 
 $style
 ILIAS style. More...
 
 $userStyles
 User assigned styles. More...
 
 $hideSkin
 Indicates if the skins are hidden. More...
 
 $disableSkin
 Indicates if the skins are enabled. More...
 
 $user_id
 
- Data Fields inherited from ilSaxParser
 $input_type = null
 
 $xml_content = ''
 
 $ilias
 
 $lng
 
 $xml_file
 
 $throwException = false
 
- Data Fields inherited from PEAR
 $_debug = false
 
 $_default_error_mode = null
 
 $_default_error_options = null
 
 $_default_error_handler = ''
 
 $_error_class = 'PEAR_Error'
 
 $_expected_errors = array()
 

Protected Member Functions

 isFieldRequired ($fieldname)
 determine if a field $fieldname is to a required field (global setting) More...
 
- Protected Member Functions inherited from ilSaxParser
 handleError ($message, $code)
 use given error handler to handle error message or internal ilias error message handle More...
 

Private Member Functions

 readAccountMailFromCache ($lang_key)
 
 readRequiredFields ()
 read required fields More...
 
 checkProfileIncomplete ($user_obj)
 Check if profile is incomplete Will set the usr_data field profile_incomplete if any required field is missing. More...
 
 verifyPref ($key, $value)
 
 updateMailPreferences ($usr_id)
 

Private Attributes

 $userObj
 
 $current_messenger_type
 

Static Private Attributes

static $account_mail_cache = array()
 

Additional Inherited Members

- Static Public Member Functions inherited from PEAR
static & getStaticProperty ($class, $var)
 If you have a class that's mostly/entirely static, and you need static properties, you can use this method to simulate them. More...
 
static setErrorHandling ($mode=null, $options=null)
 Sets how errors generated by this object should be handled. More...
 

Detailed Description

User Import Parser.

Author
Alex Killing alex..nosp@m.kill.nosp@m.ing@g.nosp@m.mx.d.nosp@m.e

Definition at line 49 of file class.ilUserImportParser.php.

Constructor & Destructor Documentation

◆ __construct()

ilUserImportParser::__construct (   $a_xml_file = '',
  $a_mode = IL_USER_IMPORT,
  $a_conflict_rule = IL_FAIL_ON_CONFLICT 
)

Constructor.

Parameters
string$a_xml_filexml file
int$a_modeIL_EXTRACT_ROLES | IL_USER_IMPORT | IL_VERIFY
int$a_conflict_rueIL_FAIL_ON_CONFLICT | IL_UPDATE_ON_CONFLICT | IL_IGNORE_ON_CONFLICT

public

Definition at line 282 of file class.ilUserImportParser.php.

References ilSaxParser\$ilias, $ilUser, ilSaxParser\$lng, $style, ilSystemStyleSettings\_lookupActivatedStyle(), array, IL_IMPORT_SUCCESS, and IL_USER_MAPPING_LOGIN.

283  {
284  global $lng, $tree, $ilias, $ilUser, $styleDefinition;
285 
286  $this->roles = array();
287  $this->mode = $a_mode;
288  $this->conflict_rule = $a_conflict_rule;
289  $this->error_level = IL_IMPORT_SUCCESS;
290  $this->protocol = array();
291  $this->logins = array();
292  $this->userCount = 0;
293  $this->localRoleCache = array();
294  $this->parentRolesCache = array();
295  $this->send_mail = false;
296  $this->mapping_mode = IL_USER_MAPPING_LOGIN;
297 
298  // get all active style instead of only assigned ones -> cannot transfer all to another otherwise
299  $this->userStyles = array();
300  include_once './Services/Style/System/classes/class.ilStyleDefinition.php';
301  $skins = ilStyleDefinition::getAllSkins();
302 
303  if (is_array($skins))
304  {
305 
306  foreach($skins as $skin)
307  {
308  foreach($skin->getStyles() as $style)
309  {
310  include_once("./Services/Style/System/classes/class.ilSystemStyleSettings.php");
311  if (!ilSystemStyleSettings::_lookupActivatedStyle($skin->getId(),$style->getId()))
312  {
313  continue;
314  }
315  $this->userStyles [] = $skin->getId().":".$style->getId();
316  }
317  }
318  }
319 
320  $settings = $ilias->getAllSettings();
321  if ($settings["usr_settings_hide_skin_style"] == 1)
322  {
323  $this->hideSkin = TRUE;
324  }
325  else
326  {
327  $this->hideSkin = FALSE;
328  }
329  if ($settings["usr_settings_disable_skin_style"] == 1)
330  {
331  $this->disableSkin = TRUE;
332  }
333  else
334  {
335  $this->disableSkin = FALSE;
336  }
337 
338  include_once("Services/Mail/classes/class.ilAccountMail.php");
339  $this->acc_mail = new ilAccountMail();
340  $this->acc_mail->useLangVariablesAsFallback(true);
341 
342  parent::__construct($a_xml_file);
343  }
const IL_USER_MAPPING_LOGIN
static _lookupActivatedStyle($a_skin, $a_style)
lookup if a style is activated
const IL_IMPORT_SUCCESS
$ilUser
Definition: imgupload.php:18
Create styles array
The data for the language used.
Class ilAccountMail.
+ Here is the call graph for this function:

Member Function Documentation

◆ assignToRole()

ilUserImportParser::assignToRole (   $a_user_obj,
  $a_role_id 
)

Assigns a user to a role.

Definition at line 813 of file class.ilUserImportParser.php.

References $ref_id, ilObjUser\_addDesktopItem(), ilObject\_getAllReferences(), ilObject\_lookupType(), and array.

Referenced by assignToRoleWithParents(), and importEndTag().

814  {
815  require_once "./Services/AccessControl/classes/class.ilObjRole.php";
816  include_once('./Services/Object/classes/class.ilObject.php');
817  #require_once "Modules/Course/classes/class.ilObjCourse.php";
818  #require_once "Modules/Course/classes/class.ilCourseParticipants.php";
819 
820  global $rbacreview, $rbacadmin, $tree;
821 
822  // Do nothing, if the user is already assigned to the role.
823  // Specifically, we do not want to put a course object or
824  // group object on the personal desktop again, if a user
825  // has removed it from the personal desktop.
826  if ($rbacreview->isAssigned($a_user_obj->getId(), $a_role_id))
827  {
828  return;
829  }
830 
831  // If it is a course role, use the ilCourseMember object to assign
832  // the user to the role
833 
834  $rbacadmin->assignUser($a_role_id, $a_user_obj->getId(), true);
835  $obj_id = $rbacreview->getObjectOfRole($a_role_id);
836  switch($type = ilObject::_lookupType($obj_id))
837  {
838  case 'grp':
839  case 'crs':
840  $ref_ids = ilObject::_getAllReferences($obj_id);
841  $ref_id = current((array) $ref_ids);
842  if($ref_id)
843  {
844  ilObjUser::_addDesktopItem($a_user_obj->getId(),$ref_id,$type);
845  }
846  break;
847  default:
848  break;
849  }
850  }
static _getAllReferences($a_id)
get all reference ids of object
Create styles array
The data for the language used.
static _lookupType($a_id, $a_reference=false)
lookup object type
static _addDesktopItem($a_usr_id, $a_item_id, $a_type, $a_par="")
add an item to user&#39;s personal desktop
$ref_id
Definition: sahs_server.php:39
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ assignToRoleWithParents()

ilUserImportParser::assignToRoleWithParents (   $a_user_obj,
  $a_role_id 
)

Assigns a user to a role and to all parent roles.

Definition at line 909 of file class.ilUserImportParser.php.

References assignToRole(), and getParentRoleIds().

Referenced by importEndTag().

910  {
911  $this->assignToRole($a_user_obj, $a_role_id);
912 
913  $parent_role_ids = $this->getParentRoleIds($a_role_id);
914  foreach ($parent_role_ids as $parent_role_id)
915  {
916  $this->assignToRole($a_user_obj, $parent_role_id);
917  }
918  }
getParentRoleIds($a_role_id)
Get array of parent role ids from cache.
assignToRole($a_user_obj, $a_role_id)
Assigns a user to a role.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ buildTag()

ilUserImportParser::buildTag (   $type,
  $name,
  $attr = "" 
)

generate a tag with given name and attributes

Parameters
string"start" | "end" for starting or ending tag
stringelement/tag name
arrayarray of attributes

Definition at line 397 of file class.ilUserImportParser.php.

398  {
399  $tag = "<";
400 
401  if ($type == "end")
402  $tag.= "/";
403 
404  $tag.= $name;
405 
406  if (is_array($attr))
407  {
408  while (list($k,$v) = each($attr))
409  $tag.= " ".$k."=\"$v\"";
410  }
411 
412  $tag.= ">";
413 
414  return $tag;
415  }

◆ checkProfileIncomplete()

ilUserImportParser::checkProfileIncomplete (   $user_obj)
private

Check if profile is incomplete Will set the usr_data field profile_incomplete if any required field is missing.

private

Definition at line 2356 of file class.ilUserImportParser.php.

References ilUserProfile\isProfileIncomplete().

Referenced by importEndTag().

2357  {
2358  include_once "Services/User/classes/class.ilUserProfile.php";
2359  return ilUserProfile::isProfileIncomplete($user_obj);
2360  }
static isProfileIncomplete($a_user, $a_include_udf=true, $a_personal_data_only=true)
Check if all required personal data fields are set.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ detachFromRole()

ilUserImportParser::detachFromRole (   $a_user_obj,
  $a_role_id 
)

Detachs a user from a role.

Definition at line 922 of file class.ilUserImportParser.php.

References $ref_id, ilObjUser\_dropDesktopItem(), ilObject\_getAllReferences(), ilObject\_lookupTitle(), and ilObject\_lookupType().

Referenced by importEndTag().

923  {
924  global $rbacreview, $rbacadmin, $tree;
925 
926  $rbacadmin->deassignUser($a_role_id, $a_user_obj->getId());
927 
928  if (substr(ilObject::_lookupTitle($a_role_id),0,6) == 'il_crs' or
929  substr(ilObject::_lookupTitle($a_role_id),0,6) == 'il_grp')
930  {
931  $obj = $rbacreview->getObjectOfRole($a_role_id);
932  $ref = ilObject::_getAllReferences($obj);
933  $ref_id = end($ref);
934  ilObjUser::_dropDesktopItem($a_user_obj->getId(), $ref_id, ilObject::_lookupType($obj));
935  }
936 }
static _lookupTitle($a_id)
lookup object title
static _getAllReferences($a_id)
get all reference ids of object
static _dropDesktopItem($a_usr_id, $a_item_id, $a_type)
drop an item from user&#39;s personal desktop
static _lookupType($a_id, $a_reference=false)
lookup object type
$ref_id
Definition: sahs_server.php:39
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ extractRolesBeginTag()

ilUserImportParser::extractRolesBeginTag (   $a_xml_parser,
  $a_name,
  $a_attribs 
)

handler for begin of element in extract roles mode

Definition at line 441 of file class.ilUserImportParser.php.

References ilUtil\__extractId().

Referenced by handlerBeginTag().

442  {
443  switch($a_name)
444  {
445  case "Role":
446  // detect numeric, ilias id (then extract role id) or alphanumeric
447  $this->current_role_id = $a_attribs["Id"];
448  if ($internal_id = ilUtil::__extractId($this->current_role_id, IL_INST_ID))
449  {
450  $this->current_role_id = $internal_id;
451  }
452  $this->current_role_type = $a_attribs["Type"];
453 
454  break;
455  }
456  }
static __extractId($ilias_id, $inst_id)
extract ref id from role title, e.g.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ extractRolesEndTag()

ilUserImportParser::extractRolesEndTag (   $a_xml_parser,
  $a_name 
)

handler for end of element when in extract roles mode.

Definition at line 755 of file class.ilUserImportParser.php.

Referenced by handlerEndTag().

756  {
757  switch($a_name)
758  {
759  case "Role":
760  $this->roles[$this->current_role_id]["name"] = $this->cdata;
761  $this->roles[$this->current_role_id]["type"] =
762  $this->current_role_type;
763  break;
764  }
765  }
+ Here is the caller graph for this function:

◆ getCollectedRoles()

ilUserImportParser::getCollectedRoles ( )

get collected roles

Definition at line 2090 of file class.ilUserImportParser.php.

References $roles.

2091  {
2092  return $this->roles;
2093  }

◆ getCourseMembersObjectForRole()

ilUserImportParser::getCourseMembersObjectForRole (   $a_role_id)

Returns the parent object of the role folder object which contains the specified role.

Definition at line 788 of file class.ilUserImportParser.php.

References ilCourseParticipants\_getInstanceByObjId().

789  {
790  global $rbacreview, $rbacadmin, $tree;
791 
792  if (array_key_exists($a_role_id.'_courseMembersObject', $this->localRoleCache))
793  {
794  return $this->localRoleCache[$a_role_id.'_courseMembersObject'];
795  }
796  else
797  {
798  require_once("Modules/Course/classes/class.ilObjCourse.php");
799  require_once("Modules/Course/classes/class.ilCourseParticipants.php");
800  $course_refs = $rbacreview->getFoldersAssignedToRole($a_role_id, true);
801  $course_ref = $course_refs[0];
802  $course_obj = new ilObjCourse($course_ref, true);
803  $crsmembers_obj = ilCourseParticipants::_getInstanceByObjId($course_obj->getId());
804  $this->localRoleCache[$a_role_id.'_courseMembersObject'] = $crsmembers_obj;
805  return $crsmembers_obj;
806  }
807 
808  }
static _getInstanceByObjId($a_obj_id)
Get singleton instance.
Class ilObjCourse.
+ Here is the call graph for this function:

◆ getErrorLevel()

ilUserImportParser::getErrorLevel ( )

Returns the error level.

Returns
IL_IMPORT_SUCCESS | IL_IMPORT_WARNING | IL_IMPORT_FAILURE

Definition at line 2212 of file class.ilUserImportParser.php.

References $error_level.

2213  {
2214  return $this->error_level;
2215  }
$error_level
This variable is used to report the error level of the validation process or the importing process...

◆ getFolderId()

ilUserImportParser::getFolderId ( )

Definition at line 355 of file class.ilUserImportParser.php.

References $folder_id.

Referenced by importEndTag().

356  {
357  return $this->folder_id;
358  }
+ Here is the caller graph for this function:

◆ getParentRoleIds()

ilUserImportParser::getParentRoleIds (   $a_role_id)

Get array of parent role ids from cache.

If necessary, create a new cache entry.

Definition at line 855 of file class.ilUserImportParser.php.

References array, and getRoleObject().

Referenced by assignToRoleWithParents().

856  {
857  global $rbacreview;
858 
859  if (! array_key_exists($a_role_id, $this->parentRolesCache))
860  {
861  $parent_role_ids = array();
862 
863  $role_obj = $this->getRoleObject($a_role_id);
864  $short_role_title = substr($role_obj->getTitle(),0,12);
865  $folders = $rbacreview->getFoldersAssignedToRole($a_role_id, true);
866  if (count($folders) > 0)
867  {
868  $all_parent_role_ids = $rbacreview->getParentRoleIds($folders[0]);
869  foreach ($all_parent_role_ids as $parent_role_id => $parent_role_data)
870  {
871  if ($parent_role_id != $a_role_id)
872  {
873  switch (substr($parent_role_data['title'],0,12))
874  {
875  case 'il_crs_admin' :
876  case 'il_grp_admin' :
877  if ($short_role_title == 'il_crs_admin' || $short_role_title == 'il_grp_admin')
878  {
879  $parent_role_ids[] = $parent_role_id;
880  }
881  break;
882  case 'il_crs_tutor' :
883  case 'il_grp_tutor' :
884  if ($short_role_title == 'il_crs_tutor' || $short_role_title == 'il_grp_tutor')
885  {
886  $parent_role_ids[] = $parent_role_id;
887  }
888  break;
889  case 'il_crs_membe' :
890  case 'il_grp_membe' :
891  if ($short_role_title == 'il_crs_membe' || $short_role_title == 'il_grp_membe')
892  {
893  $parent_role_ids[] = $parent_role_id;
894  }
895  break;
896  default :
897  break;
898  }
899  }
900  }
901  }
902  $this->parentRolesCache[$a_role_id] = $parent_role_ids;
903  }
904  return $this->parentRolesCache[$a_role_id];
905  }
getRoleObject($a_role_id)
Returns the parent object of the role folder object which contains the specified role.
Create styles array
The data for the language used.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getProtocol()

ilUserImportParser::getProtocol ( )

Returns the protocol.

The protocol is an associative array. Keys are login names. Values are non-associative arrays. Each array element contains an error message.

Definition at line 2163 of file class.ilUserImportParser.php.

References $protocol.

Referenced by getProtocolAsHTML().

2164  {
2165  return $this->protocol;
2166  }
$protocol
The variable holds the protocol of the import.
+ Here is the caller graph for this function:

◆ getProtocolAsHTML()

ilUserImportParser::getProtocolAsHTML (   $a_log_title)

Returns the protocol as a HTML table.

Definition at line 2170 of file class.ilUserImportParser.php.

References ilSaxParser\$lng, $messages, and getProtocol().

2171  {
2172  global $lng;
2173 
2174  $block = new ilTemplate("tpl.usr_import_log_block.html", true, true, "Services/User");
2175  $block->setVariable("TXT_LOG_TITLE", $a_log_title);
2176  $block->setVariable("TXT_MESSAGE_ID", $lng->txt("login"));
2177  $block->setVariable("TXT_MESSAGE_TEXT", $lng->txt("message"));
2178  foreach ($this->getProtocol() as $login => $messages)
2179  {
2180  $block->setCurrentBlock("log_row");
2181  $reason = "";
2182  foreach ($messages as $message)
2183  {
2184  if ($reason == "")
2185  {
2186  $reason = $message;
2187  }
2188  else
2189  {
2190  $reason = $reason."<br>".$message;
2191  }
2192  }
2193  $block->setVariable("MESSAGE_ID", $login);
2194  $block->setVariable("MESSAGE_TEXT", $reason);
2195  $block->parseCurrentBlock();
2196  }
2197  return $block->get();
2198  }
getProtocol()
Returns the protocol.
special template class to simplify handling of ITX/PEAR
$messages
Definition: en-x-test.php:7
+ Here is the call graph for this function:

◆ getRoleObject()

ilUserImportParser::getRoleObject (   $a_role_id)

Returns the parent object of the role folder object which contains the specified role.

Definition at line 770 of file class.ilUserImportParser.php.

Referenced by getParentRoleIds().

771  {
772  if (array_key_exists($a_role_id, $this->localRoleCache))
773  {
774  return $this->localRoleCache[$a_role_id];
775  }
776  else
777  {
778  $role_obj = new ilObjRole($a_role_id, false);
779  $role_obj->read();
780  $this->localRoleCache[$a_role_id] = $role_obj;
781  return $role_obj;
782  }
783 
784  }
Class ilObjRole.
+ Here is the caller graph for this function:

◆ getUserCount()

ilUserImportParser::getUserCount ( )

get count of User elements

Definition at line 2097 of file class.ilUserImportParser.php.

References $userCount.

2098  {
2099  return $this->userCount;
2100  }
$userCount
The count of user elements in the XML file.

◆ getUserMapping()

ilUserImportParser::getUserMapping ( )

returns a map user_id <=> login

Returns
assoc array, with user_id as key and login as value

Definition at line 2222 of file class.ilUserImportParser.php.

References $user_mapping.

2222  {
2223  return $this->user_mapping;
2224  }

◆ getUserMappingMode()

ilUserImportParser::getUserMappingMode ( )

read access to user mapping mode

Returns
int one of IL_USER_MAPPING_ID or IL_USER_MAPPING_LOGIN

Definition at line 2318 of file class.ilUserImportParser.php.

References $mapping_mode.

Referenced by importBeginTag(), and verifyBeginTag().

2319  {
2320  return $this->mapping_mode;
2321  }
+ Here is the caller graph for this function:

◆ handlerBeginTag()

ilUserImportParser::handlerBeginTag (   $a_xml_parser,
  $a_name,
  $a_attribs 
)

handler for begin of element

Definition at line 420 of file class.ilUserImportParser.php.

References extractRolesBeginTag(), IL_EXTRACT_ROLES, IL_USER_IMPORT, IL_VERIFY, importBeginTag(), and verifyBeginTag().

421  {
422  switch ($this->mode)
423  {
424  case IL_EXTRACT_ROLES :
425  $this->extractRolesBeginTag($a_xml_parser, $a_name, $a_attribs);
426  break;
427  case IL_USER_IMPORT :
428  $this->importBeginTag($a_xml_parser, $a_name, $a_attribs);
429  break;
430  case IL_VERIFY :
431  $this->verifyBeginTag($a_xml_parser, $a_name, $a_attribs);
432  break;
433  }
434 
435  $this->cdata = "";
436  }
verifyBeginTag($a_xml_parser, $a_name, $a_attribs)
handler for begin of element
const IL_USER_IMPORT
const IL_EXTRACT_ROLES
importBeginTag($a_xml_parser, $a_name, $a_attribs)
handler for begin of element in user import mode
extractRolesBeginTag($a_xml_parser, $a_name, $a_attribs)
handler for begin of element in extract roles mode
const IL_VERIFY
+ Here is the call graph for this function:

◆ handlerCharacterData()

ilUserImportParser::handlerCharacterData (   $a_xml_parser,
  $a_data 
)

handler for character data

Definition at line 2074 of file class.ilUserImportParser.php.

2075  {
2076  // DELETE WHITESPACES AND NEWLINES OF CHARACTER DATA
2077  // TODO: Mit Alex klären, ob das noch benötigt wird $a_data = preg_replace("/\n/","",$a_data);
2078  // TODO: Mit Alex klären, ob das noch benötigt wird $a_data = preg_replace("/\t+/","",$a_data);
2079  if($a_data != "\n") $a_data = preg_replace("/\t+/"," ",$a_data);
2080 
2081  if(strlen($a_data) > 0)
2082  {
2083  $this->cdata .= $a_data;
2084  }
2085  }

◆ handlerEndTag()

ilUserImportParser::handlerEndTag (   $a_xml_parser,
  $a_name 
)

handler for end of element

Definition at line 736 of file class.ilUserImportParser.php.

References extractRolesEndTag(), IL_EXTRACT_ROLES, IL_USER_IMPORT, IL_VERIFY, importEndTag(), and verifyEndTag().

737  {
738  switch ($this->mode)
739  {
740  case IL_EXTRACT_ROLES :
741  $this->extractRolesEndTag($a_xml_parser, $a_name);
742  break;
743  case IL_USER_IMPORT :
744  $this->importEndTag($a_xml_parser, $a_name);
745  break;
746  case IL_VERIFY :
747  $this->verifyEndTag($a_xml_parser, $a_name);
748  break;
749  }
750  }
const IL_USER_IMPORT
extractRolesEndTag($a_xml_parser, $a_name)
handler for end of element when in extract roles mode.
verifyEndTag($a_xml_parser, $a_name)
handler for end of element when in verify mode.
const IL_EXTRACT_ROLES
const IL_VERIFY
importEndTag($a_xml_parser, $a_name)
handler for end of element when in import user mode.
+ Here is the call graph for this function:

◆ importBeginTag()

ilUserImportParser::importBeginTag (   $a_xml_parser,
  $a_name,
  $a_attribs 
)

handler for begin of element in user import mode

Definition at line 460 of file class.ilUserImportParser.php.

References ilSaxParser\$ilias, ilSaxParser\$lng, ilUtil\__extractId(), ilLDAPServer\_getActiveServerList(), array, getUserMappingMode(), IL_USER_MAPPING_ID, and logFailure().

Referenced by handlerBeginTag().

461  {
462  global $ilias,$lng;
463 
464  switch($a_name)
465  {
466  case "Role":
467  $this->current_role_id = $a_attribs["Id"];
468  if ($internal_id = ilUtil::__extractId($this->current_role_id, IL_INST_ID))
469  {
470  $this->current_role_id = $internal_id;
471  }
472  $this->current_role_type = $a_attribs["Type"];
473  $this->current_role_action = (is_null($a_attribs["Action"])) ? "Assign" : $a_attribs["Action"];
474  break;
475 
476  case "PersonalPicture":
477  $this->personalPicture = array(
478  "encoding" => $a_attribs["encoding"],
479  "imagetype" => $a_attribs["imagetype"],
480  "content" => ""
481  );
482  break;
483 
484  case "Look":
485  $this->skin = $a_attribs["Skin"];
486  $this->style = $a_attribs["Style"];
487  break;
488 
489  case "User":
490  $this->acc_mail->reset();
491  $this->prefs = array();
492  $this->currentPrefKey = null;
493  $this->auth_mode_set = false;
494  $this->approve_date_set = false;
495  $this->time_limit_set = false;
496  $this->time_limit_owner_set = false;
497  $this->updateLookAndSkin = false;
498  $this->skin = "";
499  $this->style = "";
500  $this->personalPicture = null;
501  $this->userCount++;
502  $this->userObj = new ilObjUser();
503 
504  // user defined fields
505  $this->udf_data = array();
506 
507  // if we have an object id, store it
508  $this->user_id = -1;
509  if (!is_null($a_attribs["Id"]) && $this->getUserMappingMode() == IL_USER_MAPPING_ID)
510  {
511  if (is_numeric($a_attribs["Id"]))
512  {
513  $this->user_id = $a_attribs["Id"];
514  }
515  elseif ($id = ilUtil::__extractId ($a_attribs["Id"], IL_INST_ID))
516  {
517  $this->user_id = $id;
518  }
519  }
520 
521  $this->userObj->setPref("skin",
522  $ilias->ini->readVariable("layout","skin"));
523  $this->userObj->setPref("style",
524  $ilias->ini->readVariable("layout","style"));
525 
526  $this->userObj->setLanguage($a_attribs["Language"]);
527  $this->userObj->setImportId($a_attribs["Id"]);
528  $this->action = (is_null($a_attribs["Action"])) ? "Insert" : $a_attribs["Action"];
529  $this->currPassword = null;
530  $this->currPasswordType = null;
531  $this->currActive = null;
532  $this->multi_values = array();
533  break;
534 
535  case 'Password':
536  $this->currPasswordType = $a_attribs['Type'];
537  break;
538  case "AuthMode":
539  if (array_key_exists("type", $a_attribs))
540  {
541  switch ($a_attribs["type"])
542  {
543  case "default":
544  case "local":
545  case "ldap":
546 
547  if(strcmp('ldap', $a_attribs['type']) === 0)
548  {
549  // no server id provided => use default server
550  include_once './Services/LDAP/classes/class.ilLDAPServer.php';
552  if(count($list) == 1)
553  {
554  $this->auth_mode_set = true;
555  $ldap_id = current($list);
556  $this->userObj->setAuthMode('ldap_'.$ldap_id);
557  }
558  }
559  break;
560 
561  case "radius":
562  case "shibboleth":
563  case "script":
564  case "cas":
565  case "soap":
566  case "openid":
567  // begin-patch auth_plugin
568  default:
569  $this->auth_mode_set = true;
570  $this->userObj->setAuthMode($a_attribs["type"]);
571  break;
572  /*
573  $this->logFailure($this->userObj->getLogin(),
574  sprintf($lng->txt("usrimport_xml_element_inapplicable"),"AuthMode",$a_attribs["type"]));
575  break;
576  *
577  */
578  }
579  }
580  else
581  {
582  $this->logFailure($this->userObj->getLogin(),
583  sprintf($lng->txt("usrimport_xml_element_inapplicable"),"AuthMode",$a_attribs["type"]));
584  }
585  break;
586 
587  case 'UserDefinedField':
588  $this->tmp_udf_id = $a_attribs['Id'];
589  $this->tmp_udf_name = $a_attribs['Name'];
590  break;
591 
592  case 'AccountInfo':
593  $this->current_messenger_type = strtolower($a_attribs["Type"]);
594  break;
595  case 'GMapInfo':
596  $this->userObj->setLatitude($a_attribs["latitude"]);
597  $this->userObj->setLongitude($a_attribs["longitude"]);
598  $this->userObj->setLocationZoom($a_attribs["zoom"]);
599  break;
600  case 'Pref':
601  $this->currentPrefKey = $a_attribs["key"];
602  break;
603  }
604  }
getUserMappingMode()
read access to user mapping mode
"color:#CC0000 style
Definition: example_001.php:92
static _getActiveServerList()
Get active server list.
const IL_USER_MAPPING_ID
logFailure($aLogin, $aMessage)
Writes a failure log message to the protocol.
Create styles array
The data for the language used.
static __extractId($ilias_id, $inst_id)
extract ref id from role title, e.g.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ importEndTag()

ilUserImportParser::importEndTag (   $a_xml_parser,
  $a_name 
)

handler for end of element when in import user mode.

Definition at line 941 of file class.ilUserImportParser.php.

References $currPasswordType, ilSaxParser\$ilias, $ilSetting, $ilUser, ilSaxParser\$lng, $timestamp, $user_id, ilObjUser\_checkExternalAuthAccount(), ilAuthUtils\_getAuthModeName(), ilUserDefinedFields\_getInstance(), ilObjUser\_lookupExternalAccount(), ilObjUser\_uploadPersonalPicture(), array, assignToRole(), assignToRoleWithParents(), checkProfileIncomplete(), date, detachFromRole(), getFolderId(), ilObjUser\getUserIdByLogin(), IL_CAL_DATETIME, IL_CAL_UNIX, IL_FAIL_ON_CONFLICT, IL_IGNORE_ON_CONFLICT, IL_PASSWD_CRYPTED, IL_PASSWD_PLAIN, IL_UPDATE_ON_CONFLICT, ilUserXMLWriter\isPrefExportable(), logFailure(), logSuccess(), logWarning(), saveTempImage(), sendAccountMail(), ilUserDefinedData\set(), and updateMailPreferences().

Referenced by handlerEndTag().

942  {
943  global $ilias, $rbacadmin, $rbacreview, $ilUser, $lng, $ilSetting;
944 
945  switch($a_name)
946  {
947  case "Role":
948  $this->roles[$this->current_role_id]["name"] = $this->cdata;
949  $this->roles[$this->current_role_id]["type"] = $this->current_role_type;
950  $this->roles[$this->current_role_id]["action"] = $this->current_role_action;
951  break;
952 
953  case "PersonalPicture":
954  switch ($this->personalPicture["encoding"])
955  {
956  case "Base64":
957  $this->personalPicture["content"] = base64_decode($this->cdata);
958  break;
959  case "UUEncode":
960  $this->personalPicture["content"] = convert_uudecode($this->cdata);
961  break;
962  }
963  break;
964 
965  case "User":
966  $this->userObj->setFullname();
967  // Fetch the user_id from the database, if we didn't have it in xml file
968  // fetch as well, if we are trying to insert -> recognize duplicates!
969  if ($this->user_id == -1 || $this->action=="Insert")
970  $user_id = ilObjUser::getUserIdByLogin($this->userObj->getLogin());
971  else
973 
974  //echo $user_id.":".$this->userObj->getLogin();
975 
976  // Handle conflicts
977  switch ($this->conflict_rule)
978  {
979  case IL_FAIL_ON_CONFLICT :
980  // do not change action
981  break;
982  case IL_UPDATE_ON_CONFLICT :
983  switch ($this->action)
984  {
985  case "Insert" :
986  if ($user_id)
987  {
988  $this->logWarning($this->userObj->getLogin(),sprintf($lng->txt("usrimport_action_replaced"),"Insert","Update"));
989  $this->action = "Update";
990  }
991  break;
992  case "Update" :
993  if (! $user_id)
994  {
995  $this->logWarning($this->userObj->getLogin(),sprintf($lng->txt("usrimport_action_replaced"),"Update","Insert"));
996  $this->action = "Insert";
997  }
998  break;
999  case "Delete" :
1000  if (! $user_id)
1001  {
1002  $this->logWarning($this->userObj->getLogin(),sprintf($lng->txt("usrimport_action_ignored"),"Delete"));
1003  $this->action = "Ignore";
1004  }
1005  break;
1006  }
1007  break;
1008  case IL_IGNORE_ON_CONFLICT :
1009  switch ($this->action)
1010  {
1011  case "Insert" :
1012  if ($user_id)
1013  {
1014  $this->logWarning($this->userObj->getLogin(),sprintf($lng->txt("usrimport_action_ignored"),"Insert"));
1015  $this->action = "Ignore";
1016  }
1017  break;
1018  case "Update" :
1019  if (! $user_id)
1020  {
1021  $this->logWarning($this->userObj->getLogin(),sprintf($lng->txt("usrimport_action_ignored"),"Update"));
1022  $this->action = "Ignore";
1023  }
1024  break;
1025  case "Delete" :
1026  if (! $user_id)
1027  {
1028  $this->logWarning($this->userObj->getLogin(),sprintf($lng->txt("usrimport_action_ignored"),"Delete"));
1029  $this->action = "Ignore";
1030  }
1031  break;
1032  }
1033  break;
1034  }
1035 
1036  // check external account conflict (if external account is already used)
1037  // note: we cannot apply conflict rules in the same manner as to logins here
1038  // so we ignore records with already existing external accounts.
1039  //echo $this->userObj->getAuthMode().'h';
1040  $am = ($this->userObj->getAuthMode() == "default" || $this->userObj->getAuthMode() == "")
1041  ? ilAuthUtils::_getAuthModeName($ilSetting->get('auth_mode'))
1042  : $this->userObj->getAuthMode();
1043  $loginForExternalAccount = ($this->userObj->getExternalAccount() == "")
1044  ? ""
1045  : ilObjUser::_checkExternalAuthAccount($am, $this->userObj->getExternalAccount());
1046  switch ($this->action)
1047  {
1048  case "Insert" :
1049  if ($loginForExternalAccount != "")
1050  {
1051  $this->logWarning($this->userObj->getLogin(), $lng->txt("usrimport_no_insert_ext_account_exists")." (".$this->userObj->getExternalAccount().")");
1052  $this->action = "Ignore";
1053  }
1054  break;
1055 
1056  case "Update" :
1057  // this variable describes the ILIAS login which belongs to the given external account!!!
1058  // it is NOT nescessarily the ILIAS login of the current user record !!
1059  // so if we found an ILIAS login according to the authentication method
1060  // check if the ILIAS login belongs to the current user record, otherwise somebody else is using it!
1061  if ($loginForExternalAccount != "")
1062  {
1063  // check if we changed the value!
1064  $externalAccountHasChanged = $this->userObj->getExternalAccount() != ilObjUser::_lookupExternalAccount($this->user_id);
1065  // if it has changed and the external login
1066  if ($externalAccountHasChanged && trim($loginForExternalAccount) != trim($this->userObj->getLogin()))
1067  {
1068  $this->logWarning($this->userObj->getLogin(), $lng->txt("usrimport_no_update_ext_account_exists")." (".$this->userObj->getExternalAccount().")");
1069  $this->action = "Ignore";
1070  }
1071  }
1072  break;
1073  }
1074 
1075  if(sizeof($this->multi_values))
1076  {
1077  if(isset($this->multi_values["GeneralInterest"]))
1078  {
1079  $this->userObj->setGeneralInterests($this->multi_values["GeneralInterest"]);
1080  }
1081  if(isset($this->multi_values["OfferingHelp"]))
1082  {
1083  $this->userObj->setOfferingHelp($this->multi_values["OfferingHelp"]);
1084  }
1085  if(isset($this->multi_values["LookingForHelp"]))
1086  {
1087  $this->userObj->setLookingForHelp($this->multi_values["LookingForHelp"]);
1088  }
1089  }
1090 
1091  // Perform the action
1092  switch ($this->action)
1093  {
1094  case "Insert" :
1095  if ($user_id)
1096  {
1097  $this->logFailure($this->userObj->getLogin(),$lng->txt("usrimport_cant_insert"));
1098  }
1099  else
1100  {
1101 
1102  if(!strlen($this->currPassword) == 0)
1103  {
1104  switch(strtoupper($this->currPasswordType))
1105  {
1106  case "BCRYPT":
1107  $this->userObj->setPasswd($this->currPassword, IL_PASSWD_CRYPTED);
1108  $this->userObj->setPasswordEncodingType('bcryptphp');
1109  $this->userObj->setPasswordSalt(null);
1110  break;
1111 
1112  case "PLAIN":
1113  $this->userObj->setPasswd($this->currPassword, IL_PASSWD_PLAIN);
1114  $this->acc_mail->setUserPassword($this->currPassword);
1115  break;
1116 
1117  default:
1118  $this->logFailure($this->userObj->getLogin(), sprintf($lng->txt("usrimport_xml_attribute_value_illegal"),"Type","Password",$this->currPasswordType));
1119  break;
1120 
1121  }
1122  }
1123  else
1124  {
1125  // this does the trick for empty passwords
1126  // since a MD5 string has always 32 characters,
1127  // no hashed password combination will ever equal to
1128  // an empty string
1129  $this->userObj->setPasswd("", IL_PASSWD_CRYPTED);
1130 
1131  }
1132 
1133  $this->userObj->setTitle($this->userObj->getFullname());
1134  $this->userObj->setDescription($this->userObj->getEmail());
1135 
1136  if(!$this->time_limit_owner_set)
1137  {
1138  $this->userObj->setTimeLimitOwner($this->getFolderId());
1139  }
1140 
1141  // default time limit settings
1142  if(!$this->time_limit_set)
1143  {
1144  $this->userObj->setTimeLimitUnlimited(1);
1145  $this->userObj->setTimeLimitMessage(0);
1146 
1147  if (! $this->approve_date_set)
1148  {
1149  $this->userObj->setApproveDate(date("Y-m-d H:i:s"));
1150  }
1151  }
1152 
1153 
1154  $this->userObj->setActive($this->currActive == 'true' || is_null($this->currActive));
1155 
1156  // Finally before saving new user.
1157  // Check if profile is incomplete
1158 
1159  // #8759
1160  if(count($this->udf_data))
1161  {
1162  $this->userObj->setUserDefinedData($this->udf_data);
1163  }
1164 
1165  $this->userObj->setProfileIncomplete($this->checkProfileIncomplete($this->userObj));
1166  $this->userObj->create();
1167 
1168  //insert user data in table user_data
1169  $this->userObj->saveAsNew(false);
1170 
1171  // Set default prefs
1172  $this->userObj->setPref('hits_per_page',$ilSetting->get('hits_per_page',30));
1173  //$this->userObj->setPref('show_users_online',$ilSetting->get('show_users_online','y'));
1174 
1175  if (count ($this->prefs))
1176  {
1177  foreach ($this->prefs as $key => $value)
1178  {
1179  if ($key != "mail_incoming_type" &&
1180  $key != "mail_signature" &&
1181  $key != "mail_linebreak"
1182  )
1183  {
1184  $this->userObj->setPref($key, $value);
1185  }
1186  }
1187  }
1188 
1189  if(!is_array($this->prefs) || array_search('chat_osc_accept_msg', $this->prefs) === false)
1190  {
1191  $this->userObj->setPref('chat_osc_accept_msg', $ilSetting->get('chat_osc_accept_msg', 'n'));
1192  }
1193  if(!is_array($this->prefs) || array_search('bs_allow_to_contact_me', $this->prefs) === false)
1194  {
1195  $this->userObj->setPref('bs_allow_to_contact_me', $ilSetting->get('bs_allow_to_contact_me', 'n'));
1196  }
1197 
1198  $this->userObj->writePrefs();
1199 
1200  // update mail preferences, to be extended
1201  $this->updateMailPreferences($this->userObj->getId());
1202 
1203  if (is_array($this->personalPicture))
1204  {
1205  if (strlen($this->personalPicture["content"]))
1206  {
1207  $extension = "jpg";
1208  if (preg_match("/.*(png|jpg|gif|jpeg)$/", $this->personalPicture["imagetype"], $matches))
1209  {
1210  $extension = $matches[1];
1211  }
1212  $tmp_name = $this->saveTempImage($this->personalPicture["content"], ".$extension");
1213  if (strlen($tmp_name))
1214  {
1215  ilObjUser::_uploadPersonalPicture($tmp_name, $this->userObj->getId());
1216  unlink($tmp_name);
1217  }
1218  }
1219  }
1220 
1221  //set role entries
1222  foreach($this->roles as $role_id => $role)
1223  {
1224  if ($this->role_assign[$role_id])
1225  {
1226  $this->assignToRole($this->userObj, $this->role_assign[$role_id]);
1227  }
1228  }
1229 
1230  if(count($this->udf_data))
1231  {
1232  include_once './Services/User/classes/class.ilUserDefinedData.php';
1233  $udd = new ilUserDefinedData($this->userObj->getId());
1234  foreach($this->udf_data as $field => $value)
1235  {
1236  $udd->set("f_".$field,$value);
1237  }
1238  $udd->update();
1239  }
1240 
1241  $this->sendAccountMail();
1242  $this->logSuccess($this->userObj->getLogin(),$this->userObj->getId(), "Insert");
1243  // reset account mail object
1244  $this->acc_mail->reset();
1245  }
1246  break;
1247 
1248  case "Update" :
1249  if (! $user_id)
1250  {
1251  $this->logFailure($this->userObj->getLogin(),$lng->txt("usrimport_cant_update"));
1252  }
1253  else
1254  {
1255  $updateUser = new ilObjUser($user_id);
1256  $updateUser->read();
1257  $updateUser->readPrefs();
1258  if ($this->currPassword != null)
1259  {
1260  switch(strtoupper($this->currPasswordType))
1261  {
1262  case "BCRYPT":
1263  $updateUser->setPasswd($this->currPassword, IL_PASSWD_CRYPTED);
1264  $updateUser->setPasswordEncodingType('bcryptphp');
1265  $updateUser->setPasswordSalt(null);
1266  break;
1267 
1268  case "PLAIN":
1269  $updateUser->setPasswd($this->currPassword, IL_PASSWD_PLAIN);
1270  $this->acc_mail->setUserPassword($this->currPassword);
1271  break;
1272 
1273  default:
1274  $this->logFailure($this->userObj->getLogin(), sprintf($lng->txt("usrimport_xml_attribute_value_illegal"),"Type","Password",$this->currPasswordType));
1275  break;
1276  }
1277  }
1278  if (! is_null($this->userObj->getFirstname())) $updateUser->setFirstname($this->userObj->getFirstname());
1279  if (! is_null($this->userObj->getLastname())) $updateUser->setLastname($this->userObj->getLastname());
1280  if (! is_null($this->userObj->getUTitle())) $updateUser->setUTitle($this->userObj->getUTitle());
1281  if (! is_null($this->userObj->getGender())) $updateUser->setGender($this->userObj->getGender());
1282  if (! is_null($this->userObj->getEmail())) $updateUser->setEmail($this->userObj->getEmail());
1283  if (! is_null($this->userObj->getBirthday())) $updateUser->setBirthday($this->userObj->getBirthday());
1284  if (! is_null($this->userObj->getInstitution())) $updateUser->setInstitution($this->userObj->getInstitution());
1285  if (! is_null($this->userObj->getStreet())) $updateUser->setStreet($this->userObj->getStreet());
1286  if (! is_null($this->userObj->getCity())) $updateUser->setCity($this->userObj->getCity());
1287  if (! is_null($this->userObj->getZipCode())) $updateUser->setZipCode($this->userObj->getZipCode());
1288  if (! is_null($this->userObj->getCountry())) $updateUser->setCountry($this->userObj->getCountry());
1289  if (! is_null($this->userObj->getSelectedCountry())) $updateUser->setSelectedCountry($this->userObj->getSelectedCountry());
1290  if (! is_null($this->userObj->getPhoneOffice())) $updateUser->setPhoneOffice($this->userObj->getPhoneOffice());
1291  if (! is_null($this->userObj->getPhoneHome())) $updateUser->setPhoneHome($this->userObj->getPhoneHome());
1292  if (! is_null($this->userObj->getPhoneMobile())) $updateUser->setPhoneMobile($this->userObj->getPhoneMobile());
1293  if (! is_null($this->userObj->getFax())) $updateUser->setFax($this->userObj->getFax());
1294  if (! is_null($this->userObj->getHobby())) $updateUser->setHobby($this->userObj->getHobby());
1295  if (! is_null($this->userObj->getGeneralInterests())) $updateUser->setGeneralInterests($this->userObj->getGeneralInterests());
1296  if (! is_null($this->userObj->getOfferingHelp())) $updateUser->setOfferingHelp($this->userObj->getOfferingHelp());
1297  if (! is_null($this->userObj->getLookingForHelp())) $updateUser->setLookingForHelp($this->userObj->getLookingForHelp());
1298  if (! is_null($this->userObj->getComment())) $updateUser->setComment($this->userObj->getComment());
1299  if (! is_null($this->userObj->getDepartment())) $updateUser->setDepartment($this->userObj->getDepartment());
1300  if (! is_null($this->userObj->getMatriculation())) $updateUser->setMatriculation($this->userObj->getMatriculation());
1301  if (! is_null($this->currActive)) $updateUser->setActive($this->currActive == "true", is_object($ilUser) ? $ilUser->getId() : 0);
1302  if (! is_null($this->userObj->getClientIP())) $updateUser->setClientIP($this->userObj->getClientIP());
1303  if (! is_null($this->userObj->getTimeLimitUnlimited())) $updateUser->setTimeLimitUnlimited($this->userObj->getTimeLimitUnlimited());
1304  if (! is_null($this->userObj->getTimeLimitFrom())) $updateUser->setTimeLimitFrom($this->userObj->getTimeLimitFrom());
1305  if (! is_null($this->userObj->getTimeLimitUntil())) $updateUser->setTimeLimitUntil($this->userObj->getTimeLimitUntil());
1306  if (! is_null($this->userObj->getTimeLimitMessage())) $updateUser->setTimeLimitMessage($this->userObj->getTimeLimitMessage());
1307  if (! is_null($this->userObj->getApproveDate())) $updateUser->setApproveDate($this->userObj->getApproveDate());
1308  if (! is_null($this->userObj->getAgreeDate())) $updateUser->setAgreeDate($this->userObj->getAgreeDate());
1309  if (! is_null($this->userObj->getLanguage())) $updateUser->setLanguage($this->userObj->getLanguage());
1310  if (! is_null($this->userObj->getExternalAccount())) $updateUser->setExternalAccount($this->userObj->getExternalAccount());
1311 
1312  // Fixed: if auth_mode is not set, it was always overwritten with auth_default
1313  #if (! is_null($this->userObj->getAuthMode())) $updateUser->setAuthMode($this->userObj->getAuthMode());
1314  if($this->auth_mode_set)
1315  $updateUser->setAuthMode($this->userObj->getAuthMode());
1316 
1317  // Special handlin since it defaults to 7 (USER_FOLDER_ID)
1318  if($this->time_limit_owner_set)
1319  {
1320  $updateUser->setTimeLimitOwner($this->userObj->getTimeLimitOwner());
1321  }
1322 
1323 
1324  if (count ($this->prefs))
1325  {
1326  foreach ($this->prefs as $key => $value)
1327  {
1328  if ($key != "mail_incoming_type" &&
1329  $key != "mail_signature" &&
1330  $key != "mail_linebreak"
1331  ){
1332  $updateUser->setPref($key, $value);
1333  }
1334  }
1335  }
1336 
1337  // save user preferences (skin and style)
1338  if ($this->updateLookAndSkin)
1339  {
1340  $updateUser->setPref("skin", $this->userObj->getPref("skin"));
1341  $updateUser->setPref("style", $this->userObj->getPref("style"));
1342  }
1343 
1344 
1345  $updateUser->writePrefs();
1346 
1347  // update mail preferences, to be extended
1348  $this->updateMailPreferences($updateUser->getId());
1349 
1350  // #8759
1351  if(count($this->udf_data))
1352  {
1353  $updateUser->setUserDefinedData($this->udf_data);
1354  }
1355 
1356  $updateUser->setProfileIncomplete($this->checkProfileIncomplete($updateUser));
1357  $updateUser->setFullname();
1358  $updateUser->setTitle($updateUser->getFullname());
1359  $updateUser->setDescription($updateUser->getEmail());
1360  $updateUser->update();
1361 
1362  if(count($this->udf_data))
1363  {
1364  include_once './Services/User/classes/class.ilUserDefinedData.php';
1365  $udd = new ilUserDefinedData($updateUser->getId());
1366  foreach($this->udf_data as $field => $value)
1367  {
1368  $udd->set("f_".$field,$value);
1369  }
1370  $udd->update();
1371  }
1372 
1373  // update login
1374  if (!is_null($this->userObj->getLogin()) && $this->user_id != -1)
1375  {
1376  try
1377  {
1378  $updateUser->updateLogin($this->userObj->getLogin());
1379  }
1380  catch (ilUserException $e)
1381  {
1382  }
1383  }
1384 
1385 
1386  // if language has changed
1387 
1388  if (is_array($this->personalPicture))
1389  {
1390  if (strlen($this->personalPicture["content"]))
1391  {
1392  $extension = "jpg";
1393  if (preg_match("/.*(png|jpg|gif|jpeg)$/", $this->personalPicture["imagetype"], $matches))
1394  {
1395  $extension = $matches[1];
1396  }
1397  $tmp_name = $this->saveTempImage($this->personalPicture["content"], ".$extension");
1398  if (strlen($tmp_name))
1399  {
1400  ilObjUser::_uploadPersonalPicture($tmp_name, $this->userObj->getId());
1401  unlink($tmp_name);
1402  }
1403  }
1404  }
1405 
1406 
1407  //update role entries
1408  //-------------------
1409  foreach ($this->roles as $role_id => $role)
1410  {
1411  if ($this->role_assign[$role_id])
1412  {
1413  switch ($role["action"])
1414  {
1415  case "Assign" :
1416  $this->assignToRole($updateUser, $this->role_assign[$role_id]);
1417  break;
1418  case "AssignWithParents" :
1419  $this->assignToRoleWithParents($updateUser, $this->role_assign[$role_id]);
1420  break;
1421  case "Detach" :
1422  $this->detachFromRole($updateUser, $this->role_assign[$role_id]);
1423  break;
1424  }
1425  }
1426  }
1427  $this->logSuccess($updateUser->getLogin(), $user_id, "Update");
1428  }
1429  break;
1430  case "Delete" :
1431  if (! $user_id)
1432  {
1433  $this->logFailure($this->userObj->getLogin(),$lng->txt("usrimport_cant_delete"));
1434  }
1435  else
1436  {
1437  $deleteUser = new ilObjUser($user_id);
1438  $deleteUser->delete();
1439 
1440  $this->logSuccess($this->userObj->getLogin(),$user_id, "Delete");
1441  }
1442  break;
1443  }
1444 
1445  // init role array for next user
1446  $this->roles = array();
1447  break;
1448 
1449  case "Login":
1450  $this->userObj->setLogin($this->cdata);
1451  break;
1452 
1453  case "Password":
1454  $this->currPassword = $this->cdata;
1455  break;
1456 
1457  case "Firstname":
1458  $this->userObj->setFirstname($this->cdata);
1459  break;
1460 
1461  case "Lastname":
1462  $this->userObj->setLastname($this->cdata);
1463  break;
1464 
1465  case "Title":
1466  $this->userObj->setUTitle($this->cdata);
1467  break;
1468 
1469  case "Gender":
1470  $this->userObj->setGender($this->cdata);
1471  break;
1472 
1473  case "Email":
1474  $this->userObj->setEmail($this->cdata);
1475  break;
1476 
1477  case "Birthday":
1478  $timestamp = strtotime($this->cdata);
1479  if ($timestamp !== false)
1480  {
1481  $this->userObj->setBirthday($this->cdata);
1482  }
1483  break;
1484  case "Institution":
1485  $this->userObj->setInstitution($this->cdata);
1486  break;
1487 
1488  case "Street":
1489  $this->userObj->setStreet($this->cdata);
1490  break;
1491 
1492  case "City":
1493  $this->userObj->setCity($this->cdata);
1494  break;
1495 
1496  case "PostalCode":
1497  $this->userObj->setZipCode($this->cdata);
1498  break;
1499 
1500  case "Country":
1501  $this->userObj->setCountry($this->cdata);
1502  break;
1503 
1504  case "SelCountry":
1505  $this->userObj->setSelectedCountry($this->cdata);
1506  break;
1507 
1508  case "PhoneOffice":
1509  $this->userObj->setPhoneOffice($this->cdata);
1510  break;
1511 
1512  case "PhoneHome":
1513  $this->userObj->setPhoneHome($this->cdata);
1514  break;
1515 
1516  case "PhoneMobile":
1517  $this->userObj->setPhoneMobile($this->cdata);
1518  break;
1519 
1520  case "Fax":
1521  $this->userObj->setFax($this->cdata);
1522  break;
1523 
1524  case "Hobby":
1525  $this->userObj->setHobby($this->cdata);
1526  break;
1527 
1528  case "GeneralInterest":
1529  case "OfferingHelp":
1530  case "LookingForHelp":
1531  $this->multi_values[$a_name][] = $this->cdata;
1532  break;
1533 
1534  case "Comment":
1535  $this->userObj->setComment($this->cdata);
1536  break;
1537 
1538  case "Department":
1539  $this->userObj->setDepartment($this->cdata);
1540  break;
1541 
1542  case "Matriculation":
1543  $this->userObj->setMatriculation($this->cdata);
1544  break;
1545 
1546  case "Active":
1547  $this->currActive = $this->cdata;
1548  break;
1549 
1550  case "ClientIP":
1551  $this->userObj->setClientIP($this->cdata);
1552  break;
1553 
1554  case "TimeLimitOwner":
1555  $this->time_limit_owner_set = true;
1556  $this->userObj->setTimeLimitOwner($this->cdata);
1557  break;
1558 
1559  case "TimeLimitUnlimited":
1560  $this->time_limit_set = true;
1561  $this->userObj->setTimeLimitUnlimited($this->cdata);
1562  break;
1563 
1564  case "TimeLimitFrom":
1565  if (is_numeric($this->cdata))
1566  {
1567  // Treat cdata as a unix timestamp
1568  $this->userObj->setTimeLimitFrom($this->cdata);
1569  }
1570  else
1571  {
1572  // Try to convert cdata into unix timestamp, or ignore it
1573  $timestamp = strtotime($this->cdata);
1574  if ($timestamp !== false && trim($this->cdata) != "0000-00-00 00:00:00")
1575  {
1576  $this->userObj->setTimeLimitFrom($timestamp);
1577  }
1578  elseif ($this->cdata == "0000-00-00 00:00:00")
1579  {
1580  $this->userObj->setTimeLimitFrom(null);
1581  }
1582 
1583  }
1584  break;
1585 
1586  case "TimeLimitUntil":
1587  if (is_numeric($this->cdata))
1588  {
1589  // Treat cdata as a unix timestamp
1590  $this->userObj->setTimeLimitUntil($this->cdata);
1591  }
1592  else
1593  {
1594  // Try to convert cdata into unix timestamp, or ignore it
1595  $timestamp = strtotime($this->cdata);
1596  if ($timestamp !== false && trim($this->cdata) != "0000-00-00 00:00:00")
1597  {
1598  $this->userObj->setTimeLimitUntil($timestamp);
1599  }
1600  elseif ($this->cdata == "0000-00-00 00:00:00")
1601  {
1602  $this->userObj->setTimeLimitUntil(null);
1603  }
1604  }
1605  break;
1606 
1607  case "TimeLimitMessage":
1608  $this->userObj->setTimeLimitMessage($this->cdata);
1609  break;
1610 
1611  case "ApproveDate":
1612  $this->approve_date_set = true;
1613  if (is_numeric($this->cdata))
1614  {
1615  // Treat cdata as a unix timestamp
1616  $tmp_date = new ilDateTime($this->cdata,IL_CAL_UNIX);
1617  $this->userObj->setApproveDate($tmp_date->get(IL_CAL_DATETIME));
1618  }
1619  else
1620  {
1621  // Try to convert cdata into unix timestamp, or ignore it
1622  $timestamp = strtotime($this->cdata);
1623  if ($timestamp !== false && trim($this->cdata) != "0000-00-00 00:00:00")
1624  {
1625  $tmp_date = new ilDateTime($timestamp,IL_CAL_UNIX);
1626  $this->userObj->setApproveDate($tmp_date->get(IL_CAL_DATETIME));
1627  }
1628  elseif ($this->cdata == "0000-00-00 00:00:00")
1629  {
1630  $this->userObj->setApproveDate(null);
1631  }
1632  }
1633  break;
1634 
1635  case "AgreeDate":
1636  if (is_numeric($this->cdata))
1637  {
1638  // Treat cdata as a unix timestamp
1639  $tmp_date = new ilDateTime($this->cdata,IL_CAL_UNIX);
1640  $this->userObj->setAgreeDate($tmp_date->get(IL_CAL_DATETIME));
1641  }
1642  else
1643  {
1644  // Try to convert cdata into unix timestamp, or ignore it
1645  $timestamp = strtotime($this->cdata);
1646  if ($timestamp !== false && trim($this->cdata) != "0000-00-00 00:00:00")
1647  {
1648  $tmp_date = new ilDateTime($timestamp,IL_CAL_UNIX);
1649  $this->userObj->setAgreeDate($tmp_date->get(IL_CAL_DATETIME));
1650  }
1651  elseif ($this->cdata == "0000-00-00 00:00:00")
1652  {
1653  $this->userObj->setAgreeDate(null);
1654  }
1655  }
1656  break;
1657 
1658  case "ExternalAccount":
1659  $this->userObj->setExternalAccount($this->cdata);
1660  break;
1661 
1662  case "Look":
1663  $this->updateLookAndSkin = false;
1664  if (!$this->hideSkin)
1665  {
1666  // TODO: what to do with disabled skins? is it possible to change the skin via import?
1667  if ((strlen($this->skin) > 0) && (strlen($this->style) > 0))
1668  {
1669  if (is_array($this->userStyles))
1670  {
1671  if (in_array($this->skin . ":" . $this->style, $this->userStyles))
1672  {
1673  $this->userObj->setPref("skin", $this->skin);
1674  $this->userObj->setPref("style", $this->style);
1675  $this->updateLookAndSkin = true;
1676  }
1677  }
1678  }
1679  }
1680  break;
1681 
1682  case 'UserDefinedField':
1683  include_once './Services/User/classes/class.ilUserDefinedFields.php';
1685  if($field_id = $udf->fetchFieldIdFromImportId($this->tmp_udf_id))
1686  {
1687  $this->udf_data[$field_id] = $this->cdata;
1688  }
1689  elseif($field_id = $udf->fetchFieldIdFromName($this->tmp_udf_name))
1690  {
1691  $this->udf_data[$field_id] = $this->cdata;
1692  }
1693  break;
1694  case 'AccountInfo':
1695  if($this->current_messenger_type =="external")
1696  {
1697  $this->userObj->setExternalAccount($this->cdata);
1698  }
1699  break;
1700  case 'Pref':
1701  if ($this->currentPrefKey != null && strlen(trim($this->cdata)) > 0
1702  && ilUserXMLWriter::isPrefExportable($this->currentPrefKey))
1703  $this->prefs[$this->currentPrefKey] = trim($this->cdata);
1704  $this->currentPrefKey = null;
1705  break;
1706  }
1707  }
Class for user related exception handling in ILIAS.
static getUserIdByLogin($a_login)
static _lookupExternalAccount($a_user_id)
lookup external account for login and authmethod
const IL_PASSWD_PLAIN
sendAccountMail()
send account mail
const IL_CAL_DATETIME
static _getInstance()
Get instance.
Class ilUserDefinedData.
const IL_PASSWD_CRYPTED
"color:#CC0000 style
Definition: example_001.php:92
const IL_FAIL_ON_CONFLICT
assignToRole($a_user_obj, $a_role_id)
Assigns a user to a role.
checkProfileIncomplete($user_obj)
Check if profile is incomplete Will set the usr_data field profile_incomplete if any required field i...
$currPasswordType
The password type of the current user.
static isPrefExportable($key)
returns wether a key from db is exportable or not
const IL_CAL_UNIX
static _getAuthModeName($a_auth_key)
logWarning($aLogin, $aMessage)
Writes a warning log message to the protocol.
assignToRoleWithParents($a_user_obj, $a_role_id)
Assigns a user to a role and to all parent roles.
date( 'd-M-Y', $objPHPExcel->getProperties() ->getCreated())
Date and time handling
$ilUser
Definition: imgupload.php:18
static _uploadPersonalPicture($tmp_file, $obj_id)
Create a personal picture image file from a temporary image file.
logFailure($aLogin, $aMessage)
Writes a failure log message to the protocol.
Create styles array
The data for the language used.
foreach($mandatory_scripts as $file) $timestamp
Definition: buildRTE.php:81
logSuccess($aLogin, $userid, $action)
Writes a success log message to the protocol.
saveTempImage($image_data, $filename)
Saves binary image data to a temporary image file and returns the name of the image file on success...
set($a_field, $a_value)
global $ilSetting
Definition: privfeed.php:17
detachFromRole($a_user_obj, $a_role_id)
Detachs a user from a role.
static _checkExternalAuthAccount($a_auth, $a_account)
check whether external account and authentication method matches with a user
const IL_UPDATE_ON_CONFLICT
const IL_IGNORE_ON_CONFLICT
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isFieldRequired()

ilUserImportParser::isFieldRequired (   $fieldname)
protected

determine if a field $fieldname is to a required field (global setting)

Parameters
$fieldnamestring value of fieldname, e.g. gender
Returns
true, if field of required fields contains fieldname as key, false otherwise.

Definition at line 2368 of file class.ilUserImportParser.php.

References readRequiredFields().

Referenced by verifyEndTag().

2369  {
2370  $requiredFields = $this->readRequiredFields();
2371  $fieldname = strtolower(trim($fieldname));
2372  return array_key_exists($fieldname, $requiredFields);
2373  }
readRequiredFields()
read required fields
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isSendMail()

ilUserImportParser::isSendMail ( )

read access to property send mail

Returns
boolean

Definition at line 2297 of file class.ilUserImportParser.php.

References $send_mail.

Referenced by sendAccountMail().

2297  {
2298  return $this->send_mail;
2299  }
+ Here is the caller graph for this function:

◆ isSuccess()

ilUserImportParser::isSuccess ( )

Returns true, if the import was successful.

Definition at line 2203 of file class.ilUserImportParser.php.

References IL_IMPORT_SUCCESS.

2204  {
2205  return $this->error_level == IL_IMPORT_SUCCESS;
2206  }
const IL_IMPORT_SUCCESS

◆ logFailure()

ilUserImportParser::logFailure (   $aLogin,
  $aMessage 
)

Writes a failure log message to the protocol.

Parameters
stringlogin
stringmessage

Definition at line 2129 of file class.ilUserImportParser.php.

References array, and IL_IMPORT_FAILURE.

Referenced by importBeginTag(), importEndTag(), verifyBeginTag(), verifyEndTag(), and verifyPref().

2130  {
2131  if (! array_key_exists($aLogin, $this->protocol))
2132  {
2133  $this->protocol[$aLogin] = array();
2134  }
2135  if ($aMessage)
2136  {
2137  $this->protocol[$aLogin][] = $aMessage;
2138  }
2139  $this->error_level = IL_IMPORT_FAILURE;
2140  }
const IL_IMPORT_FAILURE
Create styles array
The data for the language used.
+ Here is the caller graph for this function:

◆ logSuccess()

ilUserImportParser::logSuccess (   $aLogin,
  $userid,
  $action 
)

Writes a success log message to the protocol.

Parameters
stringlogin
stringuserid
stringaction

Definition at line 2149 of file class.ilUserImportParser.php.

References array.

Referenced by importEndTag().

2150  {
2151  $this->user_mapping[$userid] = array("login" => $aLogin, "action" => $action, "message" => "successful");
2152  }
$action
The Action attribute determines what to do for the current User element.
Create styles array
The data for the language used.
+ Here is the caller graph for this function:

◆ logWarning()

ilUserImportParser::logWarning (   $aLogin,
  $aMessage 
)

Writes a warning log message to the protocol.

Parameters
stringlogin
stringmessage

Definition at line 2108 of file class.ilUserImportParser.php.

References array, IL_IMPORT_SUCCESS, and IL_IMPORT_WARNING.

Referenced by importEndTag(), and verifyEndTag().

2109  {
2110  if (! array_key_exists($aLogin, $this->protocol))
2111  {
2112  $this->protocol[$aLogin] = array();
2113  }
2114  if ($aMessage)
2115  {
2116  $this->protocol[$aLogin][] = $aMessage;
2117  }
2118  if ($this->error_level == IL_IMPORT_SUCCESS)
2119  {
2120  $this->error_level = IL_IMPORT_WARNING;
2121  }
2122  }
const IL_IMPORT_WARNING
const IL_IMPORT_SUCCESS
Create styles array
The data for the language used.
+ Here is the caller graph for this function:

◆ readAccountMailFromCache()

ilUserImportParser::readAccountMailFromCache (   $lang_key)
private
Parameters
$lang_key
Returns
mixed

Definition at line 2254 of file class.ilUserImportParser.php.

References $GLOBALS, and ilObjUserFolder\_lookupNewAccountMail().

Referenced by sendAccountMail().

2255  {
2256  if(!isset(self::$account_mail_cache[$lang_key]))
2257  {
2258  $default_lang_key = $GLOBALS["lng"]->getDefaultLanguage();
2259 
2260  // try individual account mail in user administration
2261  include_once './Services/User/classes/class.ilObjUserFolder.php';
2262 
2263  $amail = ilObjUserFolder::_lookupNewAccountMail($lang_key);
2264 
2265  if (trim($amail["body"]) != "" && trim($amail["subject"]) != "")
2266  {
2267  self::$account_mail_cache[$lang_key] = $amail;
2268  }
2269  else
2270  {
2271  $lang_key = $default_lang_key;
2272  }
2273 
2274  if(!isset(self::$account_mail_cache[$default_lang_key]))
2275  {
2276  $amail = ilObjUserFolder::_lookupNewAccountMail($default_lang_key);
2277  self::$account_mail_cache[$default_lang_key] = $amail;
2278  }
2279  }
2280  return self::$account_mail_cache[$lang_key];
2281  }
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
static _lookupNewAccountMail($a_lang)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ readRequiredFields()

ilUserImportParser::readRequiredFields ( )
private

read required fields

private

Definition at line 2329 of file class.ilUserImportParser.php.

References $ilSetting, and array.

Referenced by isFieldRequired().

2330  {
2331  global $ilSetting;
2332 
2333  if(is_array($this->required_fields))
2334  {
2335  return $this->required_fields;
2336  }
2337  foreach($ilSetting->getAll() as $field => $value)
2338  {
2339  if(substr($field,0,8) == 'require_' and $value == 1)
2340  {
2341  $value = substr($field,8);
2342  $this->required_fields[$value] = $value;
2343  }
2344  }
2345  return $this->required_fields ? $this->required_fields : array();
2346  }
Create styles array
The data for the language used.
global $ilSetting
Definition: privfeed.php:17
+ Here is the caller graph for this function:

◆ saveTempImage()

ilUserImportParser::saveTempImage (   $image_data,
  $filename 
)

Saves binary image data to a temporary image file and returns the name of the image file on success.

Definition at line 1713 of file class.ilUserImportParser.php.

References $fh, $filename, and ilUtil\ilTempnam().

Referenced by importEndTag().

1714  {
1715  $tempname = ilUtil::ilTempnam() . $filename;
1716  $fh = fopen($tempname, "wb");
1717  if ($fh == false)
1718  {
1719  return "";
1720  }
1721  $imagefile = fwrite($fh, $image_data);
1722  fclose($fh);
1723  return $tempname;
1724  }
static ilTempnam($a_temp_path=null)
Create a temporary file in an ILIAS writable directory.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ sendAccountMail()

ilUserImportParser::sendAccountMail ( )

send account mail

Definition at line 2229 of file class.ilUserImportParser.php.

References $_POST, $path, isSendMail(), readAccountMailFromCache(), and USER_FOLDER_ID.

Referenced by importEndTag().

2230  {
2231  if($_POST["send_mail"] != "" ||
2232  ($this->isSendMail() && $this->userObj->getEmail() != ""))
2233  {
2234  $this->acc_mail->setUser($this->userObj);
2235 
2236  $amail = $this->readAccountMailFromCache($this->userObj->getLanguage());
2237  if($amail["att_file"])
2238  {
2239  include_once "Services/User/classes/class.ilFSStorageUserFolder.php";
2241  $fs->create();
2242  $path = $fs->getAbsolutePath() . "/";
2243 
2244  $this->acc_mail->addAttachment($path . "/" . $amail["lang"], $amail["att_file"]);
2245  }
2246  $this->acc_mail->send();
2247  }
2248  }
$path
Definition: aliased.php:25
isSendMail()
read access to property send mail
const USER_FOLDER_ID
Class ilObjUserFolder.
$_POST["username"]
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setFolderId()

ilUserImportParser::setFolderId (   $a_folder_id)

assign users to this folder (normally the usr_folder) But if called from local admin => the ref_id of the category public

Definition at line 350 of file class.ilUserImportParser.php.

351  {
352  $this->folder_id = $a_folder_id;
353  }

◆ setHandlers()

ilUserImportParser::setHandlers (   $a_xml_parser)

set event handler should be overwritten by inherited class private

Definition at line 365 of file class.ilUserImportParser.php.

366  {
367  xml_set_object($a_xml_parser,$this);
368  xml_set_element_handler($a_xml_parser,'handlerBeginTag','handlerEndTag');
369  xml_set_character_data_handler($a_xml_parser,'handlerCharacterData');
370  }

◆ setRoleAssignment()

ilUserImportParser::setRoleAssignment (   $a_assign)

set import to local role assignemt

Parameters
arrayrole assignment (key: import id; value: local role id)

Definition at line 385 of file class.ilUserImportParser.php.

386  {
387  $this->role_assign = $a_assign;
388  }

◆ setSendMail()

ilUserImportParser::setSendMail (   $value)

write access to property send mail

Parameters
mixed$value

Definition at line 2288 of file class.ilUserImportParser.php.

2288  {
2289  $this->send_mail = $value ? true: false;
2290  }

◆ setUserMappingMode()

ilUserImportParser::setUserMappingMode (   $value)

write access to user mapping mode

Parameters
int$valuemust be one of IL_USER_MAPPING_ID or IL_USER_MAPPING_LOGIN, die otherwise

Definition at line 2306 of file class.ilUserImportParser.php.

References IL_USER_MAPPING_ID, and IL_USER_MAPPING_LOGIN.

2307  {
2308  if ($value == IL_USER_MAPPING_ID || $value == IL_USER_MAPPING_LOGIN)
2309  $this->mapping_mode = $value;
2310  else die ("wrong argument using methode setUserMappingMethod in ".__FILE__);
2311  }
const IL_USER_MAPPING_LOGIN
const IL_USER_MAPPING_ID

◆ startParsing()

ilUserImportParser::startParsing ( )

start the parser

Definition at line 375 of file class.ilUserImportParser.php.

376  {
377  parent::startParsing();
378  }

◆ updateMailPreferences()

ilUserImportParser::updateMailPreferences (   $usr_id)
private

Definition at line 2466 of file class.ilUserImportParser.php.

Referenced by importEndTag().

2466  {
2467  if (array_key_exists("mail_incoming_type", $this->prefs) ||
2468  array_key_exists("mail_signature", $this->prefs) ||
2469  array_key_exists("mail_linebreak", $this->prefs)
2470  )
2471  {
2472  include_once("Services/Mail/classes/class.ilMailOptions.php");
2473  $mailOptions = new ilMailOptions($usr_id);
2474  $mailOptions->updateOptions(
2475  array_key_exists("mail_signature", $this->prefs) ? $this->prefs["mail_signature"] : $mailOptions->getSignature(),
2476  array_key_exists("mail_linebreak", $this->prefs) ? $this->prefs["mail_linebreak"] : $mailOptions->getLinebreak(),
2477  array_key_exists("mail_incoming_type", $this->prefs) ? $this->prefs["mail_incoming_type"] : $mailOptions->getIncomingType(),
2478  $mailOptions->getCronjobNotification()
2479  );
2480  }
2481  }
Class UserMail this class handles user mails.
+ Here is the caller graph for this function:

◆ verifyBeginTag()

ilUserImportParser::verifyBeginTag (   $a_xml_parser,
  $a_name,
  $a_attribs 
)

handler for begin of element

Definition at line 608 of file class.ilUserImportParser.php.

References $action, ilSaxParser\$lng, ilUtil\__extractId(), ilLDAPServer\_getActiveServerList(), getUserMappingMode(), IL_USER_MAPPING_ID, and logFailure().

Referenced by handlerBeginTag().

609  {
610  global $lng;
611 
612  switch($a_name)
613  {
614  case "Role":
615  if (is_null($a_attribs['Id'])
616  || $a_attribs['Id'] == "")
617  {
618  $this->logFailure($this->userObj->getLogin(), sprintf($lng->txt("usrimport_xml_attribute_missing"),"Role","Id"));
619  }
620  $this->current_role_id = $a_attribs["Id"];
621  $this->current_role_type = $a_attribs["Type"];
622  if ($this->current_role_type != 'Global'
623  && $this->current_role_type != 'Local')
624  {
625  $this->logFailure($this->userObj->getLogin(), sprintf($lng->txt("usrimport_xml_attribute_missing"),"Role","Type"));
626  }
627  $this->current_role_action = (is_null($a_attribs["Action"])) ? "Assign" : $a_attribs["Action"];
628  if ($this->current_role_action != "Assign"
629  && $this->current_role_action != "AssignWithParents"
630  && $this->current_role_action != "Detach")
631  {
632  $this->logFailure($this->userObj->getLogin(), sprintf($lng->txt("usrimport_xml_attribute_value_illegal"),"Role","Action",$a_attribs["Action"]));
633  }
634  if ($this->action == "Insert"
635  && $this->current_role_action == "Detach")
636  {
637  $this->logFailure($this->userObj->getLogin(), sprintf($lng->txt("usrimport_xml_attribute_value_inapplicable"),"Role","Action",$this->current_role_action,$this->action));
638  }
639  if ($this->action == "Delete")
640  {
641  $this->logFailure($this->userObj->getLogin(), sprintf($lng->txt("usrimport_xml_element_inapplicable"),"Role","Delete"));
642  }
643  break;
644 
645  case "User":
646  $this->userCount++;
647  $this->userObj = new ilObjUser();
648  $this->userObj->setLanguage($a_attribs["Language"]);
649  $this->userObj->setImportId($a_attribs["Id"]);
650  $this->currentPrefKey = null;
651  // if we have an object id, store it
652  $this->user_id = -1;
653 
654  if (!is_null($a_attribs["Id"]) && $this->getUserMappingMode() == IL_USER_MAPPING_ID)
655  {
656  if (is_numeric($a_attribs["Id"]))
657  {
658  $this->user_id = $a_attribs["Id"];
659  }
660  elseif ($id = ilUtil::__extractId ($a_attribs["Id"], IL_INST_ID))
661  {
662  $this->user_id = $id;
663  }
664  }
665 
666  $this->action = (is_null($a_attribs["Action"])) ? "Insert" : $a_attribs["Action"];
667  if ($this->action != "Insert"
668  && $this->action != "Update"
669  && $this->action != "Delete")
670  {
671  $this->logFailure($this->userObj->getImportId(), sprintf($lng->txt("usrimport_xml_attribute_value_illegal"),"User","Action",$a_attribs["Action"]));
672  }
673  $this->currPassword = null;
674  $this->currPasswordType = null;
675  break;
676 
677  case 'Password':
678  $this->currPasswordType = $a_attribs['Type'];
679  break;
680  case "AuthMode":
681  if (array_key_exists("type", $a_attribs))
682  {
683  switch($a_attribs["type"])
684  {
685  case "default":
686  case "local":
687  case "ldap":
688 
689  if(strcmp('ldap', $a_attribs['type']) === 0)
690  {
691  // no server id provided
692  include_once './Services/LDAP/classes/class.ilLDAPServer.php';
694  if(count($list) != 1)
695  {
696  $this->logFailure(
697  $this->userObj->getImportId(),
698  sprintf($lng->txt("usrimport_xml_attribute_value_illegal"),"AuthMode","type",$a_attribs['type']));
699  }
700  }
701  break;
702 
703  case "radius":
704  case "shibboleth":
705  case "script":
706  case "cas":
707  case "soap":
708  case "openid":
709  // begin-patch auth_plugin
710  default:
711  $this->userObj->setAuthMode($a_attribs["type"]);
712  break;
713  /*
714  default:
715  $this->logFailure($this->userObj->getImportId(), sprintf($lng->txt("usrimport_xml_attribute_value_illegal"),"AuthMode","type",$a_attribs["type"]));
716  break;
717  *
718  */
719  }
720  }
721  else
722  {
723  $this->logFailure($this->userObj->getImportId(), sprintf($lng->txt("usrimport_xml_attribute_value_illegal"),"AuthMode","type",""));
724  }
725  break;
726  case 'Pref':
727  $this->currentPrefKey = $a_attribs["key"];
728  break;
729 
730  }
731  }
getUserMappingMode()
read access to user mapping mode
static _getActiveServerList()
Get active server list.
$action
The Action attribute determines what to do for the current User element.
const IL_USER_MAPPING_ID
logFailure($aLogin, $aMessage)
Writes a failure log message to the protocol.
static __extractId($ilias_id, $inst_id)
extract ref id from role title, e.g.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ verifyEndTag()

ilUserImportParser::verifyEndTag (   $a_xml_parser,
  $a_name 
)

handler for end of element when in verify mode.

Definition at line 1729 of file class.ilUserImportParser.php.

References $currPasswordType, $ilSetting, ilSaxParser\$lng, $user_id, ilObjUser\_checkExternalAuthAccount(), ilAuthUtils\_getAuthModeName(), ilObjUser\_lookupExternalAccount(), ilObjUser\_lookupId(), ilObjUser\_lookupLogin(), array, ilObjUser\getUserIdByLogin(), IL_FAIL_ON_CONFLICT, IL_PASSWD_CRYPTED, IL_PASSWD_PLAIN, isFieldRequired(), logFailure(), logWarning(), USER_FOLDER_ID, and verifyPref().

Referenced by handlerEndTag().

1730  {
1731  global $lng,$ilAccess,$ilSetting,$ilObjDataCache;
1732 
1733  switch($a_name)
1734  {
1735  case "Role":
1736  $this->roles[$this->current_role_id]["name"] = $this->cdata;
1737  $this->roles[$this->current_role_id]["type"] = $this->current_role_type;
1738  $this->roles[$this->current_role_id]["action"] = $this->current_role_action;
1739  break;
1740 
1741  case "User":
1742  $this->userObj->setFullname();
1743  if ($this->user_id != -1 && ($this->action == "Update" || $this->action == "Delete"))
1744  $user_exists = !is_null(ilObjUser::_lookupLogin($this->user_id));
1745  else
1746  $user_exists = ilObjUser::getUserIdByLogin($this->userObj->getLogin()) != 0;
1747 
1748  if (is_null($this->userObj->getLogin()))
1749  {
1750  $this->logFailure("---",sprintf($lng->txt("usrimport_xml_element_for_action_required"),"Login", "Insert"));
1751  }
1752 
1753  switch ($this->action)
1754  {
1755  case "Insert" :
1756  if ($user_exists and $this->conflict_rule == IL_FAIL_ON_CONFLICT)
1757  {
1758  $this->logWarning($this->userObj->getLogin(),$lng->txt("usrimport_cant_insert"));
1759  }
1760  if (is_null($this->userObj->getGender()) && $this->isFieldRequired("gender"))
1761  {
1762  $this->logFailure($this->userObj->getLogin(),sprintf($lng->txt("usrimport_xml_element_for_action_required"),"Gender", "Insert"));
1763  }
1764  if (is_null($this->userObj->getFirstname()))
1765  {
1766  $this->logFailure($this->userObj->getLogin(),sprintf($lng->txt("usrimport_xml_element_for_action_required"),"Firstname", "Insert"));
1767  }
1768  if (is_null($this->userObj->getLastname()))
1769  {
1770  $this->logFailure($this->userObj->getLogin(),sprintf($lng->txt("usrimport_xml_element_for_action_required"),"Lastname", "Insert"));
1771  }
1772  if (count($this->roles) == 0)
1773  {
1774  $this->logFailure($this->userObj->getLogin(),sprintf($lng->txt("usrimport_xml_element_for_action_required"),"Role", "Insert"));
1775  }
1776  else
1777  {
1778  $has_global_role = false;
1779  foreach ($this->roles as $role)
1780  {
1781  if ($role['type'] == 'Global')
1782  {
1783  $has_global_role = true;
1784  break;
1785  }
1786  }
1787  if (! $has_global_role)
1788  {
1789  $this->logFailure($this->userObj->getLogin(),sprintf($lng->txt("usrimport_global_role_for_action_required"),"Insert"));
1790  }
1791  }
1792  break;
1793  case "Update" :
1794  if(!$user_exists)
1795  {
1796  $this->logWarning($this->userObj->getLogin(),$lng->txt("usrimport_cant_update"));
1797  }
1798  elseif($this->user_id != -1 && !is_null($this->userObj->getLogin()))
1799  // check if someone owns the new login name!
1800  {
1801  $someonesId = ilObjUser::_lookupId($this->userObj->getLogin());
1802 
1803  if (is_numeric($someonesId ) && $someonesId != $this->user_id) {
1804  $this->logFailure($this->userObj->getLogin(), $lng->txt("usrimport_login_is_not_unique"));
1805  }
1806  }
1807  break;
1808  case "Delete" :
1809  if(!$user_exists)
1810  {
1811  $this->logWarning($this->userObj->getLogin(),$lng->txt("usrimport_cant_delete"));
1812  }
1813  break;
1814  }
1815 
1816  // init role array for next user
1817  $this->roles = array();
1818  break;
1819 
1820  case "Login":
1821  if (array_key_exists($this->cdata, $this->logins))
1822  {
1823  $this->logWarning($this->cdata, $lng->txt("usrimport_login_is_not_unique"));
1824  }
1825  else
1826  {
1827  $this->logins[$this->cdata] = $this->cdata;
1828  }
1829  $this->userObj->setLogin($this->cdata);
1830  break;
1831 
1832  case "Password":
1833  switch ($this->currPasswordType)
1834  {
1835  case "BCRYPT":
1836  $this->userObj->setPasswd($this->cdata, IL_PASSWD_CRYPTED);
1837  $this->userObj->setPasswordEncodingType('bcryptphp');
1838  $this->userObj->setPasswordSalt(null);
1839  break;
1840 
1841  case "PLAIN":
1842  $this->userObj->setPasswd($this->cdata, IL_PASSWD_PLAIN);
1843  $this->acc_mail->setUserPassword($this->currPassword);
1844  break;
1845 
1846  default :
1847  $this->logFailure($this->userObj->getLogin(), sprintf($lng->txt("usrimport_xml_attribute_value_illegal"),"Type","Password",$this->currPasswordType));
1848  break;
1849  }
1850  break;
1851 
1852  case "Firstname":
1853  $this->userObj->setFirstname($this->cdata);
1854  break;
1855 
1856  case "Lastname":
1857  $this->userObj->setLastname($this->cdata);
1858  break;
1859 
1860  case "Title":
1861  $this->userObj->setUTitle($this->cdata);
1862  break;
1863 
1864  case "Gender":
1865  if ($this->cdata != "m"
1866  && $this->cdata != "f")
1867  {
1868  $this->logFailure(
1869  $this->userObj->getLogin(),
1870  sprintf($lng->txt("usrimport_xml_element_content_illegal"),"Gender",$this->cdata)
1871  );
1872  }
1873  $this->userObj->setGender($this->cdata);
1874  break;
1875 
1876  case "Email":
1877  $this->userObj->setEmail($this->cdata);
1878  break;
1879 
1880  case "Institution":
1881  $this->userObj->setInstitution($this->cdata);
1882  break;
1883 
1884  case "Street":
1885  $this->userObj->setStreet($this->cdata);
1886  break;
1887 
1888  case "City":
1889  $this->userObj->setCity($this->cdata);
1890  break;
1891 
1892  case "PostalCode":
1893  $this->userObj->setZipCode($this->cdata);
1894  break;
1895 
1896  case "Country":
1897  $this->userObj->setCountry($this->cdata);
1898  break;
1899 
1900  case "SelCountry":
1901  $this->userObj->setSelectedCountry($this->cdata);
1902  break;
1903 
1904  case "PhoneOffice":
1905  $this->userObj->setPhoneOffice($this->cdata);
1906  break;
1907 
1908  case "PhoneHome":
1909  $this->userObj->setPhoneHome($this->cdata);
1910  break;
1911 
1912  case "PhoneMobile":
1913  $this->userObj->setPhoneMobile($this->cdata);
1914  break;
1915 
1916  case "Fax":
1917  $this->userObj->setFax($this->cdata);
1918  break;
1919 
1920  case "Hobby":
1921  $this->userObj->setHobby($this->cdata);
1922  break;
1923 
1924  case "GeneralInterest":
1925  case "OfferingHelp":
1926  case "LookingForHelp":
1927  $this->multi_values[$a_name][] = $this->cdata;
1928  break;
1929 
1930  case "Comment":
1931  $this->userObj->setComment($this->cdata);
1932  break;
1933 
1934  case "Department":
1935  $this->userObj->setDepartment($this->cdata);
1936  break;
1937 
1938  case "Matriculation":
1939  $this->userObj->setMatriculation($this->cdata);
1940  break;
1941 
1942  case "ExternalAccount":
1943 //echo "-".$this->userObj->getAuthMode()."-".$this->userObj->getLogin()."-";
1944  $am = ($this->userObj->getAuthMode() == "default" || $this->userObj->getAuthMode() == "")
1945  ? ilAuthUtils::_getAuthModeName($ilSetting->get('auth_mode'))
1946  : $this->userObj->getAuthMode();
1947  $loginForExternalAccount = (trim($this->cdata) == "")
1948  ? ""
1949  : ilObjUser::_checkExternalAuthAccount($am, trim($this->cdata));
1950  switch ($this->action)
1951  {
1952  case "Insert" :
1953  if ($loginForExternalAccount != "")
1954  {
1955  $this->logWarning($this->userObj->getLogin(), $lng->txt("usrimport_no_insert_ext_account_exists")." (".$this->cdata.")");
1956  }
1957  break;
1958 
1959  case "Update" :
1960  if ($loginForExternalAccount != "")
1961  {
1962  $externalAccountHasChanged = trim($this->cdata) != ilObjUser::_lookupExternalAccount($this->user_id);
1963  if ($externalAccountHasChanged && trim($loginForExternalAccount) != trim($this->userObj->getLogin()))
1964  {
1965  $this->logWarning($this->userObj->getLogin(),
1966  $lng->txt("usrimport_no_update_ext_account_exists")." (".$this->cdata." for ".$loginForExternalAccount.")");
1967  }
1968  }
1969  break;
1970 
1971  }
1972  if ($externalAccountHasChanged)
1973  $this->userObj->setExternalAccount(trim($this->cdata));
1974  break;
1975 
1976  case "Active":
1977  if ($this->cdata != "true"
1978  && $this->cdata != "false")
1979  {
1980  $this->logFailure($this->userObj->getLogin(),
1981  sprintf($lng->txt("usrimport_xml_element_content_illegal"),"Active",$this->cdata));
1982  }
1983  $this->currActive = $this->cdata;
1984  break;
1985  case "TimeLimitOwner":
1986  if (!preg_match("/\d+/", $this->cdata))
1987  {
1988  $this->logFailure($this->userObj->getLogin(),
1989  sprintf($lng->txt("usrimport_xml_element_content_illegal"),"TimeLimitOwner",$this->cdata));
1990  }
1991  elseif(!$ilAccess->checkAccess('cat_administrate_users','',$this->cdata))
1992  {
1993  $this->logFailure($this->userObj->getLogin(),
1994  sprintf($lng->txt("usrimport_xml_element_content_illegal"),"TimeLimitOwner",$this->cdata));
1995  }
1996  elseif($ilObjDataCache->lookupType($ilObjDataCache->lookupObjId($this->cdata)) != 'cat' && !(int) $this->cdata == USER_FOLDER_ID)
1997  {
1998  $this->logFailure($this->userObj->getLogin(),
1999  sprintf($lng->txt("usrimport_xml_element_content_illegal"),"TimeLimitOwner",$this->cdata));
2000 
2001  }
2002  $this->userObj->setTimeLimitOwner($this->cdata);
2003  break;
2004  case "TimeLimitUnlimited":
2005  switch (strtolower($this->cdata))
2006  {
2007  case "true":
2008  case "1":
2009  $this->userObj->setTimeLimitUnlimited(1);
2010  break;
2011  case "false":
2012  case "0":
2013  $this->userObj->setTimeLimitUnlimited(0);
2014  break;
2015  default:
2016  $this->logFailure($this->userObj->getLogin(), sprintf($lng->txt("usrimport_xml_element_content_illegal"),"TimeLimitUnlimited",$this->cdata));
2017  break;
2018  }
2019  break;
2020  case "TimeLimitFrom":
2021  // Accept datetime or Unix timestamp
2022  if (strtotime($this->cdata) === false && ! is_numeric($this->cdata))
2023  {
2024  $this->logFailure($this->userObj->getLogin(), sprintf($lng->txt("usrimport_xml_element_content_illegal"),"TimeLimitFrom",$this->cdata));
2025  }
2026  $this->userObj->setTimeLimitFrom($this->cdata);
2027  break;
2028  case "TimeLimitUntil":
2029  // Accept datetime or Unix timestamp
2030  if (strtotime($this->cdata) === false && ! is_numeric($this->cdata))
2031  {
2032  $this->logFailure($this->userObj->getLogin(), sprintf($lng->txt("usrimport_xml_element_content_illegal"),"TimeLimitUntil",$this->cdata));
2033  }
2034  $this->userObj->setTimeLimitUntil($this->cdata);
2035  break;
2036  case "TimeLimitMessage":
2037  switch (strtolower($this->cdata))
2038  {
2039  case "1":
2040  $this->userObj->setTimeLimitMessage(1);
2041  break;
2042  case "0":
2043  $this->userObj->setTimeLimitMessage(0);
2044  break;
2045  default:
2046  $this->logFailure($this->userObj->getLogin(), sprintf($lng->txt("usrimport_xml_element_content_illegal"),"TimeLimitMessage",$this->cdata));
2047  break;
2048  }
2049  break;
2050  case "ApproveDate":
2051  // Accept datetime or Unix timestamp
2052  if (strtotime($this->cdata) === false && ! is_numeric($this->cdata) && !$this->cdata == "0000-00-00 00:00:00")
2053  {
2054  $this->logFailure($this->userObj->getLogin(), sprintf($lng->txt("usrimport_xml_element_content_illegal"),"ApproveDate",$this->cdata));
2055  }
2056  break;
2057  case "AgreeDate":
2058  // Accept datetime or Unix timestamp
2059  if (strtotime($this->cdata) === false && ! is_numeric($this->cdata) && !$this->cdata == "0000-00-00 00:00:00")
2060  {
2061  $this->logFailure($this->userObj->getLogin(), sprintf($lng->txt("usrimport_xml_element_content_illegal"),"AgreeDate",$this->cdata));
2062  }
2063  break;
2064  case "Pref":
2065  if ($this->currentPrefKey != null)
2066  $this->verifyPref($this->currentPrefKey, $this->cdata);
2067  $this->currentPrefKey == null;
2068  }
2069  }
static _lookupLogin($a_user_id)
lookup login
static getUserIdByLogin($a_login)
static _lookupExternalAccount($a_user_id)
lookup external account for login and authmethod
const IL_PASSWD_PLAIN
const IL_PASSWD_CRYPTED
static _lookupId($a_user_str)
Lookup id by login.
isFieldRequired($fieldname)
determine if a field $fieldname is to a required field (global setting)
const IL_FAIL_ON_CONFLICT
$currPasswordType
The password type of the current user.
static _getAuthModeName($a_auth_key)
logWarning($aLogin, $aMessage)
Writes a warning log message to the protocol.
logFailure($aLogin, $aMessage)
Writes a failure log message to the protocol.
Create styles array
The data for the language used.
global $ilSetting
Definition: privfeed.php:17
static _checkExternalAuthAccount($a_auth, $a_account)
check whether external account and authentication method matches with a user
const USER_FOLDER_ID
Class ilObjUserFolder.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ verifyPref()

ilUserImportParser::verifyPref (   $key,
  $value 
)
private

Definition at line 2375 of file class.ilUserImportParser.php.

References $tz, ilTimeZone\_getInstance(), array, ilUserXMLWriter\isPrefExportable(), and logFailure().

Referenced by verifyEndTag().

2375  {
2376  switch ($key) {
2377  case 'mail_linebreak':
2378  case 'hits_per_page':
2379  if (!is_numeric($value) || $value < 0)
2380  $this->logFailure("---", "Wrong value '$value': Positiv numeric value expected for preference $key.");
2381  break;
2382  case 'language':
2383  case 'skin':
2384  case 'style':
2385  case 'ilPageEditor_HTMLMode':
2386  case 'ilPageEditor_JavaScript':
2387  case 'ilPageEditor_MediaMode':
2388  case 'tst_javascript':
2389  case 'tst_lastquestiontype':
2390  case 'tst_multiline_answers':
2391  case 'tst_use_previous_answers':
2392  case 'graphicalAnswerSetting':
2393  case 'priv_feed_pass':
2394  $this->logFailure("---", "Preference $key is not supported.");
2395  break;
2396  case 'public_city':
2397  case 'public_country':
2398  case 'public_department':
2399  case 'public_email':
2400  case 'public_fax':
2401  case 'public_hobby':
2402  case 'public_institution':
2403  case 'public_matriculation':
2404  case 'public_phone':
2405  case 'public_phone_home':
2406  case 'public_phone_mobile':
2407  case 'public_phone_office':
2408  case 'public_street':
2409  case 'public_upload':
2410  case 'public_zip':
2411  case 'public_interests_general':
2412  case 'public_interests_help_offered':
2413  case 'public_interests_help_looking':
2414  case 'send_info_mails':
2415  case 'hide_own_online_status':
2416  if (!in_array($value, array('y', 'n')))
2417  $this->logFailure("---", "Wrong value '$value': Value 'y' or 'n' expected for preference $key.");
2418  break;
2419  case 'bs_allow_to_contact_me':
2420  if(!in_array($value, array('y', 'n')))
2421  {
2422  $this->logFailure("---", "Wrong value '$value': Value 'y' or 'n' expected for preference $key.");
2423  }
2424  break;
2425  case 'chat_osc_accept_msg':
2426  if(!in_array($value, array('y', 'n')))
2427  {
2428  $this->logFailure("---", "Wrong value '$value': Value 'y' or 'n' expected for preference $key.");
2429  }
2430  break;
2431  case 'public_profile':
2432  if (!in_array($value, array('y', 'n', 'g')))
2433  $this->logFailure("---", "Wrong value '$value': Value 'y', 'g' or 'n' expected for preference $key.");
2434  break;
2435  case 'show_users_online':
2436  if (!in_array($value, array('y', 'n', 'associated')))
2437  $this->logFailure("---", "Wrong value '$value': Value 'y' or 'n' or 'associated' expected for preference $key.");
2438  break;
2439  case 'mail_incoming_type':
2440  if (!in_array((int) $value, array("0","1","2")))
2441  $this->logFailure("---", "Wrong value '$value': Value \"0\" (LOCAL),\"1\" (EMAIL) or \"2\" (BOTH) expected for preference $key.");
2442  break;
2443  case 'weekstart':
2444  if (!in_array($value, array ("0","1")))
2445  $this->logFailure("---", "Wrong value '$value': Value \"0\" (Sunday) or \"1\" (Monday) expected for preference $key.");
2446  break;
2447 
2448  case 'mail_signature':
2449  break;
2450  case 'user_tz':
2451  include_once('Services/Calendar/classes/class.ilTimeZone.php');
2452  try {
2453  $tz = ilTimeZone::_getInstance($value);
2454  return true;
2455  } catch (ilTimeZoneException $tze) {
2456  $this->logFailure("---", "Wrong value '$value': Invalid timezone $value detected for preference $key.");
2457  }
2458  break;
2459  default:
2461  $this->logFailure("---", "Preference $key is not supported.");
2462  break;
2463  }
2464  }
static isPrefExportable($key)
returns wether a key from db is exportable or not
Class for TimeZone exceptions.
logFailure($aLogin, $aMessage)
Writes a failure log message to the protocol.
Create styles array
The data for the language used.
static _getInstance($a_tz='')
get instance by timezone
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $account_mail_cache

ilUserImportParser::$account_mail_cache = array()
staticprivate

Definition at line 271 of file class.ilUserImportParser.php.

◆ $action

ilUserImportParser::$action

The Action attribute determines what to do for the current User element.

This variable supports the following values: "Insert","Update","Delete".

Definition at line 65 of file class.ilUserImportParser.php.

Referenced by verifyBeginTag().

◆ $approve_date_set

ilUserImportParser::$approve_date_set = false

Definition at line 51 of file class.ilUserImportParser.php.

◆ $conflict_rule

ilUserImportParser::$conflict_rule

Conflict handling rule.

Values: IL_FAIL_ON_CONFLICT IL_UPDATE_ON_CONFLICT IL_IGNORE_ON_CONFLICT

Definition at line 93 of file class.ilUserImportParser.php.

◆ $currActive

ilUserImportParser::$currActive

The active state of the current user.

Definition at line 178 of file class.ilUserImportParser.php.

◆ $current_messenger_type

ilUserImportParser::$current_messenger_type
private

Definition at line 266 of file class.ilUserImportParser.php.

◆ $currPassword

ilUserImportParser::$currPassword

The password of the current user.

Definition at line 173 of file class.ilUserImportParser.php.

◆ $currPasswordType

ilUserImportParser::$currPasswordType

The password type of the current user.

Definition at line 169 of file class.ilUserImportParser.php.

Referenced by importEndTag(), and verifyEndTag().

◆ $disableSkin

ilUserImportParser::$disableSkin

Indicates if the skins are enabled.

Definition at line 246 of file class.ilUserImportParser.php.

◆ $error_level

ilUserImportParser::$error_level

This variable is used to report the error level of the validation process or the importing process.

Values: IL_IMPORT_SUCCESS IL_IMPORT_WARNING IL_IMPORT_FAILURE

Meaning of the values when in validation mode: IL_IMPORT_WARNING Some of the entity actions can not be processed as specified in the XML file. One or more of the following conflicts have occurred:

  • An "Insert" action has been specified for a user who is already in the database.
  • An "Update" action has been specified for a user who is not in the database.
  • A "Delete" action has been specified for a user who is not in the database. IL_IMPORT_FAILURE Some of the XML elements are invalid.

Meaning of the values when in import mode: IL_IMPORT_WARNING Some of the entity actions have not beeen processed as specified in the XML file.

In IL_UPDATE_ON_CONFLICT mode, the following may have occured:

  • An "Insert" action has been replaced by a "Update" action for a user who is already in the database.
    • An "Update" action has been replaced by a "Insert" action for a user who is not in the database.
  • A "Delete" action has been replaced by a "Ignore" action for a user who is not in the database.

In IL_IGNORE_ON_CONFLICT mode, the following may have occured:

  • An "Insert" action has been replaced by a "Ignore" action for a user who is already in the database.
  • An "Update" action has been replaced by a "Ignore" action for a user who is not in the database.
    • A "Delete" action has been replaced by a "Ignore" action for a user who is not in the database.

IL_IMPORT_FAILURE The import could not be completed.

In IL_FAIL_ON_CONFLICT mode, the following may have occured:

  • An "Insert" action has failed for a user who is already in the database.
  • An "Update" action has failed for a user who is not in the database.
  • A "Delete" action has failed for a user who is not in the database.

Definition at line 164 of file class.ilUserImportParser.php.

Referenced by getErrorLevel().

◆ $folder_id

ilUserImportParser::$folder_id

Definition at line 59 of file class.ilUserImportParser.php.

Referenced by getFolderId().

◆ $hideSkin

ilUserImportParser::$hideSkin

Indicates if the skins are hidden.

Definition at line 241 of file class.ilUserImportParser.php.

◆ $localRoleCache

ilUserImportParser::$localRoleCache

Cached local roles.

This is used to speed up access to local roles. This is an associative array. The key is either a role_id or a role_id with the string "_courseMembersObject" appended. The value is a role object or the course members object for which the role is defined

Definition at line 206 of file class.ilUserImportParser.php.

◆ $logins

ilUserImportParser::$logins

This variable is used to collect each login that we encounter in the import data.

This variable is needed to detect duplicate logins in the import data. The variable is an associative array. (I would prefer using a set, but PHP does not appear to support sets.) Keys are logins. Values are logins.

Definition at line 84 of file class.ilUserImportParser.php.

◆ $mapping_mode

ilUserImportParser::$mapping_mode

Definition at line 197 of file class.ilUserImportParser.php.

Referenced by getUserMappingMode().

◆ $parentRolesCache

ilUserImportParser::$parentRolesCache

Cached parent roles.

This is used to speed up assignment to local roles with parents. This is an associative array. The key is a role_id . The value is an array of role_ids containing all parent roles.

Definition at line 221 of file class.ilUserImportParser.php.

◆ $personalPicture

ilUserImportParser::$personalPicture

Cached personal picture of the actual user This is used because the ilObjUser object has no field for the personal picture.

Definition at line 212 of file class.ilUserImportParser.php.

◆ $protocol

ilUserImportParser::$protocol

The variable holds the protocol of the import.

This variable is an associative array.

  • Keys are login names of users or "missing login", if the login name is missing.
  • Values are an array of error messages associated with the login. If the value array is empty, then the user was imported successfully.

Definition at line 74 of file class.ilUserImportParser.php.

Referenced by getProtocol().

◆ $roles

ilUserImportParser::$roles

Definition at line 60 of file class.ilUserImportParser.php.

Referenced by getCollectedRoles().

◆ $send_mail

ilUserImportParser::$send_mail

Definition at line 101 of file class.ilUserImportParser.php.

Referenced by isSendMail().

◆ $skin

ilUserImportParser::$skin

ILIAS skin.

Definition at line 226 of file class.ilUserImportParser.php.

◆ $style

ilUserImportParser::$style

ILIAS style.

Definition at line 231 of file class.ilUserImportParser.php.

Referenced by __construct().

◆ $time_limit_owner_set

ilUserImportParser::$time_limit_owner_set = false

Definition at line 53 of file class.ilUserImportParser.php.

◆ $time_limit_set

ilUserImportParser::$time_limit_set = false

Definition at line 52 of file class.ilUserImportParser.php.

◆ $updateLookAndSkin

ilUserImportParser::$updateLookAndSkin = false

boolean to determine if look and skin should be updated

Definition at line 58 of file class.ilUserImportParser.php.

◆ $user_id

ilUserImportParser::$user_id

Definition at line 253 of file class.ilUserImportParser.php.

Referenced by importEndTag(), and verifyEndTag().

◆ $user_mapping

ilUserImportParser::$user_mapping

Definition at line 189 of file class.ilUserImportParser.php.

Referenced by getUserMapping().

◆ $userCount

ilUserImportParser::$userCount

The count of user elements in the XML file.

Definition at line 182 of file class.ilUserImportParser.php.

Referenced by getUserCount().

◆ $userObj

ilUserImportParser::$userObj
private

Definition at line 259 of file class.ilUserImportParser.php.

◆ $userStyles

ilUserImportParser::$userStyles

User assigned styles.

Definition at line 236 of file class.ilUserImportParser.php.


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