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