798 : void {
799 $this->contained_tags[] = $a_name;
800
801 switch ($a_name) {
802 case 'Role':
806 break;
807
808 case 'PersonalPicture':
809 switch ($this->personal_picture['encoding']) {
810 case 'Base64':
811 $this->personal_picture['content'] = base64_decode($this->cdata);
812 break;
813 case 'UUEncode':
814 $this->personal_picture['content'] = convert_uudecode($this->cdata);
815 break;
816 }
817 break;
818
819 case 'User':
820 $this->user_obj->setFullname();
821
822
823 if ($this->user_id == -1 || $this->action === 'Insert') {
825 } else {
827 }
828
830 return;
831 }
832
833
834 switch ($this->conflict_rule) {
836
837 break;
839 switch ($this->action) {
840 case 'Insert':
842 $this->
logWarning($this->user_obj->getLogin(), sprintf($this->
lng->txt(
'usrimport_action_replaced'),
'Insert',
'Update'));
843 $this->action = 'Update';
844 }
845 break;
846 case 'Update':
848 $this->
logWarning($this->user_obj->getLogin(), sprintf($this->
lng->txt(
'usrimport_action_replaced'),
'Update',
'Insert'));
849 $this->action = 'Insert';
850 }
851 break;
852 case 'Delete':
854 $this->
logWarning($this->user_obj->getLogin(), sprintf($this->
lng->txt(
'usrimport_action_ignored'),
'Delete'));
855 $this->action = 'Ignore';
856 }
857 break;
858 }
859 break;
861 switch ($this->action) {
862 case 'Insert':
864 $this->
logWarning($this->user_obj->getLogin(), sprintf($this->
lng->txt(
'usrimport_action_ignored'),
'Insert'));
865 $this->action = 'Ignore';
866 }
867 break;
868 case 'Update':
870 $this->
logWarning($this->user_obj->getLogin(), sprintf($this->
lng->txt(
'usrimport_action_ignored'),
'Update'));
871 $this->action = 'Ignore';
872 }
873 break;
874 case 'Delete':
876 $this->
logWarning($this->user_obj->getLogin(), sprintf($this->
lng->txt(
'usrimport_action_ignored'),
'Delete'));
877 $this->action = 'Ignore';
878 }
879 break;
880 }
881 break;
882 }
883
884
885
886
887
888 $am = ($this->user_obj->getAuthMode() === 'default' || $this->user_obj->getAuthMode() == '')
890 : $this->user_obj->getAuthMode();
891 $loginForExternalAccount = ($this->user_obj->getExternalAccount() == '')
892 ? ''
894 switch ($this->action) {
895 case 'Insert':
896 if ($loginForExternalAccount != '') {
898 $this->user_obj->getLogin(),
899 $this->lng->txt('usrimport_no_insert_ext_account_exists')
900 . ' (' . $this->stripTags($this->user_obj->getExternalAccount()) . ')'
901 );
902 $this->action = 'Ignore';
903 }
904 break;
905
906 case 'Update':
907
908
909
910
911 if ($loginForExternalAccount != '') {
912
914
915 if ($externalAccountHasChanged && trim($loginForExternalAccount) != trim($this->user_obj->getLogin())) {
917 $this->user_obj->getLogin(),
918 $this->lng->txt('usrimport_no_update_ext_account_exists')
919 . ' (' . $this->stripTags($this->user_obj->getExternalAccount()) . ')'
920 );
921 $this->action = 'Ignore';
922 }
923 }
924 break;
925 }
926
927 if (count($this->multi_values)) {
928 if (isset($this->multi_values['GeneralInterest'])) {
929 $this->user_obj->setGeneralInterests($this->multi_values['GeneralInterest']);
930 }
931 if (isset($this->multi_values['OfferingHelp'])) {
932 $this->user_obj->setOfferingHelp($this->multi_values['OfferingHelp']);
933 }
934 if (isset($this->multi_values['LookingForHelp'])) {
935 $this->user_obj->setLookingForHelp($this->multi_values['LookingForHelp']);
936 }
937 }
938
939
940 switch ($this->action) {
941 case 'Insert':
943 $this->
logFailure($this->user_obj->getLogin(), $this->lng->txt(
'usrimport_cant_insert'));
944 } else {
945 if ($this->current_user_password !== null) {
946 switch (strtoupper($this->current_user_password_type)) {
947 case 'BCRYPT':
949 $this->user_obj->setPasswordEncodingType('bcryptphp');
950 $this->user_obj->setPasswordSalt(null);
951 break;
952
953 case 'PLAIN':
955 $this->acc_mail->setUserPassword((string) $this->current_user_password);
956 break;
957
958 default:
959 $this->
logFailure($this->user_obj->getLogin(), sprintf($this->
lng->txt(
'usrimport_xml_attribute_value_illegal'),
'Type',
'Password', $this->stripTags($this->current_user_password_type)));
960 break;
961 }
962 } else {
963
964
965
966
968 }
969
970 $this->user_obj->setTitle($this->user_obj->getFullname());
971 $this->user_obj->setDescription($this->user_obj->getEmail());
972
973 if (!$this->time_limit_owner_set) {
974 $this->user_obj->setTimeLimitOwner($this->
getFolderId());
975 }
976
977
978 if (!$this->time_limit_set) {
979 $this->user_obj->setTimeLimitUnlimited(true);
980
981 if (!$this->approve_date_set) {
982 $this->user_obj->setApproveDate(date('Y-m-d H:i:s'));
983 }
984 }
985
986
987 $this->user_obj->setActive($this->currActive === 'true' || is_null($this->currActive));
988
989
990
991
992
993 if ($this->udf_data !== []) {
995 }
996
997 if (!$this->user_obj->getLanguage()) {
998 $this->user_obj->setLanguage($this->
lng->getDefaultLanguage());
999 }
1000
1002 $this->user_obj->create();
1003
1004
1005 $this->user_obj->saveAsNew();
1006
1007 if (count($this->prefs)) {
1008 foreach ($this->prefs as $key => $value) {
1009 if ($key !== 'mail_incoming_type' &&
1010 $key !== 'mail_signature' &&
1011 $key !== 'mail_linebreak'
1012 ) {
1013 $this->user_obj->setPref($key, $value);
1014 }
1015 }
1016 }
1017
1018 if (!is_array($this->prefs) || !array_key_exists('chat_osc_accept_msg', $this->prefs)) {
1019 $this->user_obj->setPref(
'chat_osc_accept_msg', $this->
settings->get(
'chat_osc_accept_msg',
'n'));
1020 }
1021 if (!is_array($this->prefs) || !array_key_exists('chat_broadcast_typing', $this->prefs)) {
1022 $this->user_obj->setPref(
'chat_broadcast_typing', $this->
settings->get(
'chat_broadcast_typing',
'n'));
1023 }
1024 if (!is_array($this->prefs) || !array_key_exists('bs_allow_to_contact_me', $this->prefs)) {
1025 $this->user_obj->setPref(
'bs_allow_to_contact_me', $this->
settings->get(
'bs_allow_to_contact_me',
'n'));
1026 }
1027
1028 $this->user_obj->writePrefs();
1029
1030
1032
1033 if (is_array($this->personal_picture)) {
1034 if (strlen($this->personal_picture['content'])) {
1035 $extension = 'jpg';
1036 if (preg_match('/.*(png|jpg|gif|jpeg)$/', $this->personal_picture['imagetype'], $matches)) {
1037 $extension = $matches[1];
1038 }
1039 $tmp_name = $this->
saveTempImage($this->personal_picture[
'content'],
".{$extension}");
1040 if (strlen($tmp_name)) {
1041 $this->user_obj->uploadPersonalPicture($tmp_name);
1042 unlink($tmp_name);
1043 }
1044 }
1045 }
1046
1047
1048 foreach ($this->roles as $role_id => $role) {
1049 if (isset($this->role_assign[$role_id]) && $this->role_assign[$role_id]) {
1050 $this->
assignToRole($this->user_obj, (
int) $this->role_assign[$role_id]);
1051 }
1052 }
1053
1055 $this->
logSuccess($this->user_obj->getLogin(), $this->user_obj->getId(),
'Insert');
1056
1057 $this->acc_mail->reset();
1058 }
1059 break;
1060
1061 case 'Update':
1063 $this->
logFailure($this->user_obj->getLogin(), $this->lng->txt(
'usrimport_cant_update'));
1064 } else {
1066 $update_user->read();
1067 if ($this->current_user_password != null) {
1068 switch (strtoupper($this->current_user_password_type)) {
1069 case 'BCRYPT':
1071 $update_user->setPasswordEncodingType('bcryptphp');
1072 $update_user->setPasswordSalt(null);
1073 break;
1074
1075 case 'PLAIN':
1077 $this->acc_mail->setUserPassword((string) $this->current_user_password);
1078 break;
1079
1080 default:
1081 $this->
logFailure($this->user_obj->getLogin(), sprintf($this->
lng->txt(
'usrimport_xml_attribute_value_illegal'),
'Type',
'Password', $this->stripTags($this->current_user_password_type)));
1082 break;
1083 }
1084 }
1086 $update_user->setFirstname($this->user_obj->getFirstname());
1087 }
1089 $update_user->setLastname($this->user_obj->getLastname());
1090 }
1092 $update_user->setUTitle($this->user_obj->getUTitle());
1093 }
1095 $update_user->setGender($this->user_obj->getGender());
1096 }
1098 $update_user->setEmail($this->user_obj->getEmail());
1099 }
1101 $update_user->setSecondEmail($this->user_obj->getSecondEmail());
1102 }
1104 $update_user->setBirthday($this->user_obj->getBirthday());
1105 }
1107 $update_user->setInstitution($this->user_obj->getInstitution());
1108 }
1110 $update_user->setStreet($this->user_obj->getStreet());
1111 }
1113 $update_user->setCity($this->user_obj->getCity());
1114 }
1116 $update_user->setZipcode($this->user_obj->getZipcode());
1117 }
1119 $update_user->setCountry($this->user_obj->getCountry());
1120 }
1122 $update_user->setPhoneOffice($this->user_obj->getPhoneOffice());
1123 }
1125 $update_user->setPhoneHome($this->user_obj->getPhoneHome());
1126 }
1128 $update_user->setPhoneMobile($this->user_obj->getPhoneMobile());
1129 }
1131 $update_user->setFax($this->user_obj->getFax());
1132 }
1134 $update_user->setHobby($this->user_obj->getHobby());
1135 }
1137 $update_user->setGeneralInterests($this->user_obj->getGeneralInterests());
1138 }
1140 $update_user->setOfferingHelp($this->user_obj->getOfferingHelp());
1141 }
1143 $update_user->setLookingForHelp($this->user_obj->getLookingForHelp());
1144 }
1146 $update_user->setComment($this->user_obj->getComment());
1147 }
1149 $update_user->setDepartment($this->user_obj->getDepartment());
1150 }
1152 $update_user->setMatriculation($this->user_obj->getMatriculation());
1153 }
1154 if (!is_null($this->currActive)) {
1155 $update_user->setActive($this->currActive ===
'true', is_object($this->
user) ? $this->
user->getId() : 0);
1156 }
1158 $update_user->setClientIP($this->user_obj->getClientIP());
1159 }
1160 if ($this->time_limit_set) {
1161 $update_user->setTimeLimitUnlimited($this->user_obj->getTimeLimitUnlimited());
1162 }
1164 $update_user->setTimeLimitFrom($this->user_obj->getTimeLimitFrom());
1165 }
1167 $update_user->setTimeLimitUntil($this->user_obj->getTimeLimitUntil());
1168 }
1170 $update_user->setApproveDate($this->user_obj->getApproveDate());
1171 }
1173 $update_user->setAgreeDate($this->user_obj->getAgreeDate());
1174 }
1176 $update_user->setLanguage($this->user_obj->getLanguage());
1177 }
1179 $update_user->setExternalAccount($this->user_obj->getExternalAccount());
1180 }
1181
1182
1183 #if (! is_null($this->userObj->getAuthMode())) $updateUser->setAuthMode($this->userObj->getAuthMode());
1184 if ($this->auth_mode_set) {
1185 $update_user->setAuthMode($this->user_obj->getAuthMode());
1186 }
1187
1188
1189 if ($this->time_limit_owner_set) {
1190 $update_user->setTimeLimitOwner($this->user_obj->getTimeLimitOwner());
1191 }
1192
1193 if (count($this->prefs)) {
1194 foreach ($this->prefs as $key => $value) {
1195 if ($key !== 'mail_incoming_type' &&
1196 $key !== 'mail_signature' &&
1197 $key !== 'mail_linebreak'
1198 ) {
1199 $update_user->setPref($key, $value);
1200 }
1201 }
1202 }
1203
1204
1205 if ($this->update_look_and_skin) {
1206 $update_user->setPref('skin', $this->user_obj->getPref('skin'));
1207 $update_user->setPref('style', $this->user_obj->getPref('style'));
1208 }
1209
1210
1212
1213
1214 if ($this->udf_data !== []) {
1216 }
1217
1219 $update_user->setFullname();
1220 $update_user->setTitle($update_user->getFullname());
1221 $update_user->setDescription($update_user->getEmail());
1222 $update_user->update();
1223
1224
1225 if ($this->
tagContained(
'Login') && $this->user_id != -1) {
1226 try {
1227 $update_user->updateLogin($this->user_obj->getLogin());
1229 }
1230 }
1231
1232
1233
1234
1235 if (is_array($this->personal_picture)) {
1236 if (strlen($this->personal_picture['content'])) {
1237 $extension = 'jpg';
1238 if (preg_match('/.*(png|jpg|gif|jpeg)$/', $this->personal_picture['imagetype'], $matches)) {
1239 $extension = $matches[1];
1240 }
1241 $tmp_name = $this->
saveTempImage($this->personal_picture[
'content'],
".{$extension}");
1242 if (strlen($tmp_name)) {
1243 $update_user->uploadPersonalPicture($tmp_name);
1244 unlink($tmp_name);
1245 }
1246 }
1247 }
1248
1249
1250
1251
1252 foreach ($this->roles as $role_id => $role) {
1253 if (array_key_exists($role_id, $this->role_assign)) {
1254 switch ($role['action']) {
1255 case 'Assign':
1256 $this->
assignToRole($update_user, (
int) $this->role_assign[$role_id]);
1257 break;
1258 case 'AssignWithParents':
1260 break;
1261 case 'Detach':
1262 $this->
detachFromRole($update_user, (
int) $this->role_assign[$role_id]);
1263 break;
1264 }
1265 }
1266 }
1268 }
1269 break;
1270 case 'Delete':
1272 $this->
logFailure($this->user_obj->getLogin(), $this->lng->txt(
'usrimport_cant_delete'));
1273 } else {
1275 $deleteUser->delete();
1276
1278 }
1279 break;
1280 }
1281
1282
1283 $this->roles = [];
1284 break;
1285
1286 case 'Login':
1288 break;
1289
1290 case 'Password':
1292 break;
1293
1294 case 'Firstname':
1296 break;
1297
1298 case 'Lastname':
1300 break;
1301
1302 case 'Title':
1304 break;
1305
1306 case 'Gender':
1307 $this->user_obj->setGender($this->cdata);
1308 break;
1309
1310 case 'Email':
1312 break;
1313 case 'SecondEmail':
1315 break;
1316 case 'Birthday':
1318 if (strtotime($birthday) !== false) {
1319 $this->user_obj->setBirthday($birthday);
1320 }
1321 break;
1322 case 'Institution':
1324 break;
1325
1326 case 'Street':
1328 break;
1329
1330 case 'City':
1332 break;
1333
1334 case 'PostalCode':
1336 break;
1337
1338 case 'Country':
1340 break;
1341
1342 case 'SelCountry':
1344 break;
1345
1346 case 'PhoneOffice':
1348 break;
1349
1350 case 'PhoneHome':
1352 break;
1353
1354 case 'PhoneMobile':
1356 break;
1357
1358 case 'Fax':
1360 break;
1361
1362 case 'Hobby':
1364 break;
1365
1366 case 'GeneralInterest':
1367 case 'OfferingHelp':
1368 case 'LookingForHelp':
1370 break;
1371
1372 case 'Comment':
1374 break;
1375
1376 case 'Department':
1378 break;
1379
1380 case 'Matriculation':
1382 break;
1383
1384 case 'Active':
1386 break;
1387
1388 case 'ClientIP':
1390 break;
1391
1392 case 'TimeLimitOwner':
1393 $this->time_limit_owner_set = true;
1394 $this->user_obj->setTimeLimitOwner((int) $this->cdata);
1395 break;
1396
1397 case 'TimeLimitUnlimited':
1398 $this->time_limit_set = true;
1399 $this->user_obj->setTimeLimitUnlimited((bool) $this->cdata);
1400 break;
1401
1402 case 'TimeLimitFrom':
1403 if (is_numeric($this->cdata)) {
1404
1405 $this->user_obj->setTimeLimitFrom((int) $this->cdata);
1406 } else {
1407
1409 if (
$timestamp !==
false && trim($this->cdata) !==
'0000-00-00 00:00:00') {
1410 $this->user_obj->setTimeLimitFrom(
$timestamp);
1411 } elseif ($this->cdata === '0000-00-00 00:00:00') {
1412 $this->user_obj->setTimeLimitFrom(null);
1413 }
1414 }
1415 break;
1416
1417 case 'TimeLimitUntil':
1418 if (is_numeric($this->cdata)) {
1419
1420 $this->user_obj->setTimeLimitUntil((int) $this->cdata);
1421 } else {
1422
1424 if (
$timestamp !==
false && trim($this->cdata) !==
'0000-00-00 00:00:00') {
1425 $this->user_obj->setTimeLimitUntil(
$timestamp);
1426 } elseif ($this->cdata === '0000-00-00 00:00:00') {
1427 $this->user_obj->setTimeLimitUntil(null);
1428 }
1429 }
1430 break;
1431
1432 case 'ApproveDate':
1433 $this->approve_date_set = true;
1434 if (is_numeric($this->cdata)) {
1435
1438 } else {
1439
1441 if (
$timestamp !==
false && trim($this->cdata) !==
'0000-00-00 00:00:00') {
1444 } elseif ($this->cdata === '0000-00-00 00:00:00') {
1445 $this->user_obj->setApproveDate(null);
1446 }
1447 }
1448 break;
1449
1450 case 'AgreeDate':
1451 if (is_numeric($this->cdata)) {
1452
1455 } else {
1456
1458 if (
$timestamp !==
false && trim($this->cdata) !==
'0000-00-00 00:00:00') {
1461 } elseif ($this->cdata === '0000-00-00 00:00:00') {
1462 $this->user_obj->setAgreeDate(null);
1463 }
1464 }
1465 break;
1466
1467 case 'ExternalAccount':
1469 break;
1470
1471 case 'Look':
1472 $this->update_look_and_skin = false;
1473 if ($this->skin !== '' && $this->style !== '') {
1474 if (is_array($this->user_styles)) {
1475 if (in_array($this->skin . ':' . $this->style, $this->user_styles)) {
1476 $this->user_obj->setPref('skin', $this->skin);
1477 $this->user_obj->setPref('style', $this->style);
1478 $this->update_look_and_skin = true;
1479 }
1480 }
1481 }
1482 break;
1483
1484 case 'UserDefinedField':
1486
1487 if ($field_id === null) {
1489 }
1490
1491 if ($field_id === null) {
1492 break;
1493 }
1494
1496
1497 break;
1498 case 'AccountInfo':
1499 if ($this->current_messenger_type === 'external') {
1500 $this->user_obj->setExternalAccount($this->cdata);
1501 }
1502 break;
1503 case 'Pref':
1504 if ($this->current_pref_key != null && strlen(trim($this->cdata)) > 0
1507 }
1508 $this->current_pref_key = null;
1509 break;
1510 }
1511 }
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...