ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
ilUserImportParser Class Reference
+ Inheritance diagram for ilUserImportParser:
+ Collaboration diagram for ilUserImportParser:

Public Member Functions

 __construct (string $a_xml_file='', int $a_mode=IL_USER_IMPORT, int $a_conflict_rule=IL_FAIL_ON_CONFLICT)
 
 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, string $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

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
 Conflict handling rule. More...
 
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 = ""
 
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

ilObjUser $userObj
 
string $current_messenger_type
 
Refinery $refinery
 

Detailed Description

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

Constructor & Destructor Documentation

◆ __construct()

ilUserImportParser::__construct ( string  $a_xml_file = '',
int  $a_mode = IL_USER_IMPORT,
int  $a_conflict_rule = IL_FAIL_ON_CONFLICT 
)
Parameters
string$a_xml_file
int$a_modeIL_EXTRACT_ROLES | IL_USER_IMPORT | IL_VERIFY
int$a_conflict_ruleIL_FAIL_ON_CONFLICT | IL_UPDATE_ON_CONFLICT | IL_IGNORE_ON_CONFLICT
Exceptions
ilSystemStyleException

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

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

216  {
217  global $DIC;
218  $this->refinery = $DIC['refinery'];
219 
220  $this->roles = array();
221  $this->mode = $a_mode;
222  $this->conflict_rule = $a_conflict_rule;
223  $this->error_level = IL_IMPORT_SUCCESS;
224  $this->protocol = array();
225  $this->logins = array();
226  $this->userCount = 0;
227  $this->localRoleCache = array();
228  $this->parentRolesCache = array();
229  $this->send_mail = false;
230  $this->mapping_mode = IL_USER_MAPPING_LOGIN;
231 
232 
233  $this->user_settings_config = new ilUserSettingsConfig();
234 
235  // get all active style instead of only assigned ones -> cannot transfer all to another otherwise
236  $this->userStyles = array();
237  $skins = ilStyleDefinition::getAllSkins();
238 
239  if (is_array($skins)) {
240  foreach ($skins as $skin) {
241  foreach ($skin->getStyles() as $style) {
242  if (!ilSystemStyleSettings::_lookupActivatedStyle($skin->getId(), $style->getId())) {
243  continue;
244  }
245  $this->userStyles [] = $skin->getId() . ":" . $style->getId();
246  }
247  }
248  }
249 
250  $this->acc_mail = new ilAccountMail();
251  $this->acc_mail->setAttachConfiguredFiles(true);
252  $this->acc_mail->useLangVariablesAsFallback(true);
253 
254  $this->recommended_content_manager = new ilRecommendedContentManager();
255 
256  $request = new \ILIAS\User\StandardGUIRequest(
257  $DIC->http(),
259  );
260  $this->req_send_mail = $request->getSendMail();
261 
262  parent::__construct($a_xml_file);
263  }
const IL_USER_MAPPING_LOGIN
static _lookupActivatedStyle(string $a_skin, string $a_style)
lookup if a style is activated
global $DIC
Definition: feed.php:28
const IL_IMPORT_SUCCESS
__construct(Container $dic, ilPlugin $plugin)
Class ilAccountMail.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the call graph for this function:

Member Function Documentation

◆ assignToRole()

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

Assigns a user to a role.

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

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

Referenced by assignToRoleWithParents(), and importEndTag().

713  : void
714  {
715  global $DIC;
716 
717  $rbacreview = $DIC['rbacreview'];
718  $rbacadmin = $DIC['rbacadmin'];
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 ($rbacreview->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  $rbacadmin->assignUser($a_role_id, $a_user_obj->getId(), true);
732  $obj_id = $rbacreview->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
global $DIC
Definition: feed.php:28
$ref_id
Definition: ltiauth.php:67
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 803 of file class.ilUserImportParser.php.

References assignToRole(), and getParentRoleIds().

Referenced by importEndTag().

806  : void {
807  $this->assignToRole($a_user_obj, $a_role_id);
808 
809  $parent_role_ids = $this->getParentRoleIds($a_role_id);
810  foreach ($parent_role_ids as $parent_role_id) {
811  $this->assignToRole($a_user_obj, $parent_role_id);
812  }
813  }
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 306 of file class.ilUserImportParser.php.

References $name.

306  : string // Missing array type.
307  {
308  $tag = "<";
309 
310  if ($type === "end") {
311  $tag .= "/";
312  }
313 
314  $tag .= $name;
315 
316  if (is_array($attr)) {
317  foreach ($attr as $k => $v) {
318  $tag .= " " . $k . "=\"$v\"";
319  }
320  }
321 
322  $tag .= ">";
323 
324  return $tag;
325  }
$type
if($format !==null) $name
Definition: metadata.php:247

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

References ilUserProfile\isProfileIncomplete().

Referenced by importEndTag().

2173  : bool
2174  {
2175  return ilUserProfile::isProfileIncomplete($user_obj);
2176  }
static isProfileIncomplete(ilObjUser $a_user, bool $a_include_udf=true, bool $a_personal_data_only=true)
Check if all required personal data fields are set.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ detachFromRole()

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

Detaches a user from a role.

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

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

Referenced by importEndTag().

821  : void {
822  global $DIC;
823 
824  $rbacreview = $DIC['rbacreview'];
825  $rbacadmin = $DIC['rbacadmin'];
826 
827  $rbacadmin->deassignUser($a_role_id, $a_user_obj->getId());
828 
829  if (substr(ilObject::_lookupTitle($a_role_id), 0, 6) === 'il_crs' ||
830  substr(ilObject::_lookupTitle($a_role_id), 0, 6) === 'il_grp') {
831  $obj = $rbacreview->getObjectOfRole($a_role_id);
832  $ref = ilObject::_getAllReferences($obj);
833  $ref_id = end($ref);
834  $this->recommended_content_manager->removeObjectRecommendation($a_user_obj->getId(), $ref_id);
835  }
836  }
static _getAllReferences(int $id)
get all reference ids for object ID
global $DIC
Definition: feed.php:28
$ref_id
Definition: ltiauth.php:67
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 350 of file class.ilUserImportParser.php.

References ilUtil\__extractId(), and IL_INST_ID.

Referenced by handlerBeginTag().

354  : void {
355  switch ($a_name) {
356  case "Role":
357  // detect numeric, ilias id (then extract role id) or alphanumeric
358  $this->current_role_id = $a_attribs["Id"];
359  if (($internal_id = ilUtil::__extractId($this->current_role_id, IL_INST_ID)) > 0) {
360  $this->current_role_id = $internal_id;
361  }
362  $this->current_role_type = $a_attribs["Type"];
363  break;
364  }
365  }
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 661 of file class.ilUserImportParser.php.

References $cdata, $current_role_id, and $current_role_type.

Referenced by handlerEndTag().

664  : void {
665  switch ($a_name) {
666  case "Role":
667  $this->roles[$this->current_role_id]["name"] = $this->cdata;
668  $this->roles[$this->current_role_id]["type"] =
670  break;
671  }
672  }
+ Here is the caller graph for this function:

◆ getCDataWithoutTags()

ilUserImportParser::getCDataWithoutTags ( )
private

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

References stripTags().

Referenced by importEndTag().

2296  : string
2297  {
2298  return $this->stripTags($this->cdata);
2299  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getCollectedRoles()

ilUserImportParser::getCollectedRoles ( )
Returns
array[]

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

References $roles.

1979  : array
1980  {
1981  return $this->roles;
1982  }

◆ getCourseMembersObjectForRole()

ilUserImportParser::getCourseMembersObjectForRole ( int  $a_role_id)

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

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

References $DIC, and ilCourseParticipants\_getInstanceByObjId().

693  {
694  global $DIC;
695 
696  $rbacreview = $DIC['rbacreview'];
697 
698  if (array_key_exists($a_role_id . '_courseMembersObject', $this->localRoleCache)) {
699  return $this->localRoleCache[$a_role_id . '_courseMembersObject'];
700  } else {
701  $course_refs = $rbacreview->getFoldersAssignedToRole($a_role_id, true);
702  $course_ref = $course_refs[0];
703  $course_obj = new ilObjCourse($course_ref, true);
704  $crsmembers_obj = ilCourseParticipants::_getInstanceByObjId($course_obj->getId());
705  $this->localRoleCache[$a_role_id . '_courseMembersObject'] = $crsmembers_obj;
706  return $crsmembers_obj;
707  }
708  }
global $DIC
Definition: feed.php:28
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 2089 of file class.ilUserImportParser.php.

References $error_level.

Referenced by ilObjUserFolderGUI\verifyXmlData().

2089  : int
2090  {
2091  return $this->error_level;
2092  }
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 274 of file class.ilUserImportParser.php.

References $folder_id.

Referenced by importEndTag().

274  : int
275  {
276  return $this->folder_id;
277  }
+ 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 $DIC, and getRoleObject().

Referenced by assignToRoleWithParents().

754  : array
755  {
756  global $DIC;
757 
758  $rbacreview = $DIC['rbacreview'];
759 
760  if (!array_key_exists($a_role_id, $this->parentRolesCache)) {
761  $parent_role_ids = array();
762 
763  $role_obj = $this->getRoleObject($a_role_id);
764  $short_role_title = substr($role_obj->getTitle(), 0, 12);
765  $folders = $rbacreview->getFoldersAssignedToRole($a_role_id, true);
766  if (count($folders) > 0) {
767  $all_parent_role_ids = $rbacreview->getParentRoleIds($folders[0]);
768  foreach ($all_parent_role_ids as $parent_role_id => $parent_role_data) {
769  if ($parent_role_id != $a_role_id) {
770  switch (substr($parent_role_data['title'], 0, 12)) {
771  case 'il_crs_admin':
772  case 'il_grp_admin':
773  if ($short_role_title === 'il_crs_admin' || $short_role_title === 'il_grp_admin') {
774  $parent_role_ids[] = $parent_role_id;
775  }
776  break;
777  case 'il_crs_tutor':
778  case 'il_grp_tutor':
779  if ($short_role_title === 'il_crs_tutor' || $short_role_title === 'il_grp_tutor') {
780  $parent_role_ids[] = $parent_role_id;
781  }
782  break;
783  case 'il_crs_membe':
784  case 'il_grp_membe':
785  if ($short_role_title === 'il_crs_membe' || $short_role_title === 'il_grp_membe') {
786  $parent_role_ids[] = $parent_role_id;
787  }
788  break;
789  default:
790  break;
791  }
792  }
793  }
794  }
795  $this->parentRolesCache[$a_role_id] = $parent_role_ids;
796  }
797  return $this->parentRolesCache[$a_role_id];
798  }
global $DIC
Definition: feed.php:28
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 2042 of file class.ilUserImportParser.php.

References $protocol.

Referenced by getProtocolAsHTML().

2042  : array
2043  {
2044  return $this->protocol;
2045  }
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 2050 of file class.ilUserImportParser.php.

References $DIC, ilSaxParser\$lng, $message, $messages, ILIAS\LTI\ToolProvider\$reason, getProtocol(), and ilLanguage\txt().

Referenced by ilObjUserFolderGUI\verifyXmlData().

2050  : string
2051  {
2052  global $DIC;
2053 
2054  $lng = $DIC['lng'];
2055 
2056  $block = new ilTemplate("tpl.usr_import_log_block.html", true, true, "Services/User");
2057  $block->setVariable("TXT_LOG_TITLE", $a_log_title);
2058  $block->setVariable("TXT_MESSAGE_ID", $lng->txt("login"));
2059  $block->setVariable("TXT_MESSAGE_TEXT", $lng->txt("message"));
2060  foreach ($this->getProtocol() as $login => $messages) {
2061  $block->setCurrentBlock("log_row");
2062  $reason = "";
2063  foreach ($messages as $message) {
2064  if ($reason == "") {
2065  $reason = $message;
2066  } else {
2067  $reason .= "<br>" . $message;
2068  }
2069  }
2070  $block->setVariable("MESSAGE_ID", $login);
2071  $block->setVariable("MESSAGE_TEXT", $reason);
2072  $block->parseCurrentBlock();
2073  }
2074  return $block->get();
2075  }
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
ilLanguage $lng
global $DIC
Definition: feed.php:28
$messages
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: xapiexit.php:22
getProtocol()
The protocol is an associative array.
string $reason
Error message for last request processed.
Definition: System.php:102
$message
Definition: xapiexit.php:32
+ 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 677 of file class.ilUserImportParser.php.

Referenced by getParentRoleIds().

677  : ilObjRole
678  {
679  if (array_key_exists($a_role_id, $this->localRoleCache)) {
680  return $this->localRoleCache[$a_role_id];
681  } else {
682  $role_obj = new ilObjRole($a_role_id, false);
683  $role_obj->read();
684  $this->localRoleCache[$a_role_id] = $role_obj;
685  return $role_obj;
686  }
687  }
Class ilObjRole.
+ Here is the caller graph for this function:

◆ getUserCount()

ilUserImportParser::getUserCount ( )

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

References $userCount.

1984  : int
1985  {
1986  return $this->userCount;
1987  }

◆ getUserMapping()

ilUserImportParser::getUserMapping ( )

returns a map user_id <=> login

Returns
array with user_id as key and login as value

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

References $user_mapping.

2098  : array
2099  {
2100  return $this->user_mapping;
2101  }

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

References $mapping_mode.

Referenced by importBeginTag(), and verifyBeginTag().

2143  : int
2144  {
2145  return $this->mapping_mode;
2146  }
+ Here is the caller graph for this function:

◆ handlerBeginTag()

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

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

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

331  : void {
332  switch ($this->mode) {
333  case IL_EXTRACT_ROLES:
334  $this->extractRolesBeginTag($a_xml_parser, $a_name, $a_attribs);
335  break;
336  case IL_USER_IMPORT:
337  $this->importBeginTag($a_xml_parser, $a_name, $a_attribs);
338  break;
339  case IL_VERIFY:
340  $this->verifyBeginTag($a_xml_parser, $a_name, $a_attribs);
341  break;
342  }
343 
344  $this->cdata = "";
345  }
const IL_USER_IMPORT
verifyBeginTag( $a_xml_parser, string $a_name, array $a_attribs)
const IL_EXTRACT_ROLES
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
extractRolesBeginTag( $a_xml_parser, string $a_name, array $a_attribs)
importBeginTag( $a_xml_parser, string $a_name, array $a_attribs)
const IL_VERIFY
+ Here is the call 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 1963 of file class.ilUserImportParser.php.

1966  : void {
1967  if ($a_data !== "\n") {
1968  $a_data = preg_replace("/\t+/", " ", $a_data);
1969  }
1970 
1971  if (strlen($a_data) > 0) {
1972  $this->cdata .= $a_data;
1973  }
1974  }

◆ handlerEndTag()

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

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

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

644  : void {
645  switch ($this->mode) {
646  case IL_EXTRACT_ROLES:
647  $this->extractRolesEndTag($a_xml_parser, $a_name);
648  break;
649  case IL_USER_IMPORT:
650  $this->importEndTag($a_xml_parser, $a_name);
651  break;
652  case IL_VERIFY:
653  $this->verifyEndTag($a_xml_parser, $a_name);
654  break;
655  }
656  }
extractRolesEndTag( $a_xml_parser, string $a_name)
const IL_USER_IMPORT
importEndTag( $a_xml_parser, string $a_name)
const IL_EXTRACT_ROLES
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
const IL_VERIFY
verifyEndTag( $a_xml_parser, string $a_name)
handler for end of element when in verify mode.
+ Here is the call 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 370 of file class.ilUserImportParser.php.

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

Referenced by handlerBeginTag().

374  : void {
375  global $DIC;
376 
377  $ilias = $DIC['ilias'];
378  $lng = $DIC['lng'];
379 
380  switch ($a_name) {
381  case "Role":
382  $this->current_role_id = $a_attribs["Id"];
383  if (($internal_id = ilUtil::__extractId($this->current_role_id, IL_INST_ID)) > 0) {
384  $this->current_role_id = $internal_id;
385  }
386  $this->current_role_type = $a_attribs["Type"];
387  $this->current_role_action = (!isset($a_attribs["Action"])) ? "Assign" : $a_attribs["Action"];
388  break;
389 
390  case "PersonalPicture":
391  $this->personalPicture = array(
392  "encoding" => $a_attribs["encoding"],
393  "imagetype" => $a_attribs["imagetype"],
394  "content" => ""
395  );
396  break;
397 
398  case "Look":
399  $this->skin = $a_attribs["Skin"];
400  $this->style = $a_attribs["Style"];
401  break;
402 
403  case "User":
404  $this->containedTags = [];
405 
406  $this->acc_mail->reset();
407  $this->prefs = array();
408  $this->currentPrefKey = null;
409  $this->auth_mode_set = false;
410  $this->approve_date_set = false;
411  $this->time_limit_set = false;
412  $this->time_limit_owner_set = false;
413  $this->updateLookAndSkin = false;
414  $this->skin = "";
415  $this->style = "";
416  $this->personalPicture = null;
417  $this->userCount++;
418  $this->userObj = new ilObjUser();
419 
420  // user defined fields
421  $this->udf_data = array();
422 
423  // if we have an object id, store it
424  $this->user_id = -1;
425  if (isset($a_attribs["Id"]) && $this->getUserMappingMode() == IL_USER_MAPPING_ID) {
426  if (is_numeric($a_attribs["Id"])) {
427  $this->user_id = $a_attribs["Id"];
428  } elseif (($id = ilUtil::__extractId($a_attribs["Id"], IL_INST_ID)) > 0) {
429  $this->user_id = $id;
430  }
431  }
432 
433  $this->userObj->setPref(
434  "skin",
435  $ilias->ini->readVariable("layout", "skin")
436  );
437  $this->userObj->setPref(
438  "style",
439  $ilias->ini->readVariable("layout", "style")
440  );
441 
442  if (isset($a_attribs["Language"])) {
443  $this->containedTags[] = "Language";
444  }
445  $this->userObj->setLanguage($a_attribs["Language"] ?? '');
446  $this->userObj->setImportId($a_attribs["Id"] ?? '');
447  $this->action = (is_null($a_attribs["Action"])) ? "Insert" : $a_attribs["Action"];
448  $this->currPassword = null;
449  $this->currPasswordType = null;
450  $this->currActive = null;
451  $this->multi_values = array();
452  break;
453 
454  case 'Password':
455  $this->currPasswordType = $a_attribs['Type'];
456  break;
457  case "AuthMode":
458  if (array_key_exists("type", $a_attribs)) {
459  switch ($a_attribs["type"]) {
460  case "saml":
461  case "ldap":
462  if (strcmp('saml', $a_attribs['type']) === 0) {
463  $list = ilSamlIdp::getActiveIdpList();
464  if (count($list) === 1) {
465  $this->auth_mode_set = true;
466  $idp = current($list);
467  $this->userObj->setAuthMode('saml_' . $idp->getIdpId());
468  }
469  break;
470  }
471  if (strcmp('ldap', $a_attribs['type']) === 0) {
472  // no server id provided => use default server
474  if (count($list) == 1) {
475  $this->auth_mode_set = true;
476  $ldap_id = current($list);
477  $this->userObj->setAuthMode('ldap_' . $ldap_id);
478  }
479  }
480  break;
481 
482  case "default":
483  case "local":
484  case "shibboleth":
485  case "script":
486  case "cas":
487  case "soap":
488  case "openid":
489  // begin-patch auth_plugin
490  default:
491  $this->auth_mode_set = true;
492  $this->userObj->setAuthMode($a_attribs["type"]);
493  break;
494  }
495  } else {
496  $this->logFailure(
497  $this->userObj->getLogin(),
498  sprintf($lng->txt("usrimport_xml_element_inapplicable"), "AuthMode", $this->stripTags($a_attribs["type"]))
499  );
500  }
501  break;
502 
503  case 'UserDefinedField':
504  $this->tmp_udf_id = $a_attribs['Id'];
505  $this->tmp_udf_name = $a_attribs['Name'];
506  break;
507 
508  case 'AccountInfo':
509  $this->current_messenger_type = strtolower($a_attribs["Type"]);
510  break;
511  case 'GMapInfo':
512  $this->userObj->setLatitude($a_attribs["latitude"]);
513  $this->userObj->setLongitude($a_attribs["longitude"]);
514  $this->userObj->setLocationZoom($a_attribs["zoom"]);
515  break;
516  case 'Pref':
517  $this->currentPrefKey = $a_attribs["key"];
518  break;
519  }
520  }
const IL_INST_ID
Definition: constants.php:40
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
getUserMappingMode()
read access to user mapping mode
static _getActiveServerList()
Get active server list.
ilLanguage $lng
global $DIC
Definition: feed.php:28
const IL_USER_MAPPING_ID
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 846 of file class.ilUserImportParser.php.

References $cdata, $current_role_action, $current_role_id, $current_role_type, $currentPrefKey, $DIC, Vendor\Package\$e, $ilSetting, $ilUser, ILIAS\LTI\ToolProvider\$key, ilSaxParser\$lng, $timestamp, $user_id, ilObjUser\_checkExternalAuthAccount(), ilAuthUtils\_getAuthModeName(), ilUserDefinedFields\_getInstance(), ilObjAdvancedEditing\_getUsedHTMLTags(), ilObjUser\_lookupExternalAccount(), ilObjUser\_uploadPersonalPicture(), ANONYMOUS_USER_ID, assignToRole(), assignToRoleWithParents(), checkProfileIncomplete(), detachFromRole(), getCDataWithoutTags(), getFolderId(), ilObjUser\getUserIdByLogin(), IL_CAL_DATETIME, IL_CAL_UNIX, IL_FAIL_ON_CONFLICT, IL_IGNORE_ON_CONFLICT, IL_UPDATE_ON_CONFLICT, ILIAS\Repository\int(), ilUserXMLWriter\isPrefExportable(), ILIAS\Repository\lng(), logFailure(), logSuccess(), logWarning(), ilObjUser\PASSWD_CRYPTED, ilObjUser\PASSWD_PLAIN, saveTempImage(), sendAccountMail(), ilUserDefinedData\set(), stripTags(), SYSTEM_USER_ID, tagContained(), ilLanguage\txt(), and updateMailPreferences().

Referenced by handlerEndTag().

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

References readRequiredFields().

Referenced by verifyEndTag().

2184  : bool
2185  {
2186  $requiredFields = $this->readRequiredFields();
2187  $fieldname = strtolower(trim($fieldname));
2188  return array_key_exists($fieldname, $requiredFields);
2189  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isSendMail()

ilUserImportParser::isSendMail ( )

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

References $send_mail.

Referenced by sendAccountMail().

2120  : bool
2121  {
2122  return $this->send_mail;
2123  }
+ Here is the caller graph for this function:

◆ isSuccess()

ilUserImportParser::isSuccess ( )

Returns true, if the import was successful.

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

References IL_IMPORT_SUCCESS.

2080  : bool
2081  {
2082  return $this->error_level == IL_IMPORT_SUCCESS;
2083  }
const IL_IMPORT_SUCCESS

◆ logFailure()

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

Writes a failure log message to the protocol.

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

References IL_IMPORT_FAILURE.

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

2013  : void {
2014  if (!array_key_exists($aLogin, $this->protocol)) {
2015  $this->protocol[$aLogin] = array();
2016  }
2017  if ($aMessage) {
2018  $this->protocol[$aLogin][] = $aMessage;
2019  }
2020  $this->error_level = IL_IMPORT_FAILURE;
2021  }
const IL_IMPORT_FAILURE
+ Here is the caller graph for this function:

◆ logSuccess()

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

Writes a success log message to the protocol.

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

Referenced by importEndTag().

2030  : void {
2031  $this->user_mapping[$userid] = array("login" => $aLogin, "action" => $action, "message" => "successful");
2032  }
+ 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 1992 of file class.ilUserImportParser.php.

References IL_IMPORT_SUCCESS, and IL_IMPORT_WARNING.

Referenced by importEndTag(), and verifyEndTag().

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

◆ readRequiredFields()

ilUserImportParser::readRequiredFields ( )
private
Returns
array[]

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

References $DIC, $ilSetting, and $required_fields.

Referenced by isFieldRequired().

2151  : array
2152  {
2153  global $DIC;
2154 
2155  $ilSetting = $DIC['ilSetting'];
2156 
2157  if (is_array($this->required_fields)) {
2158  return $this->required_fields;
2159  }
2160  foreach ($ilSetting->getAll() as $field => $value) {
2161  if (strpos($field, 'require_') === 0 && $value == 1) {
2162  $value = substr($field, 8);
2163  $this->required_fields[$value] = $value;
2164  }
2165  }
2166  return $this->required_fields ?: array();
2167  }
global $DIC
Definition: feed.php:28
global $ilSetting
Definition: privfeed.php:17
+ 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 1612 of file class.ilUserImportParser.php.

References $filename, and ilFileUtils\ilTempnam().

Referenced by importEndTag().

1615  : string {
1616  $tempname = ilFileUtils::ilTempnam() . $filename;
1617  $fh = fopen($tempname, "wb");
1618  if ($fh == false) {
1619  return "";
1620  }
1621  fwrite($fh, $image_data);
1622  fclose($fh);
1623  return $tempname;
1624  }
$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 2106 of file class.ilUserImportParser.php.

References isSendMail().

Referenced by importEndTag().

2106  : void
2107  {
2108  if ($this->req_send_mail != "" ||
2109  ($this->isSendMail() && $this->userObj->getEmail() != "")) {
2110  $this->acc_mail->setUser($this->userObj);
2111  $this->acc_mail->send();
2112  }
2113  }
+ 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 269 of file class.ilUserImportParser.php.

269  : void
270  {
271  $this->folder_id = $a_folder_id;
272  }

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

286  : void
287  {
288  xml_set_object($a_xml_parser, $this);
289  xml_set_element_handler($a_xml_parser, 'handlerBeginTag', 'handlerEndTag');
290  xml_set_character_data_handler($a_xml_parser, 'handlerCharacterData');
291  }

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

298  : void
299  {
300  $this->role_assign = $a_assign;
301  }

◆ setSendMail()

ilUserImportParser::setSendMail ( bool  $value)

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

2115  : void
2116  {
2117  $this->send_mail = $value;
2118  }

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

References IL_USER_MAPPING_ID, and IL_USER_MAPPING_LOGIN.

2130  : void
2131  {
2132  if ($value == IL_USER_MAPPING_ID || $value == IL_USER_MAPPING_LOGIN) {
2133  $this->mapping_mode = $value;
2134  } else {
2135  die("wrong argument using methode setUserMappingMethod in " . __FILE__);
2136  }
2137  }
const IL_USER_MAPPING_LOGIN
const IL_USER_MAPPING_ID

◆ stripTags()

ilUserImportParser::stripTags ( string  $string)
private

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

References ILIAS\Repository\refinery().

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

2301  : string
2302  {
2303  return $this->refinery->string()->stripTags()->transform($string);
2304  }
+ 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 838 of file class.ilUserImportParser.php.

Referenced by importEndTag(), and verifyEndTag().

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

◆ updateMailPreferences()

ilUserImportParser::updateMailPreferences ( int  $usr_id)
private

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

Referenced by importEndTag().

2281  : void
2282  {
2283  if (array_key_exists("mail_incoming_type", $this->prefs) ||
2284  array_key_exists("mail_signature", $this->prefs) ||
2285  array_key_exists("mail_linebreak", $this->prefs)
2286  ) {
2287  $mailOptions = new ilMailOptions($usr_id);
2288 
2289  $mailOptions->setLinebreak(array_key_exists("mail_linebreak", $this->prefs) ? $this->prefs["mail_linebreak"] : $mailOptions->getLinebreak());
2290  $mailOptions->setSignature(array_key_exists("mail_signature", $this->prefs) ? $this->prefs["mail_signature"] : $mailOptions->getSignature());
2291  $mailOptions->setIncomingType(array_key_exists("mail_incoming_type", $this->prefs) ? $this->prefs["mail_incoming_type"] : $mailOptions->getIncomingType());
2292  $mailOptions->updateOptions();
2293  }
2294  }
Class ilMailOptions this class handles user mails.
+ 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 525 of file class.ilUserImportParser.php.

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

Referenced by handlerBeginTag().

529  : void {
530  global $DIC;
531 
532  $lng = $DIC['lng'];
533 
534  switch ($a_name) {
535  case "Role":
536  if ($a_attribs['Id'] == "") {
537  $this->logFailure($this->userObj->getLogin(), sprintf($lng->txt("usrimport_xml_attribute_missing"), "Role", "Id"));
538  }
539  $this->current_role_id = $a_attribs["Id"];
540  $this->current_role_type = $a_attribs["Type"];
541  if ($this->current_role_type !== 'Global'
542  && $this->current_role_type !== 'Local') {
543  $this->logFailure($this->userObj->getLogin(), sprintf($lng->txt("usrimport_xml_attribute_missing"), "Role", "Type"));
544  }
545  $this->current_role_action = (!isset($a_attribs["Action"])) ? "Assign" : $a_attribs["Action"];
546  if ($this->current_role_action !== "Assign"
547  && $this->current_role_action !== "AssignWithParents"
548  && $this->current_role_action !== "Detach") {
549  $this->logFailure($this->userObj->getLogin(), sprintf($lng->txt("usrimport_xml_attribute_value_illegal"), "Role", "Action", $this->stripTags($a_attribs["Action"])));
550  }
551  if ($this->action === "Insert"
552  && $this->current_role_action === "Detach") {
553  $this->logFailure($this->userObj->getLogin(), sprintf($lng->txt("usrimport_xml_attribute_value_inapplicable"), "Role", "Action", $this->stripTags($this->current_role_action), $this->stripTags($this->action)));
554  }
555  if ($this->action === "Delete") {
556  $this->logFailure($this->userObj->getLogin(), sprintf($lng->txt("usrimport_xml_element_inapplicable"), "Role", "Delete"));
557  }
558  break;
559 
560  case "User":
561  $this->userCount++;
562  $this->containedTags = [];
563  $this->userObj = new ilObjUser();
564  $this->userObj->setLanguage($a_attribs["Language"] ?? '');
565  $this->userObj->setImportId($a_attribs["Id"] ?? '');
566  $this->currentPrefKey = null;
567  // if we have an object id, store it
568  $this->user_id = -1;
569 
570  if (!is_null($a_attribs["Id"]) && $this->getUserMappingMode() == IL_USER_MAPPING_ID) {
571  if (is_numeric($a_attribs["Id"])) {
572  $this->user_id = $a_attribs["Id"];
573  } elseif ($id = ilUtil::__extractId($a_attribs["Id"], IL_INST_ID) > 0) {
574  $this->user_id = $id;
575  }
576  }
577 
578  $this->action = (is_null($a_attribs["Action"])) ? "Insert" : $a_attribs["Action"];
579  if ($this->action !== "Insert"
580  && $this->action !== "Update"
581  && $this->action !== "Delete") {
582  $this->logFailure($this->userObj->getImportId(), sprintf($lng->txt("usrimport_xml_attribute_value_illegal"), "User", "Action", $this->stripTags($a_attribs["Action"])));
583  }
584  $this->currPassword = null;
585  $this->currPasswordType = null;
586  break;
587 
588  case 'Password':
589  $this->currPasswordType = $a_attribs['Type'];
590  break;
591  case "AuthMode":
592  if (array_key_exists("type", $a_attribs)) {
593  switch ($a_attribs["type"]) {
594  case "saml":
595  case "ldap":
596  if (strcmp('saml', $a_attribs['type']) === 0) {
597  $list = ilSamlIdp::getActiveIdpList();
598  if (count($list) !== 1) {
599  $this->logFailure(
600  $this->userObj->getImportId(),
601  sprintf($lng->txt("usrimport_xml_attribute_value_illegal"), "AuthMode", "type", $this->stripTags($a_attribs['type']))
602  );
603  }
604  break;
605  }
606  if (strcmp('ldap', $a_attribs['type']) === 0) {
607  // no server id provided
609  if (count($list) != 1) {
610  $this->logFailure(
611  $this->userObj->getImportId(),
612  sprintf($lng->txt("usrimport_xml_attribute_value_illegal"), "AuthMode", "type", $this->stripTags($a_attribs['type']))
613  );
614  }
615  }
616  break;
617 
618  case "default":
619  case "local":
620  case "shibboleth":
621  case "script":
622  case "cas":
623  case "soap":
624  case "openid":
625  // begin-patch auth_plugin
626  default:
627  $this->userObj->setAuthMode($a_attribs["type"]);
628  break;
629  }
630  } else {
631  $this->logFailure($this->userObj->getImportId(), sprintf($lng->txt("usrimport_xml_attribute_value_illegal"), "AuthMode", "type", ""));
632  }
633  break;
634  case 'Pref':
635  $this->currentPrefKey = $a_attribs["key"];
636  break;
637 
638  }
639  }
const IL_INST_ID
Definition: constants.php:40
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
getUserMappingMode()
read access to user mapping mode
static _getActiveServerList()
Get active server list.
ilLanguage $lng
global $DIC
Definition: feed.php:28
const IL_USER_MAPPING_ID
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 1629 of file class.ilUserImportParser.php.

References $cdata, $current_role_action, $current_role_id, $current_role_type, $DIC, $ilSetting, ilSaxParser\$lng, $user_id, ilObjUser\_checkExternalAuthAccount(), ilAuthUtils\_getAuthModeName(), ilObjUser\_lookupExternalAccount(), ilObjUser\_lookupId(), ilObjUser\_lookupLogin(), ANONYMOUS_USER_ID, ilObjUser\getUserIdByLogin(), IL_FAIL_ON_CONFLICT, isFieldRequired(), logFailure(), logWarning(), ilObjUser\PASSWD_CRYPTED, ilObjUser\PASSWD_PLAIN, stripTags(), SYSTEM_USER_ID, tagContained(), ilLanguage\txt(), USER_FOLDER_ID, and verifyPref().

Referenced by handlerEndTag().

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

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

Referenced by verifyEndTag().

2191  : void
2192  {
2193  switch ($key) {
2194  case 'mail_linebreak':
2195  case 'hits_per_page':
2196  if (!is_numeric($value) || $value < 0) {
2197  $this->logFailure("---", "Wrong value '{$this->stripTags($value)}': Positiv numeric value expected for preference {$this->stripTags($key)}.");
2198  }
2199  break;
2200  case 'language':
2201  case 'skin':
2202  case 'style':
2203  case 'ilPageEditor_HTMLMode':
2204  case 'ilPageEditor_JavaScript':
2205  case 'ilPageEditor_MediaMode':
2206  case 'tst_javascript':
2207  case 'tst_lastquestiontype':
2208  case 'tst_multiline_answers':
2209  case 'tst_use_previous_answers':
2210  case 'graphicalAnswerSetting':
2211  case 'priv_feed_pass':
2212  $this->logFailure("---", "Preference {$this->stripTags($key)} is not supported.");
2213  break;
2214  case 'public_city':
2215  case 'public_country':
2216  case 'public_department':
2217  case 'public_email':
2218  case 'public_second_email':
2219  case 'public_fax':
2220  case 'public_hobby':
2221  case 'public_institution':
2222  case 'public_matriculation':
2223  case 'public_phone':
2224  case 'public_phone_home':
2225  case 'public_phone_mobile':
2226  case 'public_phone_office':
2227  case 'public_street':
2228  case 'public_upload':
2229  case 'public_zip':
2230  case 'public_interests_general':
2231  case 'public_interests_help_offered':
2232  case 'public_interests_help_looking':
2233  case 'send_info_mails':
2234  case 'bs_allow_to_contact_me':
2235  case 'chat_osc_accept_msg':
2236  case 'chat_broadcast_typing':
2237  case 'hide_own_online_status':
2238  if (!in_array($value, array('y', 'n'))) {
2239  $this->logFailure("---", "Wrong value '{$this->stripTags($value)}': Value 'y' or 'n' expected for preference {$this->stripTags($key)}.");
2240  }
2241  break;
2242  case 'public_profile':
2243  if (!in_array($value, array('y', 'n', 'g'))) {
2244  $this->logFailure("---", "Wrong value '{$this->stripTags($value)}': Value 'y', 'g' or 'n' expected for preference {$this->stripTags($key)}.");
2245  }
2246  break;
2247  case 'show_users_online':
2248  if (!in_array($value, array('y', 'n', 'associated'))) {
2249  $this->logFailure("---", "Wrong value '{$this->stripTags($value)}': Value 'y' or 'n' or 'associated' expected for preference {$this->stripTags($key)}.");
2250  }
2251  break;
2252  case 'mail_incoming_type':
2253  if (!in_array((int) $value, array("0","1","2"))) {
2254  $this->logFailure("---", "Wrong value '{$this->stripTags($value)}': Value \"0\" (LOCAL),\"1\" (EMAIL) or \"2\" (BOTH) expected for preference {$this->stripTags($key)}.");
2255  }
2256  break;
2257  case 'weekstart':
2258  if (!in_array($value, array("0","1"))) {
2259  $this->logFailure("---", "Wrong value '{$this->stripTags($value)}': Value \"0\" (Sunday) or \"1\" (Monday) expected for preference {$this->stripTags($key)}.");
2260  }
2261  break;
2262 
2263  case 'mail_signature':
2264  break;
2265  case 'user_tz':
2266  try {
2267  ilTimeZone::_getInstance($value);
2268  return;
2269  } catch (ilTimeZoneException $tze) {
2270  $this->logFailure("---", "Wrong value '{$this->stripTags($value)}': Invalid timezone $value detected for preference {$this->stripTags($key)}.");
2271  }
2272  break;
2273  default:
2275  $this->logFailure("---", "Preference {$this->stripTags($key)} is not supported.");
2276  }
2277  break;
2278  }
2279  }
static _getInstance(string $a_tz='')
get instance by timezone
Class for TimeZone exceptions.
string $key
Consumer key/client ID value.
Definition: System.php:193
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 51 of file class.ilUserImportParser.php.

◆ $action

string ilUserImportParser::$action

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

◆ $approve_date_set

bool ilUserImportParser::$approve_date_set = false

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

◆ $auth_mode_set

bool ilUserImportParser::$auth_mode_set
protected

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

◆ $cdata

string ilUserImportParser::$cdata
protected

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

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

◆ $conflict_rule

int ilUserImportParser::$conflict_rule

Conflict handling rule.

Values: IL_FAIL_ON_CONFLICT IL_UPDATE_ON_CONFLICT IL_IGNORE_ON_CONFLICT

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

◆ $containedTags

array ilUserImportParser::$containedTags = []
protected

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

◆ $currActive

string ilUserImportParser::$currActive = null

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

◆ $current_messenger_type

string ilUserImportParser::$current_messenger_type
private

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

◆ $current_role_action

string ilUserImportParser::$current_role_action
protected

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

Referenced by importEndTag(), and verifyEndTag().

◆ $current_role_id

string ilUserImportParser::$current_role_id = ""
protected

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

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

◆ $current_role_type

string ilUserImportParser::$current_role_type
protected

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

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

◆ $currentPrefKey

string ilUserImportParser::$currentPrefKey = null
protected

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

Referenced by importEndTag().

◆ $currPassword

string ilUserImportParser::$currPassword

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

◆ $currPasswordType

string ilUserImportParser::$currPasswordType

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

Referenced by getErrorLevel().

◆ $folder_id

int ilUserImportParser::$folder_id

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

Referenced by getFolderId().

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

◆ $mapping_mode

int ilUserImportParser::$mapping_mode

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

Referenced by getUserMappingMode().

◆ $mode

int ilUserImportParser::$mode
protected

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

◆ $multi_values

array ilUserImportParser::$multi_values
protected

Definition at line 40 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 188 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 179 of file class.ilUserImportParser.php.

◆ $prefs

array ilUserImportParser::$prefs
protected

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

Referenced by getProtocol().

◆ $recommended_content_manager

ilRecommendedContentManager ilUserImportParser::$recommended_content_manager
protected

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

◆ $refinery

Refinery ilUserImportParser::$refinery
private

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

Referenced by __construct().

◆ $req_send_mail

string ilUserImportParser::$req_send_mail
protected

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

◆ $required_fields

array ilUserImportParser::$required_fields = []
protected

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

Referenced by readRequiredFields().

◆ $role_assign

array ilUserImportParser::$role_assign
protected

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

◆ $roles

array ilUserImportParser::$roles

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

Referenced by getCollectedRoles().

◆ $send_mail

bool ilUserImportParser::$send_mail

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

Referenced by isSendMail().

◆ $skin

string ilUserImportParser::$skin = ''

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

◆ $style

string ilUserImportParser::$style = ''

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

Referenced by __construct().

◆ $time_limit_owner_set

bool ilUserImportParser::$time_limit_owner_set = false

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

◆ $time_limit_set

bool ilUserImportParser::$time_limit_set = false

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

◆ $tmp_udf_id

string ilUserImportParser::$tmp_udf_id = null
protected

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

◆ $tmp_udf_name

string ilUserImportParser::$tmp_udf_name = null
protected

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

◆ $udf_data

array ilUserImportParser::$udf_data
protected

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

◆ $updateLookAndSkin

bool ilUserImportParser::$updateLookAndSkin = false

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

◆ $user_id

int ilUserImportParser::$user_id

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

Referenced by importEndTag(), and verifyEndTag().

◆ $user_mapping

array ilUserImportParser::$user_mapping = []

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

Referenced by getUserMapping().

◆ $user_settings_config

ilUserSettingsConfig ilUserImportParser::$user_settings_config
protected

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

◆ $userCount

int ilUserImportParser::$userCount

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

Referenced by getUserCount().

◆ $userObj

ilObjUser ilUserImportParser::$userObj
private

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

◆ $userStyles

array ilUserImportParser::$userStyles

User assigned styles.

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


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