@@ -68,32 +68,36 @@ class UwAddUsersForm extends FormBase {
...
@@ -68,32 +68,36 @@ class UwAddUsersForm extends FormBase {
// 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.',array('@user'=>$user)));
$this->messenger()->addError($this->t('The user ID <em>@user</em> is too long and was skipped.',['@user'=>$user]));
continue;
continue;
}
}
// Don't process user IDs with invalid characters.
// Don't process user IDs with invalid characters.
if(!preg_match('/^[a-z0-9]+$/',$user)){
if(!preg_match('/^[a-z0-9]+$/',$user)){
$this->messenger()->addError($this->t('The user ID <em>@user</em> contains invalid characters and was skipped.',array('@user'=>$user)));
$this->messenger()->addError($this->t('The user ID <em>@user</em> contains invalid characters and was skipped.',['@user'=>$user]));
continue;
continue;
}
}
$existing_user=user_load_by_name($user);
$existing_user=user_load_by_name($user);
if($existing_user){
if($existing_user){
$this->messenger()->addError($this->t('The user ID <a href="@link"><em>@user</em></a> already exists and was skipped.',array('@link'=>\Drupal::service('path_alias.manager')->getAliasByPath('/user/'.$existing_user->uid->value),'@user'=>$user)));
$this->messenger()->addError($this->t('The user ID <a href="@link"><em>@user</em></a> already exists and was skipped.',
$this->messenger()->addStatus($this->t('Created a new user with the user ID <a href="@link"><em>@user</em></a>.',array('@link'=>\Drupal::service('path_alias.manager')->getAliasByPath('/user/'.$new_user->uid->value),'@user'=>$user)));
$this->messenger()->addStatus($this->t('Created a new user with the user ID <a href="@link"><em>@user</em></a>.',