ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
ilUserImportParser Class Reference

User Import Parser. More...

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

Public Member Functions

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

Data Fields

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

Protected Member Functions

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

Protected Attributes

 $recommended_content_manager
 
 $user_settings_config
 

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)
 
 getCDataWithoutTags ()
 
 stripTags (string $string)
 

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

Constructor & Destructor Documentation

◆ __construct()

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

Constructor.

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

public

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

References $DIC, $skin, $style, ILIAS\GlobalScreen\Provider\__construct(), ilSystemStyleSettings\_lookupActivatedStyle(), IL_IMPORT_SUCCESS, and IL_USER_MAPPING_LOGIN.

289  {
290  global $DIC;
291 
292  $global_settings = $DIC->settings();
293 
294  $this->roles = array();
295  $this->mode = $a_mode;
296  $this->conflict_rule = $a_conflict_rule;
297  $this->error_level = IL_IMPORT_SUCCESS;
298  $this->protocol = array();
299  $this->logins = array();
300  $this->userCount = 0;
301  $this->localRoleCache = array();
302  $this->parentRolesCache = array();
303  $this->send_mail = false;
304  $this->mapping_mode = IL_USER_MAPPING_LOGIN;
305 
306  $this->user_settings_config = new ilUserSettingsConfig();
307 
308  // get all active style instead of only assigned ones -> cannot transfer all to another otherwise
309  $this->userStyles = array();
310  include_once './Services/Style/System/classes/class.ilStyleDefinition.php';
311  $skins = ilStyleDefinition::getAllSkins();
312 
313  if (is_array($skins)) {
314  foreach ($skins as $skin) {
315  foreach ($skin->getStyles() as $style) {
316  include_once("./Services/Style/System/classes/class.ilSystemStyleSettings.php");
317  if (!ilSystemStyleSettings::_lookupActivatedStyle($skin->getId(), $style->getId())) {
318  continue;
319  }
320  $this->userStyles [] = $skin->getId() . ":" . $style->getId();
321  }
322  }
323  }
324 
325  $this->hideSkin = (!$this->user_settings_config->isVisible("skin_style"));
326  $this->disableSkin = (!$this->user_settings_config->isChangeable("skin_style"));
327 
328  include_once("Services/Mail/classes/class.ilAccountMail.php");
329  $this->acc_mail = new ilAccountMail();
330  $this->acc_mail->setAttachConfiguredFiles(true);
331  $this->acc_mail->useLangVariablesAsFallback(true);
332 
333  $this->recommended_content_manager = new ilRecommendedContentManager();
334 
335  parent::__construct($a_xml_file);
336  }
const IL_USER_MAPPING_LOGIN
static _lookupActivatedStyle($a_skin, $a_style)
lookup if a style is activated
const IL_IMPORT_SUCCESS
global $DIC
Definition: goto.php:24
__construct(Container $dic, ilPlugin $plugin)
Class ilAccountMail.
User settings configuration (what preferences can be visible/changed/...)
Recommended content manager (business logic)
+ 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 788 of file class.ilUserImportParser.php.

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

Referenced by assignToRoleWithParents(), and importEndTag().

789  {
790  require_once "./Services/AccessControl/classes/class.ilObjRole.php";
791  include_once('./Services/Object/classes/class.ilObject.php');
792  #require_once "Modules/Course/classes/class.ilObjCourse.php";
793  #require_once "Modules/Course/classes/class.ilCourseParticipants.php";
794 
795  global $DIC;
796 
797  $rbacreview = $DIC['rbacreview'];
798  $rbacadmin = $DIC['rbacadmin'];
799  $tree = $DIC['tree'];
800 
801  // Do nothing, if the user is already assigned to the role.
802  // Specifically, we do not want to put a course object or
803  // group object on the personal desktop again, if a user
804  // has removed it from the personal desktop.
805  if ($rbacreview->isAssigned($a_user_obj->getId(), $a_role_id)) {
806  return;
807  }
808 
809  // If it is a course role, use the ilCourseMember object to assign
810  // the user to the role
811 
812  $rbacadmin->assignUser($a_role_id, $a_user_obj->getId(), true);
813  $obj_id = $rbacreview->getObjectOfRole($a_role_id);
814  switch ($type = ilObject::_lookupType($obj_id)) {
815  case 'grp':
816  case 'crs':
818  $ref_id = current((array) $ref_ids);
819  if ($ref_id) {
820  // deactivated for now, see discussion at
821  // https://docu.ilias.de/goto_docu_wiki_wpage_5620_1357.html
822  //$this->recommended_content_manager->addObjectRecommendation($a_user_obj->getId(), $ref_id);
823  }
824  break;
825  default:
826  break;
827  }
828  }
$type
static _getAllReferences($a_id)
get all reference ids of object
global $DIC
Definition: goto.php:24
static _lookupType($a_id, $a_reference=false)
lookup object type
+ 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 881 of file class.ilUserImportParser.php.

References assignToRole(), and getParentRoleIds().

Referenced by importEndTag().

882  {
883  $this->assignToRole($a_user_obj, $a_role_id);
884 
885  $parent_role_ids = $this->getParentRoleIds($a_role_id);
886  foreach ($parent_role_ids as $parent_role_id) {
887  $this->assignToRole($a_user_obj, $parent_role_id);
888  }
889  }
getParentRoleIds($a_role_id)
Get array of parent role ids from cache.
assignToRole($a_user_obj, $a_role_id)
Assigns a user to a role.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ buildTag()

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

generate a tag with given name and attributes

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

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

References $name, and $type.

391  {
392  $tag = "<";
393 
394  if ($type == "end") {
395  $tag .= "/";
396  }
397 
398  $tag .= $name;
399 
400  if (is_array($attr)) {
401  foreach ($attr as $k => $v) {
402  $tag .= " " . $k . "=\"$v\"";
403  }
404  }
405 
406  $tag .= ">";
407 
408  return $tag;
409  }
$type
if($format !==null) $name
Definition: metadata.php:230

◆ checkProfileIncomplete()

ilUserImportParser::checkProfileIncomplete (   $user_obj)
private

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

private

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

References ilUserProfile\isProfileIncomplete().

Referenced by importEndTag().

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

◆ detachFromRole()

ilUserImportParser::detachFromRole (   $a_user_obj,
  $a_role_id 
)

Detachs a user from a role.

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

References $DIC, ilObject\_getAllReferences(), and ilObject\_lookupTitle().

Referenced by importEndTag().

894  {
895  global $DIC;
896 
897  $rbacreview = $DIC['rbacreview'];
898  $rbacadmin = $DIC['rbacadmin'];
899  $tree = $DIC['tree'];
900 
901  $rbacadmin->deassignUser($a_role_id, $a_user_obj->getId());
902 
903  if (substr(ilObject::_lookupTitle($a_role_id), 0, 6) == 'il_crs' or
904  substr(ilObject::_lookupTitle($a_role_id), 0, 6) == 'il_grp') {
905  $obj = $rbacreview->getObjectOfRole($a_role_id);
906  $ref = ilObject::_getAllReferences($obj);
907  $ref_id = end($ref);
908  $this->recommended_content_manager->removeObjectRecommendation($a_user_obj->getId(), $ref_id);
909  }
910  }
static _lookupTitle($a_id)
lookup object title
static _getAllReferences($a_id)
get all reference ids of object
global $DIC
Definition: goto.php:24
+ 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 434 of file class.ilUserImportParser.php.

References ilUtil\__extractId(), and IL_INST_ID.

Referenced by handlerBeginTag().

435  {
436  switch ($a_name) {
437  case "Role":
438  // detect numeric, ilias id (then extract role id) or alphanumeric
439  $this->current_role_id = $a_attribs["Id"];
440  if ($internal_id = ilUtil::__extractId($this->current_role_id, IL_INST_ID)) {
441  $this->current_role_id = $internal_id;
442  }
443  $this->current_role_type = $a_attribs["Type"];
444 
445  break;
446  }
447  }
const IL_INST_ID
Definition: constants.php:38
static __extractId($ilias_id, $inst_id)
extract ref id from role title, e.g.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ extractRolesEndTag()

ilUserImportParser::extractRolesEndTag (   $a_xml_parser,
  $a_name 
)

handler for end of element when in extract roles mode.

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

Referenced by handlerEndTag().

736  {
737  switch ($a_name) {
738  case "Role":
739  $this->roles[$this->current_role_id]["name"] = $this->cdata;
740  $this->roles[$this->current_role_id]["type"] =
741  $this->current_role_type;
742  break;
743  }
744  }
+ Here is the caller graph for this function:

◆ getCDataWithoutTags()

ilUserImportParser::getCDataWithoutTags ( )
private

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

References stripTags().

Referenced by importEndTag().

2397  : string
2398  {
2399  return $this->stripTags($this->cdata);
2400  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getCollectedRoles()

ilUserImportParser::getCollectedRoles ( )

get collected roles

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

References $roles.

2048  {
2049  return $this->roles;
2050  }

◆ getCourseMembersObjectForRole()

ilUserImportParser::getCourseMembersObjectForRole (   $a_role_id)

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

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

References $DIC, and ilCourseParticipants\_getInstanceByObjId().

764  {
765  global $DIC;
766 
767  $rbacreview = $DIC['rbacreview'];
768  $rbacadmin = $DIC['rbacadmin'];
769  $tree = $DIC['tree'];
770 
771  if (array_key_exists($a_role_id . '_courseMembersObject', $this->localRoleCache)) {
772  return $this->localRoleCache[$a_role_id . '_courseMembersObject'];
773  } else {
774  require_once("Modules/Course/classes/class.ilObjCourse.php");
775  require_once("Modules/Course/classes/class.ilCourseParticipants.php");
776  $course_refs = $rbacreview->getFoldersAssignedToRole($a_role_id, true);
777  $course_ref = $course_refs[0];
778  $course_obj = new ilObjCourse($course_ref, true);
779  $crsmembers_obj = ilCourseParticipants::_getInstanceByObjId($course_obj->getId());
780  $this->localRoleCache[$a_role_id . '_courseMembersObject'] = $crsmembers_obj;
781  return $crsmembers_obj;
782  }
783  }
static _getInstanceByObjId($a_obj_id)
Get singleton instance.
global $DIC
Definition: goto.php:24
+ 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 2161 of file class.ilUserImportParser.php.

References $error_level.

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

◆ getFolderId()

ilUserImportParser::getFolderId ( )

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

References $folder_id.

Referenced by importEndTag().

349  {
350  return $this->folder_id;
351  }
+ 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 833 of file class.ilUserImportParser.php.

References $DIC, and getRoleObject().

Referenced by assignToRoleWithParents().

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

References $protocol.

Referenced by getProtocolAsHTML().

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

◆ getProtocolAsHTML()

ilUserImportParser::getProtocolAsHTML (   $a_log_title)

Returns the protocol as a HTML table.

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

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

2122  : string
2123  {
2124  global $DIC;
2125 
2126  $lng = $DIC['lng'];
2127 
2128  $block = new ilTemplate("tpl.usr_import_log_block.html", true, true, "Services/User");
2129  $block->setVariable("TXT_LOG_TITLE", $a_log_title);
2130  $block->setVariable("TXT_MESSAGE_ID", $lng->txt("login"));
2131  $block->setVariable("TXT_MESSAGE_TEXT", $lng->txt("message"));
2132  foreach ($this->getProtocol() as $login => $messages) {
2133  $block->setCurrentBlock("log_row");
2134  $reason = "";
2135  foreach ($messages as $message) {
2136  if ($reason == "") {
2137  $reason = $message;
2138  } else {
2139  $reason = $reason . "<br>" . $message;
2140  }
2141  }
2142  $block->setVariable("MESSAGE_ID", $login);
2143  $block->setVariable("MESSAGE_TEXT", $reason);
2144  $block->parseCurrentBlock();
2145  }
2146  return $block->get();
2147  }
$login
Definition: cron.php:13
$messages
Definition: xapiexit.php:5
getProtocol()
Returns the protocol.
global $DIC
Definition: goto.php:24
$message
Definition: xapiexit.php:14
+ 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 749 of file class.ilUserImportParser.php.

Referenced by getParentRoleIds().

750  {
751  if (array_key_exists($a_role_id, $this->localRoleCache)) {
752  return $this->localRoleCache[$a_role_id];
753  } else {
754  $role_obj = new ilObjRole($a_role_id, false);
755  $role_obj->read();
756  $this->localRoleCache[$a_role_id] = $role_obj;
757  return $role_obj;
758  }
759  }
Class ilObjRole.
+ Here is the caller graph for this function:

◆ getUserCount()

ilUserImportParser::getUserCount ( )

get count of User elements

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

References $userCount.

2055  {
2056  return $this->userCount;
2057  }
$userCount
The count of user elements in the XML file.

◆ getUserMapping()

ilUserImportParser::getUserMapping ( )

returns a map user_id <=> login

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

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

References $user_mapping.

2172  {
2173  return $this->user_mapping;
2174  }

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

References $mapping_mode.

Referenced by importBeginTag(), and verifyBeginTag().

2228  {
2229  return $this->mapping_mode;
2230  }
+ 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 414 of file class.ilUserImportParser.php.

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

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

◆ handlerCharacterData()

ilUserImportParser::handlerCharacterData (   $a_xml_parser,
  $a_data 
)

handler for character data

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

2031  {
2032  // DELETE WHITESPACES AND NEWLINES OF CHARACTER DATA
2033  // TODO: Mit Alex klären, ob das noch benötigt wird $a_data = preg_replace("/\n/","",$a_data);
2034  // TODO: Mit Alex klären, ob das noch benötigt wird $a_data = preg_replace("/\t+/","",$a_data);
2035  if ($a_data != "\n") {
2036  $a_data = preg_replace("/\t+/", " ", $a_data);
2037  }
2038 
2039  if (strlen($a_data) > 0) {
2040  $this->cdata .= $a_data;
2041  }
2042  }

◆ handlerEndTag()

ilUserImportParser::handlerEndTag (   $a_xml_parser,
  $a_name 
)

handler for end of element

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

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

718  {
719  switch ($this->mode) {
720  case IL_EXTRACT_ROLES:
721  $this->extractRolesEndTag($a_xml_parser, $a_name);
722  break;
723  case IL_USER_IMPORT:
724  $this->importEndTag($a_xml_parser, $a_name);
725  break;
726  case IL_VERIFY:
727  $this->verifyEndTag($a_xml_parser, $a_name);
728  break;
729  }
730  }
const IL_USER_IMPORT
extractRolesEndTag($a_xml_parser, $a_name)
handler for end of element when in extract roles mode.
verifyEndTag($a_xml_parser, $a_name)
handler for end of element when in verify mode.
const IL_EXTRACT_ROLES
const IL_VERIFY
importEndTag($a_xml_parser, $a_name)
handler for end of element when in import user mode.
+ Here is the call graph for this function:

◆ importBeginTag()

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

handler for begin of element in user import mode

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

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

Referenced by handlerBeginTag().

452  {
453  global $DIC;
454 
455  $ilias = $DIC['ilias'];
456  $lng = $DIC['lng'];
457 
458  switch ($a_name) {
459  case "Role":
460  $this->current_role_id = $a_attribs["Id"];
461  if ($internal_id = ilUtil::__extractId($this->current_role_id, IL_INST_ID)) {
462  $this->current_role_id = $internal_id;
463  }
464  $this->current_role_type = $a_attribs["Type"];
465  $this->current_role_action = (is_null($a_attribs["Action"])) ? "Assign" : $a_attribs["Action"];
466  break;
467 
468  case "PersonalPicture":
469  $this->personalPicture = array(
470  "encoding" => $a_attribs["encoding"],
471  "imagetype" => $a_attribs["imagetype"],
472  "content" => ""
473  );
474  break;
475 
476  case "Look":
477  $this->skin = $a_attribs["Skin"];
478  $this->style = $a_attribs["Style"];
479  break;
480 
481  case "User":
482  $this->acc_mail->reset();
483  $this->prefs = array();
484  $this->currentPrefKey = null;
485  $this->auth_mode_set = false;
486  $this->approve_date_set = false;
487  $this->time_limit_set = false;
488  $this->time_limit_owner_set = false;
489  $this->updateLookAndSkin = false;
490  $this->skin = "";
491  $this->style = "";
492  $this->personalPicture = null;
493  $this->userCount++;
494  $this->userObj = new ilObjUser();
495 
496  // user defined fields
497  $this->udf_data = array();
498 
499  // if we have an object id, store it
500  $this->user_id = -1;
501  if (!is_null($a_attribs["Id"]) && $this->getUserMappingMode() == IL_USER_MAPPING_ID) {
502  if (is_numeric($a_attribs["Id"])) {
503  $this->user_id = $a_attribs["Id"];
504  } elseif ($id = ilUtil::__extractId($a_attribs["Id"], IL_INST_ID)) {
505  $this->user_id = $id;
506  }
507  }
508 
509  $this->userObj->setPref(
510  "skin",
511  $ilias->ini->readVariable("layout", "skin")
512  );
513  $this->userObj->setPref(
514  "style",
515  $ilias->ini->readVariable("layout", "style")
516  );
517 
518  $this->userObj->setLanguage($a_attribs["Language"]);
519  $this->userObj->setImportId($a_attribs["Id"]);
520  $this->action = (is_null($a_attribs["Action"])) ? "Insert" : $a_attribs["Action"];
521  $this->currPassword = null;
522  $this->currPasswordType = null;
523  $this->currActive = null;
524  $this->multi_values = array();
525  break;
526 
527  case 'Password':
528  $this->currPasswordType = $a_attribs['Type'];
529  break;
530  case "AuthMode":
531  if (array_key_exists("type", $a_attribs)) {
532  switch ($a_attribs["type"]) {
533  case "saml":
534  case "ldap":
535  if (strcmp('saml', $a_attribs['type']) === 0) {
536  $list = ilSamlIdp::getActiveIdpList();
537  if (count($list) === 1) {
538  $this->auth_mode_set = true;
539  $idp = current($list);
540  $this->userObj->setAuthMode('saml_' . $idp->getIdpId());
541  }
542  break;
543  }
544  if (strcmp('ldap', $a_attribs['type']) === 0) {
545  // no server id provided => use default server
546  include_once './Services/LDAP/classes/class.ilLDAPServer.php';
548  if (count($list) == 1) {
549  $this->auth_mode_set = true;
550  $ldap_id = current($list);
551  $this->userObj->setAuthMode('ldap_' . $ldap_id);
552  }
553  }
554  break;
555 
556  case "default":
557  case "local":
558  case "radius":
559  case "shibboleth":
560  case "script":
561  case "cas":
562  case "soap":
563  case "openid":
564  // begin-patch auth_plugin
565  default:
566  $this->auth_mode_set = true;
567  $this->userObj->setAuthMode($a_attribs["type"]);
568  break;
569  }
570  } else {
571  $this->logFailure(
572  $this->userObj->getLogin(),
573  sprintf($lng->txt("usrimport_xml_element_inapplicable"), "AuthMode", $this->stripTags($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_INST_ID
Definition: constants.php:38
getUserMappingMode()
read access to user mapping mode
static _getActiveServerList()
Get active server list.
const IL_USER_MAPPING_ID
global $DIC
Definition: goto.php:24
logFailure($aLogin, $aMessage)
Writes a failure log message to the protocol.
static getActiveIdpList()
static __extractId($ilias_id, $inst_id)
extract ref id from role title, e.g.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ importEndTag()

ilUserImportParser::importEndTag (   $a_xml_parser,
  $a_name 
)

handler for end of element when in import user mode.

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

References $DIC, Vendor\Package\$e, ilSaxParser\$ilias, $ilSetting, $ilUser, ilSaxParser\$lng, $timestamp, $user_id, ilObjUser\_checkExternalAuthAccount(), ilAuthUtils\_getAuthModeName(), ilUserDefinedFields\_getInstance(), ilObjAdvancedEditing\_getUsedHTMLTags(), ilObjUser\_lookupExternalAccount(), ilObjUser\_uploadPersonalPicture(), ANONYMOUS_USER_ID, assignToRole(), assignToRoleWithParents(), checkProfileIncomplete(), detachFromRole(), getCDataWithoutTags(), getFolderId(), ilObjUser\getUserIdByLogin(), IL_CAL_DATETIME, IL_CAL_UNIX, IL_FAIL_ON_CONFLICT, IL_IGNORE_ON_CONFLICT, IL_PASSWD_CRYPTED, IL_PASSWD_PLAIN, IL_UPDATE_ON_CONFLICT, ilUserXMLWriter\isPrefExportable(), logFailure(), logSuccess(), logWarning(), saveTempImage(), sendAccountMail(), ilUserDefinedData\set(), stripTags(), SYSTEM_USER_ID, and updateMailPreferences().

Referenced by handlerEndTag().

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

◆ isFieldRequired()

ilUserImportParser::isFieldRequired (   $fieldname)
protected

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

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

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

References readRequiredFields().

Referenced by verifyEndTag().

2277  {
2278  $requiredFields = $this->readRequiredFields();
2279  $fieldname = strtolower(trim($fieldname));
2280  return array_key_exists($fieldname, $requiredFields);
2281  }
readRequiredFields()
read required fields
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isSendMail()

ilUserImportParser::isSendMail ( )

read access to property send mail

Returns
boolean

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

References $send_mail.

Referenced by sendAccountMail().

2204  {
2205  return $this->send_mail;
2206  }
+ Here is the caller graph for this function:

◆ isSuccess()

ilUserImportParser::isSuccess ( )

Returns true, if the import was successful.

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

References IL_IMPORT_SUCCESS.

2153  {
2154  return $this->error_level == IL_IMPORT_SUCCESS;
2155  }
const IL_IMPORT_SUCCESS

◆ logFailure()

ilUserImportParser::logFailure (   $aLogin,
  $aMessage 
)

Writes a failure log message to the protocol.

Parameters
stringlogin
stringmessage

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

References IL_IMPORT_FAILURE.

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

2084  {
2085  if (!array_key_exists($aLogin, $this->protocol)) {
2086  $this->protocol[$aLogin] = array();
2087  }
2088  if ($aMessage) {
2089  $this->protocol[$aLogin][] = $aMessage;
2090  }
2091  $this->error_level = IL_IMPORT_FAILURE;
2092  }
const IL_IMPORT_FAILURE
+ 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 2101 of file class.ilUserImportParser.php.

References $action.

Referenced by importEndTag().

2102  {
2103  $this->user_mapping[$userid] = array("login" => $aLogin, "action" => $action, "message" => "successful");
2104  }
$action
The Action attribute determines what to do for the current User element.
+ 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 2065 of file class.ilUserImportParser.php.

References IL_IMPORT_SUCCESS, and IL_IMPORT_WARNING.

Referenced by importEndTag(), and verifyEndTag().

2066  {
2067  if (!array_key_exists($aLogin, $this->protocol)) {
2068  $this->protocol[$aLogin] = array();
2069  }
2070  if ($aMessage) {
2071  $this->protocol[$aLogin][] = $aMessage;
2072  }
2073  if ($this->error_level == IL_IMPORT_SUCCESS) {
2074  $this->error_level = IL_IMPORT_WARNING;
2075  }
2076  }
const IL_IMPORT_WARNING
const IL_IMPORT_SUCCESS
+ Here is the caller graph for this function:

◆ readRequiredFields()

ilUserImportParser::readRequiredFields ( )
private

read required fields

private

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

References $DIC, and $ilSetting.

Referenced by isFieldRequired().

2239  {
2240  global $DIC;
2241 
2242  $ilSetting = $DIC['ilSetting'];
2243 
2244  if (is_array($this->required_fields)) {
2245  return $this->required_fields;
2246  }
2247  foreach ($ilSetting->getAll() as $field => $value) {
2248  if (substr($field, 0, 8) == 'require_' and $value == 1) {
2249  $value = substr($field, 8);
2250  $this->required_fields[$value] = $value;
2251  }
2252  }
2253  return $this->required_fields ? $this->required_fields : array();
2254  }
global $DIC
Definition: goto.php:24
global $ilSetting
Definition: privfeed.php:17
+ Here is the caller graph for this function:

◆ saveTempImage()

ilUserImportParser::saveTempImage (   $image_data,
  $filename 
)

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

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

References $filename, and ilUtil\ilTempnam().

Referenced by importEndTag().

1685  {
1686  $tempname = ilUtil::ilTempnam() . $filename;
1687  $fh = fopen($tempname, "wb");
1688  if ($fh == false) {
1689  return "";
1690  }
1691  $imagefile = fwrite($fh, $image_data);
1692  fclose($fh);
1693  return $tempname;
1694  }
$filename
Definition: buildRTE.php:89
static ilTempnam($a_temp_path=null)
Returns a unique and non existing Path for e temporary file or directory.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ sendAccountMail()

ilUserImportParser::sendAccountMail ( )

send account mail

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

References $_POST, and isSendMail().

Referenced by importEndTag().

2180  {
2181  if ($_POST["send_mail"] != "" ||
2182  ($this->isSendMail() && $this->userObj->getEmail() != "")) {
2183  $this->acc_mail->setUser($this->userObj);
2184  $this->acc_mail->send();
2185  }
2186  }
isSendMail()
read access to property send mail
$_POST["username"]
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setFolderId()

ilUserImportParser::setFolderId (   $a_folder_id)

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

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

344  {
345  $this->folder_id = $a_folder_id;
346  }

◆ setHandlers()

ilUserImportParser::setHandlers (   $a_xml_parser)

set event handler should be overwritten by inherited class private

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

359  {
360  xml_set_object($a_xml_parser, $this);
361  xml_set_element_handler($a_xml_parser, 'handlerBeginTag', 'handlerEndTag');
362  xml_set_character_data_handler($a_xml_parser, 'handlerCharacterData');
363  }

◆ setRoleAssignment()

ilUserImportParser::setRoleAssignment (   $a_assign)

set import to local role assignemt

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

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

379  {
380  $this->role_assign = $a_assign;
381  }

◆ setSendMail()

ilUserImportParser::setSendMail (   $value)

write access to property send mail

Parameters
mixed$value

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

2194  {
2195  $this->send_mail = $value ? true: false;
2196  }

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

References IL_USER_MAPPING_ID, and IL_USER_MAPPING_LOGIN.

2214  {
2215  if ($value == IL_USER_MAPPING_ID || $value == IL_USER_MAPPING_LOGIN) {
2216  $this->mapping_mode = $value;
2217  } else {
2218  die("wrong argument using methode setUserMappingMethod in " . __FILE__);
2219  }
2220  }
const IL_USER_MAPPING_LOGIN
const IL_USER_MAPPING_ID

◆ startParsing()

ilUserImportParser::startParsing ( )

start the parser

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

369  {
370  parent::startParsing();
371  }

◆ stripTags()

ilUserImportParser::stripTags ( string  $string)
private

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

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

2402  : string
2403  {
2404  return strip_tags($string);
2405  }
+ Here is the caller graph for this function:

◆ updateMailPreferences()

ilUserImportParser::updateMailPreferences (   $usr_id)
private

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

Referenced by importEndTag().

2382  {
2383  if (array_key_exists("mail_incoming_type", $this->prefs) ||
2384  array_key_exists("mail_signature", $this->prefs) ||
2385  array_key_exists("mail_linebreak", $this->prefs)
2386  ) {
2387  include_once("Services/Mail/classes/class.ilMailOptions.php");
2388  $mailOptions = new ilMailOptions($usr_id);
2389 
2390  $mailOptions->setLinebreak(array_key_exists("mail_linebreak", $this->prefs) ? $this->prefs["mail_linebreak"] : $mailOptions->getLinebreak());
2391  $mailOptions->setSignature(array_key_exists("mail_signature", $this->prefs) ? $this->prefs["mail_signature"] : $mailOptions->getSignature());
2392  $mailOptions->setIncomingType(array_key_exists("mail_incoming_type", $this->prefs) ? $this->prefs["mail_incoming_type"] : $mailOptions->getIncomingType());
2393  $mailOptions->updateOptions();
2394  }
2395  }
Class ilMailOptions this class handles user mails.
+ Here is the caller graph for this function:

◆ verifyBeginTag()

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

handler for begin of element

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

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

Referenced by handlerBeginTag().

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", $this->stripTags($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->stripTags($this->current_role_action), $this->stripTags($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", $this->stripTags($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) {
668  $list = ilSamlIdp::getActiveIdpList();
669  if (count($list) !== 1) {
670  $this->logFailure(
671  $this->userObj->getImportId(),
672  sprintf($lng->txt("usrimport_xml_attribute_value_illegal"), "AuthMode", "type", $this->stripTags($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", $this->stripTags($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  } else {
704  $this->logFailure($this->userObj->getImportId(), sprintf($lng->txt("usrimport_xml_attribute_value_illegal"), "AuthMode", "type", ""));
705  }
706  break;
707  case 'Pref':
708  $this->currentPrefKey = $a_attribs["key"];
709  break;
710 
711  }
712  }
const IL_INST_ID
Definition: constants.php:38
getUserMappingMode()
read access to user mapping mode
static _getActiveServerList()
Get active server list.
const IL_USER_MAPPING_ID
global $DIC
Definition: goto.php:24
logFailure($aLogin, $aMessage)
Writes a failure log message to the protocol.
static getActiveIdpList()
static __extractId($ilias_id, $inst_id)
extract ref id from role title, e.g.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ verifyEndTag()

ilUserImportParser::verifyEndTag (   $a_xml_parser,
  $a_name 
)

handler for end of element when in verify mode.

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

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

Referenced by handlerEndTag().

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

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

Referenced by verifyEndTag().

2284  {
2285  switch ($key) {
2286  case 'mail_linebreak':
2287  case 'hits_per_page':
2288  if (!is_numeric($value) || $value < 0) {
2289  $this->logFailure("---", "Wrong value '{$this->stripTags($value)}': Positiv numeric value expected for preference {$this->stripTags($key)}.");
2290  }
2291  break;
2292  case 'language':
2293  case 'skin':
2294  case 'style':
2295  case 'ilPageEditor_HTMLMode':
2296  case 'ilPageEditor_JavaScript':
2297  case 'ilPageEditor_MediaMode':
2298  case 'tst_javascript':
2299  case 'tst_lastquestiontype':
2300  case 'tst_multiline_answers':
2301  case 'tst_use_previous_answers':
2302  case 'graphicalAnswerSetting':
2303  case 'priv_feed_pass':
2304  $this->logFailure("---", "Preference {$this->stripTags($key)} is not supported.");
2305  break;
2306  case 'public_city':
2307  case 'public_country':
2308  case 'public_department':
2309  case 'public_email':
2310  case 'public_second_email':
2311  case 'public_fax':
2312  case 'public_hobby':
2313  case 'public_institution':
2314  case 'public_matriculation':
2315  case 'public_phone':
2316  case 'public_phone_home':
2317  case 'public_phone_mobile':
2318  case 'public_phone_office':
2319  case 'public_street':
2320  case 'public_upload':
2321  case 'public_zip':
2322  case 'public_interests_general':
2323  case 'public_interests_help_offered':
2324  case 'public_interests_help_looking':
2325  case 'send_info_mails':
2326  case 'hide_own_online_status':
2327  if (!in_array($value, array('y', 'n'))) {
2328  $this->logFailure("---", "Wrong value '{$this->stripTags($value)}': Value 'y' or 'n' expected for preference {$this->stripTags($key)}.");
2329  }
2330  break;
2331  case 'bs_allow_to_contact_me':
2332  if (!in_array($value, array('y', 'n'))) {
2333  $this->logFailure("---", "Wrong value '{$this->stripTags($value)}': Value 'y' or 'n' expected for preference {$this->stripTags($key)}.");
2334  }
2335  break;
2336  case 'chat_osc_accept_msg':
2337  if (!in_array($value, array('y', 'n'))) {
2338  $this->logFailure("---", "Wrong value '{$this->stripTags($value)}': Value 'y' or 'n' expected for preference {$this->stripTags($key)}.");
2339  }
2340  break;
2341  case 'public_profile':
2342  if (!in_array($value, array('y', 'n', 'g'))) {
2343  $this->logFailure("---", "Wrong value '{$this->stripTags($value)}': Value 'y', 'g' or 'n' expected for preference {$this->stripTags($key)}.");
2344  }
2345  break;
2346  case 'show_users_online':
2347  if (!in_array($value, array('y', 'n', 'associated'))) {
2348  $this->logFailure("---", "Wrong value '{$this->stripTags($value)}': Value 'y' or 'n' or 'associated' expected for preference {$this->stripTags($key)}.");
2349  }
2350  break;
2351  case 'mail_incoming_type':
2352  if (!in_array((int) $value, array("0","1","2"))) {
2353  $this->logFailure("---", "Wrong value '{$this->stripTags($value)}': Value \"0\" (LOCAL),\"1\" (EMAIL) or \"2\" (BOTH) expected for preference {$this->stripTags($key)}.");
2354  }
2355  break;
2356  case 'weekstart':
2357  if (!in_array($value, array("0","1"))) {
2358  $this->logFailure("---", "Wrong value '{$this->stripTags($value)}': Value \"0\" (Sunday) or \"1\" (Monday) expected for preference {$this->stripTags($key)}.");
2359  }
2360  break;
2361 
2362  case 'mail_signature':
2363  break;
2364  case 'user_tz':
2365  include_once('Services/Calendar/classes/class.ilTimeZone.php');
2366  try {
2367  $tz = ilTimeZone::_getInstance($value);
2368  return true;
2369  } catch (ilTimeZoneException $tze) {
2370  $this->logFailure("---", "Wrong value '{$this->stripTags($value)}': Invalid timezone $value detected for preference {$this->stripTags($key)}.");
2371  }
2372  break;
2373  default:
2374  if (!ilUserXMLWriter::isPrefExportable($key)) {
2375  $this->logFailure("---", "Preference {$this->stripTags($key)} is not supported.");
2376  }
2377  break;
2378  }
2379  }
static isPrefExportable($key)
returns wether a key from db is exportable or not
Class for TimeZone exceptions.
logFailure($aLogin, $aMessage)
Writes a failure log message to the protocol.
static _getInstance($a_tz='')
get instance by timezone
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

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

Referenced by logSuccess().

◆ $approve_date_set

ilUserImportParser::$approve_date_set = false

Definition at line 52 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 94 of file class.ilUserImportParser.php.

◆ $currActive

ilUserImportParser::$currActive

The active state of the current user.

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

◆ $current_messenger_type

ilUserImportParser::$current_messenger_type
private

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

◆ $currPassword

ilUserImportParser::$currPassword

The password of the current user.

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

◆ $currPasswordType

ilUserImportParser::$currPasswordType

The password type of the current user.

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

◆ $disableSkin

ilUserImportParser::$disableSkin

Indicates if the skins are enabled.

Definition at line 247 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 165 of file class.ilUserImportParser.php.

Referenced by getErrorLevel().

◆ $folder_id

ilUserImportParser::$folder_id

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

Referenced by getFolderId().

◆ $hideSkin

ilUserImportParser::$hideSkin

Indicates if the skins are hidden.

Definition at line 242 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 207 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 85 of file class.ilUserImportParser.php.

◆ $mapping_mode

ilUserImportParser::$mapping_mode

Definition at line 198 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 222 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 213 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 75 of file class.ilUserImportParser.php.

Referenced by getProtocol().

◆ $recommended_content_manager

ilUserImportParser::$recommended_content_manager
protected

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

◆ $roles

ilUserImportParser::$roles

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

Referenced by getCollectedRoles().

◆ $send_mail

ilUserImportParser::$send_mail

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

Referenced by isSendMail().

◆ $skin

ilUserImportParser::$skin

ILIAS skin.

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

Referenced by __construct().

◆ $style

ilUserImportParser::$style

ILIAS style.

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

Referenced by __construct().

◆ $time_limit_owner_set

ilUserImportParser::$time_limit_owner_set = false

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

◆ $time_limit_set

ilUserImportParser::$time_limit_set = false

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

◆ $updateLookAndSkin

ilUserImportParser::$updateLookAndSkin = false

boolean to determine if look and skin should be updated

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

◆ $user_id

ilUserImportParser::$user_id

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

Referenced by importEndTag(), and verifyEndTag().

◆ $user_mapping

ilUserImportParser::$user_mapping = []

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

Referenced by getUserMapping().

◆ $user_settings_config

ilUserImportParser::$user_settings_config
protected

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

◆ $userCount

ilUserImportParser::$userCount

The count of user elements in the XML file.

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

Referenced by getUserCount().

◆ $userObj

ilUserImportParser::$userObj
private

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

◆ $userStyles

ilUserImportParser::$userStyles

User assigned styles.

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


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