53 return View::make(
'users/index');
67 $userGroups = Input::old(
'groups', array());
70 $permissions = config(
'permissions');
73 $userPermissions = Input::old(
'permissions', array(
'superuser' => -1));
85 return View::make(
'users/edit', compact(
'groups',
'userGroups',
'permissions',
'userPermissions'))
86 ->with(
'location_list', $location_list)
87 ->with(
'manager_list', $manager_list)
88 ->with(
'company_list', $company_list)
89 ->with(
'user',
new User);
103 $user->first_name = $data[
'first_name']= e(Input::get(
'first_name'));
104 $user->last_name = e(Input::get(
'last_name'));
105 $user->email = $data[
'email'] = e(Input::get(
'email'));
106 $user->activated = 1;
107 $user->locale = e(Input::get(
'locale'));
108 $user->username = $data[
'username'] = e(Input::get(
'username'));
109 $user->password = bcrypt(Input::get(
'password'));
110 $data[
'password'] = Input::get(
'password');
113 if ((Input::get(
'email_user') == 1) && (Input::has(
'email'))) {
116 $data[
'email'] = e(Input::get(
'email'));
117 $data[
'username'] = e(Input::get(
'username'));
118 $data[
'first_name'] = e(Input::get(
'first_name'));
119 $data[
'password'] = e(Input::get(
'password'));
121 Mail::send(
'emails.send-login', $data,
function ($m) use ($user) {
122 $m->to($user->email, $user->first_name .
' ' . $user->last_name);
123 $m->subject(
'Welcome ' . $user->first_name);
126 return redirect::route(
'users')->with(
'success', trans(
'admin/users/message.success.create'));
128 Redirect::back()->withInput()->withInput()->withErrors($user->getErrors())->withErrors($settings->getErrors());
131 return Redirect::route(
'create/user')->withInput()->with(
'error', $error);
145 $inputs = Input::except(
'csrf_token',
'password_confirm',
'groups',
'email_user');
146 $inputs[
'activated'] =
true;
151 if (Input::get(
'email_user') == 1) {
154 $data[
'email'] = e(Input::get(
'email'));
155 $data[
'first_name'] = e(Input::get(
'first_name'));
156 $data[
'password'] = e(Input::get(
'password'));
158 Mail::send(
'emails.send-login', $data,
function ($m) use ($user) {
159 $m->to($user->email, $user->first_name .
' ' . $user->last_name);
160 $m->subject(
'Welcome ' . $user->first_name);
164 return JsonResponse::create($user);
167 return JsonResponse::create([
"error" =>
"Failed validation: " . print_r($user->getErrors(),
true)], 500);
169 return JsonResponse::create([
"error" =>
"Couldn't save User"], 500);
187 $user = User::find($id);
190 return Redirect::route(
'users')->with(
'error', trans(
'general.insufficient_permissions'));
198 $userPermissions = null;
205 $permissions = config(
'permissions');
210 $manager_list = array(
'' =>
'Select a User') + DB::table(
'users')
211 ->select(DB::raw(
'concat(last_name,", ",first_name," (",email,")") as full_name, id'))
212 ->whereNull(
'deleted_at')
213 ->where(
'id',
'!=', $id)
214 ->orderBy(
'last_name',
'asc')
215 ->orderBy(
'first_name',
'asc')
216 ->lists(
'full_name',
'id');
217 }
catch (UserNotFoundException $e) {
219 $error = trans(
'admin/users/message.user_not_found', compact(
'id'));
222 return Redirect::route(
'users')->with(
'error', $error);
226 return View::make(
'users/edit', compact(
'user',
'groups',
'userGroups',
'permissions',
'userPermissions'))
227 ->with(
'location_list', $location_list)
228 ->with(
'company_list', $company_list)
229 ->with(
'manager_list', $manager_list);
244 $permissions = Input::get(
'permissions', array());
246 app(
'request')->request->set(
'permissions', $permissions);
249 if (config(
'app.lock_passwords')) {
250 return Redirect::route(
'users')->with(
'error',
'Denied! You cannot update user information on the demo.');
255 $user = User::find($id);
258 return Redirect::route(
'users')->with(
'error', trans(
'general.insufficient_permissions'));
260 }
catch (UserNotFoundException $e) {
262 $error = trans(
'admin/users/message.user_not_found', compact(
'id'));
265 return Redirect::route(
'users')->with(
'error', $error);
270 $user->first_name = e(Input::get(
'first_name'));
271 $user->last_name = e(Input::get(
'last_name'));
272 $user->locale = e(Input::get(
'locale'));
273 $user->username = e(Input::get(
'username'));
274 $user->email = e(Input::get(
'email'));
275 $user->employee_num = e(Input::get(
'employee_num'));
276 $user->activated = e(Input::get(
'activated', $user->activated));
277 $user->jobtitle = e(Input::get(
'jobtitle'));
278 $user->phone = e(Input::get(
'phone'));
279 $user->location_id = e(Input::get(
'location_id'));
281 $user->manager_id = e(Input::get(
'manager_id'));
282 $user->notes = e(Input::get(
'notes'));
284 if ($user->manager_id ==
"") {
285 $user->manager_id = null;
288 if ($user->location_id ==
"") {
289 $user->location_id = null;
294 if ((Input::has(
'password')) && (!config(
'app.lock_passwords'))) {
295 $user->password = bcrypt(Input::get(
'password'));
299 if (!config(
'app.lock_passwords')) {
300 $user->email = Input::get(
'email');
304 if (!config(
'app.lock_passwords')) {
311 $success = trans(
'admin/users/message.success.update');
314 return Redirect::route(
'users')->with(
'success', $success);
317 return Redirect::back()->withInput()->withErrors($user->getErrors());
333 $user = User::find($id);
336 if ($user->id === Auth::user()->id) {
338 $error = trans(
'admin/users/message.error.delete');
341 return Redirect::route(
'users')->with(
'error', $error);
346 if ((!Auth::user()->isSuperUser()) || (config(
'app.lock_passwords'))) {
348 return Redirect::route(
'users')->with(
'error',
'Insufficient permissions!');
351 if (count($user->assets) > 0) {
354 return Redirect::route(
'users')->with(
'error',
'This user still has ' . count($user->assets) .
' assets associated with them.');
357 if (count($user->licenses) > 0) {
360 return Redirect::route(
'users')->with(
'error',
'This user still has ' . count($user->licenses) .
' licenses associated with them.');
367 $success = trans(
'admin/users/message.success.delete');
370 return Redirect::route(
'users')->with(
'success', $success);
371 }
catch (UserNotFoundException $e) {
373 $error = trans(
'admin/users/message.user_not_found', compact(
'id'));
376 return Redirect::route(
'users')->with(
'error', $error);
390 if ((!Input::has(
'edit_user')) || (count(Input::has(
'edit_user')) == 0)) {
391 return Redirect::back()->with(
'error',
'No users selected');
394 $user_raw_array = array_keys(Input::get(
'edit_user'));
396 $users = User::whereIn(
'id', $user_raw_array)->with(
'groups');
399 return View::make(
'users/confirm-bulk-delete', compact(
'users',
'statuslabel_list'));
413 if ((!Input::has(
'edit_user')) || (count(Input::has(
'edit_user')) == 0)) {
414 return Redirect::back()->with(
'error',
'No users selected');
415 } elseif ((!Input::has(
'status_id')) || (count(Input::has(
'status_id')) == 0)) {
416 return Redirect::route(
'users')->with(
'error',
'No status selected');
419 $user_raw_array = Input::get(
'edit_user');
420 $asset_array = array();
422 if (($key = array_search(Auth::user()->
id, $user_raw_array)) !==
false) {
423 unset($user_raw_array[$key]);
426 if (!Auth::user()->isSuperUser()) {
427 return Redirect::route(
'users')->with(
'error', trans(
'admin/users/message.insufficient_permissions'));
430 if (!config(
'app.lock_passwords')) {
432 $assets = Asset::whereIn(
'assigned_to', $user_raw_array)->get();
433 $accessories = DB::table(
'accessories_users')->whereIn(
'assigned_to', $user_raw_array)->get();
435 $users = User::whereIn(
'id', $user_raw_array);
438 foreach ($assets as $asset) {
440 $asset_array[] = $asset->id;
444 $logaction->asset_id = $asset->id;
445 $logaction->checkedout_to = $asset->assigned_to;
446 $logaction->asset_type =
'hardware';
447 $logaction->user_id = Auth::user()->id;
448 $logaction->note =
'Bulk checkin';
449 $log = $logaction->logaction(
'checkin from');
451 $update_assets = Asset::whereIn(
'id', $asset_array)->update(
453 'status_id' => e(Input::get(
'status_id')),
454 'assigned_to' => null,
459 foreach ($accessories as $accessory) {
460 $accessory_array[] = $accessory->id;
463 $logaction->accessory_id = $accessory->id;
464 $logaction->checkedout_to = $accessory->assigned_to;
465 $logaction->asset_type =
'accessory';
466 $logaction->user_id = Auth::user()->id;
467 $logaction->note =
'Bulk checkin';
468 $log = $logaction->logaction(
'checkin from');
470 $update_accessories = DB::table(
'accessories_users')->whereIn(
'id', $accessory_array)->update(
472 'assigned_to' => null,
478 return Redirect::route(
'users')->with(
'success',
'Your selected users have been deleted and their assets have been updated.');
480 return Redirect::route(
'users')->with(
'error',
'Bulk delete is not enabled in this installation');
484 return Redirect::route(
'users')->with(
'error',
'An error has occurred');
503 return Redirect::route(
'users')->with(
'error', trans(
'general.insufficient_permissions'));
509 $success = trans(
'admin/users/message.success.restored');
512 return Redirect::route(
'users')->with(
'success', $success);
514 }
catch (UserNotFoundException $e) {
516 $error = trans(
'admin/users/message.user_not_found', compact(
'id'));
519 return Redirect::route(
'users')->with(
'error', $error);
535 $user = User::with(
'assets',
'assets.model',
'consumables',
'accessories',
'licenses',
'userloc')->withTrashed()->find($userId);
537 $userlog = $user->userlog->load(
'assetlog',
'consumablelog',
'assetlog.model',
'licenselog',
'accessorylog',
'userlog',
'adminlog');
539 if (isset($user->id)) {
542 return Redirect::route(
'users')->with(
'error', trans(
'general.insufficient_permissions'));
544 return View::make(
'users/view', compact(
'user',
'userlog'));
548 $error = trans(
'admin/users/message.user_not_found', compact(
'id'));
551 return Redirect::route(
'users')->with(
'error', $error);
570 if ($user->id === Auth::user()->id) {
572 $error = trans(
'admin/users/message.error.unsuspend');
575 return Redirect::route(
'users')->with(
'error', $error);
579 if ($user->isSuperUser() and ! Auth::user()->isSuperUser()) {
581 return Redirect::route(
'users')->with(
'error',
'Insufficient permissions!');
585 $success = trans(
'admin/users/message.success.unsuspend');
588 return Redirect::route(
'users')->with(
'success', $success);
589 }
catch (UserNotFoundException $e) {
591 $error = trans(
'admin/users/message.user_not_found', compact(
'id'));
594 return Redirect::route(
'users')->with(
'error', $error);
612 $permissions = Input::get(
'permissions', array());
614 app(
'request')->request->set(
'permissions', $permissions);
619 $user_to_clone = User::find($id);
620 $user = clone $user_to_clone;
621 $user->first_name =
'';
622 $user->last_name =
'';
623 $user->email = substr($user->email, ($pos = strpos($user->email,
'@')) !==
false ? $pos : 0);
628 $userGroups = $user_to_clone->groups()->lists(
'group_id',
'name');
631 $userPermissions = null;
638 $permissions = config(
'permissions');
643 $manager_list = array(
'' =>
'Select a User') + DB::table(
'users')
644 ->select(DB::raw(
'concat(last_name,", ",first_name," (",email,")") as full_name, id'))
645 ->whereNull(
'deleted_at')
646 ->where(
'id',
'!=', $id)
647 ->orderBy(
'last_name',
'asc')
648 ->orderBy(
'first_name',
'asc')
649 ->lists(
'full_name',
'id');
652 return View::make(
'users/edit', compact(
'groups',
'userGroups',
'permissions',
'userPermissions'))
653 ->with(
'location_list', $location_list)
654 ->with(
'company_list', $company_list)
655 ->with(
'manager_list', $manager_list)
656 ->with(
'user', $user)
657 ->with(
'clone_user', $user_to_clone);
658 }
catch (UserNotFoundException $e) {
660 $error = trans(
'admin/users/message.user_not_found', compact(
'id'));
663 return Redirect::route(
'users')->with(
'error', $error);
679 $selectedGroups = Input::old(
'groups', array());
681 $permissions = config(
'permissions');
684 $selectedPermissions = Input::old(
'permissions', array(
'superuser' => -1));
687 return View::make(
'users/import', compact(
'groups',
'selectedGroups',
'permissions',
'selectedPermissions'));
700 if (!ini_get(
"auto_detect_line_endings")) {
701 ini_set(
"auto_detect_line_endings",
'1');
704 $csv = Reader::createFromPath(Input::file(
'user_import_csv'));
705 $csv->setNewline(
"\r\n");
707 if (Input::get(
'has_headers') == 1) {
713 $nbInsert = $csv->each(
function ($row) use ($duplicates) {
715 if (array_key_exists(2, $row)) {
717 if (Input::get(
'activate') == 1) {
723 $pass = substr(str_shuffle(
"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), 0, 15);
726 if (array_key_exists(
'4', $row)) {
727 $user_location_id = trim($row[4]);
728 if ($user_location_id==
'') {
729 $user_location_id = null;
737 $user = DB::table(
'users')->where(
'username', $row[2])->first();
739 $duplicates .= $row[2] .
', ';
743 'first_name' => trim(e($row[0])),
744 'last_name' => trim(e($row[1])),
745 'username' => trim(e($row[2])),
746 'email' => trim(e($row[3])),
748 'activated' => $activated,
749 'location_id' => trim(e($user_location_id)),
750 'phone' => trim(e($row[5])),
751 'jobtitle' => trim(e($row[6])),
752 'employee_num' => trim(e($row[7])),
754 'permissions' =>
'{"user":1}',
755 'notes' =>
'Imported user' 758 DB::table(
'users')->insert($newuser);
760 $updateuser = User::find($row[2]);
763 $updateuser->password = $pass;
769 if (((Input::get(
'email_user') == 1) && !config(
'app.lock_passwords'))) {
773 $data[
'username'] = trim(e($row[2]));
774 $data[
'first_name'] = trim(e($row[0]));
775 $data[
'password'] = $pass;
777 if ($newuser[
'email']) {
778 Mail::send(
'emails.send-login', $data,
function ($m) use ($newuser) {
779 $m->to($newuser[
'email'], $newuser[
'first_name'] .
' ' . $newuser[
'last_name']);
780 $m->subject(
'Welcome ' . $newuser[
'first_name']);
787 echo
'Caught exception: ', $e->getMessage(),
"\n";
794 return Redirect::route(
'users')->with(
'duplicates', $duplicates)->with(
'success',
'Success');
808 if (Input::has(
'offset')) {
809 $offset = e(Input::get(
'offset'));
814 if (Input::has(
'limit')) {
815 $limit = e(Input::get(
'limit'));
820 if (Input::get(
'sort')==
'name') {
821 $sort =
'first_name';
823 $sort = e(Input::get(
'sort'));
826 $users = User::select(array(
'users.id',
'users.employee_num',
'users.email',
'users.username',
'users.location_id',
'users.manager_id',
'users.first_name',
'users.last_name',
'users.created_at',
'users.notes',
'users.company_id',
'users.deleted_at',
'users.activated'))
827 ->with(
'assets',
'accessories',
'consumables',
'licenses',
'manager',
'groups',
'userloc',
'company');
832 $users = $users->withTrashed()->Deleted();
836 if (Input::has(
'search')) {
837 $users = $users->TextSearch(Input::get(
'search'));
840 $order = Input::get(
'order') ===
'asc' ?
'asc' :
'desc';
842 switch (Input::get(
'sort')) {
844 $users = $users->OrderManager($order);
847 $users = $users->OrderLocation($order);
852 'last_name',
'first_name',
'email',
'username',
'employee_num',
853 'assets',
'accessories',
'consumables',
'licenses',
'groups',
'activated' 856 $sort = in_array($sort, $allowed_columns) ? $sort :
'first_name';
857 $users = $users->orderBy($sort, $order);
861 $userCount = $users->count();
862 $users = $users->skip($offset)->take($limit)->get();
865 foreach ($users as $user) {
870 foreach ($user->groups as $group) {
871 $group_names .=
'<a href="' . config(
'app.url') .
'/admin/groups/' . $group->id .
'/edit" class="label label-default">' . $group->name .
'</a> ';
875 if (!is_null($user->deleted_at)) {
877 $actions .=
'<a href="' . route(
'restore/user', $user->id) .
'" class="btn btn-warning btn-sm"><i class="fa fa-share icon-white"></i></a> ';
880 if ($user->accountStatus() ==
'suspended') {
881 $actions .=
'<a href="' . route(
'unsuspend/user', $user->id) .
'" class="btn btn-default btn-sm"><span class="fa fa-clock-o"></span></a> ';
884 $actions .=
'<a href="' . route(
'update/user', $user->id) .
'" class="btn btn-warning btn-sm"><i class="fa fa-pencil icon-white"></i></a> ';
886 if ((Auth::user()->
id !== $user->id) && (!config(
'app.lock_passwords'))) {
887 $actions .=
'<a data-html="false" class="btn delete-asset btn-danger btn-sm" data-toggle="modal" href="' . route(
'delete/user', $user->id) .
'" data-content="Are you sure you wish to delete this user?" data-title="Delete ' . htmlspecialchars($user->first_name) .
'?" onClick="return false;"><i class="fa fa-trash icon-white"></i></a> ';
889 $actions .=
' <span class="btn delete-asset btn-danger btn-sm disabled"><i class="fa fa-trash icon-white"></i></span>';
892 $actions .=
'</nobr>';
896 'checkbox' =>
'<div class="text-center hidden-xs hidden-sm"><input type="checkbox" name="edit_user['.e($user->id).
']" class="one_required"></div>',
897 'name' =>
'<a title="'.e($user->fullName()).
'" href="../admin/users/'.e($user->id).
'/view">'.e($user->fullName()).
'</a>',
898 'email' => ($user->email!=
'') ?
899 '<a href="mailto:'.e($user->email).
'" class="hidden-md hidden-lg">'.e($user->email).
'</a>' 900 .
'<a href="mailto:'.e($user->email).
'" class="hidden-xs hidden-sm"><i class="fa fa-envelope"></i></a>' 902 'username' => e($user->username),
903 'location' => ($user->userloc) ? e($user->userloc->name) :
'',
904 'manager' => ($user->manager) ?
'<a title="' . e($user->manager->fullName()) .
'" href="users/' . e($user->manager->id) .
'/view">' . e($user->manager->fullName()) .
'</a>' :
'',
905 'assets' => $user->assets->count(),
906 'employee_num' => e($user->employee_num),
907 'licenses' => $user->licenses->count(),
908 'accessories' => $user->accessories->count(),
909 'consumables' => $user->consumables->count(),
910 'groups' => $group_names,
911 'notes' => e($user->notes),
912 'activated' => ($user->activated==
'1') ?
'<i class="fa fa-check"></i>' :
'<i class="fa fa-times"></i>',
913 'actions' => ($actions) ? $actions :
'',
914 'companyName' => is_null($user->company) ?
'' : e($user->company->name)
918 $data = array(
'total'=>$userCount,
'rows'=>$rows);
934 $user = User::find($userId);
935 $destinationPath = config(
'app.private_uploads') .
'/users';
937 if (isset($user->id)) {
940 return Redirect::route(
'users')->with(
'error', trans(
'general.insufficient_permissions'));
943 foreach (Input::file(
'file') as $file) {
945 $extension = $file->getClientOriginalExtension();
946 $filename =
'user-' . $user->id .
'-' . str_random(8);
947 $filename .=
'-' . str_slug($file->getClientOriginalName()) .
'.' . $extension;
948 $upload_success = $file->move($destinationPath, $filename);
952 $logaction->asset_id = $user->id;
953 $logaction->asset_type =
'user';
954 $logaction->user_id = Auth::user()->id;
955 $logaction->note = e(Input::get(
'notes'));
956 $logaction->checkedout_to = null;
957 $logaction->created_at = date(
"Y-m-d h:i:s");
958 $logaction->filename = $filename;
959 $logaction->action_type =
'uploaded';
963 return JsonResponse::create($logaction);
966 return JsonResponse::create([
"error" =>
"Failed validation: ".print_r($logaction->getErrors(),
true)], 500);
982 $user = User::find($userId);
983 $destinationPath = config(
'app.private_uploads').
'/users';
986 if (isset($user->id)) {
989 return Redirect::route(
'users')->with(
'error', trans(
'general.insufficient_permissions'));
991 $log = Actionlog::find($fileId);
992 $full_filename = $destinationPath .
'/' . $log->filename;
993 if (file_exists($full_filename)) {
994 unlink($destinationPath .
'/' . $log->filename);
997 return Redirect::back()->with(
'success', trans(
'admin/users/message.deletefile.success'));
1001 $error = trans(
'admin/users/message.does_not_exist', compact(
'id'));
1004 return Redirect::route(
'users')->with(
'error', $error);
1020 $user = User::find($userId);
1023 if (isset($user->id)) {
1025 return Redirect::route(
'users')->with(
'error', trans(
'general.insufficient_permissions'));
1027 $log = Actionlog::find($fileId);
1028 $file = $log->get_src();
1029 return Response::download($file);
1033 $error = trans(
'admin/users/message.does_not_exist', compact(
'id'));
1036 return Redirect::route(
'users')->with(
'error', $error);
1052 $selectedGroups = Input::old(
'groups', array());
1054 $permissions = config(
'permissions');
1057 $selectedPermissions = Input::old(
'permissions', array(
'superuser' => -1));
1063 return View::make(
'users/ldap', compact(
'groups',
'selectedGroups',
'permissions',
'selectedPermissions'))
1064 ->with(
'location_list', $location_list);
1081 'firstname' =>
'required|string|min:2',
1082 'lastname' =>
'required|string|min:2',
1083 'employee_number' =>
'string',
1084 'username' =>
'required|min:2|unique:users,username',
1085 'email' =>
'email|unique:users,email',
1098 $location_id = e(Input::get(
'location_id'));
1118 if ($ldap_server_cert_ignore) {
1119 putenv(
'LDAPTLS_REQCERT=never');
1123 $ldapconn = @ldap_connect($url);
1126 ldap_set_option($ldapconn, LDAP_OPT_REFERRALS, 0);
1129 return Redirect::route(
'users')->with(
'error', trans(
'admin/users/message.error.ldap_could_not_connect'));
1133 $ldapopt = @ldap_set_option($ldapconn, LDAP_OPT_PROTOCOL_VERSION, $ldap_version);
1135 return Redirect::route(
'users')->with(
'error', trans(
'admin/users/message.error.ldap_could_not_connect'));
1139 $ldapbind = @ldap_bind($ldapconn, $username, $password);
1141 Log::error(ldap_errno($ldapconn));
1143 return Redirect::route(
'users')->with(
'error', trans(
'admin/users/message.error.ldap_could_not_bind').ldap_error($ldapconn));
1150 $result_set = array();
1156 ldap_control_paged_result($ldapconn, $page_size,
false, $cookie);
1158 $search_results = ldap_search($ldapconn, $base_dn,
'('.$filter.
')');
1160 if (!$search_results) {
1161 return Redirect::route(
'users')->with(
'error', trans(
'admin/users/message.error.ldap_could_not_search').ldap_error($ldapconn));
1165 $results = ldap_get_entries($ldapconn, $search_results);
1167 return Redirect::route(
'users')->with(
'error', trans(
'admin/users/message.error.ldap_could_not_get_entries').ldap_error($ldapconn));
1171 $global_count += $results[
'count'];
1172 $result_set = array_merge($result_set, $results);
1174 ldap_control_paged_result_response($ldapconn, $search_results, $cookie);
1176 }
while ($cookie !== null && $cookie !=
'');
1180 $result_set[
'count'] = $global_count;
1181 $results = $result_set;
1182 ldap_control_paged_result($ldapconn, 0);
1186 for ($i = 0; $i < $results[
"count"]; $i++) {
1187 if (empty($ldap_result_active_flag) || $results[$i][$ldap_result_active_flag][0] ==
"TRUE") {
1190 $item[
"username"] = isset($results[$i][$ldap_result_username][0]) ? $results[$i][$ldap_result_username][0] :
"";
1191 $item[
"employee_number"] = isset($results[$i][$ldap_result_emp_num][0]) ? $results[$i][$ldap_result_emp_num][0] :
"";
1192 $item[
"lastname"] = isset($results[$i][$ldap_result_last_name][0]) ? $results[$i][$ldap_result_last_name][0] :
"";
1193 $item[
"firstname"] = isset($results[$i][$ldap_result_first_name][0]) ? $results[$i][$ldap_result_first_name][0] :
"";
1194 $item[
"email"] = isset($results[$i][$ldap_result_email][0]) ? $results[$i][$ldap_result_email][0] :
"" ;
1197 $item[
"createorupdate"] =
'updated';
1198 if (!$user = User::where(
'username', $item[
"username"])->first()) {
1200 $item[
"createorupdate"] =
'created';
1205 $pass = substr(str_shuffle(
"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), 0, 20);
1207 $user->first_name = e($item[
"firstname"]);
1208 $user->last_name = e($item[
"lastname"]);
1209 $user->username = e($item[
"username"]);
1210 $user->email = e($item[
"email"]);
1211 $user->employee_num = e($item[
"employee_number"]);
1212 $user->password = bcrypt($pass);
1213 $user->activated = 1;
1214 $user->location_id = e($location_id);
1215 $user->permissions =
'{"user":1}';
1216 $user->notes =
'Imported from LDAP';
1217 $user->ldap_import = 1;
1221 if ($user->save()) {
1222 $item[
"note"] = $item[
"createorupdate"];
1223 $item[
"status"]=
'success';
1226 foreach ($user->getErrors()->getMessages() as $key => $err) {
1228 $errors .=
'<li>'.$err[0];
1230 $item[
"note"] = $errors;
1231 $item[
"status"]=
'error';
1234 array_push($summary, $item);
1241 return Redirect::route(
'ldap/user')->with(
'success',
"OK")->with(
'summary', $summary);
1253 $assets = Asset::where(
'assigned_to',
'=', $userId)->get();
1254 return response()->json($assets);
static getIdForUser($unescaped_input)
store()
JSON handler for creating a user through a modal.
Model for the Actionlog (the table that keeps a historical log of checkouts, checkins, and updates).
postLDAP()
LDAP form processing.
getIndex()
Returns a view that invokes the ajax tables which actually contains the content for the users listing...
getRestore($id=null)
Restore a deleted user.
postBulkSave()
Soft-delete bulk users.
displayFile($userId=null, $fileId=null)
Display/download the uploaded file.
postImport()
Handle user import file.
This controller handles all actions related to Users for the Snipe-IT Asset Management application...
getView($userId=null)
Return a view with user detail.
postEdit($id=null)
Validate and save edited user data from edit form.
static isCurrentUserHasAccess($companyable)
getDelete($id=null)
Delete a user.
postBulkEdit()
Returns a view that confirms the user's a bulk delete will be applied to.
postUpload(AssetFileRequest $request, $userId=null)
Return JSON response with a list of user details for the getIndex() view.
getLDAP()
Return view for LDAP import.
getCreate()
Returns a view that displays the user creation form.
getUnsuspend($id=null)
Unsuspend a user.
static scopeCompanyables($query, $column= 'company_id')
getAssetList($userId)
Return JSON containing a list of assets assigned to a user.
getEdit($id=null)
Returns a view that displays the edit user form.
getClone($id=null)
Return a view containing a pre-populated new user form, populated with some fields from an existing u...
postCreate(SetupUserRequest $request)
Validate and store the new user data, or return an error.
getImport()
Return user import view.
getDatatable($status=null)
Return JSON response with a list of user details for the getIndex() view.
getDeleteFile($userId=null, $fileId=null)
Delete file.