Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions languages/en.xml
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,7 @@
<string name="SYS_COLOR_SECONDARY">Secondary Color</string>
<string name="SYS_COLOR_SECONDARY_DESC">The secondary color used for Admidio. The side bar will use this color, as well as the preferences sections.</string>
<string name="SYS_COLUMN">Column</string>
<string name="SYS_COLUMN_POS">Column #VAR1#</string>
<string name="SYS_COLUMN_SELECTION">Column selection</string>
<string name="SYS_COLUMN_SELECTION_DESC">Selects the columns to be displayed in the list.\n\n Inactive roles are marked with (*).</string>
<string name="SYS_COMMA">Comma (,)</string>
Expand Down
7 changes: 7 additions & 0 deletions modules/contacts/import_column_config.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,13 @@
$categoryId = null;
$arrayImportableFields = array();

// Cleanup CSV columns: If a column does not have a header (null value), use its position instead
foreach ($arrayCsvColumns as $pos => $column) {
if (empty($column)) {
$arrayCsvColumns[$pos] = $gL10n->get('SYS_COLUMN_POS', array($pos));
}
}

$arrayImportableFields[] = array(
'cat_name' => $gL10n->get('SYS_BASIC_DATA'),
'cat_tooltip' => '',
Expand Down
32 changes: 21 additions & 11 deletions modules/contacts/import_user.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,9 @@
);
}

foreach ($line as $columnKey => $columnValue) {
if (empty($columnValue)) {
$columnValue = '';
}
foreach ($importProfileFields as $assignedFieldColumnId => $columnKey) {
$columnValue = $line[$columnKey] ?? '';

// get usf id or database column name
$assignedFieldColumnId = array_search($columnKey, $importProfileFields);
// remove spaces and html tags
$columnValue = trim(strip_tags($columnValue));

Expand All @@ -122,11 +118,25 @@
}

// add login data to the user
if ($userLoginName !== '' && $userPassword !== '') {
try {
$userImport->setLoginData($userLoginName, $userPassword);
} catch (Exception $e) {
$importMessages[] = $e->getMessage();
// Ideally, both username and password are set using the same import
// Setting username without password is possible (user needs to reset password to be able to log in)
// Setting the password only should only be possible if an existing user already has a username assigned
if ($userPassword !== '') {
if ($userLoginName == '') {
$userLoginName = $userImport->getValue('usr_login_name');
}
if (!empty($userLoginName)) {
try {
$userImport->setLoginData($userLoginName, $userPassword);
} catch (Exception $e) {
$importMessages[] = $e->getMessage();
}
} else {
$importMessages[] = $userImport->getValue('FIRST_NAME') . ' ' . $userImport->getValue('LAST_NAME') . ": password given for new user, but no username";
}
} else {
if (!empty($userLoginName)) {
$userImport->setValue('usr_login_name', $userLoginName);
}
}

Expand Down