diff --git a/app/commands/AssetImportCommand.php b/app/commands/AssetImportCommand.php index deca799ae0..8b74920661 100644 --- a/app/commands/AssetImportCommand.php +++ b/app/commands/AssetImportCommand.php @@ -187,12 +187,17 @@ class AssetImportCommand extends Command { $last_name = $user_email_array['last_name']; if ($user_email=='') { - $user_email = $user_email_array['username'].'@'.$this->option('domain'); + $user_email = $user_email_array['username'].'@'.Config::get('app.domain'); } if ($user_username=='') { - $user_name_array = User::generateFormattedNameFromFullName($this->option('username_format'), $user_name); - $user_username = $user_name_array['username']; + if ($this->option('username_format')=='email') { + $user_username = $user_email; + } else { + $user_name_array = User::generateFormattedNameFromFullName($this->option('username_format'), $user_name); + $user_username = $user_name_array['username']; + } + } } @@ -394,12 +399,11 @@ class AssetImportCommand extends Command { */ protected function getOptions() { - return array( - array('domain', null, InputOption::VALUE_REQUIRED, 'Email domain for generated email addresses.', null), - array('email_format', null, InputOption::VALUE_REQUIRED, 'The format of the email addresses that should be generated. Options are firstname.lastname, firstname, filastname', null), - array('username_format', null, InputOption::VALUE_REQUIRED, 'The format of the username that should be generated. Options are firstname.lastname, firstname, filastname, email', null), - array('testrun', null, InputOption::VALUE_REQUIRED, 'Test the output without writing to the database or not.', null), - ); + return array( + array('email_format', null, InputOption::VALUE_REQUIRED, 'The format of the email addresses that should be generated. Options are firstname.lastname, firstname, filastname', null), + array('username_format', null, InputOption::VALUE_REQUIRED, 'The format of the username that should be generated. Options are firstname.lastname, firstname, filastname, email', null), + array('testrun', null, InputOption::VALUE_REQUIRED, 'Test the output without writing to the database or not.', null), + ); } diff --git a/app/config/local/app.example.php b/app/config/local/app.example.php index 47f934d51d..c0c28ca49d 100755 --- a/app/config/local/app.example.php +++ b/app/config/local/app.example.php @@ -28,6 +28,19 @@ return array( 'url' => 'http://snipe-it-laravel.local:8888', + + /* + |-------------------------------------------------------------------------- + | Organization Domain Name + |-------------------------------------------------------------------------- + | + | The domain name of the organization, used when generating email addresses + | through the import tools. + | + */ + + 'domain' => 'yourserver.com', + /* |-------------------------------------------------------------------------- | Encryption Key @@ -37,7 +50,7 @@ return array( | to a random, 32 character string, otherwise these encrypted strings | will not be safe. Please do this before deploying an application! | - | Run a php artisan key:generate to create a random one + | Run a php artisan key:generate --env=staging to create a random one */ 'key' => 'Change_this_key_or_snipe_will_get_ya', diff --git a/app/config/production/app.example.php b/app/config/production/app.example.php index b8c349fe61..90d3fbe580 100755 --- a/app/config/production/app.example.php +++ b/app/config/production/app.example.php @@ -28,6 +28,19 @@ return array( 'url' => 'https://production.yourserver.com', + + /* + |-------------------------------------------------------------------------- + | Organization Domain Name + |-------------------------------------------------------------------------- + | + | The domain name of the organization, used when generating email addresses + | through the import tools. + | + */ + + 'domain' => 'yourserver.com', + /* |-------------------------------------------------------------------------- | Encryption Key diff --git a/app/config/staging/app.example.php b/app/config/staging/app.example.php index d17fded8e6..e1eeb5e106 100755 --- a/app/config/staging/app.example.php +++ b/app/config/staging/app.example.php @@ -13,7 +13,7 @@ return array( | */ - 'debug' => true, + 'debug' => false, /* |-------------------------------------------------------------------------- @@ -28,6 +28,19 @@ return array( 'url' => 'http://staging.yourserver.com', + + /* + |-------------------------------------------------------------------------- + | Organization Domain Name + |-------------------------------------------------------------------------- + | + | The domain name of the organization, used when generating email addresses + | through the import tools. + | + */ + + 'domain' => 'yourserver.com', + /* |-------------------------------------------------------------------------- | Encryption Key diff --git a/app/config/version.php b/app/config/version.php index b4e23fecde..c47bc5607c 100644 --- a/app/config/version.php +++ b/app/config/version.php @@ -1,5 +1,5 @@ 'v2.0-165', - 'hash_version' => 'v2.0-165-g66fd0c2', + 'app_version' => 'v2.0-169', + 'hash_version' => 'v2.0-169-ge75ceba', ); \ No newline at end of file diff --git a/app/models/User.php b/app/models/User.php index 42596d4624..4f51934e10 100755 --- a/app/models/User.php +++ b/app/models/User.php @@ -157,46 +157,6 @@ class User extends SentryUserModel } - public static function generateUsernameFromFullName($format = 'filastname', $domain, $users_name) { - - $name = explode(" ", $users_name); - $first_name = $name[0]; - $username_last_name = ''; - $username = $username_last_name; - - // If there is no last name given - if (!array_key_exists(1, $name)) { - $last_name=''; - $username_last_name = $last_name; - $username = $first_name; - - // There is a last name given - } else { - - $last_name = str_replace($first_name,'',$username); - - if ($format=='filastname') { - $email_last_name.=str_replace(' ','',$last_name); - $email_prefix = $first_name[0].$email_last_name; - - } elseif ($format=='firstname.lastname') { - $email_last_name.=str_replace(' ','',$last_name); - $email_prefix = $first_name.'.'.$email_last_name; - - } elseif ($format=='firstname') { - $email_last_name.=str_replace(' ','',$last_name); - $email_prefix = $first_name; - - } elseif ($format=='email') { - $email_last_name.=str_replace(' ','',$last_name); - $email_prefix = $first_name; - } - - - } - - } - public static function generateFormattedNameFromFullName($format = 'filastname', $users_name) { $name = explode(" ", $users_name); $name = str_replace("'", '', $name);