24 define (
"IL_EXTRACT_ROLES", 1);
25 define (
"IL_USER_IMPORT", 2);
26 define (
"IL_VERIFY", 3);
28 define (
"IL_FAIL_ON_CONFLICT", 1);
29 define (
"IL_UPDATE_ON_CONFLICT", 2);
30 define (
"IL_IGNORE_ON_CONFLICT", 3);
32 define (
"IL_IMPORT_SUCCESS", 1);
33 define (
"IL_IMPORT_WARNING", 2);
34 define (
"IL_IMPORT_FAILURE", 3);
36 define (
"IL_USER_MAPPING_LOGIN", 1);
37 define (
"IL_USER_MAPPING_ID", 2);
39 require_once(
"./Services/Xml/classes/class.ilSaxParser.php");
40 require_once (
'Services/User/classes/class.ilUserXMLWriter.php');
290 $this->roles = array();
291 $this->mode = $a_mode;
292 $this->conflict_rule = $a_conflict_rule;
294 $this->protocol = array();
295 $this->logins = array();
296 $this->userCount = 0;
297 $this->localRoleCache = array();
298 $this->parentRolesCache = array();
299 $this->ilincdata = array();
300 $this->send_mail =
false;
304 $this->userStyles = array();
305 include_once(
"./Services/Style/classes/class.ilObjStyleSettings.php");
306 include_once
'./Services/Style/classes/class.ilStyleDefinition.php';
309 if (is_array($templates))
312 foreach($templates as $template)
316 $styleDef->startParsing();
317 $styles = $styleDef->getStyles();
319 foreach($styles as
$style)
325 $this->userStyles [] = $template[
"id"].
":".$style[
"id"];
330 $settings = $ilias->getAllSettings();
331 if ($settings[
"usr_settings_hide_skin_style"] == 1)
333 $this->hideSkin = TRUE;
337 $this->hideSkin = FALSE;
339 if ($settings[
"usr_settings_disable_skin_style"] == 1)
341 $this->disableSkin = TRUE;
345 $this->disableSkin = FALSE;
348 include_once(
"Services/Mail/classes/class.ilAccountMail.php");
350 $this->acc_mail->useLangVariablesAsFallback(
true);
362 $this->folder_id = $a_folder_id;
377 xml_set_object($a_xml_parser,$this);
378 xml_set_element_handler($a_xml_parser,
'handlerBeginTag',
'handlerEndTag');
379 xml_set_character_data_handler($a_xml_parser,
'handlerCharacterData');
397 $this->role_assign = $a_assign;
418 while (list($k,$v) = each($attr))
419 $tag.=
" ".$k.
"=\"$v\"";
457 $this->current_role_id = $a_attribs[
"Id"];
460 $this->current_role_id = $internal_id;
462 $this->current_role_type = $a_attribs[
"Type"];
477 $this->current_role_id = $a_attribs[
"Id"];
480 $this->current_role_id = $internal_id;
482 $this->current_role_type = $a_attribs[
"Type"];
483 $this->current_role_action = (is_null($a_attribs[
"Action"])) ?
"Assign" : $a_attribs[
"Action"];
486 case "PersonalPicture":
487 $this->personalPicture = array(
488 "encoding" => $a_attribs[
"encoding"],
489 "imagetype" => $a_attribs[
"imagetype"],
495 $this->skin = $a_attribs[
"Skin"];
496 $this->style = $a_attribs[
"Style"];
500 $this->acc_mail->reset();
501 $this->prefs = array();
502 $this->currentPrefKey = null;
503 $this->auth_mode_set =
false;
504 $this->approve_date_set =
false;
505 $this->time_limit_set =
false;
506 $this->time_limit_owner_set =
false;
507 $this->updateLookAndSkin =
false;
510 $this->personalPicture = null;
515 $this->udf_data = array();
521 if (is_numeric($a_attribs[
"Id"]))
523 $this->user_id = $a_attribs[
"Id"];
527 $this->user_id = $id;
531 $this->userObj->setPref(
"skin",
532 $ilias->ini->readVariable(
"layout",
"skin"));
533 $this->userObj->setPref(
"style",
534 $ilias->ini->readVariable(
"layout",
"style"));
536 $this->userObj->setLanguage($a_attribs[
"Language"]);
537 $this->userObj->setImportId($a_attribs[
"Id"]);
538 $this->action = (is_null($a_attribs[
"Action"])) ?
"Insert" : $a_attribs[
"Action"];
539 $this->currPassword = null;
540 $this->currPasswordType = null;
541 $this->currActive = null;
545 $this->currPasswordType = $a_attribs[
"Type"];
548 if (array_key_exists(
"type", $a_attribs))
550 switch ($a_attribs[
"type"])
561 $this->auth_mode_set =
true;
562 $this->userObj->setAuthMode($a_attribs[
"type"]);
566 sprintf($lng->txt(
"usrimport_xml_element_inapplicable"),
"AuthMode",$a_attribs[
"type"]));
573 sprintf($lng->txt(
"usrimport_xml_element_inapplicable"),
"AuthMode",$a_attribs[
"type"]));
577 case 'UserDefinedField':
578 $this->tmp_udf_id = $a_attribs[
'Id'];
579 $this->tmp_udf_name = $a_attribs[
'Name'];
583 $this->current_messenger_type = strtolower($a_attribs[
"Type"]);
586 $this->userObj->setLatitude($a_attribs[
"latitude"]);
587 $this->userObj->setLongitude($a_attribs[
"longitude"]);
588 $this->userObj->setLocationZoom($a_attribs[
"zoom"]);
591 $this->currentPrefKey = $a_attribs[
"key"];
606 if (is_null($a_attribs[
'Id'])
607 || $a_attribs[
'Id'] ==
"")
609 $this->
logFailure($this->userObj->getLogin(), sprintf($lng->txt(
"usrimport_xml_attribute_missing"),
"Role",
"Id"));
611 $this->current_role_id = $a_attribs[
"Id"];
612 $this->current_role_type = $a_attribs[
"Type"];
613 if ($this->current_role_type !=
'Global'
614 && $this->current_role_type !=
'Local')
616 $this->
logFailure($this->userObj->getLogin(), sprintf($lng->txt(
"usrimport_xml_attribute_missing"),
"Role",
"Type"));
618 $this->current_role_action = (is_null($a_attribs[
"Action"])) ?
"Assign" : $a_attribs[
"Action"];
619 if ($this->current_role_action !=
"Assign"
620 && $this->current_role_action !=
"AssignWithParents"
621 && $this->current_role_action !=
"Detach")
623 $this->
logFailure($this->userObj->getLogin(), sprintf($lng->txt(
"usrimport_xml_attribute_value_illegal"),
"Role",
"Action",$a_attribs[
"Action"]));
625 if ($this->action ==
"Insert"
626 && $this->current_role_action ==
"Detach")
628 $this->
logFailure($this->userObj->getLogin(), sprintf($lng->txt(
"usrimport_xml_attribute_value_inapplicable"),
"Role",
"Action",$this->current_role_action,
$this->action));
630 if ($this->action ==
"Delete")
632 $this->
logFailure($this->userObj->getLogin(), sprintf($lng->txt(
"usrimport_xml_element_inapplicable"),
"Role",
"Delete"));
639 $this->userObj->setLanguage($a_attribs[
"Language"]);
640 $this->userObj->setImportId($a_attribs[
"Id"]);
641 $this->currentPrefKey = null;
647 if (is_numeric($a_attribs[
"Id"]))
649 $this->user_id = $a_attribs[
"Id"];
653 $this->user_id = $id;
657 $this->action = (is_null($a_attribs[
"Action"])) ?
"Insert" : $a_attribs[
"Action"];
658 if ($this->action !=
"Insert"
659 && $this->action !=
"Update"
660 && $this->action !=
"Delete")
662 $this->
logFailure($this->userObj->getImportId(), sprintf($lng->txt(
"usrimport_xml_attribute_value_illegal"),
"User",
"Action",$a_attribs[
"Action"]));
664 $this->currPassword = null;
665 $this->currPasswordType = null;
669 $this->currPasswordType = $a_attribs[
"Type"];
672 if (array_key_exists(
"type", $a_attribs))
674 switch ($a_attribs[
"type"])
685 $this->userObj->setAuthMode($a_attribs[
"type"]);
688 $this->
logFailure($this->userObj->getImportId(), sprintf($lng->txt(
"usrimport_xml_attribute_value_illegal"),
"AuthMode",
"type",$a_attribs[
"type"]));
694 $this->
logFailure($this->userObj->getImportId(), sprintf($lng->txt(
"usrimport_xml_attribute_value_illegal"),
"AuthMode",
"type",
""));
698 $this->currentPrefKey = $a_attribs[
"key"];
731 $this->roles[$this->current_role_id][
"name"] = $this->cdata;
732 $this->roles[$this->current_role_id][
"type"] =
733 $this->current_role_type;
743 if (array_key_exists($a_role_id, $this->localRoleCache))
745 return $this->localRoleCache[$a_role_id];
749 $role_obj =
new ilObjRole($a_role_id,
false);
751 $this->localRoleCache[$a_role_id] = $role_obj;
761 global $rbacreview, $rbacadmin, $tree;
763 if (array_key_exists($a_role_id.
'_courseMembersObject', $this->localRoleCache))
765 return $this->localRoleCache[$a_role_id.
'_courseMembersObject'];
769 require_once(
"Modules/Course/classes/class.ilObjCourse.php");
770 require_once(
"Modules/Course/classes/class.ilCourseParticipants.php");
771 $rolf_refs = $rbacreview->getFoldersAssignedToRole($a_role_id,
true);
772 $course_ref = $tree->getParentId($rolf_refs[0]);
775 $this->localRoleCache[$a_role_id.
'_courseMembersObject'] = $crsmembers_obj;
776 return $crsmembers_obj;
786 require_once
"./Services/AccessControl/classes/class.ilObjRole.php";
787 include_once(
'./Services/Object/classes/class.ilObject.php');
788 #require_once "Modules/Course/classes/class.ilObjCourse.php";
789 #require_once "Modules/Course/classes/class.ilCourseParticipants.php";
791 global $rbacreview, $rbacadmin, $tree;
797 if ($rbacreview->isAssigned($a_user_obj->getId(), $a_role_id))
805 $rbacadmin->assignUser($a_role_id, $a_user_obj->getId(),
true);
806 $obj_id = $rbacreview->getObjectOfRole($a_role_id);
812 $ref_id = current((array) $ref_ids);
830 if (! array_key_exists($a_role_id, $this->parentRolesCache))
832 $parent_role_ids = array();
835 $short_role_title = substr($role_obj->getTitle(),0,12);
836 $folders = $rbacreview->getFoldersAssignedToRole($a_role_id,
true);
837 if (count($folders) > 0)
839 $all_parent_role_ids = $rbacreview->getParentRoleIds($folders[0]);
840 foreach ($all_parent_role_ids as $parent_role_id => $parent_role_data)
842 if ($parent_role_id != $a_role_id)
844 switch (substr($parent_role_data[
'title'],0,12))
846 case 'il_crs_admin' :
847 case 'il_grp_admin' :
848 if ($short_role_title ==
'il_crs_admin' || $short_role_title ==
'il_grp_admin')
850 $parent_role_ids[] = $parent_role_id;
853 case 'il_crs_tutor' :
854 case 'il_grp_tutor' :
855 if ($short_role_title ==
'il_crs_tutor' || $short_role_title ==
'il_grp_tutor')
857 $parent_role_ids[] = $parent_role_id;
860 case 'il_crs_membe' :
861 case 'il_grp_membe' :
862 if ($short_role_title ==
'il_crs_membe' || $short_role_title ==
'il_grp_membe')
864 $parent_role_ids[] = $parent_role_id;
873 $this->parentRolesCache[$a_role_id] = $parent_role_ids;
875 return $this->parentRolesCache[$a_role_id];
885 foreach ($parent_role_ids as $parent_role_id)
895 global $rbacreview, $rbacadmin, $tree;
897 $rbacadmin->deassignUser($a_role_id, $a_user_obj->getId());
902 $obj = $rbacreview->getObjectOfRole($a_role_id);
919 $this->roles[$this->current_role_id][
"name"] = $this->cdata;
920 $this->roles[$this->current_role_id][
"type"] = $this->current_role_type;
921 $this->roles[$this->current_role_id][
"action"] = $this->current_role_action;
924 case "PersonalPicture":
925 switch ($this->personalPicture[
"encoding"])
928 $this->personalPicture[
"content"] = base64_decode($this->cdata);
932 if (version_compare(PHP_VERSION,
'5',
'>='))
934 $this->personalPicture[
"content"] = convert_uudecode($this->cdata);
941 $this->userObj->setFullname();
944 if ($this->user_id == -1 || $this->action==
"Insert")
952 switch ($this->conflict_rule)
958 switch ($this->action)
963 $this->
logWarning($this->userObj->getLogin(),sprintf($lng->txt(
"usrimport_action_replaced"),
"Insert",
"Update"));
964 $this->action =
"Update";
970 $this->
logWarning($this->userObj->getLogin(),sprintf($lng->txt(
"usrimport_action_replaced"),
"Update",
"Insert"));
971 $this->action =
"Insert";
977 $this->
logWarning($this->userObj->getLogin(),sprintf($lng->txt(
"usrimport_action_ignored"),
"Delete"));
978 $this->action =
"Ignore";
984 switch ($this->action)
989 $this->
logWarning($this->userObj->getLogin(),sprintf($lng->txt(
"usrimport_action_ignored"),
"Insert"));
990 $this->action =
"Ignore";
996 $this->
logWarning($this->userObj->getLogin(),sprintf($lng->txt(
"usrimport_action_ignored"),
"Update"));
997 $this->action =
"Ignore";
1003 $this->
logWarning($this->userObj->getLogin(),sprintf($lng->txt(
"usrimport_action_ignored"),
"Delete"));
1004 $this->action =
"Ignore";
1015 $am = ($this->userObj->getAuthMode() ==
"default" || $this->userObj->getAuthMode() ==
"")
1017 : $this->userObj->getAuthMode();
1018 $loginForExternalAccount = ($this->userObj->getExternalAccount() ==
"")
1021 switch ($this->action)
1024 if ($loginForExternalAccount !=
"")
1026 $this->
logWarning($this->userObj->getLogin(), $lng->txt(
"usrimport_no_insert_ext_account_exists").
" (".$this->userObj->getExternalAccount().
")");
1027 $this->action =
"Ignore";
1036 if ($loginForExternalAccount !=
"")
1041 if ($externalAccountHasChanged && trim($loginForExternalAccount) != trim($this->userObj->getLogin()))
1043 $this->
logWarning($this->userObj->getLogin(), $lng->txt(
"usrimport_no_update_ext_account_exists").
" (".$this->userObj->getExternalAccount().
")");
1044 $this->action =
"Ignore";
1051 switch ($this->action)
1056 $this->
logFailure($this->userObj->getLogin(),$lng->txt(
"usrimport_cant_insert"));
1061 if (!strlen($this->currPassword)==0)
1062 switch ($this->currPasswordType)
1069 $this->userObj->setPasswd($this->currPassword,
IL_PASSWD_MD5);
1074 $this->acc_mail->setUserPassword($this->currPassword);
1088 $this->userObj->setTitle($this->userObj->getFullname());
1089 $this->userObj->setDescription($this->userObj->getEmail());
1091 if(!$this->time_limit_owner_set)
1093 $this->userObj->setTimeLimitOwner($this->
getFolderId());
1097 if(!$this->time_limit_set)
1099 $this->userObj->setTimeLimitUnlimited(1);
1100 $this->userObj->setTimeLimitMessage(0);
1102 if (! $this->approve_date_set)
1104 $this->userObj->setApproveDate(date(
"Y-m-d H:i:s"));
1109 $this->userObj->setActive($this->currActive ==
'true' || is_null($this->currActive));
1115 if(count($this->udf_data))
1117 $this->userObj->setUserDefinedData($this->udf_data);
1121 $this->userObj->create();
1124 $this->userObj->saveAsNew(
false);
1127 $this->userObj->setPref(
'hits_per_page',$ilSetting->get(
'hits_per_page',30));
1128 $this->userObj->setPref(
'show_users_online',$ilSetting->get(
'show_users_online',
'y'));
1130 if (count ($this->prefs))
1132 foreach ($this->prefs as $key => $value)
1134 if ($key !=
"mail_incoming_type" &&
1135 $key !=
"mail_signature" &&
1136 $key !=
"mail_linebreak"
1139 $this->userObj->setPref($key, $value);
1144 $this->userObj->writePrefs();
1149 if (is_array($this->personalPicture))
1151 if (strlen($this->personalPicture[
"content"]))
1154 if (preg_match(
"/.*(png|jpg|gif|jpeg)$/", $this->personalPicture[
"imagetype"], $matches))
1156 $extension = $matches[1];
1158 $tmp_name = $this->
saveTempImage($this->personalPicture[
"content"],
".$extension");
1159 if (strlen($tmp_name))
1167 if ($this->ilincdata[
"id"]) {
1168 include_once
'Modules/ILinc/classes/class.ilObjiLincUser.php';
1170 $ilinc_user->setVar(
"id", $this->ilincdata[
"id"]);
1171 $ilinc_user->setVar(
"login", $this->ilincdata[
"login"]);
1172 $ilinc_user->setVar(
"passwd", $this->ilincdata[
"password"]);
1173 $ilinc_user->update();
1177 foreach($this->roles as $role_id => $role)
1179 if ($this->role_assign[$role_id])
1181 $this->
assignToRole($this->userObj, $this->role_assign[$role_id]);
1185 if(count($this->udf_data))
1187 include_once
'./Services/User/classes/class.ilUserDefinedData.php';
1189 foreach($this->udf_data as $field => $value)
1191 $udd->
set(
"f_".$field,$value);
1197 $this->
logSuccess($this->userObj->getLogin(),$this->userObj->getId(),
"Insert");
1199 $this->acc_mail->reset();
1206 $this->
logFailure($this->userObj->getLogin(),$lng->txt(
"usrimport_cant_update"));
1211 $updateUser->read();
1212 $updateUser->readPrefs();
1213 if ($this->currPassword != null)
1215 switch ($this->currPasswordType)
1227 $this->acc_mail->setUserPassword($this->currPassword);
1231 if (! is_null($this->userObj->getFirstname())) $updateUser->setFirstname($this->userObj->getFirstname());
1232 if (! is_null($this->userObj->getLastname())) $updateUser->setLastname($this->userObj->getLastname());
1233 if (! is_null($this->userObj->getUTitle())) $updateUser->setUTitle($this->userObj->getUTitle());
1234 if (! is_null($this->userObj->getGender())) $updateUser->setGender($this->userObj->getGender());
1235 if (! is_null($this->userObj->getEmail())) $updateUser->setEmail($this->userObj->getEmail());
1236 if (! is_null($this->userObj->getBirthday())) $updateUser->setBirthday($this->userObj->getBirthday());
1237 if (! is_null($this->userObj->getInstitution())) $updateUser->setInstitution($this->userObj->getInstitution());
1238 if (! is_null($this->userObj->getStreet())) $updateUser->setStreet($this->userObj->getStreet());
1239 if (! is_null($this->userObj->getCity())) $updateUser->setCity($this->userObj->getCity());
1240 if (! is_null($this->userObj->getZipCode())) $updateUser->setZipCode($this->userObj->getZipCode());
1241 if (! is_null($this->userObj->getCountry())) $updateUser->setCountry($this->userObj->getCountry());
1242 if (! is_null($this->userObj->getPhoneOffice())) $updateUser->setPhoneOffice($this->userObj->getPhoneOffice());
1243 if (! is_null($this->userObj->getPhoneHome())) $updateUser->setPhoneHome($this->userObj->getPhoneHome());
1244 if (! is_null($this->userObj->getPhoneMobile())) $updateUser->setPhoneMobile($this->userObj->getPhoneMobile());
1245 if (! is_null($this->userObj->getFax())) $updateUser->setFax($this->userObj->getFax());
1246 if (! is_null($this->userObj->getHobby())) $updateUser->setHobby($this->userObj->getHobby());
1247 if (! is_null($this->userObj->getComment())) $updateUser->setComment($this->userObj->getComment());
1248 if (! is_null($this->userObj->getDepartment())) $updateUser->setDepartment($this->userObj->getDepartment());
1249 if (! is_null($this->userObj->getMatriculation())) $updateUser->setMatriculation($this->userObj->getMatriculation());
1250 if (! is_null($this->currActive)) $updateUser->setActive($this->currActive ==
"true", is_object($ilUser) ? $ilUser->getId() : 0);
1251 if (! is_null($this->userObj->getClientIP())) $updateUser->setClientIP($this->userObj->getClientIP());
1252 if (! is_null($this->userObj->getTimeLimitUnlimited())) $updateUser->setTimeLimitUnlimited($this->userObj->getTimeLimitUnlimited());
1253 if (! is_null($this->userObj->getTimeLimitFrom())) $updateUser->setTimeLimitFrom($this->userObj->getTimeLimitFrom());
1254 if (! is_null($this->userObj->getTimeLimitUntil())) $updateUser->setTimeLimitUntil($this->userObj->getTimeLimitUntil());
1255 if (! is_null($this->userObj->getTimeLimitMessage())) $updateUser->setTimeLimitMessage($this->userObj->getTimeLimitMessage());
1256 if (! is_null($this->userObj->getApproveDate())) $updateUser->setApproveDate($this->userObj->getApproveDate());
1257 if (! is_null($this->userObj->getAgreeDate())) $updateUser->setAgreeDate($this->userObj->getAgreeDate());
1258 if (! is_null($this->userObj->getLanguage())) $updateUser->setLanguage($this->userObj->getLanguage());
1259 if (! is_null($this->userObj->getExternalAccount())) $updateUser->setExternalAccount($this->userObj->getExternalAccount());
1262 #if (! is_null($this->userObj->getAuthMode())) $updateUser->setAuthMode($this->userObj->getAuthMode());
1263 if($this->auth_mode_set)
1264 $updateUser->setAuthMode($this->userObj->getAuthMode());
1266 if (! is_null($this->userObj->getInstantMessengerId(
"aim"))) $updateUser->setInstantMessengerId(
"aim", $this->userObj->getInstantMessengerId(
"aim"));
1267 if (! is_null($this->userObj->getInstantMessengerId(
"msn"))) $updateUser->setInstantMessengerId(
"msn", $this->userObj->getInstantMessengerId(
"msn"));
1268 if (! is_null($this->userObj->getInstantMessengerId(
"icq"))) $updateUser->setInstantMessengerId(
"icq", $this->userObj->getInstantMessengerId(
"icq"));
1269 if (! is_null($this->userObj->getInstantMessengerId(
"yahoo"))) $updateUser->setInstantMessengerId(
"yahoo", $this->userObj->getInstantMessengerId(
"yahoo"));
1270 if (! is_null($this->userObj->getInstantMessengerId(
"skype"))) $updateUser->setInstantMessengerId(
"skype", $this->userObj->getInstantMessengerId(
"skype"));
1271 if (! is_null($this->userObj->getInstantMessengerId(
"jabber"))) $updateUser->setInstantMessengerId(
"jabber", $this->userObj->getInstantMessengerId(
"jabber"));
1272 if (! is_null($this->userObj->getInstantMessengerId(
"voip"))) $updateUser->setInstantMessengerId(
"voip", $this->userObj->getInstantMessengerId(
"voip"));
1275 if($this->time_limit_owner_set)
1277 $updateUser->setTimeLimitOwner($this->userObj->getTimeLimitOwner());
1281 if (count ($this->prefs))
1283 foreach ($this->prefs as $key => $value)
1285 if ($key !=
"mail_incoming_type" &&
1286 $key !=
"mail_signature" &&
1287 $key !=
"mail_linebreak"
1289 $updateUser->setPref($key, $value);
1295 if ($this->updateLookAndSkin)
1297 $updateUser->setPref(
"skin", $this->userObj->getPref(
"skin"));
1298 $updateUser->setPref(
"style", $this->userObj->getPref(
"style"));
1302 $updateUser->writePrefs();
1308 if(count($this->udf_data))
1310 $updateUser->setUserDefinedData($this->udf_data);
1315 $updateUser->setTitle($updateUser->getFullname());
1316 $updateUser->setDescription($updateUser->getEmail());
1317 $updateUser->update();
1319 if ($this->ilincdata[
"id"]) {
1320 include_once
'Modules/ILinc/classes/class.ilObjiLincUser.php';
1322 $ilinc_user->setVar(
"id", $this->ilincdata[
"id"]);
1323 $ilinc_user->setVar(
"login", $this->ilincdata[
"login"]);
1324 $ilinc_user->setVar(
"passwd", $this->ilincdata[
"password"]);
1325 $ilinc_user->update();
1328 if(count($this->udf_data))
1330 include_once
'./Services/User/classes/class.ilUserDefinedData.php';
1332 foreach($this->udf_data as $field => $value)
1334 $udd->
set(
"f_".$field,$value);
1340 if (!is_null($this->userObj->getLogin()) && $this->user_id != -1)
1344 $updateUser->updateLogin($this->userObj->getLogin());
1354 if (is_array($this->personalPicture))
1356 if (strlen($this->personalPicture[
"content"]))
1359 if (preg_match(
"/.*(png|jpg|gif|jpeg)$/", $this->personalPicture[
"imagetype"], $matches))
1361 $extension = $matches[1];
1363 $tmp_name = $this->
saveTempImage($this->personalPicture[
"content"],
".$extension");
1364 if (strlen($tmp_name))
1375 foreach ($this->roles as $role_id => $role)
1377 if ($this->role_assign[$role_id])
1379 switch ($role[
"action"])
1382 $this->
assignToRole($updateUser, $this->role_assign[$role_id]);
1384 case "AssignWithParents" :
1388 $this->
detachFromRole($updateUser, $this->role_assign[$role_id]);
1399 $this->
logFailure($this->userObj->getLogin(),$lng->txt(
"usrimport_cant_delete"));
1404 $deleteUser->delete();
1412 $this->roles = array();
1416 $this->userObj->setLogin($this->cdata);
1420 $this->currPassword = $this->cdata;
1424 $this->userObj->setFirstname($this->cdata);
1428 $this->userObj->setLastname($this->cdata);
1432 $this->userObj->setUTitle($this->cdata);
1436 $this->userObj->setGender($this->cdata);
1440 $this->userObj->setEmail($this->cdata);
1447 $this->userObj->setBirthday($this->cdata);
1451 $this->userObj->setInstitution($this->cdata);
1455 $this->userObj->setStreet($this->cdata);
1459 $this->userObj->setCity($this->cdata);
1463 $this->userObj->setZipCode($this->cdata);
1467 $this->userObj->setCountry($this->cdata);
1471 $this->userObj->setPhoneOffice($this->cdata);
1475 $this->userObj->setPhoneHome($this->cdata);
1479 $this->userObj->setPhoneMobile($this->cdata);
1483 $this->userObj->setFax($this->cdata);
1487 $this->userObj->setHobby($this->cdata);
1491 $this->userObj->setComment($this->cdata);
1495 $this->userObj->setDepartment($this->cdata);
1498 case "Matriculation":
1499 $this->userObj->setMatriculation($this->cdata);
1503 $this->currActive = $this->cdata;
1507 $this->userObj->setClientIP($this->cdata);
1510 case "TimeLimitOwner":
1511 $this->time_limit_owner_set =
true;
1512 $this->userObj->setTimeLimitOwner($this->cdata);
1515 case "TimeLimitUnlimited":
1516 $this->time_limit_set =
true;
1517 $this->userObj->setTimeLimitUnlimited($this->cdata);
1520 case "TimeLimitFrom":
1521 if (is_numeric($this->cdata))
1524 $this->userObj->setTimeLimitFrom($this->cdata);
1530 if (
$timestamp !==
false && trim($this->cdata) !=
"0000-00-00 00:00:00")
1532 $this->userObj->setTimeLimitFrom(
$timestamp);
1534 elseif ($this->cdata ==
"0000-00-00 00:00:00")
1536 $this->userObj->setTimeLimitFrom(null);
1542 case "TimeLimitUntil":
1543 if (is_numeric($this->cdata))
1546 $this->userObj->setTimeLimitUntil($this->cdata);
1552 if (
$timestamp !==
false && trim($this->cdata) !=
"0000-00-00 00:00:00")
1554 $this->userObj->setTimeLimitUntil(
$timestamp);
1556 elseif ($this->cdata ==
"0000-00-00 00:00:00")
1558 $this->userObj->setTimeLimitUntil(null);
1563 case "TimeLimitMessage":
1564 $this->userObj->setTimeLimitMessage($this->cdata);
1568 $this->approve_date_set =
true;
1569 if (is_numeric($this->cdata))
1579 if (
$timestamp !==
false && trim($this->cdata) !=
"0000-00-00 00:00:00")
1584 elseif ($this->cdata ==
"0000-00-00 00:00:00")
1586 $this->userObj->setApproveDate(null);
1592 if (is_numeric($this->cdata))
1602 if (
$timestamp !==
false && trim($this->cdata) !=
"0000-00-00 00:00:00")
1607 elseif ($this->cdata ==
"0000-00-00 00:00:00")
1609 $this->userObj->setAgreeDate(null);
1615 $this->ilincdata[
"id"] = $this->cdata;
1619 $this->ilincdata[
"login"] = $this->cdata;
1623 $this->ilincdata[
"password"] = $this->cdata;
1627 case "ExternalAccount":
1628 $this->userObj->setExternalAccount($this->cdata);
1632 $this->updateLookAndSkin =
false;
1633 if (!$this->hideSkin)
1636 if ((strlen($this->skin) > 0) && (strlen($this->style) > 0))
1638 if (is_array($this->userStyles))
1640 if (in_array($this->skin .
":" . $this->style, $this->userStyles))
1642 $this->userObj->setPref(
"skin", $this->skin);
1643 $this->userObj->setPref(
"style", $this->style);
1644 $this->updateLookAndSkin =
true;
1651 case 'UserDefinedField':
1652 include_once
'./Services/User/classes/class.ilUserDefinedFields.php';
1654 if($field_id = $udf->fetchFieldIdFromImportId($this->tmp_udf_id))
1656 $this->udf_data[$field_id] = $this->cdata;
1658 elseif($field_id = $udf->fetchFieldIdFromName($this->tmp_udf_name))
1660 $this->udf_data[$field_id] = $this->cdata;
1664 if ($this->current_messenger_type ==
"delicious")
1666 $this->userObj->setDelicious($this->cdata);
1668 elseif ($this->current_messenger_type ==
"external")
1670 $this->userObj->setExternalAccount($this->cdata);
1674 $this->userObj->setInstantMessengerId($this->current_messenger_type, $this->cdata);
1678 if ($this->currentPrefKey != null && strlen(trim($this->cdata)) > 0
1680 $this->prefs[$this->currentPrefKey] = trim($this->cdata);
1681 $this->currentPrefKey = null;
1693 $fh = fopen($tempname,
"wb");
1698 $imagefile = fwrite($fh, $image_data);
1713 $this->roles[$this->current_role_id][
"name"] = $this->cdata;
1714 $this->roles[$this->current_role_id][
"type"] = $this->current_role_type;
1715 $this->roles[$this->current_role_id][
"action"] = $this->current_role_action;
1719 $this->userObj->setFullname();
1720 if ($this->user_id != -1 && $this->action ==
"Update")
1725 if (is_null($this->userObj->getLogin()))
1727 $this->
logFailure(
"---",sprintf($lng->txt(
"usrimport_xml_element_for_action_required"),
"Login",
"Insert"));
1730 switch ($this->action)
1735 $this->
logWarning($this->userObj->getLogin(),$lng->txt(
"usrimport_cant_insert"));
1737 if (is_null($this->userObj->getGender()) && $this->
isFieldRequired(
"gender"))
1739 $this->
logFailure($this->userObj->getLogin(),sprintf($lng->txt(
"usrimport_xml_element_for_action_required"),
"Gender",
"Insert"));
1741 if (is_null($this->userObj->getFirstname()))
1743 $this->
logFailure($this->userObj->getLogin(),sprintf($lng->txt(
"usrimport_xml_element_for_action_required"),
"Firstname",
"Insert"));
1745 if (is_null($this->userObj->getLastname()))
1747 $this->
logFailure($this->userObj->getLogin(),sprintf($lng->txt(
"usrimport_xml_element_for_action_required"),
"Lastname",
"Insert"));
1749 if (count($this->roles) == 0)
1751 $this->
logFailure($this->userObj->getLogin(),sprintf($lng->txt(
"usrimport_xml_element_for_action_required"),
"Role",
"Insert"));
1755 $has_global_role =
false;
1756 foreach ($this->roles as $role)
1758 if ($role[
'type'] ==
'Global')
1760 $has_global_role =
true;
1764 if (! $has_global_role)
1766 $this->
logFailure($this->userObj->getLogin(),sprintf($lng->txt(
"usrimport_global_role_for_action_required"),
"Insert"));
1773 $this->
logWarning($this->userObj->getLogin(),$lng->txt(
"usrimport_cant_update"));
1775 elseif($this->user_id != -1 && !is_null($this->userObj->getLogin()))
1781 $this->
logFailure($this->userObj->getLogin(), $lng->txt(
"usrimport_login_is_not_unique"));
1788 $this->
logWarning($this->userObj->getLogin(),$lng->txt(
"usrimport_cant_delete"));
1794 $this->roles = array();
1798 if (array_key_exists($this->cdata, $this->logins))
1800 $this->
logWarning($this->cdata, $lng->txt(
"usrimport_login_is_not_unique"));
1804 $this->logins[$this->cdata] = $this->cdata;
1806 $this->userObj->setLogin($this->cdata);
1810 switch ($this->currPasswordType)
1822 $this->acc_mail->setUserPassword($this->cdata);
1832 $this->userObj->setFirstname($this->cdata);
1836 $this->userObj->setLastname($this->cdata);
1840 $this->userObj->setUTitle($this->cdata);
1844 if ($this->cdata !=
"m"
1845 && $this->cdata !=
"f")
1848 $this->userObj->getLogin(),
1849 sprintf($lng->txt(
"usrimport_xml_element_content_illegal"),
"Gender",$this->cdata)
1852 $this->userObj->setGender($this->cdata);
1856 $this->userObj->setEmail($this->cdata);
1860 $this->userObj->setInstitution($this->cdata);
1864 $this->userObj->setStreet($this->cdata);
1868 $this->userObj->setCity($this->cdata);
1872 $this->userObj->setZipCode($this->cdata);
1876 $this->userObj->setCountry($this->cdata);
1880 $this->userObj->setPhoneOffice($this->cdata);
1884 $this->userObj->setPhoneHome($this->cdata);
1888 $this->userObj->setPhoneMobile($this->cdata);
1892 $this->userObj->setFax($this->cdata);
1896 $this->userObj->setHobby($this->cdata);
1900 $this->userObj->setComment($this->cdata);
1904 $this->userObj->setDepartment($this->cdata);
1907 case "Matriculation":
1908 $this->userObj->setMatriculation($this->cdata);
1911 case "ExternalAccount":
1913 $am = ($this->userObj->getAuthMode() ==
"default" || $this->userObj->getAuthMode() ==
"")
1915 : $this->userObj->getAuthMode();
1916 $loginForExternalAccount = (trim($this->cdata) ==
"")
1919 switch ($this->action)
1922 if ($loginForExternalAccount !=
"")
1924 $this->
logWarning($this->userObj->getLogin(), $lng->txt(
"usrimport_no_insert_ext_account_exists").
" (".$this->cdata.
")");
1929 if ($loginForExternalAccount !=
"")
1932 if ($externalAccountHasChanged && trim($loginForExternalAccount) != trim($this->userObj->getLogin()))
1934 $this->
logWarning($this->userObj->getLogin(),
1935 $lng->txt(
"usrimport_no_update_ext_account_exists").
" (".$this->cdata.
" for ".$loginForExternalAccount.
")");
1941 if ($externalAccountHasChanged)
1942 $this->userObj->setExternalAccount(trim($this->cdata));
1946 if ($this->cdata !=
"true"
1947 && $this->cdata !=
"false")
1949 $this->
logFailure($this->userObj->getLogin(),
1950 sprintf($lng->txt(
"usrimport_xml_element_content_illegal"),
"Active",$this->cdata));
1952 $this->currActive = $this->cdata;
1954 case "TimeLimitOwner":
1955 if (!preg_match(
"/\d+/", $this->cdata))
1957 $this->
logFailure($this->userObj->getLogin(),
1958 sprintf($lng->txt(
"usrimport_xml_element_content_illegal"),
"TimeLimitOwner",$this->cdata));
1960 elseif(!$ilAccess->checkAccess(
'cat_administrate_users',
'',$this->cdata))
1962 $this->
logFailure($this->userObj->getLogin(),
1963 sprintf($lng->txt(
"usrimport_xml_element_content_illegal"),
"TimeLimitOwner",$this->cdata));
1965 elseif($ilObjDataCache->lookupType($ilObjDataCache->lookupObjId($this->cdata)) !=
'cat' && !(
int) $this->cdata ==
USER_FOLDER_ID)
1967 $this->
logFailure($this->userObj->getLogin(),
1968 sprintf($lng->txt(
"usrimport_xml_element_content_illegal"),
"TimeLimitOwner",$this->cdata));
1971 $this->userObj->setTimeLimitOwner($this->cdata);
1973 case "TimeLimitUnlimited":
1974 switch (strtolower($this->cdata))
1978 $this->userObj->setTimeLimitUnlimited(1);
1982 $this->userObj->setTimeLimitUnlimited(0);
1985 $this->
logFailure($this->userObj->getLogin(), sprintf($lng->txt(
"usrimport_xml_element_content_illegal"),
"TimeLimitUnlimited",$this->cdata));
1989 case "TimeLimitFrom":
1991 if (strtotime($this->cdata) ===
false && ! is_numeric($this->cdata))
1993 $this->
logFailure($this->userObj->getLogin(), sprintf($lng->txt(
"usrimport_xml_element_content_illegal"),
"TimeLimitFrom",$this->cdata));
1995 $this->userObj->setTimeLimitFrom($this->cdata);
1997 case "TimeLimitUntil":
1999 if (strtotime($this->cdata) ===
false && ! is_numeric($this->cdata))
2001 $this->
logFailure($this->userObj->getLogin(), sprintf($lng->txt(
"usrimport_xml_element_content_illegal"),
"TimeLimitUntil",$this->cdata));
2003 $this->userObj->setTimeLimitUntil($this->cdata);
2005 case "TimeLimitMessage":
2006 switch (strtolower($this->cdata))
2009 $this->userObj->setTimeLimitMessage(1);
2012 $this->userObj->setTimeLimitMessage(0);
2015 $this->
logFailure($this->userObj->getLogin(), sprintf($lng->txt(
"usrimport_xml_element_content_illegal"),
"TimeLimitMessage",$this->cdata));
2021 if (strtotime($this->cdata) ===
false && ! is_numeric($this->cdata) && !$this->cdata ==
"0000-00-00 00:00:00")
2023 $this->
logFailure($this->userObj->getLogin(), sprintf($lng->txt(
"usrimport_xml_element_content_illegal"),
"ApproveDate",$this->cdata));
2028 if (strtotime($this->cdata) ===
false && ! is_numeric($this->cdata) && !$this->cdata ==
"0000-00-00 00:00:00")
2030 $this->
logFailure($this->userObj->getLogin(), sprintf($lng->txt(
"usrimport_xml_element_content_illegal"),
"AgreeDate",$this->cdata));
2034 if (!preg_match(
"/\d+/", $this->cdata))
2036 $this->
logFailure($this->userObj->getLogin(), sprintf($lng->txt(
"usrimport_xml_element_content_illegal"),
"iLincID",$this->cdata));
2040 if (!preg_match(
"/\w+/", $this->cdata))
2042 $this->
logFailure($this->userObj->getLogin(), sprintf($lng->txt(
"usrimport_xml_element_content_illegal"),
"iLincUser",$this->cdata));
2046 if (!preg_match(
"/\w+/", $this->cdata))
2048 $this->
logFailure($this->userObj->getLogin(), sprintf($lng->txt(
"usrimport_xml_element_content_illegal"),
"iLincPasswd",$this->cdata));
2052 if ($this->currentPrefKey != null)
2053 $this->
verifyPref($this->currentPrefKey, $this->cdata);
2054 $this->currentPrefKey == null;
2066 if($a_data !=
"\n") $a_data = preg_replace(
"/\t+/",
" ",$a_data);
2068 if(strlen($a_data) > 0)
2070 $this->cdata .= $a_data;
2097 if (! array_key_exists($aLogin, $this->protocol))
2099 $this->protocol[$aLogin] = array();
2103 $this->protocol[$aLogin][] = $aMessage;
2118 if (! array_key_exists($aLogin, $this->protocol))
2120 $this->protocol[$aLogin] = array();
2124 $this->protocol[$aLogin][] = $aMessage;
2138 $this->user_mapping[$userid] = array(
"login" => $aLogin,
"action" =>
$action,
"message" =>
"successful");
2161 $block =
new ilTemplate(
"tpl.usr_import_log_block.html",
true,
true,
"Services/User");
2162 $block->setVariable(
"TXT_LOG_TITLE", $a_log_title);
2163 $block->setVariable(
"TXT_MESSAGE_ID", $lng->txt(
"login"));
2164 $block->setVariable(
"TXT_MESSAGE_TEXT", $lng->txt(
"message"));
2167 $block->setCurrentBlock(
"log_row");
2177 $reason = $reason.
"<br>".$message;
2180 $block->setVariable(
"MESSAGE_ID", $login);
2181 $block->setVariable(
"MESSAGE_TEXT", $reason);
2182 $block->parseCurrentBlock();
2184 return $block->get();
2218 if(
$_POST[
"send_mail"] !=
"" ||
2219 ($this->
isSendMail() && $this->userObj->getEmail() !=
""))
2221 $this->acc_mail->setUser($this->userObj);
2224 if($amail[
"att_file"])
2226 include_once
"Services/User/classes/class.ilFSStorageUserFolder.php";
2229 $path = $fs->getAbsolutePath() .
"/";
2231 $this->acc_mail->addAttachment(
$path .
"/" . $amail[
"lang"], $amail[
"att_file"]);
2233 $this->acc_mail->send();
2239 if(!isset(self::$account_mail_cache[$lang_key]))
2241 $default_lang_key =
$GLOBALS[
"lng"]->getDefaultLanguage();
2244 include_once
'./Services/User/classes/class.ilObjUserFolder.php';
2248 if (trim($amail[
"body"]) !=
"" && trim($amail[
"subject"]) !=
"")
2250 self::$account_mail_cache[$lang_key] = $amail;
2254 $lang_key = $default_lang_key;
2257 if(!isset(self::$account_mail_cache[$default_lang_key]))
2260 self::$account_mail_cache[$default_lang_key] = $amail;
2263 return self::$account_mail_cache[$lang_key];
2272 $this->send_mail = $value ?
true:
false;
2292 $this->mapping_mode = $value;
2293 else die (
"wrong argument using methode setUserMappingMethod in ".__FILE__);
2316 if(is_array($this->required_fields))
2318 return $this->required_fields;
2320 foreach($ilSetting->getAll() as $field => $value)
2322 if(substr($field,0,8) ==
'require_' and $value == 1)
2324 $value = substr($field,8);
2325 $this->required_fields[$value] = $value;
2328 return $this->required_fields ? $this->required_fields : array();
2341 include_once
"Services/User/classes/class.ilUserProfile.php";
2354 $fieldname = strtolower(trim($fieldname));
2355 return array_key_exists($fieldname, $requiredFields);
2360 case 'mail_linebreak':
2361 case 'hits_per_page':
2362 if (!is_numeric($value) || $value < 0)
2363 $this->
logFailure(
"---",
"Wrong value '$value': Positiv numeric value expected for preference $key.");
2368 case 'ilPageEditor_HTMLMode':
2369 case 'ilPageEditor_JavaScript':
2370 case 'ilPageEditor_MediaMode':
2371 case 'tst_javascript':
2372 case 'tst_lastquestiontype':
2373 case 'tst_multiline_answers':
2374 case 'tst_use_previous_answers':
2375 case 'graphicalAnswerSetting':
2376 case 'priv_feed_pass':
2377 $this->
logFailure(
"---",
"Preference $key is not supported.");
2380 case 'public_country':
2381 case 'public_department':
2382 case 'public_email':
2384 case 'public_hobby':
2385 case 'public_institution':
2386 case 'public_matriculation':
2387 case 'public_phone':
2388 case 'public_phone_home':
2389 case 'public_phone_mobile':
2390 case 'public_phone_office':
2391 case 'public_street':
2392 case 'public_upload':
2394 case 'send_info_mails':
2395 case 'hide_own_online_status':
2396 if (!in_array($value, array(
'y',
'n')))
2397 $this->
logFailure(
"---",
"Wrong value '$value': Value 'y' or 'n' expected for preference $key.");
2399 case 'public_profile':
2400 if (!in_array($value, array(
'y',
'n',
'g')))
2401 $this->
logFailure(
"---",
"Wrong value '$value': Value 'y', 'g' or 'n' expected for preference $key.");
2403 case 'show_users_online':
2404 if (!in_array($value, array(
'y',
'n',
'associated')))
2405 $this->
logFailure(
"---",
"Wrong value '$value': Value 'y' or 'n' or 'associated' expected for preference $key.");
2407 case 'mail_incoming_type':
2408 if (!in_array((
int) $value, array(
"0",
"1",
"2")))
2409 $this->
logFailure(
"---",
"Wrong value '$value': Value \"0\" (LOCAL),\"1\" (EMAIL) or \"2\" (BOTH) expected for preference $key.");
2412 if (!in_array($value, array (
"0",
"1")))
2413 $this->
logFailure(
"---",
"Wrong value '$value': Value \"0\" (Sunday) or \"1\" (Monday) expected for preference $key.");
2416 case 'mail_signature':
2419 include_once(
'Services/Calendar/classes/class.ilTimeZone.php');
2424 $this->
logFailure(
"---",
"Wrong value '$value': Invalid timezone $value detected for preference $key.");
2429 $this->
logFailure(
"---",
"Preference $key is not supported.");
2435 if (array_key_exists(
"mail_incoming_type", $this->prefs) ||
2436 array_key_exists(
"mail_signature", $this->prefs) ||
2437 array_key_exists(
"mail_linebreak", $this->prefs)
2440 include_once(
"Services/Mail/classes/class.ilMailOptions.php");
2442 $mailOptions->updateOptions(
2443 array_key_exists(
"mail_signature", $this->prefs) ? $this->prefs[
"mail_signature"] : $mailOptions->getSignature(),
2444 array_key_exists(
"mail_linebreak", $this->prefs) ? $this->prefs[
"mail_linebreak"] : $mailOptions->getLinebreak(),
2445 array_key_exists(
"mail_incoming_type", $this->prefs) ? $this->prefs[
"mail_incoming_type"] : $mailOptions->getIncomingType(),
2446 $mailOptions->getCronjobNotification()