Skip to content
Snippets Groups Projects
Commit f0e3351d authored by Igor Biki's avatar Igor Biki
Browse files

ISTWCMS-5983: Adding array_filter and array_map to remove empty lines, and...

ISTWCMS-5983: Adding array_filter and array_map to remove empty lines, and transform all to lower case.
parent 35f44885
No related branches found
No related tags found
3 merge requests!297Feature/istwcms 5983 bulk account creation,!274Draft: ISTWCMS-5551: fixing office hours display,!260Feature/istwcms 5668 a5kulkar rename references to publications
...@@ -98,21 +98,16 @@ class UwAddUsersForm extends FormBase { ...@@ -98,21 +98,16 @@ class UwAddUsersForm extends FormBase {
// Be nice and remove whitespace. // Be nice and remove whitespace.
$submitted_users = array_map('trim', $submitted_users); $submitted_users = array_map('trim', $submitted_users);
// Remove empty lines.
$submitted_users = array_filter($submitted_users);
// Apply to lower case on all lines.
$submitted_users = array_map('strtolower', $submitted_users);
// Remove any duplicates. // Remove any duplicates.
$submitted_users = array_unique($submitted_users); $submitted_users = array_unique($submitted_users);
// Step through each of the submitted users to create if needed/possible, // Step through each of the submitted users to create if needed/possible,
// or show a message if not. // or show a message if not.
foreach ($submitted_users as $user) { foreach ($submitted_users as $user) {
// Make sure the user ID is in lower case.
$user = strtolower($user);
// Ignore blank lines.
if ($user === '') {
continue;
}
// Don't process long user IDs. // Don't process long user IDs.
if (strlen($user) > 8) { if (strlen($user) > 8) {
$this->messenger()->addError($this->t('The user ID <em>@user</em> is too long and was skipped.', ['@user' => $user])); $this->messenger()->addError($this->t('The user ID <em>@user</em> is too long and was skipped.', ['@user' => $user]));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment