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(
"classes/class.ilSaxParser.php");
40 require_once (
'Services/User/classes/class.ilUserXMLWriter.php');
283 global
$lng, $tree,
$ilias, $ilUser, $styleDefinition;
285 $this->roles = array();
286 $this->mode = $a_mode;
287 $this->conflict_rule = $a_conflict_rule;
289 $this->protocol = array();
290 $this->logins = array();
291 $this->userCount = 0;
292 $this->localRoleCache = array();
293 $this->parentRolesCache = array();
294 $this->ilincdata = array();
295 $this->send_mail =
false;
299 $this->userStyles = array();
300 include_once(
"./Services/Style/classes/class.ilObjStyleSettings.php");
303 if (is_array($templates))
306 foreach($templates as $template)
310 $styleDef->startParsing();
311 $styles = $styleDef->getStyles();
313 foreach($styles as
$style)
319 $this->userStyles [] = $template[
"id"].
":".$style[
"id"];
324 $settings = $ilias->getAllSettings();
325 if ($settings[
"usr_settings_hide_skin_style"] == 1)
327 $this->hideSkin = TRUE;
331 $this->hideSkin = FALSE;
333 if ($settings[
"usr_settings_disable_skin_style"] == 1)
335 $this->disableSkin = TRUE;
339 $this->disableSkin = FALSE;
342 include_once(
"Services/Mail/classes/class.ilAccountMail.php");
344 $this->acc_mail->useLangVariablesAsFallback(
true);
356 $this->folder_id = $a_folder_id;
371 xml_set_object($a_xml_parser,$this);
372 xml_set_element_handler($a_xml_parser,
'handlerBeginTag',
'handlerEndTag');
373 xml_set_character_data_handler($a_xml_parser,
'handlerCharacterData');
391 $this->role_assign = $a_assign;
412 while (list($k,$v) = each($attr))
413 $tag.=
" ".$k.
"=\"$v\"";
451 $this->current_role_id = $a_attribs[
"Id"];
454 $this->current_role_id = $internal_id;
456 $this->current_role_type = $a_attribs[
"Type"];
471 $this->current_role_id = $a_attribs[
"Id"];
474 $this->current_role_id = $internal_id;
476 $this->current_role_type = $a_attribs[
"Type"];
477 $this->current_role_action = (is_null($a_attribs[
"Action"])) ?
"Assign" : $a_attribs[
"Action"];
480 case "PersonalPicture":
481 $this->personalPicture = array(
482 "encoding" => $a_attribs[
"encoding"],
483 "imagetype" => $a_attribs[
"imagetype"],
489 $this->skin = $a_attribs[
"Skin"];
490 $this->style = $a_attribs[
"Style"];
494 $this->prefs = array();
495 $this->currentPrefKey = null;
496 $this->auth_mode_set =
false;
497 $this->approve_date_set =
false;
498 $this->time_limit_set =
false;
499 $this->time_limit_owner_set =
false;
500 $this->updateLookAndSkin =
false;
503 $this->personalPicture = null;
508 $this->udf_data = array();
514 if (is_numeric($a_attribs[
"Id"]))
516 $this->user_id = $a_attribs[
"Id"];
520 $this->user_id = $id;
524 $this->userObj->setPref(
"skin",
525 $ilias->ini->readVariable(
"layout",
"skin"));
526 $this->userObj->setPref(
"style",
527 $ilias->ini->readVariable(
"layout",
"style"));
529 $this->userObj->setLanguage($a_attribs[
"Language"]);
530 $this->userObj->setImportId($a_attribs[
"Id"]);
531 $this->action = (is_null($a_attribs[
"Action"])) ?
"Insert" : $a_attribs[
"Action"];
532 $this->currPassword = null;
533 $this->currPasswordType = null;
534 $this->currActive = null;
538 $this->currPasswordType = $a_attribs[
"Type"];
541 if (array_key_exists(
"type", $a_attribs))
543 switch ($a_attribs[
"type"])
554 $this->auth_mode_set =
true;
555 $this->userObj->setAuthMode($a_attribs[
"type"]);
559 sprintf($lng->txt(
"usrimport_xml_element_inapplicable"),
"AuthMode",$a_attribs[
"type"]));
566 sprintf($lng->txt(
"usrimport_xml_element_inapplicable"),
"AuthMode",$a_attribs[
"type"]));
570 case 'UserDefinedField':
571 $this->tmp_udf_id = $a_attribs[
'Id'];
572 $this->tmp_udf_name = $a_attribs[
'Name'];
576 $this->current_messenger_type = strtolower($a_attribs[
"Type"]);
579 $this->userObj->setLatitude($a_attribs[
"latitude"]);
580 $this->userObj->setLongitude($a_attribs[
"longitude"]);
581 $this->userObj->setLocationZoom($a_attribs[
"zoom"]);
584 $this->currentPrefKey = $a_attribs[
"key"];
599 if (is_null($a_attribs[
'Id'])
600 || $a_attribs[
'Id'] ==
"")
602 $this->
logFailure($this->userObj->getLogin(), sprintf($lng->txt(
"usrimport_xml_attribute_missing"),
"Role",
"Id"));
604 $this->current_role_id = $a_attribs[
"Id"];
605 $this->current_role_type = $a_attribs[
"Type"];
606 if ($this->current_role_type !=
'Global'
607 && $this->current_role_type !=
'Local')
609 $this->
logFailure($this->userObj->getLogin(), sprintf($lng->txt(
"usrimport_xml_attribute_missing"),
"Role",
"Type"));
611 $this->current_role_action = (is_null($a_attribs[
"Action"])) ?
"Assign" : $a_attribs[
"Action"];
612 if ($this->current_role_action !=
"Assign"
613 && $this->current_role_action !=
"AssignWithParents"
614 && $this->current_role_action !=
"Detach")
616 $this->
logFailure($this->userObj->getLogin(), sprintf($lng->txt(
"usrimport_xml_attribute_value_illegal"),
"Role",
"Action",$a_attribs[
"Action"]));
618 if ($this->action ==
"Insert"
619 && $this->current_role_action ==
"Detach")
621 $this->
logFailure($this->userObj->getLogin(), sprintf($lng->txt(
"usrimport_xml_attribute_value_inapplicable"),
"Role",
"Action",$this->current_role_action,
$this->action));
623 if ($this->action ==
"Delete")
625 $this->
logFailure($this->userObj->getLogin(), sprintf($lng->txt(
"usrimport_xml_element_inapplicable"),
"Role",
"Delete"));
632 $this->userObj->setLanguage($a_attribs[
"Language"]);
633 $this->userObj->setImportId($a_attribs[
"Id"]);
634 $this->currentPrefKey = null;
640 if (is_numeric($a_attribs[
"Id"]))
642 $this->user_id = $a_attribs[
"Id"];
646 $this->user_id = $id;
650 $this->action = (is_null($a_attribs[
"Action"])) ?
"Insert" : $a_attribs[
"Action"];
651 if ($this->action !=
"Insert"
652 && $this->action !=
"Update"
653 && $this->action !=
"Delete")
655 $this->
logFailure($this->userObj->getImportId(), sprintf($lng->txt(
"usrimport_xml_attribute_value_illegal"),
"User",
"Action",$a_attribs[
"Action"]));
657 $this->currPassword = null;
658 $this->currPasswordType = null;
662 $this->currPasswordType = $a_attribs[
"Type"];
665 if (array_key_exists(
"type", $a_attribs))
667 switch ($a_attribs[
"type"])
678 $this->userObj->setAuthMode($a_attribs[
"type"]);
681 $this->
logFailure($this->userObj->getImportId(), sprintf($lng->txt(
"usrimport_xml_attribute_value_illegal"),
"AuthMode",
"type",$a_attribs[
"type"]));
687 $this->
logFailure($this->userObj->getImportId(), sprintf($lng->txt(
"usrimport_xml_attribute_value_illegal"),
"AuthMode",
"type",
""));
691 $this->currentPrefKey = $a_attribs[
"key"];
724 $this->roles[$this->current_role_id][
"name"] = $this->cdata;
725 $this->roles[$this->current_role_id][
"type"] =
726 $this->current_role_type;
736 if (array_key_exists($a_role_id, $this->localRoleCache))
738 return $this->localRoleCache[$a_role_id];
742 $role_obj =
new ilObjRole($a_role_id,
false);
744 $this->localRoleCache[$a_role_id] = $role_obj;
754 global $rbacreview, $rbacadmin, $tree;
756 if (array_key_exists($a_role_id.
'_courseMembersObject', $this->localRoleCache))
758 return $this->localRoleCache[$a_role_id.
'_courseMembersObject'];
762 require_once(
"Modules/Course/classes/class.ilObjCourse.php");
763 require_once(
"Modules/Course/classes/class.ilCourseParticipants.php");
764 $rolf_refs = $rbacreview->getFoldersAssignedToRole($a_role_id,
true);
765 $course_ref = $tree->getParentId($rolf_refs[0]);
768 $this->localRoleCache[$a_role_id.
'_courseMembersObject'] = $crsmembers_obj;
769 return $crsmembers_obj;
779 require_once
"./Services/AccessControl/classes/class.ilObjRole.php";
780 include_once(
'./classes/class.ilObject.php');
781 #require_once "Modules/Course/classes/class.ilObjCourse.php";
782 #require_once "Modules/Course/classes/class.ilCourseParticipants.php";
784 global $rbacreview, $rbacadmin, $tree;
790 if ($rbacreview->isAssigned($a_user_obj->getId(), $a_role_id))
798 $rbacadmin->assignUser($a_role_id, $a_user_obj->getId(),
true);
799 $obj_id = $rbacreview->getObjectOfRole($a_role_id);
805 $ref_id = current((array) $ref_ids);
823 if (! array_key_exists($a_role_id, $this->parentRolesCache))
825 $parent_role_ids = array();
828 $short_role_title = substr($role_obj->getTitle(),0,12);
829 $folders = $rbacreview->getFoldersAssignedToRole($a_role_id,
true);
830 if (count($folders) > 0)
832 $all_parent_role_ids = $rbacreview->getParentRoleIds($folders[0]);
833 foreach ($all_parent_role_ids as $parent_role_id => $parent_role_data)
835 if ($parent_role_id != $a_role_id)
837 switch (substr($parent_role_data[
'title'],0,12))
839 case 'il_crs_admin' :
840 case 'il_grp_admin' :
841 if ($short_role_title ==
'il_crs_admin' || $short_role_title ==
'il_grp_admin')
843 $parent_role_ids[] = $parent_role_id;
846 case 'il_crs_tutor' :
847 case 'il_grp_tutor' :
848 if ($short_role_title ==
'il_crs_tutor' || $short_role_title ==
'il_grp_tutor')
850 $parent_role_ids[] = $parent_role_id;
853 case 'il_crs_membe' :
854 case 'il_grp_membe' :
855 if ($short_role_title ==
'il_crs_membe' || $short_role_title ==
'il_grp_membe')
857 $parent_role_ids[] = $parent_role_id;
866 $this->parentRolesCache[$a_role_id] = $parent_role_ids;
868 return $this->parentRolesCache[$a_role_id];
878 foreach ($parent_role_ids as $parent_role_id)
888 global $rbacreview, $rbacadmin, $tree;
890 $rbacadmin->deassignUser($a_role_id, $a_user_obj->getId());
895 $obj = $rbacreview->getObjectOfRole($a_role_id);
912 $this->roles[$this->current_role_id][
"name"] = $this->cdata;
913 $this->roles[$this->current_role_id][
"type"] = $this->current_role_type;
914 $this->roles[$this->current_role_id][
"action"] = $this->current_role_action;
917 case "PersonalPicture":
918 switch ($this->personalPicture[
"encoding"])
921 $this->personalPicture[
"content"] = base64_decode($this->cdata);
925 if (version_compare(PHP_VERSION,
'5',
'>='))
927 $this->personalPicture[
"content"] = convert_uudecode($this->cdata);
936 if ($this->user_id == -1 || $this->action==
"Insert")
944 switch ($this->conflict_rule)
950 switch ($this->action)
955 $this->
logWarning($this->userObj->getLogin(),sprintf($lng->txt(
"usrimport_action_replaced"),
"Insert",
"Update"));
956 $this->action =
"Update";
962 $this->
logWarning($this->userObj->getLogin(),sprintf($lng->txt(
"usrimport_action_replaced"),
"Update",
"Insert"));
963 $this->action =
"Insert";
969 $this->
logWarning($this->userObj->getLogin(),sprintf($lng->txt(
"usrimport_action_ignored"),
"Delete"));
970 $this->action =
"Ignore";
976 switch ($this->action)
981 $this->
logWarning($this->userObj->getLogin(),sprintf($lng->txt(
"usrimport_action_ignored"),
"Insert"));
982 $this->action =
"Ignore";
988 $this->
logWarning($this->userObj->getLogin(),sprintf($lng->txt(
"usrimport_action_ignored"),
"Update"));
989 $this->action =
"Ignore";
995 $this->
logWarning($this->userObj->getLogin(),sprintf($lng->txt(
"usrimport_action_ignored"),
"Delete"));
996 $this->action =
"Ignore";
1007 $am = ($this->userObj->getAuthMode() ==
"default" || $this->userObj->getAuthMode() ==
"")
1009 : $this->userObj->getAuthMode();
1010 $loginForExternalAccount = ($this->userObj->getExternalAccount() ==
"")
1013 switch ($this->action)
1016 if ($loginForExternalAccount !=
"")
1018 $this->
logWarning($this->userObj->getLogin(), $lng->txt(
"usrimport_no_insert_ext_account_exists").
" (".$this->userObj->getExternalAccount().
")");
1019 $this->action =
"Ignore";
1028 if ($loginForExternalAccount !=
"")
1033 if ($externalAccountHasChanged && trim($loginForExternalAccount) != trim($this->userObj->getLogin()))
1035 $this->
logWarning($this->userObj->getLogin(), $lng->txt(
"usrimport_no_update_ext_account_exists").
" (".$this->userObj->getExternalAccount().
")");
1036 $this->action =
"Ignore";
1043 switch ($this->action)
1048 $this->
logFailure($this->userObj->getLogin(),$lng->txt(
"usrimport_cant_insert"));
1053 if (!strlen($this->currPassword)==0)
1054 switch ($this->currPasswordType)
1061 $this->userObj->setPasswd($this->currPassword,
IL_PASSWD_MD5);
1066 $this->acc_mail->setUserPassword($this->currPassword);
1080 $this->userObj->setTitle($this->userObj->getFullname());
1081 $this->userObj->setDescription($this->userObj->getEmail());
1083 if(!$this->time_limit_owner_set)
1085 $this->userObj->setTimeLimitOwner($this->
getFolderId());
1089 if(!$this->time_limit_set)
1091 $this->userObj->setTimeLimitUnlimited(1);
1092 $this->userObj->setTimeLimitMessage(0);
1094 if (! $this->approve_date_set)
1096 $this->userObj->setApproveDate(date(
"Y-m-d H:i:s"));
1101 $this->userObj->setActive($this->currActive ==
'true' || is_null($this->currActive));
1106 $this->userObj->create();
1109 $this->userObj->saveAsNew(
false);
1112 $this->userObj->setPref(
'hits_per_page',$ilSetting->get(
'hits_per_page',30));
1113 $this->userObj->setPref(
'show_users_online',$ilSetting->get(
'show_users_online',
'y'));
1115 if (count ($this->prefs))
1117 foreach ($this->prefs as $key => $value)
1119 if ($key !=
"mail_incoming_type" &&
1120 $key !=
"mail_signature" &&
1121 $key !=
"mail_linebreak"
1124 $this->userObj->setPref($key, $value);
1129 $this->userObj->writePrefs();
1134 if (is_array($this->personalPicture))
1136 if (strlen($this->personalPicture[
"content"]))
1139 if (preg_match(
"/.*(png|jpg|gif|jpeg)$/", $this->personalPicture[
"imagetype"], $matches))
1141 $extension = $matches[1];
1143 $tmp_name = $this->
saveTempImage($this->personalPicture[
"content"],
".$extension");
1144 if (strlen($tmp_name))
1152 if ($this->ilincdata[
"id"]) {
1153 include_once
'./ilinc/classes.ilObjiLincUser.php';
1155 $ilinc_user->setVar(
"id", $this->ilincdata[
"id"]);
1156 $ilinc_user->setVar(
"login", $this->ilincdata[
"login"]);
1157 $ilinc_user->setVar(
"passwd", $this->ilincdata[
"password"]);
1158 $ilinc_user->update();
1162 foreach($this->roles as $role_id => $role)
1164 if ($this->role_assign[$role_id])
1166 $this->
assignToRole($this->userObj, $this->role_assign[$role_id]);
1170 if(count($this->udf_data))
1172 include_once
'./Services/User/classes/class.ilUserDefinedData.php';
1174 foreach($this->udf_data as $field => $value)
1176 $udd->
set(
"f_".$field,$value);
1182 $this->
logSuccess($this->userObj->getLogin(),$this->userObj->getId(),
"Insert");
1184 $this->acc_mail->reset();
1191 $this->
logFailure($this->userObj->getLogin(),$lng->txt(
"usrimport_cant_update"));
1196 $updateUser->read();
1197 $updateUser->readPrefs();
1198 if ($this->currPassword != null)
1200 switch ($this->currPasswordType)
1212 $this->acc_mail->setUserPassword($this->currPassword);
1216 if (! is_null($this->userObj->getFirstname())) $updateUser->setFirstname($this->userObj->getFirstname());
1217 if (! is_null($this->userObj->getLastname())) $updateUser->setLastname($this->userObj->getLastname());
1218 if (! is_null($this->userObj->getUTitle())) $updateUser->setUTitle($this->userObj->getUTitle());
1219 if (! is_null($this->userObj->getGender())) $updateUser->setGender($this->userObj->getGender());
1220 if (! is_null($this->userObj->getEmail())) $updateUser->setEmail($this->userObj->getEmail());
1221 if (! is_null($this->userObj->getBirthday())) $updateUser->setBirthday($this->userObj->getBirthday());
1222 if (! is_null($this->userObj->getInstitution())) $updateUser->setInstitution($this->userObj->getInstitution());
1223 if (! is_null($this->userObj->getStreet())) $updateUser->setStreet($this->userObj->getStreet());
1224 if (! is_null($this->userObj->getCity())) $updateUser->setCity($this->userObj->getCity());
1225 if (! is_null($this->userObj->getZipCode())) $updateUser->setZipCode($this->userObj->getZipCode());
1226 if (! is_null($this->userObj->getCountry())) $updateUser->setCountry($this->userObj->getCountry());
1227 if (! is_null($this->userObj->getPhoneOffice())) $updateUser->setPhoneOffice($this->userObj->getPhoneOffice());
1228 if (! is_null($this->userObj->getPhoneHome())) $updateUser->setPhoneHome($this->userObj->getPhoneHome());
1229 if (! is_null($this->userObj->getPhoneMobile())) $updateUser->setPhoneMobile($this->userObj->getPhoneMobile());
1230 if (! is_null($this->userObj->getFax())) $updateUser->setFax($this->userObj->getFax());
1231 if (! is_null($this->userObj->getHobby())) $updateUser->setHobby($this->userObj->getHobby());
1232 if (! is_null($this->userObj->getComment())) $updateUser->setComment($this->userObj->getComment());
1233 if (! is_null($this->userObj->getDepartment())) $updateUser->setDepartment($this->userObj->getDepartment());
1234 if (! is_null($this->userObj->getMatriculation())) $updateUser->setMatriculation($this->userObj->getMatriculation());
1235 if (! is_null($this->currActive)) $updateUser->setActive($this->currActive ==
"true", is_object($ilUser) ? $ilUser->getId() : 0);
1236 if (! is_null($this->userObj->getClientIP())) $updateUser->setClientIP($this->userObj->getClientIP());
1237 if (! is_null($this->userObj->getTimeLimitUnlimited())) $updateUser->setTimeLimitUnlimited($this->userObj->getTimeLimitUnlimited());
1238 if (! is_null($this->userObj->getTimeLimitFrom())) $updateUser->setTimeLimitFrom($this->userObj->getTimeLimitFrom());
1239 if (! is_null($this->userObj->getTimeLimitUntil())) $updateUser->setTimeLimitUntil($this->userObj->getTimeLimitUntil());
1240 if (! is_null($this->userObj->getTimeLimitMessage())) $updateUser->setTimeLimitMessage($this->userObj->getTimeLimitMessage());
1241 if (! is_null($this->userObj->getApproveDate())) $updateUser->setApproveDate($this->userObj->getApproveDate());
1242 if (! is_null($this->userObj->getAgreeDate())) $updateUser->setAgreeDate($this->userObj->getAgreeDate());
1243 if (! is_null($this->userObj->getLanguage())) $updateUser->setLanguage($this->userObj->getLanguage());
1244 if (! is_null($this->userObj->getExternalAccount())) $updateUser->setExternalAccount($this->userObj->getExternalAccount());
1247 #if (! is_null($this->userObj->getAuthMode())) $updateUser->setAuthMode($this->userObj->getAuthMode());
1248 if($this->auth_mode_set)
1249 $updateUser->setAuthMode($this->userObj->getAuthMode());
1251 if (! is_null($this->userObj->getInstantMessengerId(
"aim"))) $updateUser->setInstantMessengerId(
"aim", $this->userObj->getInstantMessengerId(
"aim"));
1252 if (! is_null($this->userObj->getInstantMessengerId(
"msn"))) $updateUser->setInstantMessengerId(
"msn", $this->userObj->getInstantMessengerId(
"msn"));
1253 if (! is_null($this->userObj->getInstantMessengerId(
"icq"))) $updateUser->setInstantMessengerId(
"icq", $this->userObj->getInstantMessengerId(
"icq"));
1254 if (! is_null($this->userObj->getInstantMessengerId(
"yahoo"))) $updateUser->setInstantMessengerId(
"yahoo", $this->userObj->getInstantMessengerId(
"yahoo"));
1255 if (! is_null($this->userObj->getInstantMessengerId(
"skype"))) $updateUser->setInstantMessengerId(
"skype", $this->userObj->getInstantMessengerId(
"skype"));
1256 if (! is_null($this->userObj->getInstantMessengerId(
"jabber"))) $updateUser->setInstantMessengerId(
"jabber", $this->userObj->getInstantMessengerId(
"jabber"));
1257 if (! is_null($this->userObj->getInstantMessengerId(
"voip"))) $updateUser->setInstantMessengerId(
"voip", $this->userObj->getInstantMessengerId(
"voip"));
1260 if($this->time_limit_owner_set)
1262 $updateUser->setTimeLimitOwner($this->userObj->getTimeLimitOwner());
1266 if (count ($this->prefs))
1268 foreach ($this->prefs as $key => $value)
1270 if ($key !=
"mail_incoming_type" &&
1271 $key !=
"mail_signature" &&
1272 $key !=
"mail_linebreak"
1274 $updateUser->setPref($key, $value);
1280 if ($this->updateLookAndSkin)
1282 $updateUser->setPref(
"skin", $this->userObj->getPref(
"skin"));
1283 $updateUser->setPref(
"style", $this->userObj->getPref(
"style"));
1287 $updateUser->writePrefs();
1294 $updateUser->setTitle($updateUser->getFullname());
1295 $updateUser->setDescription($updateUser->getEmail());
1296 $updateUser->update();
1298 if ($this->ilincdata[
"id"]) {
1299 include_once
'./ilinc/classes.ilObjiLincUser.php';
1301 $ilinc_user->setVar(
"id", $this->ilincdata[
"id"]);
1302 $ilinc_user->setVar(
"login", $this->ilincdata[
"login"]);
1303 $ilinc_user->setVar(
"passwd", $this->ilincdata[
"password"]);
1304 $ilinc_user->update();
1307 if(count($this->udf_data))
1309 include_once
'./Services/User/classes/class.ilUserDefinedData.php';
1311 foreach($this->udf_data as $field => $value)
1313 $udd->
set(
"f_".$field,$value);
1319 if (!is_null($this->userObj->getLogin()) && $this->user_id != -1)
1323 $updateUser->updateLogin($this->userObj->getLogin());
1333 if (is_array($this->personalPicture))
1335 if (strlen($this->personalPicture[
"content"]))
1338 if (preg_match(
"/.*(png|jpg|gif|jpeg)$/", $this->personalPicture[
"imagetype"], $matches))
1340 $extension = $matches[1];
1342 $tmp_name = $this->
saveTempImage($this->personalPicture[
"content"],
".$extension");
1343 if (strlen($tmp_name))
1354 foreach ($this->roles as $role_id => $role)
1356 if ($this->role_assign[$role_id])
1358 switch ($role[
"action"])
1361 $this->
assignToRole($updateUser, $this->role_assign[$role_id]);
1363 case "AssignWithParents" :
1367 $this->
detachFromRole($updateUser, $this->role_assign[$role_id]);
1378 $this->
logFailure($this->userObj->getLogin(),$lng->txt(
"usrimport_cant_delete"));
1383 $deleteUser->delete();
1391 $this->roles = array();
1395 $this->userObj->setLogin($this->cdata);
1399 $this->currPassword = $this->cdata;
1403 $this->userObj->setFirstname($this->cdata);
1407 $this->userObj->setLastname($this->cdata);
1408 $this->userObj->setFullname();
1412 $this->userObj->setUTitle($this->cdata);
1416 $this->userObj->setGender($this->cdata);
1420 $this->userObj->setEmail($this->cdata);
1427 $this->userObj->setBirthday($this->cdata);
1431 $this->userObj->setInstitution($this->cdata);
1435 $this->userObj->setStreet($this->cdata);
1439 $this->userObj->setCity($this->cdata);
1443 $this->userObj->setZipCode($this->cdata);
1447 $this->userObj->setCountry($this->cdata);
1451 $this->userObj->setPhoneOffice($this->cdata);
1455 $this->userObj->setPhoneHome($this->cdata);
1459 $this->userObj->setPhoneMobile($this->cdata);
1463 $this->userObj->setFax($this->cdata);
1467 $this->userObj->setHobby($this->cdata);
1471 $this->userObj->setComment($this->cdata);
1475 $this->userObj->setDepartment($this->cdata);
1478 case "Matriculation":
1479 $this->userObj->setMatriculation($this->cdata);
1483 $this->currActive = $this->cdata;
1487 $this->userObj->setClientIP($this->cdata);
1490 case "TimeLimitOwner":
1491 $this->time_limit_owner_set =
true;
1492 $this->userObj->setTimeLimitOwner($this->cdata);
1495 case "TimeLimitUnlimited":
1496 $this->time_limit_set =
true;
1497 $this->userObj->setTimeLimitUnlimited($this->cdata);
1500 case "TimeLimitFrom":
1501 if (is_numeric($this->cdata))
1504 $this->userObj->setTimeLimitFrom($this->cdata);
1510 if (
$timestamp !==
false && trim($this->cdata) !=
"0000-00-00 00:00:00")
1512 $this->userObj->setTimeLimitFrom(
$timestamp);
1514 elseif ($this->cdata ==
"0000-00-00 00:00:00")
1516 $this->userObj->setTimeLimitFrom(null);
1522 case "TimeLimitUntil":
1523 if (is_numeric($this->cdata))
1526 $this->userObj->setTimeLimitUntil($this->cdata);
1532 if (
$timestamp !==
false && trim($this->cdata) !=
"0000-00-00 00:00:00")
1534 $this->userObj->setTimeLimitUntil(
$timestamp);
1536 elseif ($this->cdata ==
"0000-00-00 00:00:00")
1538 $this->userObj->setTimeLimitUntil(null);
1543 case "TimeLimitMessage":
1544 $this->userObj->setTimeLimitMessage($this->cdata);
1548 $this->approve_date_set =
true;
1549 if (is_numeric($this->cdata))
1559 if (
$timestamp !==
false && trim($this->cdata) !=
"0000-00-00 00:00:00")
1564 elseif ($this->cdata ==
"0000-00-00 00:00:00")
1566 $this->userObj->setApproveDate(null);
1572 if (is_numeric($this->cdata))
1582 if (
$timestamp !==
false && trim($this->cdata) !=
"0000-00-00 00:00:00")
1587 elseif ($this->cdata ==
"0000-00-00 00:00:00")
1589 $this->userObj->setAgreeDate(null);
1595 $this->ilincdata[
"id"] = $this->cdata;
1603 $this->
$ilincdata[
"password"] = $this->cdata;
1607 case "ExternalAccount":
1608 $this->userObj->setExternalAccount($this->cdata);
1612 $this->updateLookAndSkin =
false;
1613 if (!$this->hideSkin)
1616 if ((strlen($this->skin) > 0) && (strlen($this->style) > 0))
1618 if (is_array($this->userStyles))
1620 if (in_array($this->skin .
":" . $this->style, $this->userStyles))
1622 $this->userObj->setPref(
"skin", $this->skin);
1623 $this->userObj->setPref(
"style", $this->style);
1624 $this->updateLookAndSkin =
true;
1631 case 'UserDefinedField':
1632 include_once
'./Services/User/classes/class.ilUserDefinedFields.php';
1634 if($field_id = $udf->fetchFieldIdFromImportId($this->tmp_udf_id))
1636 $this->udf_data[$field_id] = $this->cdata;
1638 elseif($field_id = $udf->fetchFieldIdFromName($this->tmp_udf_name))
1640 $this->udf_data[$field_id] = $this->cdata;
1644 if ($this->current_messenger_type ==
"delicious")
1646 $this->userObj->setDelicious($this->cdata);
1648 elseif ($this->current_messenger_type ==
"external")
1650 $this->userObj->setExternalAccount($this->cdata);
1654 $this->userObj->setInstantMessengerId($this->current_messenger_type, $this->cdata);
1658 if ($this->currentPrefKey != null && strlen(trim($this->cdata)) > 0
1660 $this->prefs[$this->currentPrefKey] = trim($this->cdata);
1661 $this->currentPrefKey = null;
1673 $fh = fopen($tempname,
"wb");
1678 $imagefile = fwrite($fh, $image_data);
1693 $this->roles[$this->current_role_id][
"name"] = $this->cdata;
1694 $this->roles[$this->current_role_id][
"type"] = $this->current_role_type;
1695 $this->roles[$this->current_role_id][
"action"] = $this->current_role_action;
1699 if ($this->user_id != -1 && $this->action ==
"Update")
1704 if (is_null($this->userObj->getLogin()))
1706 $this->
logFailure(
"---",sprintf($lng->txt(
"usrimport_xml_element_for_action_required"),
"Login",
"Insert"));
1709 switch ($this->action)
1714 $this->
logWarning($this->userObj->getLogin(),$lng->txt(
"usrimport_cant_insert"));
1716 if (is_null($this->userObj->getGender()) && $this->
isFieldRequired(
"gender"))
1718 $this->
logFailure($this->userObj->getLogin(),sprintf($lng->txt(
"usrimport_xml_element_for_action_required"),
"Gender",
"Insert"));
1720 if (is_null($this->userObj->getFirstname()))
1722 $this->
logFailure($this->userObj->getLogin(),sprintf($lng->txt(
"usrimport_xml_element_for_action_required"),
"Firstname",
"Insert"));
1724 if (is_null($this->userObj->getLastname()))
1726 $this->
logFailure($this->userObj->getLogin(),sprintf($lng->txt(
"usrimport_xml_element_for_action_required"),
"Lastname",
"Insert"));
1728 if (count($this->roles) == 0)
1730 $this->
logFailure($this->userObj->getLogin(),sprintf($lng->txt(
"usrimport_xml_element_for_action_required"),
"Role",
"Insert"));
1734 $has_global_role =
false;
1735 foreach ($this->roles as $role)
1737 if ($role[
'type'] ==
'Global')
1739 $has_global_role =
true;
1743 if (! $has_global_role)
1745 $this->
logFailure($this->userObj->getLogin(),sprintf($lng->txt(
"usrimport_global_role_for_action_required"),
"Insert"));
1752 $this->
logWarning($this->userObj->getLogin(),$lng->txt(
"usrimport_cant_update"));
1754 elseif($this->user_id != -1 && !is_null($this->userObj->getLogin()))
1760 $this->
logFailure($this->userObj->getLogin(), $lng->txt(
"usrimport_login_is_not_unique"));
1767 $this->
logWarning($this->userObj->getLogin(),$lng->txt(
"usrimport_cant_delete"));
1773 $this->roles = array();
1777 if (array_key_exists($this->cdata, $this->logins))
1779 $this->
logWarning($this->cdata, $lng->txt(
"usrimport_login_is_not_unique"));
1783 $this->logins[$this->cdata] = $this->cdata;
1785 $this->userObj->setLogin($this->cdata);
1789 switch ($this->currPasswordType)
1801 $this->acc_mail->setUserPassword($this->currPassword);
1811 $this->userObj->setFirstname($this->cdata);
1815 $this->userObj->setLastname($this->cdata);
1816 $this->userObj->setFullname();
1820 $this->userObj->setUTitle($this->cdata);
1824 if ($this->cdata !=
"m"
1825 && $this->cdata !=
"f")
1828 $this->userObj->getLogin(),
1829 sprintf($lng->txt(
"usrimport_xml_element_content_illegal"),
"Gender",$this->cdata)
1832 $this->userObj->setGender($this->cdata);
1836 $this->userObj->setEmail($this->cdata);
1840 $this->userObj->setInstitution($this->cdata);
1844 $this->userObj->setStreet($this->cdata);
1848 $this->userObj->setCity($this->cdata);
1852 $this->userObj->setZipCode($this->cdata);
1856 $this->userObj->setCountry($this->cdata);
1860 $this->userObj->setPhoneOffice($this->cdata);
1864 $this->userObj->setPhoneHome($this->cdata);
1868 $this->userObj->setPhoneMobile($this->cdata);
1872 $this->userObj->setFax($this->cdata);
1876 $this->userObj->setHobby($this->cdata);
1880 $this->userObj->setComment($this->cdata);
1884 $this->userObj->setDepartment($this->cdata);
1887 case "Matriculation":
1888 $this->userObj->setMatriculation($this->cdata);
1891 case "ExternalAccount":
1893 $am = ($this->userObj->getAuthMode() ==
"default" || $this->userObj->getAuthMode() ==
"")
1895 : $this->userObj->getAuthMode();
1896 $loginForExternalAccount = (trim($this->cdata) ==
"")
1899 switch ($this->action)
1902 if ($loginForExternalAccount !=
"")
1904 $this->
logWarning($this->userObj->getLogin(), $lng->txt(
"usrimport_no_insert_ext_account_exists").
" (".$this->cdata.
")");
1909 if ($loginForExternalAccount !=
"")
1912 if ($externalAccountHasChanged && trim($loginForExternalAccount) != trim($this->userObj->getLogin()))
1914 $this->
logWarning($this->userObj->getLogin(),
1915 $lng->txt(
"usrimport_no_update_ext_account_exists").
" (".$this->cdata.
" for ".$loginForExternalAccount.
")");
1921 if ($externalAccountHasChanged)
1922 $this->userObj->setExternalAccount(trim($this->cdata));
1926 if ($this->cdata !=
"true"
1927 && $this->cdata !=
"false")
1929 $this->
logFailure($this->userObj->getLogin(),
1930 sprintf($lng->txt(
"usrimport_xml_element_content_illegal"),
"Active",$this->cdata));
1932 $this->currActive = $this->cdata;
1934 case "TimeLimitOwner":
1935 if (!preg_match(
"/\d+/", $this->cdata))
1937 $this->
logFailure($this->userObj->getLogin(),
1938 sprintf($lng->txt(
"usrimport_xml_element_content_illegal"),
"TimeLimitOwner",$this->cdata));
1940 elseif(!$ilAccess->checkAccess(
'cat_administrate_users',
'',$this->cdata))
1942 $this->
logFailure($this->userObj->getLogin(),
1943 sprintf($lng->txt(
"usrimport_xml_element_content_illegal"),
"TimeLimitOwner",$this->cdata));
1945 elseif($ilObjDataCache->lookupType($ilObjDataCache->lookupObjId($this->cdata)) !=
'cat' && !(
int) $this->cdata ==
USER_FOLDER_ID)
1947 $this->
logFailure($this->userObj->getLogin(),
1948 sprintf($lng->txt(
"usrimport_xml_element_content_illegal"),
"TimeLimitOwner",$this->cdata));
1951 $this->userObj->setTimeLimitOwner($this->cdata);
1953 case "TimeLimitUnlimited":
1954 switch (strtolower($this->cdata))
1958 $this->userObj->setTimeLimitUnlimited(1);
1962 $this->userObj->setTimeLimitUnlimited(0);
1965 $this->
logFailure($this->userObj->getLogin(), sprintf($lng->txt(
"usrimport_xml_element_content_illegal"),
"TimeLimitUnlimited",$this->cdata));
1969 case "TimeLimitFrom":
1971 if (strtotime($this->cdata) ===
false && ! is_numeric($this->cdata))
1973 $this->
logFailure($this->userObj->getLogin(), sprintf($lng->txt(
"usrimport_xml_element_content_illegal"),
"TimeLimitFrom",$this->cdata));
1975 $this->userObj->setTimeLimitFrom($this->cdata);
1977 case "TimeLimitUntil":
1979 if (strtotime($this->cdata) ===
false && ! is_numeric($this->cdata))
1981 $this->
logFailure($this->userObj->getLogin(), sprintf($lng->txt(
"usrimport_xml_element_content_illegal"),
"TimeLimitUntil",$this->cdata));
1983 $this->userObj->setTimeLimitUntil($this->cdata);
1985 case "TimeLimitMessage":
1986 switch (strtolower($this->cdata))
1989 $this->userObj->setTimeLimitMessage(1);
1992 $this->userObj->setTimeLimitMessage(0);
1995 $this->
logFailure($this->userObj->getLogin(), sprintf($lng->txt(
"usrimport_xml_element_content_illegal"),
"TimeLimitMessage",$this->cdata));
2001 if (strtotime($this->cdata) ===
false && ! is_numeric($this->cdata) && !$this->cdata ==
"0000-00-00 00:00:00")
2003 $this->
logFailure($this->userObj->getLogin(), sprintf($lng->txt(
"usrimport_xml_element_content_illegal"),
"ApproveDate",$this->cdata));
2008 if (strtotime($this->cdata) ===
false && ! is_numeric($this->cdata) && !$this->cdata ==
"0000-00-00 00:00:00")
2010 $this->
logFailure($this->userObj->getLogin(), sprintf($lng->txt(
"usrimport_xml_element_content_illegal"),
"AgreeDate",$this->cdata));
2014 if (!preg_match(
"/\d+/", $this->cdata))
2016 $this->
logFailure($this->userObj->getLogin(), sprintf($lng->txt(
"usrimport_xml_element_content_illegal"),
"iLincID",$this->cdata));
2020 if (!preg_match(
"/\w+/", $this->cdata))
2022 $this->
logFailure($this->userObj->getLogin(), sprintf($lng->txt(
"usrimport_xml_element_content_illegal"),
"iLincUser",$this->cdata));
2026 if (!preg_match(
"/\w+/", $this->cdata))
2028 $this->
logFailure($this->userObj->getLogin(), sprintf($lng->txt(
"usrimport_xml_element_content_illegal"),
"iLincPasswd",$this->cdata));
2032 if ($this->currentPrefKey != null)
2033 $this->
verifyPref($this->currentPrefKey, $this->cdata);
2034 $this->currentPrefKey == null;
2046 if($a_data !=
"\n") $a_data = preg_replace(
"/\t+/",
" ",$a_data);
2048 if(strlen($a_data) > 0)
2050 $this->cdata .= $a_data;
2077 if (! array_key_exists($aLogin, $this->protocol))
2079 $this->protocol[$aLogin] = array();
2083 $this->protocol[$aLogin][] = $aMessage;
2098 if (! array_key_exists($aLogin, $this->protocol))
2100 $this->protocol[$aLogin] = array();
2104 $this->protocol[$aLogin][] = $aMessage;
2118 $this->user_mapping[$userid] = array(
"login" => $aLogin,
"action" =>
$action,
"message" =>
"successful");
2141 $block =
new ilTemplate(
"tpl.usr_import_log_block.html",
true,
true);
2142 $block->setVariable(
"TXT_LOG_TITLE", $a_log_title);
2143 $block->setVariable(
"TXT_MESSAGE_ID", $lng->txt(
"login"));
2144 $block->setVariable(
"TXT_MESSAGE_TEXT", $lng->txt(
"message"));
2147 $block->setCurrentBlock(
"log_row");
2157 $reason = $reason.
"<br>".$message;
2160 $block->setVariable(
"MESSAGE_ID", $login);
2161 $block->setVariable(
"MESSAGE_TEXT", $reason);
2162 $block->parseCurrentBlock();
2164 return $block->get();
2199 if (
$_POST[
"send_mail"] !=
"" ||
2200 ($this->
isSendMail() && $this->userObj->getEmail() !=
"")
2203 $this->acc_mail->setUser($this->userObj);
2204 $this->acc_mail->send();
2214 $this->send_mail = $value ?
true:
false;
2234 $this->mapping_mode = $value;
2235 else die (
"wrong argument using methode setUserMappingMethod in ".__FILE__);
2258 if(is_array($this->required_fields))
2260 return $this->required_fields;
2262 foreach($ilSetting->getAll() as $field => $value)
2264 if(substr($field,0,8) ==
'require_' and $value == 1)
2266 $value = substr($field,8);
2267 $this->required_fields[$value] = $value;
2270 return $this->required_fields ? $this->required_fields : array();
2285 foreach($this->required_fields as $field)
2291 if(!strlen($user_obj->getLogin()))
2297 if(!strlen($user_obj->getGender()))
2303 if(!strlen($user_obj->getFirstname()))
2309 if(!strlen($user_obj->getLastname()))
2315 if(!strlen($user_obj->getEmail()))
2321 if(!strlen($user_obj->getUTitle()))
2327 if(!strlen($user_obj->getInstitution()))
2333 if(!strlen($user_obj->getDepartment()))
2339 if(!strlen($user_obj->getStreet()))
2345 if(!strlen($user_obj->getZipcode()))
2351 if(!strlen($user_obj->getCity()))
2357 if(!strlen($user_obj->getCountry()))
2362 case 'phone_office':
2363 if(!strlen($user_obj->getPhoneOffice()))
2368 case 'phone_mobile':
2369 if(!strlen($user_obj->getPhoneMobile()))
2375 if(!strlen($user_obj->getPhoneHome()))
2381 if(!strlen($user_obj->getFax()))
2387 if(!strlen($user_obj->getHobby()))
2392 case 'matriculation':
2393 if(!strlen($user_obj->getMatriculation()))
2415 $fieldname = strtolower(trim($fieldname));
2416 return array_key_exists($fieldname, $requiredFields);
2421 case 'mail_linebreak':
2422 case 'hits_per_page':
2423 if (!is_numeric($value) || $value < 0)
2424 $this->
logFailure(
"---",
"Wrong value '$value': Positiv numeric value expected for preference $key.");
2429 case 'ilPageEditor_HTMLMode':
2430 case 'ilPageEditor_JavaScript':
2431 case 'ilPageEditor_MediaMode':
2432 case 'tst_javascript':
2433 case 'tst_lastquestiontype':
2434 case 'tst_multiline_answers':
2435 case 'tst_use_previous_answers':
2436 case 'graphicalAnswerSetting':
2437 case 'priv_feed_pass':
2438 $this->
logFailure(
"---",
"Preference $key is not supported.");
2441 case 'public_country':
2442 case 'public_department':
2443 case 'public_email':
2445 case 'public_hobby':
2446 case 'public_institution':
2447 case 'public_matriculation':
2448 case 'public_phone':
2449 case 'public_phone_home':
2450 case 'public_phone_mobile':
2451 case 'public_phone_office':
2452 case 'public_street':
2453 case 'public_upload':
2455 case 'send_info_mails':
2456 case 'hide_own_online_status':
2457 if (!in_array($value, array(
'y',
'n')))
2458 $this->
logFailure(
"---",
"Wrong value '$value': Value 'y' or 'n' expected for preference $key.");
2460 case 'public_profile':
2461 if (!in_array($value, array(
'y',
'n',
'g')))
2462 $this->
logFailure(
"---",
"Wrong value '$value': Value 'y', 'g' or 'n' expected for preference $key.");
2464 case 'show_users_online':
2465 if (!in_array($value, array(
'y',
'n',
'associated')))
2466 $this->
logFailure(
"---",
"Wrong value '$value': Value 'y' or 'n' or 'associated' expected for preference $key.");
2468 case 'mail_incoming_type':
2469 if (!in_array((
int) $value, array(
"0",
"1",
"2")))
2470 $this->
logFailure(
"---",
"Wrong value '$value': Value \"0\" (LOCAL),\"1\" (EMAIL) or \"2\" (BOTH) expected for preference $key.");
2473 if (!in_array($value, array (
"0",
"1")))
2474 $this->
logFailure(
"---",
"Wrong value '$value': Value \"0\" (Sunday) or \"1\" (Monday) expected for preference $key.");
2477 case 'mail_signature':
2480 include_once(
'Services/Calendar/classes/class.ilTimeZone.php');
2485 $this->
logFailure(
"---",
"Wrong value '$value': Invalid timezone $value detected for preference $key.");
2490 $this->
logFailure(
"---",
"Preference $key is not supported.");
2496 if (array_key_exists(
"mail_incoming_type", $this->prefs) ||
2497 array_key_exists(
"mail_signature", $this->prefs) ||
2498 array_key_exists(
"mail_linebreak", $this->prefs)
2501 include_once(
"Services/Mail/classes/class.ilMailOptions.php");
2503 $mailOptions->updateOptions(
2504 array_key_exists(
"mail_signature", $this->prefs) ? $this->prefs[
"mail_signature"] : $mailOptions->getSignature(),
2505 array_key_exists(
"mail_linebreak", $this->prefs) ? $this->prefs[
"mail_linebreak"] : $mailOptions->getLinebreak(),
2506 array_key_exists(
"mail_incoming_type", $this->prefs) ? $this->prefs[
"mail_incoming_type"] : $mailOptions->getIncomingType(),
2507 $mailOptions->getCronjobNotification()