mirror of
https://github.com/snipe/snipe-it.git
synced 2024-11-09 23:24:06 -08:00
Merge pull request #8254 from Godmartinz/gmartinez_adds_email_formats
Added firstinitial.lastname, lastname_firstinitial, firstnamelastname…
This commit is contained in:
commit
2fa17ac185
|
@ -379,6 +379,18 @@ class User extends SnipeModel implements AuthenticatableContract, CanResetPasswo
|
|||
} elseif ($format=='firstname') {
|
||||
$username = str_slug($first_name);
|
||||
}
|
||||
elseif ($format=='firstinitial.lastname') {
|
||||
$username = str_slug(substr($first_name, 0, 1). '.' . str_slug($last_name));
|
||||
}
|
||||
elseif ($format=='lastname_firstinitial') {
|
||||
$username = str_slug($last_name).'_'.str_slug(substr($first_name, 0, 1));
|
||||
}
|
||||
elseif ($format=='firstnamelastname') {
|
||||
$username = str_slug($first_name) . str_slug($last_name);
|
||||
}
|
||||
elseif ($format=='firstnamelastinitial') {
|
||||
$username = str_slug(($first_name.substr($last_name, 0, 1)));
|
||||
}
|
||||
}
|
||||
|
||||
$user['first_name'] = $first_name;
|
||||
|
|
|
@ -88,6 +88,9 @@
|
|||
'firstname_lastname_underscore_format' => 'First Name Last Name (jane_smith@example.com)',
|
||||
'lastnamefirstinitial_format' => 'Last Name First Initial (smithj@example.com)',
|
||||
'first' => 'First',
|
||||
'firstnamelastname' => 'First Name Last Name (janesmith@example.com)',
|
||||
'lastname_firstinitial' => 'Last Name First Initial (smith_j@example.com)',
|
||||
'firstinitial.lastname' => 'First Initial Last Name (j.smith@example.com)', 'first' => 'First',
|
||||
'first_name' => 'First Name',
|
||||
'first_name_format' => 'First Name (jane@example.com)',
|
||||
'files' => 'Files',
|
||||
|
|
|
@ -88,6 +88,11 @@
|
|||
'firstname_lastname_underscore_format' => 'First Name Last Name (jane_smith@example.com)',
|
||||
'lastnamefirstinitial_format' => 'Last Name First Initial (smithj@example.com)',
|
||||
'first' => 'First',
|
||||
'firstnamelastname' => 'First Name Last Name (janesmith@example.com)',
|
||||
'lastname_firstinitial' => 'Last Name First Initial (smith_j@example.com)',
|
||||
'firstinitial.lastname' => 'First Initial Last Name (j.smith@example.com)',
|
||||
'firstnamelastinitial' => 'First Name Last Initial (janes@example.com)',
|
||||
'first' => 'First',
|
||||
'first_name' => 'First Name',
|
||||
'first_name_format' => 'First Name (jane@example.com)',
|
||||
'files' => 'Files',
|
||||
|
|
|
@ -469,7 +469,10 @@ Form::macro('username_format', function ($name = "username_format", $selected =
|
|||
'filastname' => trans('general.filastname_format'),
|
||||
'lastnamefirstinitial' => trans('general.lastnamefirstinitial_format'),
|
||||
'firstname_lastname' => trans('general.firstname_lastname_underscore_format'),
|
||||
|
||||
'firstinitial.lastname' => trans('general.firstinitial.lastname'),
|
||||
'lastname_firstinitial' => trans('general.lastname_firstinitial'),
|
||||
'firstnamelastname' => trans('general.firstnamelastname'),
|
||||
'firstnamelastinitial' => trans('general.firstnamelastinitial')
|
||||
);
|
||||
|
||||
$select = '<select name="'.$name.'" class="'.$class.'" style="width: 100%" aria-label="'.$name.'">';
|
||||
|
|
|
@ -74,7 +74,7 @@ class UserTest extends BaseTest
|
|||
public function testFirstInitialUnderscoreLastName()
|
||||
{
|
||||
$fullname = "Natalia Allanovna Romanova-O'Shostakova";
|
||||
$expected_username = 'natalia_allanovna-romanova-oshostakova';
|
||||
$expected_username = 'n_allanovna-romanova-oshostakova';
|
||||
$user = User::generateFormattedNameFromFullName('firstname_lastname', $fullname);
|
||||
$this->assertEquals($expected_username, $user['username']);
|
||||
}
|
||||
|
@ -86,6 +86,33 @@ class UserTest extends BaseTest
|
|||
$user = User::generateFormattedNameFromFullName('firstname_lastname', $fullname);
|
||||
$this->assertEquals($expected_username, $user['username']);
|
||||
}
|
||||
|
||||
public function firstInitialDotLastname()
|
||||
{
|
||||
$fullname = "Natalia Allanovna Romanova-O'Shostakova";
|
||||
$expected_username = 'n.allanovnaromanovaoshostakova';
|
||||
$user = User::generateFormattedNameFromFullName('firstinitial.lastname', $fullname);
|
||||
$this->assertEquals($expected_username, $user['username']);
|
||||
}
|
||||
public function lastNameUnderscoreFirstInitial()
|
||||
{
|
||||
$fullname = "Natalia Allanovna Romanova-O'Shostakova";
|
||||
$expected_username = 'allanovnaromanovaoshostakova_n';
|
||||
$user = User::generateFormattedNameFromFullName('lastname_firstinitial', $fullname);
|
||||
$this->assertEquals($expected_username, $user['username']);
|
||||
}
|
||||
public function firstNameLastName()
|
||||
{
|
||||
$fullname = "Natalia Allanovna Romanova-O'Shostakova";
|
||||
$expected_username = 'nataliaallanovnaromanovaoshostakova';
|
||||
$user = User::generateFormattedNameFromFullName('firstnamelastname', $fullname);
|
||||
$this->assertEquals($expected_username, $user['username']);
|
||||
}
|
||||
public function firstNameLastInitial()
|
||||
{
|
||||
$fullname = "Natalia Allanovna Romanova-O'Shostakova";
|
||||
$expected_username = 'nataliaa';
|
||||
$user = User::generateFormattedNameFromFullName('firstnamelastinitial', $fullname);
|
||||
$this->assertEquals($expected_username, $user['username']);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue