From 4037200fadeaa7353e2a18809ddbca58cbf0f7fb Mon Sep 17 00:00:00 2001 From: snipe Date: Mon, 11 Jan 2016 18:39:40 -0800 Subject: [PATCH] Additional fields for user import --- app/config/version.php | 2 +- app/controllers/admin/UsersController.php | 22 +++++++++++++++++++--- app/views/backend/users/import.blade.php | 6 +++++- 3 files changed, 25 insertions(+), 5 deletions(-) diff --git a/app/config/version.php b/app/config/version.php index f041e2820f..a52b9d121c 100644 --- a/app/config/version.php +++ b/app/config/version.php @@ -1,5 +1,5 @@ 'v2.1.0-pre', - 'hash_version' => 'v2.1.0-pre-21-gce6b2f2', + 'hash_version' => 'v2.1.0-pre-22-g9800786', ); \ No newline at end of file diff --git a/app/controllers/admin/UsersController.php b/app/controllers/admin/UsersController.php index f7d3bf4341..d92f3dc182 100755 --- a/app/controllers/admin/UsersController.php +++ b/app/controllers/admin/UsersController.php @@ -810,7 +810,15 @@ class UsersController extends AdminController { $activated = '0'; } - $pass = substr(str_shuffle("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), 0, 10); + $pass = substr(str_shuffle("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), 0, 15); + + // Location + if (array_key_exists('4',$row)) { + $user_location_id = trim($row[4]); + if ($user_location_id=='') { + $user_location_id = null; + } + } @@ -821,6 +829,11 @@ class UsersController extends AdminController { $duplicates .= $row[2] . ', '; } else { + // echo '
';
+                      // print_r($row);
+                      // echo '
'; + // exit; + $newuser = array( 'first_name' => $row[0], 'last_name' => $row[1], @@ -828,8 +841,11 @@ class UsersController extends AdminController { 'email' => $row[3], 'password' => $pass, 'activated' => $activated, - 'location_id' => $row[4], - //'company_id' => Company::getIdForUser($row[5]), + 'location_id' => $user_location_id, + 'phone' => $row[5], + 'jobtitle' => $row[6], + 'employee_num' => $row[7], + //'company_id' => Company::getIdForUser($row[8]), 'permissions' => '{"user":1}', 'notes' => 'Imported user' ); diff --git a/app/views/backend/users/import.blade.php b/app/views/backend/users/import.blade.php index 5699a8e333..5a03e07153 100644 --- a/app/views/backend/users/import.blade.php +++ b/app/views/backend/users/import.blade.php @@ -38,7 +38,11 @@ Create a User :: @endif

- Upload a CSV file with one or more users. Passwords will be auto-generated. The CSV should have the first fields as: firstName,lastName,username,email, location_id. Any additional fields to the right of those fields will be ignored. Email is optional, however users will not be able to recover their passwords or receive EULAs if you do not provide an email address. + Upload a CSV file with one or more users. Passwords will be auto-generated. The CSV should have the first fields as:

+ +

firstName,lastName, username, email, location_id, phone, jobtitle, employee_num.

+ +

Any additional fields to the right of those fields will be ignored. Email is optional, however users will not be able to recover their passwords or receive EULAs if you do not provide an email address.

@if (Config::get('app.lock_passwords'))