799 : void {
800 $this->contained_tags[] = $a_name;
801
802 switch ($a_name) {
803 case 'Role':
807 break;
808
809 case 'PersonalPicture':
810 switch ($this->personal_picture['encoding']) {
811 case 'Base64':
812 $this->personal_picture['content'] = base64_decode($this->cdata);
813 break;
814 case 'UUEncode':
815 $this->personal_picture['content'] = convert_uudecode($this->cdata);
816 break;
817 }
818 break;
819
820 case 'User':
821 $this->user_obj->setFullname();
822
823
824 if ($this->user_id == -1 || $this->action === 'Insert') {
826 } else {
828 }
829
831 return;
832 }
833
834
835 switch ($this->conflict_rule) {
837
838 break;
840 switch ($this->action) {
841 case 'Insert':
843 $this->
logWarning($this->user_obj->getLogin(), sprintf($this->
lng->txt(
'usrimport_action_replaced'),
'Insert',
'Update'));
844 $this->action = 'Update';
845 }
846 break;
847 case 'Update':
849 $this->
logWarning($this->user_obj->getLogin(), sprintf($this->
lng->txt(
'usrimport_action_replaced'),
'Update',
'Insert'));
850 $this->action = 'Insert';
851 }
852 break;
853 case 'Delete':
855 $this->
logWarning($this->user_obj->getLogin(), sprintf($this->
lng->txt(
'usrimport_action_ignored'),
'Delete'));
856 $this->action = 'Ignore';
857 }
858 break;
859 }
860 break;
862 switch ($this->action) {
863 case 'Insert':
865 $this->
logWarning($this->user_obj->getLogin(), sprintf($this->
lng->txt(
'usrimport_action_ignored'),
'Insert'));
866 $this->action = 'Ignore';
867 }
868 break;
869 case 'Update':
871 $this->
logWarning($this->user_obj->getLogin(), sprintf($this->
lng->txt(
'usrimport_action_ignored'),
'Update'));
872 $this->action = 'Ignore';
873 }
874 break;
875 case 'Delete':
877 $this->
logWarning($this->user_obj->getLogin(), sprintf($this->
lng->txt(
'usrimport_action_ignored'),
'Delete'));
878 $this->action = 'Ignore';
879 }
880 break;
881 }
882 break;
883 }
884
885
886
887
888
889 $am = ($this->user_obj->getAuthMode() === 'default' || $this->user_obj->getAuthMode() == '')
891 : $this->user_obj->getAuthMode();
892 $loginForExternalAccount = ($this->user_obj->getExternalAccount() == '')
893 ? ''
895 switch ($this->action) {
896 case 'Insert':
897 if ($loginForExternalAccount != '') {
899 $this->user_obj->getLogin(),
900 $this->lng->txt('usrimport_no_insert_ext_account_exists')
901 . ' (' . $this->stripTags($this->user_obj->getExternalAccount()) . ')'
902 );
903 $this->action = 'Ignore';
904 }
905 break;
906
907 case 'Update':
908
909
910
911
912 if ($loginForExternalAccount != '') {
913
915
916 if ($externalAccountHasChanged && trim($loginForExternalAccount) != trim($this->user_obj->getLogin())) {
918 $this->user_obj->getLogin(),
919 $this->lng->txt('usrimport_no_update_ext_account_exists')
920 . ' (' . $this->stripTags($this->user_obj->getExternalAccount()) . ')'
921 );
922 $this->action = 'Ignore';
923 }
924 }
925 break;
926 }
927
928 if (count($this->multi_values)) {
929 if (isset($this->multi_values['GeneralInterest'])) {
930 $this->user_obj->setGeneralInterests($this->multi_values['GeneralInterest']);
931 }
932 if (isset($this->multi_values['OfferingHelp'])) {
933 $this->user_obj->setOfferingHelp($this->multi_values['OfferingHelp']);
934 }
935 if (isset($this->multi_values['LookingForHelp'])) {
936 $this->user_obj->setLookingForHelp($this->multi_values['LookingForHelp']);
937 }
938 }
939
940
941 switch ($this->action) {
942 case 'Insert':
944 $this->
logFailure($this->user_obj->getLogin(), $this->lng->txt(
'usrimport_cant_insert'));
945 } else {
946 if ($this->current_user_password !== null) {
947 switch (strtoupper($this->current_user_password_type)) {
948 case 'BCRYPT':
950 $this->user_obj->setPasswordEncodingType('bcryptphp');
951 $this->user_obj->setPasswordSalt(null);
952 break;
953
954 case 'PLAIN':
956 $this->acc_mail->setUserPassword((string) $this->current_user_password);
957 break;
958
959 default:
960 $this->
logFailure($this->user_obj->getLogin(), sprintf($this->
lng->txt(
'usrimport_xml_attribute_value_illegal'),
'Type',
'Password', $this->stripTags($this->current_user_password_type)));
961 break;
962 }
963 } else {
964
965
966
967
969 }
970
971 $this->user_obj->setTitle($this->user_obj->getFullname());
972 $this->user_obj->setDescription($this->user_obj->getEmail());
973
974 if (!$this->time_limit_owner_set) {
975 $this->user_obj->setTimeLimitOwner($this->
getFolderId());
976 }
977
978
979 if (!$this->time_limit_set) {
980 $this->user_obj->setTimeLimitUnlimited(true);
981
982 if (!$this->approve_date_set) {
983 $this->user_obj->setApproveDate(date('Y-m-d H:i:s'));
984 }
985 }
986
987
988 $this->user_obj->setActive($this->currActive === 'true' || is_null($this->currActive));
989
990
991
992
993
994 if ($this->udf_data !== []) {
996 }
997
998 if (!$this->user_obj->getLanguage()) {
999 $this->user_obj->setLanguage($this->
lng->getDefaultLanguage());
1000 }
1001
1003 $this->user_obj->create();
1004
1005
1006 $this->user_obj->saveAsNew();
1007
1008 if (count($this->prefs)) {
1009 foreach ($this->prefs as $key => $value) {
1010 if ($key !== 'mail_incoming_type' &&
1011 $key !== 'mail_signature' &&
1012 $key !== 'mail_linebreak'
1013 ) {
1014 $this->user_obj->setPref($key, $value);
1015 }
1016 }
1017 }
1018
1019 if (!is_array($this->prefs) || !array_key_exists('chat_osc_accept_msg', $this->prefs)) {
1020 $this->user_obj->setPref(
'chat_osc_accept_msg', $this->
settings->get(
'chat_osc_accept_msg',
'n'));
1021 }
1022 if (!is_array($this->prefs) || !array_key_exists('chat_broadcast_typing', $this->prefs)) {
1023 $this->user_obj->setPref(
'chat_broadcast_typing', $this->
settings->get(
'chat_broadcast_typing',
'n'));
1024 }
1025 if (!is_array($this->prefs) || !array_key_exists('bs_allow_to_contact_me', $this->prefs)) {
1026 $this->user_obj->setPref(
'bs_allow_to_contact_me', $this->
settings->get(
'bs_allow_to_contact_me',
'n'));
1027 }
1028
1029 $this->user_obj->update();
1030
1031
1033
1034 if (is_array($this->personal_picture)) {
1035 if (strlen($this->personal_picture['content'])) {
1036 $extension = 'jpg';
1037 if (preg_match('/.*(png|jpg|gif|jpeg)$/', $this->personal_picture['imagetype'], $matches)) {
1038 $extension = $matches[1];
1039 }
1040 $tmp_name = $this->
saveTempImage($this->personal_picture[
'content'],
".{$extension}");
1041 if (strlen($tmp_name)) {
1042 $this->user_obj->uploadPersonalPicture($tmp_name);
1043 unlink($tmp_name);
1044 }
1045 }
1046 }
1047
1048
1049 foreach ($this->roles as $role_id => $role) {
1050 if (isset($this->role_assign[$role_id]) && $this->role_assign[$role_id]) {
1051 $this->
assignToRole($this->user_obj, (
int) $this->role_assign[$role_id]);
1052 }
1053 }
1054
1056 $this->
logSuccess($this->user_obj->getLogin(), $this->user_obj->getId(),
'Insert');
1057
1058 $this->acc_mail->reset();
1059 }
1060 break;
1061
1062 case 'Update':
1064 $this->
logFailure($this->user_obj->getLogin(), $this->lng->txt(
'usrimport_cant_update'));
1065 } else {
1067 $update_user->read();
1068 if ($this->current_user_password != null) {
1069 switch (strtoupper($this->current_user_password_type)) {
1070 case 'BCRYPT':
1072 $update_user->setPasswordEncodingType('bcryptphp');
1073 $update_user->setPasswordSalt(null);
1074 break;
1075
1076 case 'PLAIN':
1078 $this->acc_mail->setUserPassword((string) $this->current_user_password);
1079 break;
1080
1081 default:
1082 $this->
logFailure($this->user_obj->getLogin(), sprintf($this->
lng->txt(
'usrimport_xml_attribute_value_illegal'),
'Type',
'Password', $this->stripTags($this->current_user_password_type)));
1083 break;
1084 }
1085 }
1087 $update_user->setFirstname($this->user_obj->getFirstname());
1088 }
1090 $update_user->setLastname($this->user_obj->getLastname());
1091 }
1093 $update_user->setUTitle($this->user_obj->getUTitle());
1094 }
1096 $update_user->setGender($this->user_obj->getGender());
1097 }
1099 $update_user->setEmail($this->user_obj->getEmail());
1100 }
1102 $update_user->setSecondEmail($this->user_obj->getSecondEmail());
1103 }
1105 $update_user->setBirthday($this->user_obj->getBirthday());
1106 }
1108 $update_user->setInstitution($this->user_obj->getInstitution());
1109 }
1111 $update_user->setStreet($this->user_obj->getStreet());
1112 }
1114 $update_user->setCity($this->user_obj->getCity());
1115 }
1117 $update_user->setZipcode($this->user_obj->getZipcode());
1118 }
1119 if ($this->
tagContained(
'SelCountry') && mb_strlen($this->cdata) === 2) {
1120 $update_user->setCountry($this->user_obj->getCountry());
1121 }
1123 $update_user->setPhoneOffice($this->user_obj->getPhoneOffice());
1124 }
1126 $update_user->setPhoneHome($this->user_obj->getPhoneHome());
1127 }
1129 $update_user->setPhoneMobile($this->user_obj->getPhoneMobile());
1130 }
1132 $update_user->setFax($this->user_obj->getFax());
1133 }
1135 $update_user->setHobby($this->user_obj->getHobby());
1136 }
1138 $update_user->setGeneralInterests($this->user_obj->getGeneralInterests());
1139 }
1141 $update_user->setOfferingHelp($this->user_obj->getOfferingHelp());
1142 }
1144 $update_user->setLookingForHelp($this->user_obj->getLookingForHelp());
1145 }
1147 $update_user->setComment($this->user_obj->getComment());
1148 }
1150 $update_user->setDepartment($this->user_obj->getDepartment());
1151 }
1153 $update_user->setMatriculation($this->user_obj->getMatriculation());
1154 }
1155 if (!is_null($this->currActive)) {
1156 $update_user->setActive($this->currActive ===
'true', is_object($this->
user) ? $this->
user->getId() : 0);
1157 }
1159 $update_user->setClientIP($this->user_obj->getClientIP());
1160 }
1161 if ($this->time_limit_set) {
1162 $update_user->setTimeLimitUnlimited($this->user_obj->getTimeLimitUnlimited());
1163 }
1165 $update_user->setTimeLimitFrom($this->user_obj->getTimeLimitFrom());
1166 }
1168 $update_user->setTimeLimitUntil($this->user_obj->getTimeLimitUntil());
1169 }
1171 $update_user->setApproveDate($this->user_obj->getApproveDate());
1172 }
1174 $update_user->setAgreeDate($this->user_obj->getAgreeDate());
1175 }
1177 $update_user->setLanguage($this->user_obj->getLanguage());
1178 }
1180 $update_user->setExternalAccount($this->user_obj->getExternalAccount());
1181 }
1182
1183
1184 #if (! is_null($this->userObj->getAuthMode())) $updateUser->setAuthMode($this->userObj->getAuthMode());
1185 if ($this->auth_mode_set) {
1186 $update_user->setAuthMode($this->user_obj->getAuthMode());
1187 }
1188
1189
1190 if ($this->time_limit_owner_set) {
1191 $update_user->setTimeLimitOwner($this->user_obj->getTimeLimitOwner());
1192 }
1193
1194 if (count($this->prefs)) {
1195 foreach ($this->prefs as $key => $value) {
1196 if ($key !== 'mail_incoming_type' &&
1197 $key !== 'mail_signature' &&
1198 $key !== 'mail_linebreak'
1199 ) {
1200 $update_user->setPref($key, $value);
1201 }
1202 }
1203 }
1204
1205
1206 if ($this->update_look_and_skin) {
1207 $update_user->setPref('skin', $this->user_obj->getPref('skin'));
1208 $update_user->setPref('style', $this->user_obj->getPref('style'));
1209 }
1210
1211
1213
1214
1215 if ($this->udf_data !== []) {
1217 }
1218
1220 $update_user->setFullname();
1221 $update_user->setTitle($update_user->getFullname());
1222 $update_user->setDescription($update_user->getEmail());
1223 $update_user->update();
1224
1225
1226 if ($this->
tagContained(
'Login') && $this->user_id != -1) {
1227 try {
1228 $update_user->updateLogin($this->user_obj->getLogin(), Context::UserAdministration);
1230 }
1231 }
1232
1233
1234
1235
1236 if (is_array($this->personal_picture)) {
1237 if (strlen($this->personal_picture['content'])) {
1238 $extension = 'jpg';
1239 if (preg_match('/.*(png|jpg|gif|jpeg)$/', $this->personal_picture['imagetype'], $matches)) {
1240 $extension = $matches[1];
1241 }
1242 $tmp_name = $this->
saveTempImage($this->personal_picture[
'content'],
".{$extension}");
1243 if (strlen($tmp_name)) {
1244 $update_user->uploadPersonalPicture($tmp_name);
1245 unlink($tmp_name);
1246 }
1247 }
1248 }
1249
1250
1251
1252
1253 foreach ($this->roles as $role_id => $role) {
1254 if (array_key_exists($role_id, $this->role_assign)) {
1255 switch ($role['action']) {
1256 case 'Assign':
1257 $this->
assignToRole($update_user, (
int) $this->role_assign[$role_id]);
1258 break;
1259 case 'AssignWithParents':
1261 break;
1262 case 'Detach':
1263 $this->
detachFromRole($update_user, (
int) $this->role_assign[$role_id]);
1264 break;
1265 }
1266 }
1267 }
1269 }
1270 break;
1271 case 'Delete':
1273 $this->
logFailure($this->user_obj->getLogin(), $this->lng->txt(
'usrimport_cant_delete'));
1274 } else {
1276 $deleteUser->delete();
1277
1279 }
1280 break;
1281 }
1282
1283
1284 $this->roles = [];
1285 break;
1286
1287 case 'Login':
1289 break;
1290
1291 case 'Password':
1293 break;
1294
1295 case 'Firstname':
1297 break;
1298
1299 case 'Lastname':
1301 break;
1302
1303 case 'Title':
1305 break;
1306
1307 case 'Gender':
1308 $this->user_obj->setGender($this->cdata);
1309 break;
1310
1311 case 'Email':
1313 break;
1314 case 'SecondEmail':
1316 break;
1317 case 'Birthday':
1319 if (strtotime($birthday) !== false) {
1320 $this->user_obj->setBirthday($birthday);
1321 }
1322 break;
1323 case 'Institution':
1325 break;
1326
1327 case 'Street':
1329 break;
1330
1331 case 'City':
1333 break;
1334
1335 case 'PostalCode':
1337 break;
1338
1339 case 'Country':
1340 case 'SelCountry':
1341 if (mb_strlen($this->cdata) !== 2) {
1342 break;
1343 }
1345 break;
1346
1347 case 'PhoneOffice':
1349 break;
1350
1351 case 'PhoneHome':
1353 break;
1354
1355 case 'PhoneMobile':
1357 break;
1358
1359 case 'Fax':
1361 break;
1362
1363 case 'Hobby':
1365 break;
1366
1367 case 'GeneralInterest':
1368 case 'OfferingHelp':
1369 case 'LookingForHelp':
1371 break;
1372
1373 case 'Comment':
1375 break;
1376
1377 case 'Department':
1379 break;
1380
1381 case 'Matriculation':
1383 break;
1384
1385 case 'Active':
1387 break;
1388
1389 case 'ClientIP':
1391 break;
1392
1393 case 'TimeLimitOwner':
1394 $this->time_limit_owner_set = true;
1395 $this->user_obj->setTimeLimitOwner((int) $this->cdata);
1396 break;
1397
1398 case 'TimeLimitUnlimited':
1399 $this->time_limit_set = true;
1400 $this->user_obj->setTimeLimitUnlimited((bool) $this->cdata);
1401 break;
1402
1403 case 'TimeLimitFrom':
1404 if (is_numeric($this->cdata)) {
1405
1406 $this->user_obj->setTimeLimitFrom((int) $this->cdata);
1407 } else {
1408
1410 if (
$timestamp !==
false && trim($this->cdata) !==
'0000-00-00 00:00:00') {
1411 $this->user_obj->setTimeLimitFrom(
$timestamp);
1412 } elseif ($this->cdata === '0000-00-00 00:00:00') {
1413 $this->user_obj->setTimeLimitFrom(null);
1414 }
1415 }
1416 break;
1417
1418 case 'TimeLimitUntil':
1419 if (is_numeric($this->cdata)) {
1420
1421 $this->user_obj->setTimeLimitUntil((int) $this->cdata);
1422 } else {
1423
1425 if (
$timestamp !==
false && trim($this->cdata) !==
'0000-00-00 00:00:00') {
1426 $this->user_obj->setTimeLimitUntil(
$timestamp);
1427 } elseif ($this->cdata === '0000-00-00 00:00:00') {
1428 $this->user_obj->setTimeLimitUntil(null);
1429 }
1430 }
1431 break;
1432
1433 case 'ApproveDate':
1434 $this->approve_date_set = true;
1435 if (is_numeric($this->cdata)) {
1436
1439 } else {
1440
1442 if (
$timestamp !==
false && trim($this->cdata) !==
'0000-00-00 00:00:00') {
1445 } elseif ($this->cdata === '0000-00-00 00:00:00') {
1446 $this->user_obj->setApproveDate(null);
1447 }
1448 }
1449 break;
1450
1451 case 'AgreeDate':
1452 if (is_numeric($this->cdata)) {
1453
1456 } else {
1457
1459 if (
$timestamp !==
false && trim($this->cdata) !==
'0000-00-00 00:00:00') {
1462 } elseif ($this->cdata === '0000-00-00 00:00:00') {
1463 $this->user_obj->setAgreeDate(null);
1464 }
1465 }
1466 break;
1467
1468 case 'ExternalAccount':
1470 break;
1471
1472 case 'Look':
1473 $this->update_look_and_skin = false;
1474 if ($this->skin !== '' && $this->style !== '') {
1475 if (is_array($this->user_styles)) {
1476 if (in_array($this->skin . ':' . $this->style, $this->user_styles)) {
1477 $this->user_obj->setPref('skin', $this->skin);
1478 $this->user_obj->setPref('style', $this->style);
1479 $this->update_look_and_skin = true;
1480 }
1481 }
1482 }
1483 break;
1484
1485 case 'UserDefinedField':
1487
1488 if ($field_id === null) {
1490 }
1491
1492 if ($field_id === null) {
1493 break;
1494 }
1495
1497
1498 break;
1499 case 'AccountInfo':
1500 if ($this->current_messenger_type === 'external') {
1501 $this->user_obj->setExternalAccount($this->cdata);
1502 }
1503 break;
1504 case 'Pref':
1505 if ($this->current_pref_key != null && strlen(trim($this->cdata)) > 0
1508 }
1509 $this->current_pref_key = null;
1510 break;
1511 }
1512 }
foreach($mandatory_scripts as $file) $timestamp
static _getAuthModeName($a_auth_key)
@classDescription Date and time handling
static _lookupExternalAccount(int $a_user_id)
static getUserIdByLogin(string $a_login)
static _checkExternalAuthAccount(string $a_auth, string $a_account, bool $tryFallback=true)
check whether external account and authentication method matches with a user
static _getUsedHTMLTags(string $module='')
detachFromRole(ilObjUser $a_user_obj, int $a_role_id)
Detaches a user from a role.
const IL_IGNORE_ON_CONFLICT
addUDFDataToUser(\ilObjUser $user)
logSuccess(string $aLogin, int $userid, string $action)
Writes a success log message to the protocol.
updateMailPreferences(int $usr_id)
const IL_UPDATE_ON_CONFLICT
string $current_role_action
const IL_FAIL_ON_CONFLICT
checkProfileIncomplete(ilObjUser $user_obj)
Check if profile is incomplete Will set the usr_data field profile_incomplete if any required field i...
fetchFieldIdFromName(string $name)
assignToRoleWithParents(ilObjUser $a_user_obj, int $a_role_id)
Assigns a user to a role and to all parent roles.
sendAccountMail()
send account mail
tagContained(string $tagname)
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.
logWarning(string $aLogin, string $aMessage)
Writes a warning log message to the protocol.
fetchFieldIdFromImportId(string $import_id)
static isPrefExportable(string $key)
returns wether a key from db is exportable or not
const SYSTEM_USER_ID
This file contains constants for PHPStan analyis, see: https://phpstan.org/config-reference#constants...