ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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 @access public More...
 
 getFolderId ()
 
 setHandlers ($a_xml_parser)
 set event handler should be overwritten by inherited class @access 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 @access 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 @access 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

 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
 

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

@access public

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

278 {
279 global $DIC;
280
281 $global_settings = $DIC->settings();
282
283 $this->roles = array();
284 $this->mode = $a_mode;
285 $this->conflict_rule = $a_conflict_rule;
286 $this->error_level = IL_IMPORT_SUCCESS;
287 $this->protocol = array();
288 $this->logins = array();
289 $this->userCount = 0;
290 $this->localRoleCache = array();
291 $this->parentRolesCache = array();
292 $this->send_mail = false;
293 $this->mapping_mode = IL_USER_MAPPING_LOGIN;
294
295 // get all active style instead of only assigned ones -> cannot transfer all to another otherwise
296 $this->userStyles = array();
297 include_once './Services/Style/System/classes/class.ilStyleDefinition.php';
298 $skins = ilStyleDefinition::getAllSkins();
299
300 if (is_array($skins)) {
301 foreach ($skins as $skin) {
302 foreach ($skin->getStyles() as $style) {
303 include_once("./Services/Style/System/classes/class.ilSystemStyleSettings.php");
305 continue;
306 }
307 $this->userStyles [] = $skin->getId() . ":" . $style->getId();
308 }
309 }
310 }
311
312 $settings = $global_settings->getAll();
313 if ($settings["usr_settings_hide_skin_style"] == 1) {
314 $this->hideSkin = true;
315 } else {
316 $this->hideSkin = false;
317 }
318 if ($settings["usr_settings_disable_skin_style"] == 1) {
319 $this->disableSkin = true;
320 } else {
321 $this->disableSkin = false;
322 }
323
324 include_once("Services/Mail/classes/class.ilAccountMail.php");
325 $this->acc_mail = new ilAccountMail();
326 $this->acc_mail->setAttachConfiguredFiles(true);
327 $this->acc_mail->useLangVariablesAsFallback(true);
328
329 parent::__construct($a_xml_file);
330 }
const IL_IMPORT_SUCCESS
const IL_USER_MAPPING_LOGIN
Class ilAccountMail.
static _lookupActivatedStyle($a_skin, $a_style)
lookup if a style is activated
global $DIC
Definition: saml.php:7

References $DIC, $skin, $style, ilSystemStyleSettings\_lookupActivatedStyle(), IL_IMPORT_SUCCESS, and IL_USER_MAPPING_LOGIN.

+ 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 794 of file class.ilUserImportParser.php.

795 {
796 require_once "./Services/AccessControl/classes/class.ilObjRole.php";
797 include_once('./Services/Object/classes/class.ilObject.php');
798 #require_once "Modules/Course/classes/class.ilObjCourse.php";
799 #require_once "Modules/Course/classes/class.ilCourseParticipants.php";
800
801 global $DIC;
802
803 $rbacreview = $DIC['rbacreview'];
804 $rbacadmin = $DIC['rbacadmin'];
805 $tree = $DIC['tree'];
806
807 // Do nothing, if the user is already assigned to the role.
808 // Specifically, we do not want to put a course object or
809 // group object on the personal desktop again, if a user
810 // has removed it from the personal desktop.
811 if ($rbacreview->isAssigned($a_user_obj->getId(), $a_role_id)) {
812 return;
813 }
814
815 // If it is a course role, use the ilCourseMember object to assign
816 // the user to the role
817
818 $rbacadmin->assignUser($a_role_id, $a_user_obj->getId(), true);
819 $obj_id = $rbacreview->getObjectOfRole($a_role_id);
820 switch ($type = ilObject::_lookupType($obj_id)) {
821 case 'grp':
822 case 'crs':
823 $ref_ids = ilObject::_getAllReferences($obj_id);
824 $ref_id = current((array) $ref_ids);
825 if ($ref_id) {
826 ilObjUser::_addDesktopItem($a_user_obj->getId(), $ref_id, $type);
827 }
828 break;
829 default:
830 break;
831 }
832 }
static _addDesktopItem($a_usr_id, $a_item_id, $a_type, $a_par="")
add an item to user's personal desktop
static _getAllReferences($a_id)
get all reference ids of object
static _lookupType($a_id, $a_reference=false)
lookup object type
$type

References $DIC, $tree, $type, ilObjUser\_addDesktopItem(), ilObject\_getAllReferences(), and ilObject\_lookupType().

Referenced by assignToRoleWithParents(), and importEndTag().

+ 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 885 of file class.ilUserImportParser.php.

886 {
887 $this->assignToRole($a_user_obj, $a_role_id);
888
889 $parent_role_ids = $this->getParentRoleIds($a_role_id);
890 foreach ($parent_role_ids as $parent_role_id) {
891 $this->assignToRole($a_user_obj, $parent_role_id);
892 }
893 }
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.

References assignToRole(), and getParentRoleIds().

Referenced by importEndTag().

+ 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 384 of file class.ilUserImportParser.php.

385 {
386 $tag = "<";
387
388 if ($type == "end") {
389 $tag .= "/";
390 }
391
392 $tag .= $name;
393
394 if (is_array($attr)) {
395 foreach ($attr as $k => $v) {
396 $tag .= " " . $k . "=\"$v\"";
397 }
398 }
399
400 $tag .= ">";
401
402 return $tag;
403 }
if(function_exists( 'posix_getuid') &&posix_getuid()===0) if(!array_key_exists('t', $options)) $tag
Definition: cron.php:35

References $name, $tag, and $type.

◆ 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.

@access private

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

2241 {
2242 include_once "Services/User/classes/class.ilUserProfile.php";
2243 return ilUserProfile::isProfileIncomplete($user_obj);
2244 }
static isProfileIncomplete($a_user, $a_include_udf=true, $a_personal_data_only=true)
Check if all required personal data fields are set.

References ilUserProfile\isProfileIncomplete().

Referenced by importEndTag().

+ 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 897 of file class.ilUserImportParser.php.

898 {
899 global $DIC;
900
901 $rbacreview = $DIC['rbacreview'];
902 $rbacadmin = $DIC['rbacadmin'];
903 $tree = $DIC['tree'];
904
905 $rbacadmin->deassignUser($a_role_id, $a_user_obj->getId());
906
907 if (substr(ilObject::_lookupTitle($a_role_id), 0, 6) == 'il_crs' or
908 substr(ilObject::_lookupTitle($a_role_id), 0, 6) == 'il_grp') {
909 $obj = $rbacreview->getObjectOfRole($a_role_id);
910 $ref = ilObject::_getAllReferences($obj);
911 $ref_id = end($ref);
912 ilObjUser::_dropDesktopItem($a_user_obj->getId(), $ref_id, ilObject::_lookupType($obj));
913 }
914 }
static _dropDesktopItem($a_usr_id, $a_item_id, $a_type)
drop an item from user's personal desktop
static _lookupTitle($a_id)
lookup object title

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

Referenced by importEndTag().

+ 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 428 of file class.ilUserImportParser.php.

429 {
430 switch ($a_name) {
431 case "Role":
432 // detect numeric, ilias id (then extract role id) or alphanumeric
433 $this->current_role_id = $a_attribs["Id"];
434 if ($internal_id = ilUtil::__extractId($this->current_role_id, IL_INST_ID)) {
435 $this->current_role_id = $internal_id;
436 }
437 $this->current_role_type = $a_attribs["Type"];
438
439 break;
440 }
441 }
static __extractId($ilias_id, $inst_id)
extract ref id from role title, e.g.

References ilUtil\__extractId().

Referenced by handlerBeginTag().

+ 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 741 of file class.ilUserImportParser.php.

742 {
743 switch ($a_name) {
744 case "Role":
745 $this->roles[$this->current_role_id]["name"] = $this->cdata;
746 $this->roles[$this->current_role_id]["type"] =
747 $this->current_role_type;
748 break;
749 }
750 }

Referenced by handlerEndTag().

+ Here is the caller graph for this function:

◆ getCollectedRoles()

ilUserImportParser::getCollectedRoles ( )

get collected roles

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

2024 {
2025 return $this->roles;
2026 }

References $roles.

◆ getCourseMembersObjectForRole()

ilUserImportParser::getCourseMembersObjectForRole (   $a_role_id)

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

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

770 {
771 global $DIC;
772
773 $rbacreview = $DIC['rbacreview'];
774 $rbacadmin = $DIC['rbacadmin'];
775 $tree = $DIC['tree'];
776
777 if (array_key_exists($a_role_id . '_courseMembersObject', $this->localRoleCache)) {
778 return $this->localRoleCache[$a_role_id . '_courseMembersObject'];
779 } else {
780 require_once("Modules/Course/classes/class.ilObjCourse.php");
781 require_once("Modules/Course/classes/class.ilCourseParticipants.php");
782 $course_refs = $rbacreview->getFoldersAssignedToRole($a_role_id, true);
783 $course_ref = $course_refs[0];
784 $course_obj = new ilObjCourse($course_ref, true);
785 $crsmembers_obj = ilCourseParticipants::_getInstanceByObjId($course_obj->getId());
786 $this->localRoleCache[$a_role_id . '_courseMembersObject'] = $crsmembers_obj;
787 return $crsmembers_obj;
788 }
789 }
static _getInstanceByObjId($a_obj_id)
Get singleton instance.
Class ilObjCourse.

References $DIC, $tree, and ilCourseParticipants\_getInstanceByObjId().

+ 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 2137 of file class.ilUserImportParser.php.

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

References $error_level.

◆ getFolderId()

ilUserImportParser::getFolderId ( )

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

References $folder_id.

Referenced by importEndTag().

+ 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 837 of file class.ilUserImportParser.php.

838 {
839 global $DIC;
840
841 $rbacreview = $DIC['rbacreview'];
842
843 if (!array_key_exists($a_role_id, $this->parentRolesCache)) {
844 $parent_role_ids = array();
845
846 $role_obj = $this->getRoleObject($a_role_id);
847 $short_role_title = substr($role_obj->getTitle(), 0, 12);
848 $folders = $rbacreview->getFoldersAssignedToRole($a_role_id, true);
849 if (count($folders) > 0) {
850 $all_parent_role_ids = $rbacreview->getParentRoleIds($folders[0]);
851 foreach ($all_parent_role_ids as $parent_role_id => $parent_role_data) {
852 if ($parent_role_id != $a_role_id) {
853 switch (substr($parent_role_data['title'], 0, 12)) {
854 case 'il_crs_admin':
855 case 'il_grp_admin':
856 if ($short_role_title == 'il_crs_admin' || $short_role_title == 'il_grp_admin') {
857 $parent_role_ids[] = $parent_role_id;
858 }
859 break;
860 case 'il_crs_tutor':
861 case 'il_grp_tutor':
862 if ($short_role_title == 'il_crs_tutor' || $short_role_title == 'il_grp_tutor') {
863 $parent_role_ids[] = $parent_role_id;
864 }
865 break;
866 case 'il_crs_membe':
867 case 'il_grp_membe':
868 if ($short_role_title == 'il_crs_membe' || $short_role_title == 'il_grp_membe') {
869 $parent_role_ids[] = $parent_role_id;
870 }
871 break;
872 default:
873 break;
874 }
875 }
876 }
877 }
878 $this->parentRolesCache[$a_role_id] = $parent_role_ids;
879 }
880 return $this->parentRolesCache[$a_role_id];
881 }
getRoleObject($a_role_id)
Returns the parent object of the role folder object which contains the specified role.

References $DIC, and getRoleObject().

Referenced by assignToRoleWithParents().

+ 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 2091 of file class.ilUserImportParser.php.

2092 {
2093 return $this->protocol;
2094 }
$protocol
The variable holds the protocol of the import.

References $protocol.

Referenced by getProtocolAsHTML().

+ Here is the caller graph for this function:

◆ getProtocolAsHTML()

ilUserImportParser::getProtocolAsHTML (   $a_log_title)

Returns the protocol as a HTML table.

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

2099 {
2100 global $DIC;
2101
2102 $lng = $DIC['lng'];
2103
2104 $block = new ilTemplate("tpl.usr_import_log_block.html", true, true, "Services/User");
2105 $block->setVariable("TXT_LOG_TITLE", $a_log_title);
2106 $block->setVariable("TXT_MESSAGE_ID", $lng->txt("login"));
2107 $block->setVariable("TXT_MESSAGE_TEXT", $lng->txt("message"));
2108 foreach ($this->getProtocol() as $login => $messages) {
2109 $block->setCurrentBlock("log_row");
2110 $reason = "";
2111 foreach ($messages as $message) {
2112 if ($reason == "") {
2113 $reason = $message;
2114 } else {
2115 $reason = $reason . "<br>" . $message;
2116 }
2117 }
2118 $block->setVariable("MESSAGE_ID", $login);
2119 $block->setVariable("MESSAGE_TEXT", $reason);
2120 $block->parseCurrentBlock();
2121 }
2122 return $block->get();
2123 }
special template class to simplify handling of ITX/PEAR
getProtocol()
Returns the protocol.
$login
Definition: cron.php:13
$messages
Definition: en.php:5
catch(Exception $e) $message

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

+ 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 755 of file class.ilUserImportParser.php.

756 {
757 if (array_key_exists($a_role_id, $this->localRoleCache)) {
758 return $this->localRoleCache[$a_role_id];
759 } else {
760 $role_obj = new ilObjRole($a_role_id, false);
761 $role_obj->read();
762 $this->localRoleCache[$a_role_id] = $role_obj;
763 return $role_obj;
764 }
765 }
Class ilObjRole.

Referenced by getParentRoleIds().

+ Here is the caller graph for this function:

◆ getUserCount()

ilUserImportParser::getUserCount ( )

get count of User elements

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

2031 {
2032 return $this->userCount;
2033 }
$userCount
The count of user elements in the XML file.

References $userCount.

◆ getUserMapping()

ilUserImportParser::getUserMapping ( )

returns a map user_id <=> login

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

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

References $user_mapping.

◆ 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 2203 of file class.ilUserImportParser.php.

References $mapping_mode.

Referenced by importBeginTag(), and verifyBeginTag().

+ 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 408 of file class.ilUserImportParser.php.

409 {
410 switch ($this->mode) {
411 case IL_EXTRACT_ROLES:
412 $this->extractRolesBeginTag($a_xml_parser, $a_name, $a_attribs);
413 break;
414 case IL_USER_IMPORT:
415 $this->importBeginTag($a_xml_parser, $a_name, $a_attribs);
416 break;
417 case IL_VERIFY:
418 $this->verifyBeginTag($a_xml_parser, $a_name, $a_attribs);
419 break;
420 }
421
422 $this->cdata = "";
423 }
const IL_EXTRACT_ROLES
const IL_USER_IMPORT
const IL_VERIFY
verifyBeginTag($a_xml_parser, $a_name, $a_attribs)
handler for begin of element
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

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

+ Here is the call graph for this function:

◆ handlerCharacterData()

ilUserImportParser::handlerCharacterData (   $a_xml_parser,
  $a_data 
)

handler for character data

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

2007 {
2008 // DELETE WHITESPACES AND NEWLINES OF CHARACTER DATA
2009 // TODO: Mit Alex klären, ob das noch benötigt wird $a_data = preg_replace("/\n/","",$a_data);
2010 // TODO: Mit Alex klären, ob das noch benötigt wird $a_data = preg_replace("/\t+/","",$a_data);
2011 if ($a_data != "\n") {
2012 $a_data = preg_replace("/\t+/", " ", $a_data);
2013 }
2014
2015 if (strlen($a_data) > 0) {
2016 $this->cdata .= $a_data;
2017 }
2018 }

◆ handlerEndTag()

ilUserImportParser::handlerEndTag (   $a_xml_parser,
  $a_name 
)

handler for end of element

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

724 {
725 switch ($this->mode) {
726 case IL_EXTRACT_ROLES:
727 $this->extractRolesEndTag($a_xml_parser, $a_name);
728 break;
729 case IL_USER_IMPORT:
730 $this->importEndTag($a_xml_parser, $a_name);
731 break;
732 case IL_VERIFY:
733 $this->verifyEndTag($a_xml_parser, $a_name);
734 break;
735 }
736 }
extractRolesEndTag($a_xml_parser, $a_name)
handler for end of element when in extract roles mode.
importEndTag($a_xml_parser, $a_name)
handler for end of element when in import user mode.
verifyEndTag($a_xml_parser, $a_name)
handler for end of element when in verify mode.

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

+ 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 445 of file class.ilUserImportParser.php.

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

References $DIC, $id, $idp, ilSaxParser\$ilias, $list, ilSaxParser\$lng, ilUtil\__extractId(), ilLDAPServer\_getActiveServerList(), ilSamlIdp\getActiveIdpList(), getUserMappingMode(), IL_USER_MAPPING_ID, and logFailure().

Referenced by handlerBeginTag().

+ 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 919 of file class.ilUserImportParser.php.

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

References $DIC, ilSaxParser\$ilias, $ilSetting, $ilUser, $key, ilSaxParser\$lng, $timestamp, $user_id, ilObjUser\_checkExternalAuthAccount(), ilAuthUtils\_getAuthModeName(), ilUserDefinedFields\_getInstance(), ilObjUser\_lookupExternalAccount(), ilObjUser\_uploadPersonalPicture(), assignToRole(), assignToRoleWithParents(), checkProfileIncomplete(), 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(), and updateMailPreferences().

Referenced by handlerEndTag().

+ 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 2252 of file class.ilUserImportParser.php.

2253 {
2254 $requiredFields = $this->readRequiredFields();
2255 $fieldname = strtolower(trim($fieldname));
2256 return array_key_exists($fieldname, $requiredFields);
2257 }
readRequiredFields()
read required fields

References readRequiredFields().

+ Here is the call graph for this function:

◆ isSendMail()

ilUserImportParser::isSendMail ( )

read access to property send mail

Returns
boolean

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

2180 {
2181 return $this->send_mail;
2182 }

References $send_mail.

Referenced by sendAccountMail().

+ Here is the caller graph for this function:

◆ isSuccess()

ilUserImportParser::isSuccess ( )

Returns true, if the import was successful.

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

2129 {
2130 return $this->error_level == IL_IMPORT_SUCCESS;
2131 }

References IL_IMPORT_SUCCESS.

◆ logFailure()

ilUserImportParser::logFailure (   $aLogin,
  $aMessage 
)

Writes a failure log message to the protocol.

Parameters
stringlogin
stringmessage

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

2060 {
2061 if (!array_key_exists($aLogin, $this->protocol)) {
2062 $this->protocol[$aLogin] = array();
2063 }
2064 if ($aMessage) {
2065 $this->protocol[$aLogin][] = $aMessage;
2066 }
2067 $this->error_level = IL_IMPORT_FAILURE;
2068 }
const IL_IMPORT_FAILURE

References IL_IMPORT_FAILURE.

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

+ 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 2077 of file class.ilUserImportParser.php.

2078 {
2079 $this->user_mapping[$userid] = array("login" => $aLogin, "action" => $action, "message" => "successful");
2080 }
$action
The Action attribute determines what to do for the current User element.
if(empty($userids)) $userid

References $action, and $userid.

Referenced by importEndTag().

+ 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 2041 of file class.ilUserImportParser.php.

2042 {
2043 if (!array_key_exists($aLogin, $this->protocol)) {
2044 $this->protocol[$aLogin] = array();
2045 }
2046 if ($aMessage) {
2047 $this->protocol[$aLogin][] = $aMessage;
2048 }
2049 if ($this->error_level == IL_IMPORT_SUCCESS) {
2050 $this->error_level = IL_IMPORT_WARNING;
2051 }
2052 }
const IL_IMPORT_WARNING

References IL_IMPORT_SUCCESS, and IL_IMPORT_WARNING.

Referenced by importEndTag(), and verifyEndTag().

+ Here is the caller graph for this function:

◆ readRequiredFields()

ilUserImportParser::readRequiredFields ( )
private

read required fields

@access private

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

2215 {
2216 global $DIC;
2217
2218 $ilSetting = $DIC['ilSetting'];
2219
2220 if (is_array($this->required_fields)) {
2221 return $this->required_fields;
2222 }
2223 foreach ($ilSetting->getAll() as $field => $value) {
2224 if (substr($field, 0, 8) == 'require_' and $value == 1) {
2225 $value = substr($field, 8);
2226 $this->required_fields[$value] = $value;
2227 }
2228 }
2229 return $this->required_fields ? $this->required_fields : array();
2230 }

References $DIC, and $ilSetting.

Referenced by isFieldRequired().

+ 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 1666 of file class.ilUserImportParser.php.

1667 {
1668 $tempname = ilUtil::ilTempnam() . $filename;
1669 $fh = fopen($tempname, "wb");
1670 if ($fh == false) {
1671 return "";
1672 }
1673 $imagefile = fwrite($fh, $image_data);
1674 fclose($fh);
1675 return $tempname;
1676 }
$filename
Definition: buildRTE.php:89
static ilTempnam($a_temp_path=null)
Returns a unique and non existing Path for e temporary file or directory.

References $filename, and ilUtil\ilTempnam().

Referenced by importEndTag().

+ 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 2155 of file class.ilUserImportParser.php.

2156 {
2157 if ($_POST["send_mail"] != "" ||
2158 ($this->isSendMail() && $this->userObj->getEmail() != "")) {
2159 $this->acc_mail->setUser($this->userObj);
2160 $this->acc_mail->send();
2161 }
2162 }
$_POST["username"]
isSendMail()
read access to property send mail

References $_POST, and isSendMail().

Referenced by importEndTag().

+ 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 @access public

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

338 {
339 $this->folder_id = $a_folder_id;
340 }

◆ setHandlers()

ilUserImportParser::setHandlers (   $a_xml_parser)

set event handler should be overwritten by inherited class @access private

Reimplemented from ilSaxParser.

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

353 {
354 xml_set_object($a_xml_parser, $this);
355 xml_set_element_handler($a_xml_parser, 'handlerBeginTag', 'handlerEndTag');
356 xml_set_character_data_handler($a_xml_parser, 'handlerCharacterData');
357 }

◆ setRoleAssignment()

ilUserImportParser::setRoleAssignment (   $a_assign)

set import to local role assignemt

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

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

373 {
374 $this->role_assign = $a_assign;
375 }

◆ setSendMail()

ilUserImportParser::setSendMail (   $value)

write access to property send mail

Parameters
mixed$value

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

2170 {
2171 $this->send_mail = $value ? true: false;
2172 }

◆ 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 2189 of file class.ilUserImportParser.php.

2190 {
2191 if ($value == IL_USER_MAPPING_ID || $value == IL_USER_MAPPING_LOGIN) {
2192 $this->mapping_mode = $value;
2193 } else {
2194 die("wrong argument using methode setUserMappingMethod in " . __FILE__);
2195 }
2196 }

References IL_USER_MAPPING_ID, and IL_USER_MAPPING_LOGIN.

◆ startParsing()

ilUserImportParser::startParsing ( )

start the parser

Reimplemented from ilSaxParser.

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

363 {
364 parent::startParsing();
365 }

◆ updateMailPreferences()

ilUserImportParser::updateMailPreferences (   $usr_id)
private

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

2358 {
2359 if (array_key_exists("mail_incoming_type", $this->prefs) ||
2360 array_key_exists("mail_signature", $this->prefs) ||
2361 array_key_exists("mail_linebreak", $this->prefs)
2362 ) {
2363 include_once("Services/Mail/classes/class.ilMailOptions.php");
2364 $mailOptions = new ilMailOptions($usr_id);
2365
2366 $mailOptions->setLinebreak(array_key_exists("mail_linebreak", $this->prefs) ? $this->prefs["mail_linebreak"] : $mailOptions->getLinebreak());
2367 $mailOptions->setSignature(array_key_exists("mail_signature", $this->prefs) ? $this->prefs["mail_signature"] : $mailOptions->getSignature());
2368 $mailOptions->setIncomingType(array_key_exists("mail_incoming_type", $this->prefs) ? $this->prefs["mail_incoming_type"] : $mailOptions->getIncomingType());
2369 $mailOptions->updateOptions();
2370 }
2371 }
Class ilMailOptions this class handles user mails.

Referenced by importEndTag().

+ 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 599 of file class.ilUserImportParser.php.

600 {
601 global $DIC;
602
603 $lng = $DIC['lng'];
604
605 switch ($a_name) {
606 case "Role":
607 if (is_null($a_attribs['Id'])
608 || $a_attribs['Id'] == "") {
609 $this->logFailure($this->userObj->getLogin(), sprintf($lng->txt("usrimport_xml_attribute_missing"), "Role", "Id"));
610 }
611 $this->current_role_id = $a_attribs["Id"];
612 $this->current_role_type = $a_attribs["Type"];
613 if ($this->current_role_type != 'Global'
614 && $this->current_role_type != 'Local') {
615 $this->logFailure($this->userObj->getLogin(), sprintf($lng->txt("usrimport_xml_attribute_missing"), "Role", "Type"));
616 }
617 $this->current_role_action = (is_null($a_attribs["Action"])) ? "Assign" : $a_attribs["Action"];
618 if ($this->current_role_action != "Assign"
619 && $this->current_role_action != "AssignWithParents"
620 && $this->current_role_action != "Detach") {
621 $this->logFailure($this->userObj->getLogin(), sprintf($lng->txt("usrimport_xml_attribute_value_illegal"), "Role", "Action", $a_attribs["Action"]));
622 }
623 if ($this->action == "Insert"
624 && $this->current_role_action == "Detach") {
625 $this->logFailure($this->userObj->getLogin(), sprintf($lng->txt("usrimport_xml_attribute_value_inapplicable"), "Role", "Action", $this->current_role_action, $this->action));
626 }
627 if ($this->action == "Delete") {
628 $this->logFailure($this->userObj->getLogin(), sprintf($lng->txt("usrimport_xml_element_inapplicable"), "Role", "Delete"));
629 }
630 break;
631
632 case "User":
633 $this->userCount++;
634 $this->userObj = new ilObjUser();
635 $this->userObj->setLanguage($a_attribs["Language"]);
636 $this->userObj->setImportId($a_attribs["Id"]);
637 $this->currentPrefKey = null;
638 // if we have an object id, store it
639 $this->user_id = -1;
640
641 if (!is_null($a_attribs["Id"]) && $this->getUserMappingMode() == IL_USER_MAPPING_ID) {
642 if (is_numeric($a_attribs["Id"])) {
643 $this->user_id = $a_attribs["Id"];
644 } elseif ($id = ilUtil::__extractId($a_attribs["Id"], IL_INST_ID)) {
645 $this->user_id = $id;
646 }
647 }
648
649 $this->action = (is_null($a_attribs["Action"])) ? "Insert" : $a_attribs["Action"];
650 if ($this->action != "Insert"
651 && $this->action != "Update"
652 && $this->action != "Delete") {
653 $this->logFailure($this->userObj->getImportId(), sprintf($lng->txt("usrimport_xml_attribute_value_illegal"), "User", "Action", $a_attribs["Action"]));
654 }
655 $this->currPassword = null;
656 $this->currPasswordType = null;
657 break;
658
659 case 'Password':
660 $this->currPasswordType = $a_attribs['Type'];
661 break;
662 case "AuthMode":
663 if (array_key_exists("type", $a_attribs)) {
664 switch ($a_attribs["type"]) {
665 case "saml":
666 case "ldap":
667 if (strcmp('saml', $a_attribs['type']) === 0) {
669 if (count($list) !== 1) {
670 $this->logFailure(
671 $this->userObj->getImportId(),
672 sprintf($lng->txt("usrimport_xml_attribute_value_illegal"), "AuthMode", "type", $a_attribs['type'])
673 );
674 }
675 break;
676 }
677 if (strcmp('ldap', $a_attribs['type']) === 0) {
678 // no server id provided
679 include_once './Services/LDAP/classes/class.ilLDAPServer.php';
681 if (count($list) != 1) {
682 $this->logFailure(
683 $this->userObj->getImportId(),
684 sprintf($lng->txt("usrimport_xml_attribute_value_illegal"), "AuthMode", "type", $a_attribs['type'])
685 );
686 }
687 }
688 break;
689
690 case "default":
691 case "local":
692 case "radius":
693 case "shibboleth":
694 case "script":
695 case "cas":
696 case "soap":
697 case "openid":
698 // begin-patch auth_plugin
699 default:
700 $this->userObj->setAuthMode($a_attribs["type"]);
701 break;
702 /*
703 default:
704 $this->logFailure($this->userObj->getImportId(), sprintf($lng->txt("usrimport_xml_attribute_value_illegal"),"AuthMode","type",$a_attribs["type"]));
705 break;
706 *
707 */
708 }
709 } else {
710 $this->logFailure($this->userObj->getImportId(), sprintf($lng->txt("usrimport_xml_attribute_value_illegal"), "AuthMode", "type", ""));
711 }
712 break;
713 case 'Pref':
714 $this->currentPrefKey = $a_attribs["key"];
715 break;
716
717 }
718 }

References $DIC, $id, $list, ilSaxParser\$lng, ilUtil\__extractId(), ilLDAPServer\_getActiveServerList(), ilSamlIdp\getActiveIdpList(), getUserMappingMode(), IL_USER_MAPPING_ID, and logFailure().

Referenced by handlerBeginTag().

+ 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 1681 of file class.ilUserImportParser.php.

1682 {
1683 global $DIC;
1684
1685 $lng = $DIC['lng'];
1686 $ilAccess = $DIC['ilAccess'];
1687 $ilSetting = $DIC['ilSetting'];
1688 $ilObjDataCache = $DIC['ilObjDataCache'];
1689
1690 switch ($a_name) {
1691 case "Role":
1692 $this->roles[$this->current_role_id]["name"] = $this->cdata;
1693 $this->roles[$this->current_role_id]["type"] = $this->current_role_type;
1694 $this->roles[$this->current_role_id]["action"] = $this->current_role_action;
1695 break;
1696
1697 case "User":
1698 $this->userObj->setFullname();
1699 if ($this->user_id != -1 && ($this->action == "Update" || $this->action == "Delete")) {
1700 $user_exists = !is_null(ilObjUser::_lookupLogin($this->user_id));
1701 } else {
1702 $user_exists = ilObjUser::getUserIdByLogin($this->userObj->getLogin()) != 0;
1703 }
1704
1705 if (is_null($this->userObj->getLogin())) {
1706 $this->logFailure("---", sprintf($lng->txt("usrimport_xml_element_for_action_required"), "Login", "Insert"));
1707 }
1708
1709 switch ($this->action) {
1710 case "Insert":
1711 if ($user_exists and $this->conflict_rule == IL_FAIL_ON_CONFLICT) {
1712 $this->logWarning($this->userObj->getLogin(), $lng->txt("usrimport_cant_insert"));
1713 }
1714 if (is_null($this->userObj->getGender()) && $this->isFieldRequired("gender")) {
1715 $this->logFailure($this->userObj->getLogin(), sprintf($lng->txt("usrimport_xml_element_for_action_required"), "Gender", "Insert"));
1716 }
1717 if (is_null($this->userObj->getFirstname())) {
1718 $this->logFailure($this->userObj->getLogin(), sprintf($lng->txt("usrimport_xml_element_for_action_required"), "Firstname", "Insert"));
1719 }
1720 if (is_null($this->userObj->getLastname())) {
1721 $this->logFailure($this->userObj->getLogin(), sprintf($lng->txt("usrimport_xml_element_for_action_required"), "Lastname", "Insert"));
1722 }
1723 if (count($this->roles) == 0) {
1724 $this->logFailure($this->userObj->getLogin(), sprintf($lng->txt("usrimport_xml_element_for_action_required"), "Role", "Insert"));
1725 } else {
1726 $has_global_role = false;
1727 foreach ($this->roles as $role) {
1728 if ($role['type'] == 'Global') {
1729 $has_global_role = true;
1730 break;
1731 }
1732 }
1733 if (!$has_global_role) {
1734 $this->logFailure($this->userObj->getLogin(), sprintf($lng->txt("usrimport_global_role_for_action_required"), "Insert"));
1735 }
1736 }
1737 break;
1738 case "Update":
1739 if (!$user_exists) {
1740 $this->logWarning($this->userObj->getLogin(), $lng->txt("usrimport_cant_update"));
1741 } elseif ($this->user_id != -1 && !is_null($this->userObj->getLogin())) {
1742 // check if someone owns the new login name!
1743 $someonesId = ilObjUser::_lookupId($this->userObj->getLogin());
1744
1745 if (is_numeric($someonesId) && $someonesId != $this->user_id) {
1746 $this->logFailure($this->userObj->getLogin(), $lng->txt("usrimport_login_is_not_unique"));
1747 }
1748 }
1749 break;
1750 case "Delete":
1751 if (!$user_exists) {
1752 $this->logWarning($this->userObj->getLogin(), $lng->txt("usrimport_cant_delete"));
1753 }
1754 break;
1755 }
1756
1757 // init role array for next user
1758 $this->roles = array();
1759 break;
1760
1761 case "Login":
1762 if (array_key_exists($this->cdata, $this->logins)) {
1763 $this->logWarning($this->cdata, $lng->txt("usrimport_login_is_not_unique"));
1764 } else {
1765 $this->logins[$this->cdata] = $this->cdata;
1766 }
1767 $this->userObj->setLogin($this->cdata);
1768 break;
1769
1770 case "Password":
1771 switch ($this->currPasswordType) {
1772 case "BCRYPT":
1773 $this->userObj->setPasswd($this->cdata, IL_PASSWD_CRYPTED);
1774 $this->userObj->setPasswordEncodingType('bcryptphp');
1775 $this->userObj->setPasswordSalt(null);
1776 break;
1777
1778 case "PLAIN":
1779 $this->userObj->setPasswd($this->cdata, IL_PASSWD_PLAIN);
1780 $this->acc_mail->setUserPassword($this->currPassword);
1781 break;
1782
1783 default:
1784 $this->logFailure($this->userObj->getLogin(), sprintf($lng->txt("usrimport_xml_attribute_value_illegal"), "Type", "Password", $this->currPasswordType));
1785 break;
1786 }
1787 break;
1788
1789 case "Firstname":
1790 $this->userObj->setFirstname($this->cdata);
1791 break;
1792
1793 case "Lastname":
1794 $this->userObj->setLastname($this->cdata);
1795 break;
1796
1797 case "Title":
1798 $this->userObj->setUTitle($this->cdata);
1799 break;
1800
1801 case "Gender":
1802 if (!in_array(strtolower($this->cdata), ['n', 'm', 'f'])) {
1803 $this->logFailure(
1804 $this->userObj->getLogin(),
1805 sprintf($lng->txt("usrimport_xml_element_content_illegal"), "Gender", $this->cdata)
1806 );
1807 }
1808 $this->userObj->setGender($this->cdata);
1809 break;
1810
1811 case "Email":
1812 $this->userObj->setEmail($this->cdata);
1813 break;
1814 case "SecondEmail":
1815 $this->userObj->setSecondEmail($this->cdata);
1816 break;
1817 case "Institution":
1818 $this->userObj->setInstitution($this->cdata);
1819 break;
1820
1821 case "Street":
1822 $this->userObj->setStreet($this->cdata);
1823 break;
1824
1825 case "City":
1826 $this->userObj->setCity($this->cdata);
1827 break;
1828
1829 case "PostalCode":
1830 $this->userObj->setZipCode($this->cdata);
1831 break;
1832
1833 case "Country":
1834 $this->userObj->setCountry($this->cdata);
1835 break;
1836
1837 case "SelCountry":
1838 $this->userObj->setSelectedCountry($this->cdata);
1839 break;
1840
1841 case "PhoneOffice":
1842 $this->userObj->setPhoneOffice($this->cdata);
1843 break;
1844
1845 case "PhoneHome":
1846 $this->userObj->setPhoneHome($this->cdata);
1847 break;
1848
1849 case "PhoneMobile":
1850 $this->userObj->setPhoneMobile($this->cdata);
1851 break;
1852
1853 case "Fax":
1854 $this->userObj->setFax($this->cdata);
1855 break;
1856
1857 case "Hobby":
1858 $this->userObj->setHobby($this->cdata);
1859 break;
1860
1861 case "GeneralInterest":
1862 case "OfferingHelp":
1863 case "LookingForHelp":
1864 $this->multi_values[$a_name][] = $this->cdata;
1865 break;
1866
1867 case "Comment":
1868 $this->userObj->setComment($this->cdata);
1869 break;
1870
1871 case "Department":
1872 $this->userObj->setDepartment($this->cdata);
1873 break;
1874
1875 case "Matriculation":
1876 $this->userObj->setMatriculation($this->cdata);
1877 break;
1878
1879 case "ExternalAccount":
1880//echo "-".$this->userObj->getAuthMode()."-".$this->userObj->getLogin()."-";
1881 $am = ($this->userObj->getAuthMode() == "default" || $this->userObj->getAuthMode() == "")
1882 ? ilAuthUtils::_getAuthModeName($ilSetting->get('auth_mode'))
1883 : $this->userObj->getAuthMode();
1884 $loginForExternalAccount = (trim($this->cdata) == "")
1885 ? ""
1886 : ilObjUser::_checkExternalAuthAccount($am, trim($this->cdata));
1887 switch ($this->action) {
1888 case "Insert":
1889 if ($loginForExternalAccount != "") {
1890 $this->logWarning($this->userObj->getLogin(), $lng->txt("usrimport_no_insert_ext_account_exists") . " (" . $this->cdata . ")");
1891 }
1892 break;
1893
1894 case "Update":
1895 if ($loginForExternalAccount != "") {
1896 $externalAccountHasChanged = trim($this->cdata) != ilObjUser::_lookupExternalAccount($this->user_id);
1897 if ($externalAccountHasChanged && trim($loginForExternalAccount) != trim($this->userObj->getLogin())) {
1898 $this->logWarning(
1899 $this->userObj->getLogin(),
1900 $lng->txt("usrimport_no_update_ext_account_exists") . " (" . $this->cdata . " for " . $loginForExternalAccount . ")"
1901 );
1902 }
1903 }
1904 break;
1905
1906 }
1907 if ($externalAccountHasChanged) {
1908 $this->userObj->setExternalAccount(trim($this->cdata));
1909 }
1910 break;
1911
1912 case "Active":
1913 if ($this->cdata != "true"
1914 && $this->cdata != "false") {
1915 $this->logFailure(
1916 $this->userObj->getLogin(),
1917 sprintf($lng->txt("usrimport_xml_element_content_illegal"), "Active", $this->cdata)
1918 );
1919 }
1920 $this->currActive = $this->cdata;
1921 break;
1922 case "TimeLimitOwner":
1923 if (!preg_match("/\d+/", $this->cdata)) {
1924 $this->logFailure(
1925 $this->userObj->getLogin(),
1926 sprintf($lng->txt("usrimport_xml_element_content_illegal"), "TimeLimitOwner", $this->cdata)
1927 );
1928 } elseif (!$ilAccess->checkAccess('cat_administrate_users', '', $this->cdata)) {
1929 $this->logFailure(
1930 $this->userObj->getLogin(),
1931 sprintf($lng->txt("usrimport_xml_element_content_illegal"), "TimeLimitOwner", $this->cdata)
1932 );
1933 } elseif ($ilObjDataCache->lookupType($ilObjDataCache->lookupObjId($this->cdata)) != 'cat' && !(int) $this->cdata == USER_FOLDER_ID) {
1934 $this->logFailure(
1935 $this->userObj->getLogin(),
1936 sprintf($lng->txt("usrimport_xml_element_content_illegal"), "TimeLimitOwner", $this->cdata)
1937 );
1938 }
1939 $this->userObj->setTimeLimitOwner($this->cdata);
1940 break;
1941 case "TimeLimitUnlimited":
1942 switch (strtolower($this->cdata)) {
1943 case "true":
1944 case "1":
1945 $this->userObj->setTimeLimitUnlimited(1);
1946 break;
1947 case "false":
1948 case "0":
1949 $this->userObj->setTimeLimitUnlimited(0);
1950 break;
1951 default:
1952 $this->logFailure($this->userObj->getLogin(), sprintf($lng->txt("usrimport_xml_element_content_illegal"), "TimeLimitUnlimited", $this->cdata));
1953 break;
1954 }
1955 break;
1956 case "TimeLimitFrom":
1957 // Accept datetime or Unix timestamp
1958 if (strtotime($this->cdata) === false && !is_numeric($this->cdata)) {
1959 $this->logFailure($this->userObj->getLogin(), sprintf($lng->txt("usrimport_xml_element_content_illegal"), "TimeLimitFrom", $this->cdata));
1960 }
1961 $this->userObj->setTimeLimitFrom($this->cdata);
1962 break;
1963 case "TimeLimitUntil":
1964 // Accept datetime or Unix timestamp
1965 if (strtotime($this->cdata) === false && !is_numeric($this->cdata)) {
1966 $this->logFailure($this->userObj->getLogin(), sprintf($lng->txt("usrimport_xml_element_content_illegal"), "TimeLimitUntil", $this->cdata));
1967 }
1968 $this->userObj->setTimeLimitUntil($this->cdata);
1969 break;
1970 case "TimeLimitMessage":
1971 switch (strtolower($this->cdata)) {
1972 case "1":
1973 $this->userObj->setTimeLimitMessage(1);
1974 break;
1975 case "0":
1976 $this->userObj->setTimeLimitMessage(0);
1977 break;
1978 default:
1979 $this->logFailure($this->userObj->getLogin(), sprintf($lng->txt("usrimport_xml_element_content_illegal"), "TimeLimitMessage", $this->cdata));
1980 break;
1981 }
1982 break;
1983 case "ApproveDate":
1984 // Accept datetime or Unix timestamp
1985 if (strtotime($this->cdata) === false && !is_numeric($this->cdata) && !$this->cdata == "0000-00-00 00:00:00") {
1986 $this->logFailure($this->userObj->getLogin(), sprintf($lng->txt("usrimport_xml_element_content_illegal"), "ApproveDate", $this->cdata));
1987 }
1988 break;
1989 case "AgreeDate":
1990 // Accept datetime or Unix timestamp
1991 if (strtotime($this->cdata) === false && !is_numeric($this->cdata) && !$this->cdata == "0000-00-00 00:00:00") {
1992 $this->logFailure($this->userObj->getLogin(), sprintf($lng->txt("usrimport_xml_element_content_illegal"), "AgreeDate", $this->cdata));
1993 }
1994 break;
1995 case "Pref":
1996 if ($this->currentPrefKey != null) {
1997 $this->verifyPref($this->currentPrefKey, $this->cdata);
1998 }
1999 $this->currentPrefKey == null;
2000 }
2001 }
const USER_FOLDER_ID
Class ilObjUserFolder.
static _lookupLogin($a_user_id)
lookup login
static _lookupId($a_user_str)
Lookup id by login.

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

Referenced by handlerEndTag().

+ 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 2259 of file class.ilUserImportParser.php.

2260 {
2261 switch ($key) {
2262 case 'mail_linebreak':
2263 case 'hits_per_page':
2264 if (!is_numeric($value) || $value < 0) {
2265 $this->logFailure("---", "Wrong value '$value': Positiv numeric value expected for preference $key.");
2266 }
2267 break;
2268 case 'language':
2269 case 'skin':
2270 case 'style':
2271 case 'ilPageEditor_HTMLMode':
2272 case 'ilPageEditor_JavaScript':
2273 case 'ilPageEditor_MediaMode':
2274 case 'tst_javascript':
2275 case 'tst_lastquestiontype':
2276 case 'tst_multiline_answers':
2277 case 'tst_use_previous_answers':
2278 case 'graphicalAnswerSetting':
2279 case 'priv_feed_pass':
2280 $this->logFailure("---", "Preference $key is not supported.");
2281 break;
2282 case 'public_city':
2283 case 'public_country':
2284 case 'public_department':
2285 case 'public_email':
2286 case 'public_second_email':
2287 case 'public_fax':
2288 case 'public_hobby':
2289 case 'public_institution':
2290 case 'public_matriculation':
2291 case 'public_phone':
2292 case 'public_phone_home':
2293 case 'public_phone_mobile':
2294 case 'public_phone_office':
2295 case 'public_street':
2296 case 'public_upload':
2297 case 'public_zip':
2298 case 'public_interests_general':
2299 case 'public_interests_help_offered':
2300 case 'public_interests_help_looking':
2301 case 'send_info_mails':
2302 case 'hide_own_online_status':
2303 if (!in_array($value, array('y', 'n'))) {
2304 $this->logFailure("---", "Wrong value '$value': Value 'y' or 'n' expected for preference $key.");
2305 }
2306 break;
2307 case 'bs_allow_to_contact_me':
2308 if (!in_array($value, array('y', 'n'))) {
2309 $this->logFailure("---", "Wrong value '$value': Value 'y' or 'n' expected for preference $key.");
2310 }
2311 break;
2312 case 'chat_osc_accept_msg':
2313 if (!in_array($value, array('y', 'n'))) {
2314 $this->logFailure("---", "Wrong value '$value': Value 'y' or 'n' expected for preference $key.");
2315 }
2316 break;
2317 case 'public_profile':
2318 if (!in_array($value, array('y', 'n', 'g'))) {
2319 $this->logFailure("---", "Wrong value '$value': Value 'y', 'g' or 'n' expected for preference $key.");
2320 }
2321 break;
2322 case 'show_users_online':
2323 if (!in_array($value, array('y', 'n', 'associated'))) {
2324 $this->logFailure("---", "Wrong value '$value': Value 'y' or 'n' or 'associated' expected for preference $key.");
2325 }
2326 break;
2327 case 'mail_incoming_type':
2328 if (!in_array((int) $value, array("0","1","2"))) {
2329 $this->logFailure("---", "Wrong value '$value': Value \"0\" (LOCAL),\"1\" (EMAIL) or \"2\" (BOTH) expected for preference $key.");
2330 }
2331 break;
2332 case 'weekstart':
2333 if (!in_array($value, array("0","1"))) {
2334 $this->logFailure("---", "Wrong value '$value': Value \"0\" (Sunday) or \"1\" (Monday) expected for preference $key.");
2335 }
2336 break;
2337
2338 case 'mail_signature':
2339 break;
2340 case 'user_tz':
2341 include_once('Services/Calendar/classes/class.ilTimeZone.php');
2342 try {
2343 $tz = ilTimeZone::_getInstance($value);
2344 return true;
2345 } catch (ilTimeZoneException $tze) {
2346 $this->logFailure("---", "Wrong value '$value': Invalid timezone $value detected for preference $key.");
2347 }
2348 break;
2349 default:
2351 $this->logFailure("---", "Preference $key is not supported.");
2352 }
2353 break;
2354 }
2355 }
Class for TimeZone exceptions.
static _getInstance($a_tz='')
get instance by timezone

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

Referenced by verifyEndTag().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $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 logSuccess().

◆ $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.

◆ $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.

Referenced by __construct().

◆ $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().

◆ $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: