ILIAS  trunk Revision v11.0_alpha-1744-gb0451eebef4
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilUserImportParser Class Reference
+ Inheritance diagram for ilUserImportParser:
+ Collaboration diagram for ilUserImportParser:

Public Member Functions

 setFolderId (int $a_folder_id)
 assign users to this folder (normally the usr_folder) But if called from local admin => the ref_id of the category More...
 
 getFolderId ()
 
 setHandlers ($a_xml_parser)
 set event handler should be overwritten by inherited class private More...
 
 setRoleAssignment (array $a_assign)
 set import to local role assignemt More...
 
 buildTag (string $type, string $name, ?array $attr=null)
 generate a tag with given name and attributes More...
 
 handlerBeginTag ( $a_xml_parser, string $a_name, array $a_attribs)
 
 extractRolesBeginTag ( $a_xml_parser, string $a_name, array $a_attribs)
 
 importBeginTag ( $a_xml_parser, string $a_name, array $a_attribs)
 
 verifyBeginTag ( $a_xml_parser, string $a_name, array $a_attribs)
 
 handlerEndTag ( $a_xml_parser, string $a_name)
 
 extractRolesEndTag ( $a_xml_parser, string $a_name)
 
 getRoleObject (int $a_role_id)
 Returns the parent object of the role folder object which contains the specified role. More...
 
 getCourseMembersObjectForRole (int $a_role_id)
 Returns the parent object of the role folder object which contains the specified role. More...
 
 assignToRole (ilObjUser $a_user_obj, int $a_role_id)
 Assigns a user to a role. More...
 
 getParentRoleIds (int $a_role_id)
 Get array of parent role ids from cache. More...
 
 assignToRoleWithParents (ilObjUser $a_user_obj, int $a_role_id)
 Assigns a user to a role and to all parent roles. More...
 
 detachFromRole (ilObjUser $a_user_obj, int $a_role_id)
 Detaches a user from a role. More...
 
 importEndTag ( $a_xml_parser, string $a_name)
 
 saveTempImage (string $image_data, string $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, string $a_name)
 handler for end of element when in verify mode. More...
 
 handlerCharacterData ( $a_xml_parser, string $a_data)
 handler for character data More...
 
 getCollectedRoles ()
 
 getUserCount ()
 
 logWarning (string $aLogin, string $aMessage)
 Writes a warning log message to the protocol. More...
 
 logFailure (string $aLogin, string $aMessage)
 Writes a failure log message to the protocol. More...
 
 logSuccess (string $aLogin, int $userid, string $action)
 Writes a success log message to the protocol. More...
 
 getProtocol ()
 The protocol is an associative array. More...
 
 getProtocolAsHTML (string $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 (bool $value)
 
 isSendMail ()
 
 setUserMappingMode (int $value)
 write access to user mapping mode More...
 
 getUserMappingMode ()
 read access to user mapping mode More...
 
- Public Member Functions inherited from ilSaxParser
 __construct (?string $path_to_file='', ?bool $throw_exception=false)
 
 setXMLContent (string $a_xml_content)
 
 getXMLContent ()
 
 getInputType ()
 
 startParsing ()
 stores xml data in array More...
 
 createParser ()
 
 setHandlers ($a_xml_parser)
 
 parse ($a_xml_parser, $a_fp=null)
 

Data Fields

const IL_EXTRACT_ROLES = 1
 
const IL_USER_IMPORT = 2
 
const IL_VERIFY = 3
 
const IL_FAIL_ON_CONFLICT = 1
 
const IL_UPDATE_ON_CONFLICT = 2
 
const IL_IGNORE_ON_CONFLICT = 3
 
const IL_IMPORT_SUCCESS = 1
 
const IL_IMPORT_WARNING = 2
 
const IL_IMPORT_FAILURE = 3
 
const IL_USER_MAPPING_ID = 2
 
bool $approve_date_set = false
 
bool $time_limit_set = false
 
bool $time_limit_owner_set = false
 
bool $updateLookAndSkin = false
 
int $folder_id
 
array $roles
 
string $action
 
array $protocol
 The variable holds the protocol of the import. More...
 
array $logins
 This variable is used to collect each login that we encounter in the import data. More...
 
int $conflict_rule
 
bool $send_mail
 
int $error_level
 This variable is used to report the error level of the validation process or the importing process. More...
 
string $currPasswordType
 
string $currPassword
 
string $currActive = null
 
int $userCount
 
array $user_mapping = []
 
int $mapping_mode
 
array $localRoleCache
 Cached local roles. More...
 
array $personalPicture = null
 Cached personal picture of the actual user This is used because the ilObjUser object has no field for the personal picture. More...
 
array $parentRolesCache
 Cached parent roles. More...
 
string $skin = ''
 
string $style = ''
 
array $userStyles
 User assigned styles. More...
 
int $user_id
 
- Data Fields inherited from ilSaxParser
string $xml_file
 
bool $throw_exception = false
 

Protected Member Functions

 tagContained (string $tagname)
 
 isFieldRequired (string $fieldname)
 determine if a field $fieldname is to a required field (global setting) More...
 
- Protected Member Functions inherited from ilSaxParser
 openXMLFile ()
 
 handleError (string $message)
 
 setThrowException (bool $throw_exception)
 

Protected Attributes

string $tmp_udf_name = null
 
string $tmp_udf_id = null
 
array $multi_values
 
array $udf_data
 
bool $auth_mode_set
 
string $currentPrefKey = null
 
array $prefs
 
string $current_role_action
 
string $current_role_type
 
string $current_role_id = '0'
 
string $cdata
 
array $role_assign
 
string $req_send_mail
 
ilAccountMail $acc_mail
 
int $mode
 
array $required_fields = []
 
array $containedTags = []
 
ilRecommendedContentManager $recommended_content_manager
 
ilUserSettingsConfig $user_settings_config
 
- Protected Attributes inherited from ilSaxParser
ilLanguage $lng = null
 

Private Member Functions

 readRequiredFields ()
 
 checkProfileIncomplete (ilObjUser $user_obj)
 Check if profile is incomplete Will set the usr_data field profile_incomplete if any required field is missing. More...
 
 verifyPref (string $key, string $value)
 
 updateMailPreferences (int $usr_id)
 
 getCDataWithoutTags ()
 
 stripTags (string $string)
 

Private Attributes

const IL_USER_MAPPING_LOGIN = 1
 
ILIAS $ilias
 
ilSetting $settings
 
ilObjectDataCache $object_data_cache
 
ilRbacReview $rbac_review
 
ilRbacAdmin $rbac_admin
 
ilAccess $access
 
ilObjUser $user
 
ilUserProfile $user_profile
 
ilObjUser $userObj
 
string $current_messenger_type
 
Refinery $refinery
 

Detailed Description

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

Member Function Documentation

◆ assignToRole()

ilUserImportParser::assignToRole ( ilObjUser  $a_user_obj,
int  $a_role_id 
)

Assigns a user to a role.

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

References $ref_id, ilObject\_getAllReferences(), ilObject\_lookupType(), and ilObject\getId().

Referenced by assignToRoleWithParents(), and importEndTag().

718  : void
719  {
720  // Do nothing, if the user is already assigned to the role.
721  // Specifically, we do not want to put a course object or
722  // group object on the personal desktop again, if a user
723  // has removed it from the personal desktop.
724  if ($this->rbac_review->isAssigned($a_user_obj->getId(), $a_role_id)) {
725  return;
726  }
727 
728  // If it is a course role, use the ilCourseMember object to assign
729  // the user to the role
730 
731  $this->rbac_admin->assignUser($a_role_id, $a_user_obj->getId(), true);
732  $obj_id = $this->rbac_review->getObjectOfRole($a_role_id);
733  switch (ilObject::_lookupType($obj_id)) {
734  case 'grp':
735  case 'crs':
736  $ref_ids = ilObject::_getAllReferences($obj_id);
737  $ref_id = current((array) $ref_ids);
738  if ($ref_id) {
739  // deactivated for now, see discussion at
740  // https://docu.ilias.de/goto_docu_wiki_wpage_5620_1357.html
741  //$this->recommended_content_manager->addObjectRecommendation($a_user_obj->getId(), $ref_id);
742  }
743  break;
744  default:
745  break;
746  }
747  }
static _getAllReferences(int $id)
get all reference ids for object ID
$ref_id
Definition: ltiauth.php:65
static _lookupType(int $id, bool $reference=false)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ assignToRoleWithParents()

ilUserImportParser::assignToRoleWithParents ( ilObjUser  $a_user_obj,
int  $a_role_id 
)

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

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

References assignToRole(), and getParentRoleIds().

Referenced by importEndTag().

802  : void {
803  $this->assignToRole($a_user_obj, $a_role_id);
804 
805  $parent_role_ids = $this->getParentRoleIds($a_role_id);
806  foreach ($parent_role_ids as $parent_role_id) {
807  $this->assignToRole($a_user_obj, $parent_role_id);
808  }
809  }
getParentRoleIds(int $a_role_id)
Get array of parent role ids from cache.
assignToRole(ilObjUser $a_user_obj, int $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 ( string  $type,
string  $name,
?array  $attr = null 
)

generate a tag with given name and attributes

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

323  : string // Missing array type.
324  {
325  $tag = '<';
326 
327  if ($type === 'end') {
328  $tag .= '/';
329  }
330 
331  $tag .= $name;
332 
333  if (is_array($attr)) {
334  foreach ($attr as $k => $v) {
335  $tag .= " {$k}='{$v}'";
336  }
337  }
338 
339  $tag .= '>';
340 
341  return $tag;
342  }

◆ checkProfileIncomplete()

ilUserImportParser::checkProfileIncomplete ( ilObjUser  $user_obj)
private

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

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

Referenced by importEndTag().

2149  : bool
2150  {
2151  return $this->user_profile->isProfileIncomplete($user_obj);
2152  }
+ Here is the caller graph for this function:

◆ detachFromRole()

ilUserImportParser::detachFromRole ( ilObjUser  $a_user_obj,
int  $a_role_id 
)

Detaches a user from a role.

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

References $ref_id, ilObject\_getAllReferences(), ilObject\_lookupTitle(), and ilObject\getId().

Referenced by importEndTag().

817  : void {
818  $this->rbac_admin->deassignUser($a_role_id, $a_user_obj->getId());
819 
820  if (substr(ilObject::_lookupTitle($a_role_id), 0, 6) !== 'il_crs'
821  && substr(ilObject::_lookupTitle($a_role_id), 0, 6) !== 'il_grp') {
822  return;
823  }
824 
826  $this->rbac_review->getObjectOfRole($a_role_id)
827  );
828  $ref_id = end($ref);
829  if (!$ref_id) {
830  return;
831  }
832  $this->recommended_content_manager->removeObjectRecommendation($a_user_obj->getId(), $ref_id);
833  }
static _getAllReferences(int $id)
get all reference ids for object ID
$ref_id
Definition: ltiauth.php:65
static _lookupTitle(int $obj_id)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ extractRolesBeginTag()

ilUserImportParser::extractRolesBeginTag (   $a_xml_parser,
string  $a_name,
array  $a_attribs 
)
Parameters
\XMLParser | resource$a_xml_parser

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

References ilUtil\__extractId(), IL_INST_ID, and ILIAS\Repository\refinery().

Referenced by handlerBeginTag().

371  : void {
372  switch ($a_name) {
373  case 'Role':
374  // detect numeric, ilias id (then extract role id) or alphanumeric
375  $current_role_id = $a_attribs['Id'];
376  if (($internal_id = ilUtil::__extractId($current_role_id, (int) IL_INST_ID)) > 0) {
377  $current_role_id = $internal_id;
378  }
379  $this->current_role_id = $this->refinery->kindlyTo()->string()->transform($current_role_id);
380  $this->current_role_type = $a_attribs['Type'];
381  break;
382  }
383  }
const IL_INST_ID
Definition: constants.php:40
static __extractId(string $ilias_id, int $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,
string  $a_name 
)
Parameters
\XMLParser | resource$a_xml_parser

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

References $cdata, $current_role_id, and $current_role_type.

Referenced by handlerEndTag().

673  : void {
674  switch ($a_name) {
675  case 'Role':
676  $this->roles[$this->current_role_id]['name'] = $this->cdata;
677  $this->roles[$this->current_role_id]['type'] =
679  break;
680  }
681  }
+ Here is the caller graph for this function:

◆ getCDataWithoutTags()

ilUserImportParser::getCDataWithoutTags ( )
private

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

References stripTags().

Referenced by importEndTag().

2266  : string
2267  {
2268  return $this->stripTags($this->cdata);
2269  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getCollectedRoles()

ilUserImportParser::getCollectedRoles ( )
Returns
array[]

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

References $roles.

1963  : array
1964  {
1965  return $this->roles;
1966  }

◆ getCourseMembersObjectForRole()

ilUserImportParser::getCourseMembersObjectForRole ( int  $a_role_id)

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

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

References ilCourseParticipants\_getInstanceByObjId().

702  {
703  if (array_key_exists($a_role_id . '_courseMembersObject', $this->localRoleCache)) {
704  return $this->localRoleCache[$a_role_id . '_courseMembersObject'];
705  } else {
706  $course_refs = $this->rbac_review->getFoldersAssignedToRole($a_role_id, true);
707  $course_ref = $course_refs[0];
708  $course_obj = new ilObjCourse($course_ref, true);
709  $crsmembers_obj = ilCourseParticipants::_getInstanceByObjId($course_obj->getId());
710  $this->localRoleCache[$a_role_id . '_courseMembersObject'] = $crsmembers_obj;
711  return $crsmembers_obj;
712  }
713  }
static _getInstanceByObjId(int $a_obj_id)
+ Here is the call graph for this function:

◆ getErrorLevel()

ilUserImportParser::getErrorLevel ( )

Returns the error level.

Returns
int IL_IMPORT_SUCCESS | IL_IMPORT_WARNING | IL_IMPORT_FAILURE

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

References $error_level.

Referenced by ilObjUserFolderGUI\verifyXmlData().

2069  : int
2070  {
2071  return $this->error_level;
2072  }
int $error_level
This variable is used to report the error level of the validation process or the importing process...
+ Here is the caller graph for this function:

◆ getFolderId()

ilUserImportParser::getFolderId ( )

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

References $folder_id.

Referenced by importEndTag().

292  : int
293  {
294  return $this->folder_id;
295  }
+ Here is the caller graph for this function:

◆ getParentRoleIds()

ilUserImportParser::getParentRoleIds ( int  $a_role_id)

Get array of parent role ids from cache.

If necessary, create a new cache entry.

Returns
array[]

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

References getRoleObject().

Referenced by assignToRoleWithParents().

754  : array
755  {
756  if (!array_key_exists($a_role_id, $this->parentRolesCache)) {
757  $parent_role_ids = [];
758 
759  $role_obj = $this->getRoleObject($a_role_id);
760  $short_role_title = substr($role_obj->getTitle(), 0, 12);
761  $folders = $this->rbac_review->getFoldersAssignedToRole($a_role_id, true);
762  if (count($folders) > 0) {
763  $all_parent_role_ids = $this->rbac_review->getParentRoleIds($folders[0]);
764  foreach ($all_parent_role_ids as $parent_role_id => $parent_role_data) {
765  if ($parent_role_id != $a_role_id) {
766  switch (substr($parent_role_data['title'], 0, 12)) {
767  case 'il_crs_admin':
768  case 'il_grp_admin':
769  if ($short_role_title === 'il_crs_admin' || $short_role_title === 'il_grp_admin') {
770  $parent_role_ids[] = $parent_role_id;
771  }
772  break;
773  case 'il_crs_tutor':
774  case 'il_grp_tutor':
775  if ($short_role_title === 'il_crs_tutor' || $short_role_title === 'il_grp_tutor') {
776  $parent_role_ids[] = $parent_role_id;
777  }
778  break;
779  case 'il_crs_membe':
780  case 'il_grp_membe':
781  if ($short_role_title === 'il_crs_membe' || $short_role_title === 'il_grp_membe') {
782  $parent_role_ids[] = $parent_role_id;
783  }
784  break;
785  default:
786  break;
787  }
788  }
789  }
790  }
791  $this->parentRolesCache[$a_role_id] = $parent_role_ids;
792  }
793  return $this->parentRolesCache[$a_role_id];
794  }
getRoleObject(int $a_role_id)
Returns the parent object of the role folder object which contains the specified role.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getProtocol()

ilUserImportParser::getProtocol ( )

The protocol is an associative array.

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

Returns
array[]

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

References $protocol.

Referenced by getProtocolAsHTML().

2026  : array
2027  {
2028  return $this->protocol;
2029  }
array $protocol
The variable holds the protocol of the import.
+ Here is the caller graph for this function:

◆ getProtocolAsHTML()

ilUserImportParser::getProtocolAsHTML ( string  $a_log_title)

Returns the protocol as a HTML table.

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

References $message, $messages, getProtocol(), and ILIAS\Repository\lng().

Referenced by ilObjUserFolderGUI\verifyXmlData().

2034  : string
2035  {
2036  $block = new ilTemplate('tpl.usr_import_log_block.html', true, true, 'components/ILIAS/User');
2037  $block->setVariable('TXT_LOG_TITLE', $a_log_title);
2038  $block->setVariable('TXT_MESSAGE_ID', $this->lng->txt('login'));
2039  $block->setVariable('TXT_MESSAGE_TEXT', $this->lng->txt('message'));
2040  foreach ($this->getProtocol() as $login => $messages) {
2041  $block->setCurrentBlock('log_row');
2042  $reason = '';
2043  foreach ($messages as $message) {
2044  if ($reason == '') {
2045  $reason = $message;
2046  } else {
2047  $reason .= '<br>' . $message;
2048  }
2049  }
2050  $block->setVariable('MESSAGE_ID', $login);
2051  $block->setVariable('MESSAGE_TEXT', $reason);
2052  $block->parseCurrentBlock();
2053  }
2054  return $block->get();
2055  }
$messages
Definition: xapiexit.php:21
getProtocol()
The protocol is an associative array.
$message
Definition: xapiexit.php:31
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getRoleObject()

ilUserImportParser::getRoleObject ( int  $a_role_id)

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

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

Referenced by getParentRoleIds().

686  : ilObjRole
687  {
688  if (array_key_exists($a_role_id, $this->localRoleCache)) {
689  return $this->localRoleCache[$a_role_id];
690  } else {
691  $role_obj = new ilObjRole($a_role_id, false);
692  $role_obj->read();
693  $this->localRoleCache[$a_role_id] = $role_obj;
694  return $role_obj;
695  }
696  }
Class ilObjRole.
+ Here is the caller graph for this function:

◆ getUserCount()

ilUserImportParser::getUserCount ( )

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

References $userCount.

1968  : int
1969  {
1970  return $this->userCount;
1971  }

◆ getUserMapping()

ilUserImportParser::getUserMapping ( )

returns a map user_id <=> login

Returns
array with user_id as key and login as value

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

References $user_mapping.

2078  : array
2079  {
2080  return $this->user_mapping;
2081  }

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

References $mapping_mode.

Referenced by importBeginTag(), and verifyBeginTag().

2123  : int
2124  {
2125  return $this->mapping_mode;
2126  }
+ Here is the caller graph for this function:

◆ handlerBeginTag()

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

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

References extractRolesBeginTag(), importBeginTag(), and verifyBeginTag().

Referenced by setHandlers().

348  : void {
349  switch ($this->mode) {
350  case self::IL_EXTRACT_ROLES:
351  $this->extractRolesBeginTag($a_xml_parser, $a_name, $a_attribs);
352  break;
353  case self::IL_USER_IMPORT:
354  $this->importBeginTag($a_xml_parser, $a_name, $a_attribs);
355  break;
356  case self::IL_VERIFY:
357  $this->verifyBeginTag($a_xml_parser, $a_name, $a_attribs);
358  break;
359  }
360 
361  $this->cdata = '';
362  }
verifyBeginTag( $a_xml_parser, string $a_name, array $a_attribs)
extractRolesBeginTag( $a_xml_parser, string $a_name, array $a_attribs)
importBeginTag( $a_xml_parser, string $a_name, array $a_attribs)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ handlerCharacterData()

ilUserImportParser::handlerCharacterData (   $a_xml_parser,
string  $a_data 
)

handler for character data

Parameters
\XMLParser | resource$a_xml_parser

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

Referenced by setHandlers().

1950  : void {
1951  if ($a_data !== "\n") {
1952  $a_data = preg_replace('/\t+/', ' ', $a_data);
1953  }
1954 
1955  if (strlen($a_data) > 0) {
1956  $this->cdata .= $a_data;
1957  }
1958  }
+ Here is the caller graph for this function:

◆ handlerEndTag()

ilUserImportParser::handlerEndTag (   $a_xml_parser,
string  $a_name 
)

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

References extractRolesEndTag(), importEndTag(), and verifyEndTag().

Referenced by setHandlers().

653  : void {
654  switch ($this->mode) {
655  case self::IL_EXTRACT_ROLES:
656  $this->extractRolesEndTag($a_xml_parser, $a_name);
657  break;
658  case self::IL_USER_IMPORT:
659  $this->importEndTag($a_xml_parser, $a_name);
660  break;
661  case self::IL_VERIFY:
662  $this->verifyEndTag($a_xml_parser, $a_name);
663  break;
664  }
665  }
extractRolesEndTag( $a_xml_parser, string $a_name)
importEndTag( $a_xml_parser, string $a_name)
verifyEndTag( $a_xml_parser, string $a_name)
handler for end of element when in verify mode.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ importBeginTag()

ilUserImportParser::importBeginTag (   $a_xml_parser,
string  $a_name,
array  $a_attribs 
)
Parameters
\XMLParser | resource$a_xml_parser

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

References $id, ilUtil\__extractId(), ilLDAPServer\_getActiveServerList(), ilSamlIdp\getActiveIdpList(), getUserMappingMode(), IL_INST_ID, ILIAS\Repository\int(), ILIAS\Repository\lng(), logFailure(), null, and stripTags().

Referenced by handlerBeginTag().

392  : void {
393  switch ($a_name) {
394  case 'Role':
395  $current_role_id = $a_attribs['Id'];
396  if (($internal_id = ilUtil::__extractId($current_role_id, (int) IL_INST_ID)) > 0) {
397  $current_role_id = $internal_id;
398  }
399  $this->current_role_id = (string) $current_role_id;
400  $this->current_role_type = $a_attribs['Type'];
401  $this->current_role_action = (!isset($a_attribs['Action'])) ? 'Assign' : $a_attribs['Action'];
402  break;
403 
404  case 'PersonalPicture':
405  $this->personalPicture = [
406  'encoding' => $a_attribs['encoding'],
407  'imagetype' => $a_attribs['imagetype'],
408  'content' => ''
409  ];
410  break;
411 
412  case 'Look':
413  $this->skin = $a_attribs['Skin'];
414  $this->style = $a_attribs['Style'];
415  break;
416 
417  case 'User':
418  $this->containedTags = [];
419 
420  $this->acc_mail->reset();
421  $this->prefs = [];
422  $this->currentPrefKey = null;
423  $this->auth_mode_set = false;
424  $this->approve_date_set = false;
425  $this->time_limit_set = false;
426  $this->time_limit_owner_set = false;
427  $this->updateLookAndSkin = false;
428  $this->skin = '';
429  $this->style = '';
430  $this->personalPicture = null;
431  $this->userCount++;
432  $this->userObj = new ilObjUser();
433 
434  // user defined fields
435  $this->udf_data = [];
436 
437  // if we have an object id, store it
438  $this->user_id = -1;
439  if (isset($a_attribs['Id']) && $this->getUserMappingMode() === self::IL_USER_MAPPING_ID) {
440  if (is_numeric($a_attribs['Id'])) {
441  $this->user_id = (int) $a_attribs['Id'];
442  } elseif (($id = (int) ilUtil::__extractId($a_attribs['Id'], (int) IL_INST_ID)) > 0) {
443  $this->user_id = $id;
444  }
445  }
446 
447  $this->userObj->setPref(
448  'skin',
449  $this->ilias->ini->readVariable('layout', 'skin')
450  );
451  $this->userObj->setPref(
452  'style',
453  $this->ilias->ini->readVariable('layout', 'style')
454  );
455 
456  if (isset($a_attribs['Language'])) {
457  $this->containedTags[] = 'Language';
458  }
459  $this->userObj->setLanguage($a_attribs['Language'] ?? '');
460  $this->userObj->setImportId($a_attribs['Id'] ?? '');
461  $this->action = (is_null($a_attribs['Action'])) ? 'Insert' : $a_attribs['Action'];
462  $this->currPassword = null;
463  $this->currPasswordType = null;
464  $this->currActive = null;
465  $this->multi_values = [];
466  break;
467 
468  case 'Password':
469  $this->currPasswordType = $a_attribs['Type'];
470  break;
471  case 'AuthMode':
472  if (array_key_exists('type', $a_attribs)) {
473  switch ($a_attribs['type']) {
474  case 'saml':
475  case 'ldap':
476  if (strcmp('saml', $a_attribs['type']) === 0) {
477  $list = ilSamlIdp::getActiveIdpList();
478  if (count($list) === 1) {
479  $this->auth_mode_set = true;
480  $idp = current($list);
481  $this->userObj->setAuthMode('saml_' . $idp->getIdpId());
482  }
483  break;
484  }
485  if (strcmp('ldap', $a_attribs['type']) === 0) {
486  // no server id provided => use default server
488  if (count($list) == 1) {
489  $this->auth_mode_set = true;
490  $ldap_id = current($list);
491  $this->userObj->setAuthMode('ldap_' . $ldap_id);
492  }
493  }
494  break;
495 
496  case 'default':
497  case 'local':
498  case 'shibboleth':
499  case 'script':
500  case 'cas':
501  case 'soap':
502  case 'openid':
503  // begin-patch auth_plugin
504  default:
505  $this->auth_mode_set = true;
506  $this->userObj->setAuthMode($a_attribs['type']);
507  break;
508  }
509  } else {
510  $this->logFailure(
511  $this->userObj->getLogin(),
512  sprintf($this->lng->txt('usrimport_xml_element_inapplicable'), 'AuthMode', $this->stripTags($a_attribs['type']))
513  );
514  }
515  break;
516 
517  case 'UserDefinedField':
518  $this->tmp_udf_id = $a_attribs['Id'];
519  $this->tmp_udf_name = $a_attribs['Name'];
520  break;
521 
522  case 'AccountInfo':
523  $this->current_messenger_type = strtolower($a_attribs['Type']);
524  break;
525  case 'GMapInfo':
526  $this->userObj->setLatitude($a_attribs['latitude']);
527  $this->userObj->setLongitude($a_attribs['longitude']);
528  $this->userObj->setLocationZoom($a_attribs['zoom']);
529  break;
530  case 'Pref':
531  $this->currentPrefKey = $a_attribs['key'];
532  break;
533  }
534  }
const IL_INST_ID
Definition: constants.php:40
getUserMappingMode()
read access to user mapping mode
static _getActiveServerList()
Get active server list.
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
Class ilObjForumAdministration.
logFailure(string $aLogin, string $aMessage)
Writes a failure log message to the protocol.
static __extractId(string $ilias_id, int $inst_id)
extract ref id from role title, e.g.
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
static getActiveIdpList()
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ importEndTag()

ilUserImportParser::importEndTag (   $a_xml_parser,
string  $a_name 
)
Parameters
\XMLParser | resource$a_xml_parser

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

References $cdata, $current_role_action, $current_role_id, $current_role_type, $currentPrefKey, Vendor\Package\$e, $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, ILIAS\Repository\int(), ilUserXMLWriter\isPrefExportable(), ILIAS\Repository\lng(), logFailure(), logSuccess(), logWarning(), null, ilObjUser\PASSWD_CRYPTED, ilObjUser\PASSWD_PLAIN, saveTempImage(), sendAccountMail(), ilUserDefinedData\set(), ILIAS\Repository\settings(), stripTags(), SYSTEM_USER_ID, tagContained(), updateMailPreferences(), and ILIAS\Repository\user().

Referenced by handlerEndTag().

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

◆ isFieldRequired()

ilUserImportParser::isFieldRequired ( string  $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 2160 of file class.ilUserImportParser.php.

References readRequiredFields().

Referenced by verifyEndTag().

2160  : bool
2161  {
2162  $requiredFields = $this->readRequiredFields();
2163  $fieldname = strtolower(trim($fieldname));
2164  return array_key_exists($fieldname, $requiredFields);
2165  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isSendMail()

ilUserImportParser::isSendMail ( )

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

References $send_mail.

Referenced by sendAccountMail().

2100  : bool
2101  {
2102  return $this->send_mail;
2103  }
+ Here is the caller graph for this function:

◆ isSuccess()

ilUserImportParser::isSuccess ( )

Returns true, if the import was successful.

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

2060  : bool
2061  {
2062  return $this->error_level === self::IL_IMPORT_SUCCESS;
2063  }

◆ logFailure()

ilUserImportParser::logFailure ( string  $aLogin,
string  $aMessage 
)

Writes a failure log message to the protocol.

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

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

1997  : void {
1998  if (!array_key_exists($aLogin, $this->protocol)) {
1999  $this->protocol[$aLogin] = [];
2000  }
2001  if ($aMessage) {
2002  $this->protocol[$aLogin][] = $aMessage;
2003  }
2004  $this->error_level = self::IL_IMPORT_FAILURE;
2005  }
+ Here is the caller graph for this function:

◆ logSuccess()

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

Writes a success log message to the protocol.

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

References $action.

Referenced by importEndTag().

2014  : void {
2015  $this->user_mapping[$userid] = ['login' => $aLogin, 'action' => $action, 'message' => 'successful'];
2016  }
+ Here is the caller graph for this function:

◆ logWarning()

ilUserImportParser::logWarning ( string  $aLogin,
string  $aMessage 
)

Writes a warning log message to the protocol.

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

Referenced by importEndTag(), and verifyEndTag().

1979  : void {
1980  if (!array_key_exists($aLogin, $this->protocol)) {
1981  $this->protocol[$aLogin] = [];
1982  }
1983  if ($aMessage) {
1984  $this->protocol[$aLogin][] = $aMessage;
1985  }
1986  if ($this->error_level === self::IL_IMPORT_SUCCESS) {
1987  $this->error_level = self::IL_IMPORT_WARNING;
1988  }
1989  }
+ Here is the caller graph for this function:

◆ readRequiredFields()

ilUserImportParser::readRequiredFields ( )
private
Returns
array[]

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

References $required_fields, and ILIAS\Repository\settings().

Referenced by isFieldRequired().

2131  : array
2132  {
2133  if (is_array($this->required_fields)) {
2134  return $this->required_fields;
2135  }
2136  foreach ($this->settings->getAll() as $field => $value) {
2137  if (strpos($field, 'require_') === 0 && $value == 1) {
2138  $value = substr($field, 8);
2139  $this->required_fields[$value] = $value;
2140  }
2141  }
2142  return $this->required_fields ?: [];
2143  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ saveTempImage()

ilUserImportParser::saveTempImage ( string  $image_data,
string  $filename 
)

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

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

References $filename, and ilFileUtils\ilTempnam().

Referenced by importEndTag().

1601  : string {
1602  $tempname = ilFileUtils::ilTempnam() . $filename;
1603  $fh = fopen($tempname, 'wb');
1604  if ($fh == false) {
1605  return '';
1606  }
1607  fwrite($fh, $image_data);
1608  fclose($fh);
1609  return $tempname;
1610  }
$filename
Definition: buildRTE.php:78
static ilTempnam(?string $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 2086 of file class.ilUserImportParser.php.

References isSendMail().

Referenced by importEndTag().

2086  : void
2087  {
2088  if ($this->req_send_mail != '' ||
2089  ($this->isSendMail() && $this->userObj->getEmail() != '')) {
2090  $this->acc_mail->setUser($this->userObj);
2091  $this->acc_mail->send();
2092  }
2093  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setFolderId()

ilUserImportParser::setFolderId ( int  $a_folder_id)

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

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

287  : void
288  {
289  $this->folder_id = $a_folder_id;
290  }

◆ setHandlers()

ilUserImportParser::setHandlers (   $a_xml_parser)

set event handler should be overwritten by inherited class private

Parameters
resource | \XMLParser$a_xml_parser

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

References handlerBeginTag(), handlerCharacterData(), and handlerEndTag().

304  : void
305  {
306  xml_set_element_handler($a_xml_parser, $this->handlerBeginTag(...), $this->handlerEndTag(...));
307  xml_set_character_data_handler($a_xml_parser, $this->handlerCharacterData(...));
308  }
handlerBeginTag( $a_xml_parser, string $a_name, array $a_attribs)
handlerCharacterData( $a_xml_parser, string $a_data)
handler for character data
handlerEndTag( $a_xml_parser, string $a_name)
+ Here is the call graph for this function:

◆ setRoleAssignment()

ilUserImportParser::setRoleAssignment ( array  $a_assign)

set import to local role assignemt

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

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

315  : void
316  {
317  $this->role_assign = $a_assign;
318  }

◆ setSendMail()

ilUserImportParser::setSendMail ( bool  $value)

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

2095  : void
2096  {
2097  $this->send_mail = $value;
2098  }

◆ setUserMappingMode()

ilUserImportParser::setUserMappingMode ( int  $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 2110 of file class.ilUserImportParser.php.

2110  : void
2111  {
2112  if ($value === self::IL_USER_MAPPING_ID || $value === self::IL_USER_MAPPING_LOGIN) {
2113  $this->mapping_mode = $value;
2114  } else {
2115  die('wrong argument using methode setUserMappingMethod in ' . __FILE__);
2116  }
2117  }

◆ stripTags()

ilUserImportParser::stripTags ( string  $string)
private

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

References ILIAS\Repository\refinery().

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

2271  : string
2272  {
2273  return $this->refinery->string()->stripTags()->transform($string);
2274  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ tagContained()

ilUserImportParser::tagContained ( string  $tagname)
protected

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

Referenced by importEndTag(), and verifyEndTag().

835  : bool
836  {
837  return in_array($tagname, $this->containedTags, true);
838  }
+ Here is the caller graph for this function:

◆ updateMailPreferences()

ilUserImportParser::updateMailPreferences ( int  $usr_id)
private

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

Referenced by importEndTag().

2252  : void
2253  {
2254  if (array_key_exists('mail_incoming_type', $this->prefs) ||
2255  array_key_exists('mail_signature', $this->prefs) ||
2256  array_key_exists('mail_linebreak', $this->prefs)
2257  ) {
2258  $mailOptions = new ilMailOptions($usr_id);
2259 
2260  $mailOptions->setSignature(array_key_exists('mail_signature', $this->prefs) ? $this->prefs['mail_signature'] : $mailOptions->getSignature());
2261  $mailOptions->setIncomingType(array_key_exists('mail_incoming_type', $this->prefs) ? (int) $this->prefs['mail_incoming_type'] : $mailOptions->getIncomingType());
2262  $mailOptions->updateOptions();
2263  }
2264  }
+ Here is the caller graph for this function:

◆ verifyBeginTag()

ilUserImportParser::verifyBeginTag (   $a_xml_parser,
string  $a_name,
array  $a_attribs 
)
Parameters
\XMLParser | resource$a_xml_parser

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

References $id, ilUtil\__extractId(), ilLDAPServer\_getActiveServerList(), ilSamlIdp\getActiveIdpList(), getUserMappingMode(), IL_INST_ID, ILIAS\Repository\int(), ILIAS\Repository\lng(), logFailure(), null, and stripTags().

Referenced by handlerBeginTag().

543  : void {
544  switch ($a_name) {
545  case 'Role':
546  if ($a_attribs['Id'] == '') {
547  $this->logFailure($this->userObj->getLogin(), sprintf($this->lng->txt('usrimport_xml_attribute_missing'), 'Role', 'Id'));
548  }
549  $this->current_role_id = $a_attribs['Id'];
550  $this->current_role_type = $a_attribs['Type'];
551  if ($this->current_role_type !== 'Global'
552  && $this->current_role_type !== 'Local') {
553  $this->logFailure($this->userObj->getLogin(), sprintf($this->lng->txt('usrimport_xml_attribute_missing'), 'Role', 'Type'));
554  }
555  $this->current_role_action = (!isset($a_attribs['Action'])) ? 'Assign' : $a_attribs['Action'];
556  if ($this->current_role_action !== 'Assign'
557  && $this->current_role_action !== 'AssignWithParents'
558  && $this->current_role_action !== 'Detach') {
559  $this->logFailure($this->userObj->getLogin(), sprintf($this->lng->txt('usrimport_xml_attribute_value_illegal'), 'Role', 'Action', $this->stripTags($a_attribs['Action'])));
560  }
561  if ($this->action === 'Insert'
562  && $this->current_role_action === 'Detach') {
563  $this->logFailure($this->userObj->getLogin(), sprintf($this->lng->txt('usrimport_xml_attribute_value_inapplicable'), 'Role', 'Action', $this->stripTags($this->current_role_action), $this->stripTags($this->action)));
564  }
565  if ($this->action === 'Delete') {
566  $this->logFailure($this->userObj->getLogin(), sprintf($this->lng->txt('usrimport_xml_element_inapplicable'), 'Role', 'Delete'));
567  }
568  break;
569 
570  case 'User':
571  $this->userCount++;
572  $this->containedTags = [];
573  $this->userObj = new ilObjUser();
574  $this->userObj->setLanguage($a_attribs['Language'] ?? '');
575  $this->userObj->setImportId($a_attribs['Id'] ?? '');
576  $this->currentPrefKey = null;
577  // if we have an object id, store it
578  $this->user_id = -1;
579 
580  if (isset($a_attribs['Id']) && $this->getUserMappingMode() === self::IL_USER_MAPPING_ID) {
581  if (is_numeric($a_attribs['Id'])) {
582  $this->user_id = (int) $a_attribs['Id'];
583  } elseif (($id = (int) ilUtil::__extractId($a_attribs['Id'], (int) IL_INST_ID)) > 0) {
584  $this->user_id = $id;
585  }
586  }
587 
588  $this->action = !isset($a_attribs['Action']) ? 'Insert' : $a_attribs['Action'];
589  if ($this->action !== 'Insert'
590  && $this->action !== 'Update'
591  && $this->action !== 'Delete') {
592  $this->logFailure($this->userObj->getImportId(), sprintf($this->lng->txt('usrimport_xml_attribute_value_illegal'), 'User', 'Action', $this->stripTags($a_attribs['Action'])));
593  }
594  $this->currPassword = null;
595  $this->currPasswordType = null;
596  break;
597 
598  case 'Password':
599  $this->currPasswordType = $a_attribs['Type'];
600  break;
601  case 'AuthMode':
602  if (array_key_exists('type', $a_attribs)) {
603  switch ($a_attribs['type']) {
604  case 'saml':
605  case 'ldap':
606  if (strcmp('saml', $a_attribs['type']) === 0) {
607  $list = ilSamlIdp::getActiveIdpList();
608  if (count($list) !== 1) {
609  $this->logFailure(
610  $this->userObj->getImportId(),
611  sprintf($this->lng->txt('usrimport_xml_attribute_value_illegal'), 'AuthMode', 'type', $this->stripTags($a_attribs['type']))
612  );
613  }
614  break;
615  }
616  if (strcmp('ldap', $a_attribs['type']) === 0) {
617  // no server id provided
619  if (count($list) != 1) {
620  $this->logFailure(
621  $this->userObj->getImportId(),
622  sprintf($this->lng->txt('usrimport_xml_attribute_value_illegal'), 'AuthMode', 'type', $this->stripTags($a_attribs['type']))
623  );
624  }
625  }
626  break;
627 
628  case 'default':
629  case 'local':
630  case 'shibboleth':
631  case 'script':
632  case 'cas':
633  case 'soap':
634  case 'openid':
635  // begin-patch auth_plugin
636  default:
637  $this->userObj->setAuthMode($a_attribs['type']);
638  break;
639  }
640  } else {
641  $this->logFailure($this->userObj->getImportId(), sprintf($this->lng->txt('usrimport_xml_attribute_value_illegal'), 'AuthMode', 'type', ''));
642  }
643  break;
644  case 'Pref':
645  $this->currentPrefKey = $a_attribs['key'];
646  break;
647  }
648  }
const IL_INST_ID
Definition: constants.php:40
getUserMappingMode()
read access to user mapping mode
static _getActiveServerList()
Get active server list.
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
logFailure(string $aLogin, string $aMessage)
Writes a failure log message to the protocol.
static __extractId(string $ilias_id, int $inst_id)
extract ref id from role title, e.g.
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
static getActiveIdpList()
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ verifyEndTag()

ilUserImportParser::verifyEndTag (   $a_xml_parser,
string  $a_name 
)

handler for end of element when in verify mode.

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

References $cdata, $current_role_action, $current_role_id, $current_role_type, $user_id, ilObjUser\_checkExternalAuthAccount(), ilAuthUtils\_getAuthModeName(), ilObjUser\_lookupExternalAccount(), ilObjUser\_lookupId(), ilObjUser\_lookupLogin(), ILIAS\Repository\access(), ANONYMOUS_USER_ID, ilObjUser\getUserIdByLogin(), isFieldRequired(), ILIAS\Repository\lng(), logFailure(), logWarning(), null, ilObjUser\PASSWD_CRYPTED, ilObjUser\PASSWD_PLAIN, ILIAS\Repository\settings(), stripTags(), SYSTEM_USER_ID, tagContained(), USER_FOLDER_ID, and verifyPref().

Referenced by handlerEndTag().

1618  : void {
1619  $externalAccountHasChanged = false;
1620 
1621  switch ($a_name) {
1622  case 'Role':
1623  $this->roles[$this->current_role_id]['name'] = $this->cdata;
1624  $this->roles[$this->current_role_id]['type'] = $this->current_role_type;
1625  $this->roles[$this->current_role_id]['action'] = $this->current_role_action;
1626  break;
1627 
1628  case 'User':
1629  $this->userObj->setFullname();
1630  if ($this->user_id != -1 && ($this->action === 'Update' || $this->action === 'Delete')) {
1632  $user_exists = !is_null(ilObjUser::_lookupLogin($user_id));
1633  } else {
1634  $user_id = ilObjUser::getUserIdByLogin($this->userObj->getLogin());
1635  $user_exists = $user_id != 0;
1636  }
1637  if (is_null($this->userObj->getLogin())) {
1638  $this->logFailure('---', sprintf($this->lng->txt('usrimport_xml_element_for_action_required'), 'Login', 'Insert'));
1639  }
1640 
1641  if ($user_id === (int) ANONYMOUS_USER_ID || $user_id === (int) SYSTEM_USER_ID) {
1642  $this->logWarning($this->userObj->getLogin(), $this->lng->txt('usrimport_xml_anonymous_or_root_not_allowed'));
1643  break;
1644  }
1645 
1646  switch ($this->action) {
1647  case 'Insert':
1648  if ($user_exists and $this->conflict_rule === self::IL_FAIL_ON_CONFLICT) {
1649  $this->logWarning($this->userObj->getLogin(), $this->lng->txt('usrimport_cant_insert'));
1650  }
1651  if (is_null($this->userObj->getGender()) && $this->isFieldRequired('gender')) {
1652  $this->logFailure($this->userObj->getLogin(), sprintf($this->lng->txt('usrimport_xml_element_for_action_required'), 'Gender', 'Insert'));
1653  }
1654  if (is_null($this->userObj->getFirstname())) {
1655  $this->logFailure($this->userObj->getLogin(), sprintf($this->lng->txt('usrimport_xml_element_for_action_required'), 'Firstname', 'Insert'));
1656  }
1657  if (is_null($this->userObj->getLastname())) {
1658  $this->logFailure($this->userObj->getLogin(), sprintf($this->lng->txt('usrimport_xml_element_for_action_required'), 'Lastname', 'Insert'));
1659  }
1660  if (count($this->roles) == 0) {
1661  $this->logFailure($this->userObj->getLogin(), sprintf($this->lng->txt('usrimport_xml_element_for_action_required'), 'Role', 'Insert'));
1662  } else {
1663  $has_global_role = false;
1664  foreach ($this->roles as $role) {
1665  if ($role['type'] === 'Global') {
1666  $has_global_role = true;
1667  break;
1668  }
1669  }
1670  if (!$has_global_role) {
1671  $this->logFailure($this->userObj->getLogin(), sprintf($this->lng->txt('usrimport_global_role_for_action_required'), 'Insert'));
1672  }
1673  }
1674  break;
1675  case 'Update':
1676  if (!$user_exists) {
1677  $this->logWarning($this->userObj->getLogin(), $this->lng->txt('usrimport_cant_update'));
1678  } elseif ($this->user_id != -1 && $this->tagContained('Login')) {
1679  // check if someone owns the new login name!
1680  $someonesId = ilObjUser::_lookupId($this->userObj->getLogin());
1681 
1682  if (is_numeric($someonesId) && $someonesId != $this->user_id) {
1683  $this->logFailure($this->userObj->getLogin(), $this->lng->txt('usrimport_login_is_not_unique'));
1684  }
1685  }
1686  break;
1687  case 'Delete':
1688  if (!$user_exists) {
1689  $this->logWarning($this->userObj->getLogin(), $this->lng->txt('usrimport_cant_delete'));
1690  }
1691  break;
1692  }
1693 
1694  // init role array for next user
1695  $this->roles = [];
1696  break;
1697 
1698  case 'Login':
1699  if (array_key_exists($this->cdata, $this->logins)) {
1700  $this->logWarning($this->cdata, $this->lng->txt('usrimport_login_is_not_unique'));
1701  } else {
1702  $this->logins[$this->cdata] = $this->cdata;
1703  }
1704  $this->userObj->setLogin($this->stripTags($this->cdata));
1705  break;
1706 
1707  case 'Password':
1708  switch ($this->currPasswordType) {
1709  case 'BCRYPT':
1710  $this->userObj->setPasswd($this->cdata, ilObjUser::PASSWD_CRYPTED);
1711  $this->userObj->setPasswordEncodingType('bcryptphp');
1712  $this->userObj->setPasswordSalt(null);
1713  break;
1714 
1715  case 'PLAIN':
1716  $this->userObj->setPasswd($this->cdata, ilObjUser::PASSWD_PLAIN);
1717  $this->acc_mail->setUserPassword((string) $this->currPassword);
1718  break;
1719 
1720  default:
1721  $this->logFailure($this->userObj->getLogin(), sprintf($this->lng->txt('usrimport_xml_attribute_value_illegal'), 'Type', 'Password', $this->stripTags($this->currPasswordType)));
1722  break;
1723  }
1724  break;
1725 
1726  case 'Firstname':
1727  $this->userObj->setFirstname($this->cdata);
1728  break;
1729 
1730  case 'Lastname':
1731  $this->userObj->setLastname($this->cdata);
1732  break;
1733 
1734  case 'Title':
1735  $this->userObj->setUTitle($this->cdata);
1736  break;
1737 
1738  case 'Gender':
1739  if (!in_array(strtolower($this->cdata), ['n', 'm', 'f', ''])) {
1740  $this->logFailure(
1741  $this->userObj->getLogin(),
1742  sprintf($this->lng->txt('usrimport_xml_element_content_illegal'), 'Gender', $this->stripTags($this->cdata))
1743  );
1744  }
1745  $this->userObj->setGender($this->cdata);
1746  break;
1747 
1748  case 'Email':
1749  $this->userObj->setEmail($this->cdata);
1750  break;
1751  case 'SecondEmail':
1752  $this->userObj->setSecondEmail($this->cdata);
1753  break;
1754  case 'Institution':
1755  $this->userObj->setInstitution($this->cdata);
1756  break;
1757 
1758  case 'Street':
1759  $this->userObj->setStreet($this->cdata);
1760  break;
1761 
1762  case 'City':
1763  $this->userObj->setCity($this->cdata);
1764  break;
1765 
1766  case 'PostalCode':
1767  $this->userObj->setZipcode($this->cdata);
1768  break;
1769 
1770  case 'Country':
1771  $this->userObj->setCountry($this->cdata);
1772  break;
1773 
1774  case 'SelCountry':
1775  if (mb_strlen($this->cdata) !== 2) {
1776  $this->logFailure(
1777  $this->userObj->getLogin(),
1778  sprintf($this->lng->txt('usrimport_xml_element_content_illegal'), 'SelCountry', $this->stripTags($this->cdata))
1779  );
1780  }
1781  $this->userObj->setSelectedCountry($this->cdata);
1782  break;
1783 
1784  case 'PhoneOffice':
1785  $this->userObj->setPhoneOffice($this->cdata);
1786  break;
1787 
1788  case 'PhoneHome':
1789  $this->userObj->setPhoneHome($this->cdata);
1790  break;
1791 
1792  case 'PhoneMobile':
1793  $this->userObj->setPhoneMobile($this->cdata);
1794  break;
1795 
1796  case 'Fax':
1797  $this->userObj->setFax($this->cdata);
1798  break;
1799 
1800  case 'Hobby':
1801  $this->userObj->setHobby($this->cdata);
1802  break;
1803 
1804  case 'GeneralInterest':
1805  case 'OfferingHelp':
1806  case 'LookingForHelp':
1807  $this->multi_values[$a_name][] = $this->cdata;
1808  break;
1809 
1810  case 'Comment':
1811  $this->userObj->setComment($this->cdata);
1812  break;
1813 
1814  case 'Department':
1815  $this->userObj->setDepartment($this->cdata);
1816  break;
1817 
1818  case 'Matriculation':
1819  $this->userObj->setMatriculation($this->cdata);
1820  break;
1821 
1822  case 'ExternalAccount':
1823  $am = ($this->userObj->getAuthMode() === 'default' || $this->userObj->getAuthMode() == '')
1824  ? ilAuthUtils::_getAuthModeName($this->settings->get('auth_mode'))
1825  : $this->userObj->getAuthMode();
1826  $loginForExternalAccount = (trim($this->cdata) == '')
1827  ? ''
1828  : ilObjUser::_checkExternalAuthAccount($am, trim($this->cdata));
1829  switch ($this->action) {
1830  case 'Insert':
1831  if ($loginForExternalAccount != '') {
1832  $this->logWarning($this->userObj->getLogin(), $this->lng->txt('usrimport_no_insert_ext_account_exists') . ' (' . $this->stripTags($this->cdata) . ')');
1833  }
1834  break;
1835 
1836  case 'Update':
1837  if ($loginForExternalAccount != '') {
1838  $externalAccountHasChanged = trim($this->cdata) != ilObjUser::_lookupExternalAccount($this->user_id);
1839  if ($externalAccountHasChanged && trim($loginForExternalAccount) != trim($this->userObj->getLogin())) {
1840  $this->logWarning(
1841  $this->userObj->getLogin(),
1842  $this->lng->txt('usrimport_no_update_ext_account_exists') . ' (' . $this->stripTags($this->cdata) . ' for ' . $this->stripTags($loginForExternalAccount) . ')'
1843  );
1844  }
1845  }
1846  break;
1847  }
1848  if ($externalAccountHasChanged) {
1849  $this->userObj->setExternalAccount(trim($this->cdata));
1850  }
1851  break;
1852 
1853  case 'Active':
1854  if ($this->cdata !== 'true'
1855  && $this->cdata !== 'false') {
1856  $this->logFailure(
1857  $this->userObj->getLogin(),
1858  sprintf($this->lng->txt('usrimport_xml_element_content_illegal'), 'Active', $this->stripTags($this->cdata))
1859  );
1860  }
1861  $this->currActive = $this->cdata;
1862  break;
1863  case 'TimeLimitOwner':
1864  if (!preg_match('/\d+/', $this->cdata)) {
1865  $this->logFailure(
1866  $this->userObj->getLogin(),
1867  sprintf($this->lng->txt('usrimport_xml_element_content_illegal'), 'TimeLimitOwner', $this->stripTags($this->cdata))
1868  );
1869  } elseif (!$this->access->checkAccess('cat_administrate_users', '', (int) $this->cdata)) {
1870  $this->logFailure(
1871  $this->userObj->getLogin(),
1872  sprintf($this->lng->txt('usrimport_xml_element_content_illegal'), 'TimeLimitOwner', $this->stripTags($this->cdata))
1873  );
1874  } elseif ($this->object_data_cache->lookupType($this->object_data_cache->lookupObjId((int) $this->cdata)) !== 'cat' && !(int) $this->cdata == USER_FOLDER_ID) {
1875  $this->logFailure(
1876  $this->userObj->getLogin(),
1877  sprintf($this->lng->txt('usrimport_xml_element_content_illegal'), 'TimeLimitOwner', $this->stripTags($this->cdata))
1878  );
1879  }
1880  $this->userObj->setTimeLimitOwner((int) $this->cdata);
1881  break;
1882  case 'TimeLimitUnlimited':
1883  switch (strtolower($this->cdata)) {
1884  case 'true':
1885  case '1':
1886  $this->userObj->setTimeLimitUnlimited(true);
1887  break;
1888  case 'false':
1889  case '0':
1890  $this->userObj->setTimeLimitUnlimited(false);
1891  break;
1892  default:
1893  $this->logFailure($this->userObj->getLogin(), sprintf($this->lng->txt('usrimport_xml_element_content_illegal'), 'TimeLimitUnlimited', $this->stripTags($this->cdata)));
1894  break;
1895  }
1896  break;
1897  case 'TimeLimitFrom':
1898  // Accept datetime or Unix timestamp
1899  if (strtotime($this->cdata) === false && !is_numeric($this->cdata)) {
1900  $this->logFailure($this->userObj->getLogin(), sprintf($this->lng->txt('usrimport_xml_element_content_illegal'), 'TimeLimitFrom', $this->stripTags($this->cdata)));
1901  }
1902  $this->userObj->setTimeLimitFrom((int) $this->cdata);
1903  break;
1904  case 'TimeLimitUntil':
1905  // Accept datetime or Unix timestamp
1906  if (strtotime($this->cdata) === false && !is_numeric($this->cdata)) {
1907  $this->logFailure($this->userObj->getLogin(), sprintf($this->lng->txt('usrimport_xml_element_content_illegal'), 'TimeLimitUntil', $this->stripTags($this->cdata)));
1908  }
1909  $this->userObj->setTimeLimitUntil((int) $this->cdata);
1910  break;
1911  case 'TimeLimitMessage':
1912  switch (strtolower($this->cdata)) {
1913  case '1':
1914  $this->userObj->setTimeLimitMessage('1');
1915  break;
1916  case '0':
1917  $this->userObj->setTimeLimitMessage('0');
1918  break;
1919  default:
1920  $this->logFailure($this->userObj->getLogin(), sprintf($this->lng->txt('usrimport_xml_element_content_illegal'), 'TimeLimitMessage', $this->stripTags($this->cdata)));
1921  break;
1922  }
1923  break;
1924  case 'ApproveDate':
1925  // Accept datetime or Unix timestamp
1926  if (strtotime($this->cdata) === false && !is_numeric($this->cdata) && !$this->cdata === '0000-00-00 00:00:00') {
1927  $this->logFailure($this->userObj->getLogin(), sprintf($this->lng->txt('usrimport_xml_element_content_illegal'), 'ApproveDate', $this->stripTags($this->cdata)));
1928  }
1929  break;
1930  case 'AgreeDate':
1931  // Accept datetime or Unix timestamp
1932  if (strtotime($this->cdata) === false && !is_numeric($this->cdata) && !$this->cdata === '0000-00-00 00:00:00') {
1933  $this->logFailure($this->userObj->getLogin(), sprintf($this->lng->txt('usrimport_xml_element_content_illegal'), 'AgreeDate', $this->stripTags($this->cdata)));
1934  }
1935  break;
1936  case 'Pref':
1937  if ($this->currentPrefKey != null) {
1938  $this->verifyPref($this->currentPrefKey, $this->cdata);
1939  }
1940  }
1941  }
const ANONYMOUS_USER_ID
Definition: constants.php:27
const USER_FOLDER_ID
Definition: constants.php:33
const SYSTEM_USER_ID
This file contains constants for PHPStan analyis, see: https://phpstan.org/config-reference#constants...
Definition: constants.php:26
isFieldRequired(string $fieldname)
determine if a field $fieldname is to a required field (global setting)
const PASSWD_PLAIN
static _lookupId($a_user_str)
logWarning(string $aLogin, string $aMessage)
Writes a warning log message to the protocol.
static _checkExternalAuthAccount(string $a_auth, string $a_account, bool $tryFallback=true)
check whether external account and authentication method matches with a user
static _lookupExternalAccount(int $a_user_id)
static _getAuthModeName($a_auth_key)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
static getUserIdByLogin(string $a_login)
verifyPref(string $key, string $value)
logFailure(string $aLogin, string $aMessage)
Writes a failure log message to the protocol.
const PASSWD_CRYPTED
static _lookupLogin(int $a_user_id)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ verifyPref()

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

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

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

Referenced by verifyEndTag().

2167  : void
2168  {
2169  switch ($key) {
2170  case 'mail_linebreak':
2171  case 'language':
2172  case 'skin':
2173  case 'style':
2174  case 'ilPageEditor_HTMLMode':
2175  case 'ilPageEditor_JavaScript':
2176  case 'ilPageEditor_MediaMode':
2177  case 'tst_javascript':
2178  case 'tst_lastquestiontype':
2179  case 'tst_multiline_answers':
2180  case 'tst_use_previous_answers':
2181  case 'graphicalAnswerSetting':
2182  case 'priv_feed_pass':
2183  $this->logFailure('---', "Preference {$this->stripTags($key)} is not supported.");
2184  break;
2185  case 'public_city':
2186  case 'public_country':
2187  case 'public_department':
2188  case 'public_email':
2189  case 'public_second_email':
2190  case 'public_fax':
2191  case 'public_hobby':
2192  case 'public_institution':
2193  case 'public_matriculation':
2194  case 'public_phone':
2195  case 'public_phone_home':
2196  case 'public_phone_mobile':
2197  case 'public_phone_office':
2198  case 'public_street':
2199  case 'public_upload':
2200  case 'public_zip':
2201  case 'public_interests_general':
2202  case 'public_interests_help_offered':
2203  case 'public_interests_help_looking':
2204  case 'send_info_mails':
2205  case 'bs_allow_to_contact_me':
2206  case 'chat_osc_accept_msg':
2207  case 'chat_broadcast_typing':
2208  case 'hide_own_online_status':
2209  if (!in_array($value, ['y', 'n', ''])) {
2210  $this->logFailure('---', "Wrong value '{$this->stripTags($value)}': Value 'y' or 'n' expected for preference {$this->stripTags($key)}.");
2211  }
2212  break;
2213  case 'public_profile':
2214  if (!in_array($value, ['y', 'n', 'g'])) {
2215  $this->logFailure('---', "Wrong value '{$this->stripTags($value)}': Value 'y', 'g' or 'n' expected for preference {$this->stripTags($key)}.");
2216  }
2217  break;
2218  case 'show_users_online':
2219  if (!in_array($value, ['y', 'n', 'associated'])) {
2220  $this->logFailure('---', "Wrong value '{$this->stripTags($value)}': Value 'y' or 'n' or 'associated' expected for preference {$this->stripTags($key)}.");
2221  }
2222  break;
2223  case 'mail_incoming_type':
2224  if (!in_array((int) $value, ['0','1','2'])) {
2225  $this->logFailure('---', "Wrong value '{$this->stripTags($value)}': Value '0' (LOCAL),'1' (EMAIL) or '2' (BOTH) expected for preference {$this->stripTags($key)}.");
2226  }
2227  break;
2228  case 'weekstart':
2229  if (!in_array($value, ['0','1'])) {
2230  $this->logFailure('---', "Wrong value '{$this->stripTags($value)}': Value '0' (Sunday) or '1' (Monday) expected for preference {$this->stripTags($key)}.");
2231  }
2232  break;
2233 
2234  case 'mail_signature':
2235  break;
2236  case 'user_tz':
2237  try {
2238  ilTimeZone::_getInstance($value);
2239  return;
2240  } catch (ilTimeZoneException $tze) {
2241  $this->logFailure('---', "Wrong value '{$this->stripTags($value)}': Invalid timezone $value detected for preference {$this->stripTags($key)}.");
2242  }
2243  break;
2244  default:
2245  if (!ilUserXMLWriter::isPrefExportable($key)) {
2246  $this->logFailure('---', "Preference {$this->stripTags($key)} is not supported.");
2247  }
2248  break;
2249  }
2250  }
static _getInstance(string $a_tz='')
get instance by timezone
Class for TimeZone exceptions.
logFailure(string $aLogin, string $aMessage)
Writes a failure log message to the protocol.
static isPrefExportable(string $key)
returns wether a key from db is exportable or not
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $acc_mail

ilAccountMail ilUserImportParser::$acc_mail
protected

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

◆ $access

ilAccess ilUserImportParser::$access
private

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

◆ $action

string ilUserImportParser::$action

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

Referenced by logSuccess().

◆ $approve_date_set

bool ilUserImportParser::$approve_date_set = false

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

◆ $auth_mode_set

bool ilUserImportParser::$auth_mode_set
protected

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

◆ $cdata

string ilUserImportParser::$cdata
protected

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

Referenced by extractRolesEndTag(), importEndTag(), and verifyEndTag().

◆ $conflict_rule

int ilUserImportParser::$conflict_rule

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

◆ $containedTags

array ilUserImportParser::$containedTags = []
protected

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

◆ $currActive

string ilUserImportParser::$currActive = null

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

◆ $current_messenger_type

string ilUserImportParser::$current_messenger_type
private

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

◆ $current_role_action

string ilUserImportParser::$current_role_action
protected

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

Referenced by importEndTag(), and verifyEndTag().

◆ $current_role_id

string ilUserImportParser::$current_role_id = '0'
protected

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

Referenced by extractRolesEndTag(), importEndTag(), and verifyEndTag().

◆ $current_role_type

string ilUserImportParser::$current_role_type
protected

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

Referenced by extractRolesEndTag(), importEndTag(), and verifyEndTag().

◆ $currentPrefKey

string ilUserImportParser::$currentPrefKey = null
protected

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

Referenced by importEndTag().

◆ $currPassword

string ilUserImportParser::$currPassword

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

◆ $currPasswordType

string ilUserImportParser::$currPasswordType

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

◆ $error_level

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

Referenced by getErrorLevel().

◆ $folder_id

int ilUserImportParser::$folder_id

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

Referenced by getFolderId().

◆ $ilias

ILIAS ilUserImportParser::$ilias
private

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

◆ $localRoleCache

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

◆ $logins

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

◆ $mapping_mode

int ilUserImportParser::$mapping_mode

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

Referenced by getUserMappingMode().

◆ $mode

int ilUserImportParser::$mode
protected

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

◆ $multi_values

array ilUserImportParser::$multi_values
protected

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

◆ $object_data_cache

ilObjectDataCache ilUserImportParser::$object_data_cache
private

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

◆ $parentRolesCache

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

◆ $personalPicture

array ilUserImportParser::$personalPicture = null

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

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

◆ $prefs

array ilUserImportParser::$prefs
protected

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

◆ $protocol

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

Referenced by getProtocol().

◆ $rbac_admin

ilRbacAdmin ilUserImportParser::$rbac_admin
private

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

◆ $rbac_review

ilRbacReview ilUserImportParser::$rbac_review
private

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

◆ $recommended_content_manager

ilRecommendedContentManager ilUserImportParser::$recommended_content_manager
protected

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

◆ $refinery

Refinery ilUserImportParser::$refinery
private

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

◆ $req_send_mail

string ilUserImportParser::$req_send_mail
protected

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

◆ $required_fields

array ilUserImportParser::$required_fields = []
protected

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

Referenced by readRequiredFields().

◆ $role_assign

array ilUserImportParser::$role_assign
protected

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

◆ $roles

array ilUserImportParser::$roles

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

Referenced by getCollectedRoles().

◆ $send_mail

bool ilUserImportParser::$send_mail

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

Referenced by isSendMail().

◆ $settings

ilSetting ilUserImportParser::$settings
private

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

◆ $skin

string ilUserImportParser::$skin = ''

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

◆ $style

string ilUserImportParser::$style = ''

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

◆ $time_limit_owner_set

bool ilUserImportParser::$time_limit_owner_set = false

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

◆ $time_limit_set

bool ilUserImportParser::$time_limit_set = false

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

◆ $tmp_udf_id

string ilUserImportParser::$tmp_udf_id = null
protected

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

◆ $tmp_udf_name

string ilUserImportParser::$tmp_udf_name = null
protected

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

◆ $udf_data

array ilUserImportParser::$udf_data
protected

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

◆ $updateLookAndSkin

bool ilUserImportParser::$updateLookAndSkin = false

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

◆ $user

ilObjUser ilUserImportParser::$user
private

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

◆ $user_id

int ilUserImportParser::$user_id

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

Referenced by importEndTag(), and verifyEndTag().

◆ $user_mapping

array ilUserImportParser::$user_mapping = []

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

Referenced by getUserMapping().

◆ $user_profile

ilUserProfile ilUserImportParser::$user_profile
private

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

◆ $user_settings_config

ilUserSettingsConfig ilUserImportParser::$user_settings_config
protected

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

◆ $userCount

int ilUserImportParser::$userCount

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

Referenced by getUserCount().

◆ $userObj

ilObjUser ilUserImportParser::$userObj
private

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

◆ $userStyles

array ilUserImportParser::$userStyles

User assigned styles.

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

◆ IL_EXTRACT_ROLES

const ilUserImportParser::IL_EXTRACT_ROLES = 1

◆ IL_FAIL_ON_CONFLICT

const ilUserImportParser::IL_FAIL_ON_CONFLICT = 1

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

Referenced by ilSoapUserAdministration\importUsers().

◆ IL_IGNORE_ON_CONFLICT

const ilUserImportParser::IL_IGNORE_ON_CONFLICT = 3

◆ IL_IMPORT_FAILURE

const ilUserImportParser::IL_IMPORT_FAILURE = 3

◆ IL_IMPORT_SUCCESS

const ilUserImportParser::IL_IMPORT_SUCCESS = 1

◆ IL_IMPORT_WARNING

const ilUserImportParser::IL_IMPORT_WARNING = 2

◆ IL_UPDATE_ON_CONFLICT

const ilUserImportParser::IL_UPDATE_ON_CONFLICT = 2

◆ IL_USER_IMPORT

const ilUserImportParser::IL_USER_IMPORT = 2

◆ IL_USER_MAPPING_ID

const ilUserImportParser::IL_USER_MAPPING_ID = 2

◆ IL_USER_MAPPING_LOGIN

const ilUserImportParser::IL_USER_MAPPING_LOGIN = 1
private

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

◆ IL_VERIFY

const ilUserImportParser::IL_VERIFY = 3

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