User resource routes

This commit is contained in:
snipe 2016-12-15 20:52:39 -08:00
parent 76344a8c9b
commit 9ea05bacf3
19 changed files with 175 additions and 177 deletions

View file

@ -338,34 +338,12 @@ class ReportsController extends Controller
$rows = array();
foreach ($activitylogs as $activity) {
// This is janky AF and should be handled better.
if ($activity->itemType() == "asset") {
$routename = 'assets';
$activity_icons = '<i class="fa fa-barcode"></i>';
} elseif ($activity->itemType() == "accessory") {
$routename = 'accessories';
$activity_icons = '<i class="fa fa-keyboard-o"></i>';
} elseif ($activity->itemType()=="consumable") {
$routename = 'consumables';
$activity_icons = '<i class="fa fa-tint"></i>';
} elseif ($activity->itemType()=="license"){
$routename = 'licenses';
$activity_icons = '<i class="fa fa-floppy-o"></i>';
} elseif ($activity->itemType()=="component") {
$routename = 'components';
$activity_icons = '<i class="fa fa-hdd-o"></i>';
} else {
$activity_icons = '<i class="fa fa-paperclip"></i>';
}
if (($activity->item) && ($activity->itemType()=="asset")) {
$activity_item = '<a href="'.route('hardware.show', $activity->item_id).'">'.e($activity->item->asset_tag).' - '. e($activity->item->showAssetName()).'</a>';
$item_type = 'asset';
} elseif ($activity->item) {
$activity_item = '<a href="' . route($routename.'.show', $activity->item_id) . '">' . e($activity->item->name) . '</a>';
$activity_item = '<a href="' . route($activity->parseItemRoute().'.show', $activity->item_id) . '">' . e($activity->item->name) . '</a>';
$item_type = $activity->itemType();
} else {
$activity_item = "unkonwn";
$item_type = "null";
@ -373,7 +351,7 @@ class ReportsController extends Controller
if (($activity->user) && ($activity->action_type=="uploaded") && ($activity->itemType()=="user")) {
$activity_target = '<a href="'.route('view/user', $activity->target_id).'">'.$activity->user->fullName().'</a>';
$activity_target = '<a href="'.route('users.show', $activity->target_id).'">'.$activity->user->fullName().'</a>';
} elseif ($activity->target_type === "App\Models\Asset") {
if($activity->target) {
$activity_target = '<a href="'.route('hardware.show', $activity->target_id).'">'.$activity->target->showAssetName().'</a>';
@ -382,16 +360,16 @@ class ReportsController extends Controller
}
} elseif ( $activity->target_type === "App\Models\User") {
if($activity->target) {
$activity_target = '<a href="'.route('view/user', $activity->target_id).'">'.$activity->target->fullName().'</a>';
$activity_target = '<a href="'.route('users.show', $activity->target_id).'">'.$activity->target->fullName().'</a>';
} else {
$activity_target = '';
}
} elseif (($activity->action_type=='accepted') || ($activity->action_type=='declined')) {
$activity_target = '<a href="' . route('view/user', $activity->item->assigneduser->id) . '">' . e($activity->item->assigneduser->fullName()) . '</a>';
$activity_target = '<a href="' . route('users.show', $activity->item->assigneduser->id) . '">' . e($activity->item->assigneduser->fullName()) . '</a>';
} elseif ($activity->action_type=='requested') {
if ($activity->user) {
$activity_target = '<a href="'.route('view/user', $activity->user_id).'">'.$activity->user->fullName().'</a>';
$activity_target = '<a href="'.route('users.show', $activity->user_id).'">'.$activity->user->fullName().'</a>';
} else {
$activity_target = '';
}
@ -405,7 +383,7 @@ class ReportsController extends Controller
$rows[] = array(
'icon' => $activity_icons,
'icon' => '<i class="'.$activity->parseItemIcon().'"></i>',
'created_at' => date("M d, Y g:iA", strtotime($activity->created_at)),
'action_type' => strtolower(trans('general.'.str_replace(' ','_',$activity->action_type))),
'admin' => $activity->user ? (string) link_to('/admin/users/'.$activity->user_id.'/view', $activity->user->fullName()) : '',

View file

@ -57,7 +57,7 @@ class UsersController extends Controller
* @since [v1.0]
* @return View
*/
public function getIndex()
public function index()
{
return View::make('users/index');
}
@ -69,7 +69,7 @@ class UsersController extends Controller
* @since [v1.0]
* @return View
*/
public function getCreate()
public function create()
{
$groups = Group::pluck('name', 'id');
@ -102,7 +102,7 @@ class UsersController extends Controller
* @since [v1.0]
* @return Redirect
*/
public function postCreate(SaveUserRequest $request)
public function store(SaveUserRequest $request)
{
$user = new User;
@ -189,7 +189,7 @@ class UsersController extends Controller
* @since [v1.8]
* @return string JSON
*/
public function store()
public function apiStore()
{
$user = new User;
@ -255,7 +255,7 @@ class UsersController extends Controller
return $output;
}
public function getEdit($id = null)
public function edit($id = null)
{
try {
// Get the user information
@ -263,7 +263,7 @@ class UsersController extends Controller
$permissions = config('permissions');
if (!Company::isCurrentUserHasAccess($user)) {
return redirect()->route('users')->with('error', trans('general.insufficient_permissions'));
return redirect()->route('users.index')->with('error', trans('general.insufficient_permissions'));
}
$groups = Group::pluck('name', 'id');
@ -280,7 +280,7 @@ class UsersController extends Controller
$error = trans('admin/users/message.user_not_found', compact('id'));
// Redirect to the user management page
return redirect()->route('users')->with('error', $error);
return redirect()->route('users.index')->with('error', $error);
}
// Show the page
@ -298,7 +298,7 @@ class UsersController extends Controller
* @param int $id
* @return Redirect
*/
public function postEdit(UpdateUserRequest $request, $id = null)
public function update(UpdateUserRequest $request, $id = null)
{
// We need to reverse the UI specific logic for our
// permissions here before we update the user.
@ -306,7 +306,7 @@ class UsersController extends Controller
app('request')->request->set('permissions', $permissions);
// Only update the email address if locking is set to false
if (config('app.lock_passwords')) {
return redirect()->route('users')->with('error', 'Denied! You cannot update user information on the demo.');
return redirect()->route('users.index')->with('error', 'Denied! You cannot update user information on the demo.');
}
try {
@ -328,12 +328,12 @@ class UsersController extends Controller
if (!Company::isCurrentUserHasAccess($user)) {
return redirect()->route('users')->with('error', trans('general.insufficient_permissions'));
return redirect()->route('users.index')->with('error', trans('general.insufficient_permissions'));
}
} catch (UserNotFoundException $e) {
$error = trans('admin/users/message.user_not_found', compact('id'));
return redirect()->route('users')->with('error', $error);
return redirect()->route('users.index')->with('error', $error);
}
@ -402,7 +402,7 @@ class UsersController extends Controller
$success = trans('admin/users/message.success.update');
// Redirect to the user page
return redirect()->route('users')->with('success', $success);
return redirect()->route('users.index')->with('success', $success);
}
return redirect()->back()->withInput()->withErrors($user->getErrors());
@ -417,7 +417,7 @@ class UsersController extends Controller
* @param int $id
* @return Redirect
*/
public function getDelete($id = null)
public function destroy($id = null)
{
try {
// Get user information
@ -429,32 +429,32 @@ class UsersController extends Controller
$error = trans('admin/users/message.error.delete');
// Redirect to the user management page
return redirect()->route('users')->with('error', $error);
return redirect()->route('users.index')->with('error', $error);
}
// Do we have permission to delete this user?
if ((!Auth::user()->isSuperUser()) || (config('app.lock_passwords'))) {
// Redirect to the user management page
return redirect()->route('users')->with('error', 'Insufficient permissions!');
return redirect()->route('users.index')->with('error', 'Insufficient permissions!');
}
if (count($user->assets) > 0) {
// Redirect to the user management page
return redirect()->route('users')->with('error', 'This user still has ' . count($user->assets) . ' assets associated with them.');
return redirect()->route('users.index')->with('error', 'This user still has ' . count($user->assets) . ' assets associated with them.');
}
if (count($user->licenses) > 0) {
// Redirect to the user management page
return redirect()->route('users')->with('error', 'This user still has ' . count($user->licenses) . ' licenses associated with them.');
return redirect()->route('users.index')->with('error', 'This user still has ' . count($user->licenses) . ' licenses associated with them.');
}
if (count($user->accessories) > 0) {
// Redirect to the user management page
return redirect()->route('users')->with('error', 'This user still has ' . count($user->accessories) . ' accessories associated with them.');
return redirect()->route('users.index')->with('error', 'This user still has ' . count($user->accessories) . ' accessories associated with them.');
}
// Delete the user
@ -464,13 +464,13 @@ class UsersController extends Controller
$success = trans('admin/users/message.success.delete');
// Redirect to the user management page
return redirect()->route('users')->with('success', $success);
return redirect()->route('users.index')->with('success', $success);
} catch (UserNotFoundException $e) {
// Prepare the error message
$error = trans('admin/users/message.user_not_found', compact('id'));
// Redirect to the user management page
return redirect()->route('users')->with('error', $error);
return redirect()->route('users.index')->with('error', $error);
}
}
@ -513,7 +513,7 @@ class UsersController extends Controller
if ((!Input::has('edit_user')) || (count(Input::has('edit_user')) == 0)) {
return redirect()->back()->with('error', 'No users selected');
} elseif ((!Input::has('status_id')) || (count(Input::has('status_id')) == 0)) {
return redirect()->route('users')->with('error', 'No status selected');
return redirect()->route('users.index')->with('error', 'No status selected');
} else {
$user_raw_array = Input::get('edit_user');
@ -524,7 +524,7 @@ class UsersController extends Controller
}
if (!Auth::user()->isSuperUser()) {
return redirect()->route('users')->with('error', trans('admin/users/message.insufficient_permissions'));
return redirect()->route('users.index')->with('error', trans('admin/users/message.insufficient_permissions'));
}
if (!config('app.lock_passwords')) {
@ -595,12 +595,9 @@ class UsersController extends Controller
$user->delete();
}
return redirect()->route('users')->with('success', 'Your selected users have been deleted and their assets have been updated.');
return redirect()->route('users.index')->with('success', 'Your selected users have been deleted and their assets have been updated.');
} else {
return redirect()->route('users')->with('error', 'Bulk delete is not enabled in this installation');
return redirect()->route('users.index')->with('error', 'Bulk delete is not enabled in this installation');
}
}
@ -619,18 +616,18 @@ class UsersController extends Controller
// Get user information
if (!$user = User::onlyTrashed()->find($id)) {
return redirect()->route('users')->with('error', trans('admin/users/messages.user_not_found'));
return redirect()->route('users.index')->with('error', trans('admin/users/messages.user_not_found'));
}
if (!Company::isCurrentUserHasAccess($user)) {
return redirect()->route('users')->with('error', trans('general.insufficient_permissions'));
return redirect()->route('users.index')->with('error', trans('general.insufficient_permissions'));
} else {
// Restore the user
if (User::withTrashed()->where('id', $id)->restore()) {
return redirect()->route('users')->with('success', trans('admin/users/message.success.restored'));
return redirect()->route('users.index')->with('success', trans('admin/users/message.success.restored'));
} else {
return redirect()->route('users')->with('error', 'User could not be restored.');
return redirect()->route('users.index')->with('error', 'User could not be restored.');
}
}
@ -645,7 +642,7 @@ class UsersController extends Controller
* @param int $userId
* @return View
*/
public function getView($userId = null)
public function show($userId = null)
{
$user = User::with('assets', 'assets.model', 'consumables', 'accessories', 'licenses', 'userloc')->withTrashed()->find($userId);
@ -655,7 +652,7 @@ class UsersController extends Controller
if (isset($user->id)) {
if (!Company::isCurrentUserHasAccess($user)) {
return redirect()->route('users')->with('error', trans('general.insufficient_permissions'));
return redirect()->route('users.index')->with('error', trans('general.insufficient_permissions'));
} else {
return View::make('users/view', compact('user', 'userlog'));
}
@ -664,7 +661,7 @@ class UsersController extends Controller
$error = trans('admin/users/message.user_not_found', compact('id'));
// Redirect to the user management page
return redirect()->route('users')->with('error', $error);
return redirect()->route('users.index')->with('error', $error);
}
}
@ -688,26 +685,26 @@ class UsersController extends Controller
$error = trans('admin/users/message.error.unsuspend');
// Redirect to the user management page
return redirect()->route('users')->with('error', $error);
return redirect()->route('users.index')->with('error', $error);
}
// Do we have permission to unsuspend this user?
if ($user->isSuperUser() && !Auth::user()->isSuperUser()) {
// Redirect to the user management page
return redirect()->route('users')->with('error', 'Insufficient permissions!');
return redirect()->route('users.index')->with('error', 'Insufficient permissions!');
}
// Prepare the success message
$success = trans('admin/users/message.success.unsuspend');
// Redirect to the user management page
return redirect()->route('users')->with('success', $success);
return redirect()->route('users.index')->with('success', $success);
} catch (UserNotFoundException $e) {
// Prepare the error message
$error = trans('admin/users/message.user_not_found', compact('id'));
// Redirect to the user management page
return redirect()->route('users')->with('error', $error);
return redirect()->route('users.index')->with('error', $error);
}
}
@ -771,7 +768,7 @@ class UsersController extends Controller
$error = trans('admin/users/message.user_not_found', compact('id'));
// Redirect to the user management page
return redirect()->route('users')->with('error', $error);
return redirect()->route('users.index')->with('error', $error);
}
}
@ -896,7 +893,7 @@ class UsersController extends Controller
});
return redirect()->route('users')->with('duplicates', $duplicates)->with('success', 'Success');
return redirect()->route('users.index')->with('duplicates', $duplicates)->with('success', 'Success');
}
/**
@ -992,7 +989,7 @@ class UsersController extends Controller
}
}
if (Gate::allows('users.edit')) {
$actions .= '<a href="' . route('update/user',
$actions .= '<a href="' . route('users.edit',
$user->id) . '" class="btn btn-warning btn-sm"><i class="fa fa-pencil icon-white"></i></a> ';
$actions .= '<a href="' . route('clone/user',
@ -1000,7 +997,7 @@ class UsersController extends Controller
}
if (Gate::allows('users.delete')) {
if ((Auth::user()->id !== $user->id) && (!config('app.lock_passwords'))) {
$actions .= '<a data-html="false" class="btn delete-asset btn-danger btn-sm" data-toggle="modal" href="' . route('delete/user',
$actions .= '<a data-html="false" class="btn delete-asset btn-danger btn-sm" data-toggle="modal" href="' . route('users.destroy',
$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> ';
} else {
$actions .= ' <span class="btn delete-asset btn-danger btn-sm disabled"><i class="fa fa-trash icon-white"></i></span>';
@ -1015,7 +1012,7 @@ class UsersController extends Controller
$rows[] = array(
'id' => $user->id,
'checkbox' => ($status!='deleted') ? '<div class="text-center hidden-xs hidden-sm"><input type="checkbox" name="edit_user['.e($user->id).']" class="one_required"></div>' : '',
'name' => '<a title="'.e($user->fullName()).'" href="'.url('/').'/admin/users/'.e($user->id).'/view">'.e($user->fullName()).'</a>',
'name' => (string)link_to_route('users.show', e($user->fullName()), ['user' => $user->id]),
'jobtitle' => e($user->jobtitle),
'email' => ($user->email!='') ?
'<a href="mailto:'.e($user->email).'" class="hidden-md hidden-lg">'.e($user->email).'</a>'
@ -1062,7 +1059,7 @@ class UsersController extends Controller
if (isset($user->id)) {
if (!Company::isCurrentUserHasAccess($user)) {
return redirect()->route('users')->with('error', trans('general.insufficient_permissions'));
return redirect()->route('users.index')->with('error', trans('general.insufficient_permissions'));
}
foreach (Input::file('file') as $file) {
@ -1111,7 +1108,7 @@ class UsersController extends Controller
if (isset($user->id)) {
if (!Company::isCurrentUserHasAccess($user)) {
return redirect()->route('users')->with('error', trans('general.insufficient_permissions'));
return redirect()->route('users.index')->with('error', trans('general.insufficient_permissions'));
} else {
$log = Actionlog::find($fileId);
$full_filename = $destinationPath . '/' . $log->filename;
@ -1126,7 +1123,7 @@ class UsersController extends Controller
$error = trans('admin/users/message.does_not_exist', compact('id'));
// Redirect to the licence management page
return redirect()->route('users')->with('error', $error);
return redirect()->route('users.index')->with('error', $error);
}
}
@ -1147,7 +1144,7 @@ class UsersController extends Controller
// the license is valid
if (isset($user->id)) {
if (!Company::isCurrentUserHasAccess($user)) {
return redirect()->route('users')->with('error', trans('general.insufficient_permissions'));
return redirect()->route('users.index')->with('error', trans('general.insufficient_permissions'));
} else {
$log = Actionlog::find($fileId);
$file = $log->get_src('users');
@ -1158,7 +1155,7 @@ class UsersController extends Controller
$error = trans('admin/users/message.does_not_exist', compact('id'));
// Redirect to the licence management page
return redirect()->route('users')->with('error', $error);
return redirect()->route('users.index')->with('error', $error);
}
}
@ -1177,14 +1174,14 @@ class UsersController extends Controller
try {
$ldapconn = Ldap::connectToLdap();
} catch (\Exception $e) {
return redirect()->route('users')->with('error',$e->getMessage());
return redirect()->route('users.index')->with('error',$e->getMessage());
}
try {
Ldap::bindAdminToLdap($ldapconn);
} catch (\Exception $e) {
return redirect()->route('users')->with('error',$e->getMessage());
return redirect()->route('users.index')->with('error',$e->getMessage());
}
return View::make('users/ldap')
@ -1358,7 +1355,7 @@ class UsersController extends Controller
trans('admin/users/table.activated'),
trans('general.created_at')
];
fputcsv($handle, $headers);
foreach ($users as $user) {

View file

@ -58,6 +58,43 @@ class Actionlog extends Model
return camel_case(class_basename($this->item_type));
}
public function parseItemRoute() {
if ($this->itemType() == "asset") {
$itemroute = 'assets';
} elseif ($this->itemType() == "accessory") {
$itemroute = 'accessories';
} elseif ($this->itemType()=="consumable") {
$itemroute = 'consumables';
} elseif ($this->itemType()=="license"){
$itemroute = 'licenses';
} elseif ($this->itemType()=="component") {
$itemroute = 'components';
} else {
$itemroute = '';
}
return $itemroute;
}
public function parseItemIcon() {
if ($this->itemType() == "asset") {
$itemicon = 'fa fa-barcode';
} elseif ($this->itemType() == "accessory") {
$itemicon = 'fa fa-keyboard-o';
} elseif ($this->itemType()=="consumable") {
$itemicon = 'fa fa-tint';
} elseif ($this->itemType()=="license"){
$itemicon = 'fa fa-floppy-o';
} elseif ($this->itemType()=="component") {
$itemicon = 'fa fa-hdd-o';
} else {
$itemicon = 'fa fa-paperclip';
}
return $itemicon;
}
public function uploads()
{
return $this->morphTo('item')

View file

@ -62,6 +62,7 @@ class RouteServiceProvider extends ServiceProvider
require base_path('routes/web/consumables.php');
require base_path('routes/web/fields.php');
require base_path('routes/web/components.php');
require base_path('routes/web/users.php');
require base_path('routes/web.php');
});
}

View file

@ -2,6 +2,6 @@
return array (
'app_version' => 'v3.6.1',
'build_version' => 'pre',
'hash_version' => '90',
'full_hash' => 'v3.6.1-pre-90-ge685e0f',
'hash_version' => '92',
'full_hash' => 'v3.6.1-pre-92-g4751bcd',
);

View file

@ -33,7 +33,7 @@
@foreach ($users as $user)
<tr>
<td><a href="{{ route('view/user', $user->id) }}">{{ $user->first_name }} {{ $user->last_name }}</a></td>
<td><a href="{{ route('users.show', $user->id) }}">{{ $user->first_name }} {{ $user->last_name }}</a></td>
</tr>
@endforeach

View file

@ -281,7 +281,7 @@
@if ((isset($log->target_id)) && ($log->target_id!=0) && ($log->target_id!=''))
@if ($log->target->deleted_at=='')
<a href="{{ route('view/user', $log->target_id) }}">
<a href="{{ route('users.show', $log->target_id) }}">
{{ $log->user->fullName() }}
</a>
@else
@ -346,7 +346,7 @@
<ul>
<li><img src="{{ $asset->assigneduser->gravatar() }}" class="img-circle" style="width: 100px; margin-right: 20px;" /><br /><br /></li>
<li><a href="{{ route('view/user', $asset->assigned_to) }}">{{ $asset->assigneduser->fullName() }}</a></li>
<li><a href="{{ route('users.show', $asset->assigned_to) }}">{{ $asset->assigneduser->fullName() }}</a></li>
@if (isset($asset->assetloc->address))

View file

@ -368,7 +368,7 @@
<h4>{{ trans('admin/hardware/form.checkedout_to') }}</h4>
<p>
<img src="{{ $asset->assigneduser->gravatar() }}" class="user-image-inline" alt="{{ $asset->assigneduser->fullName() }}">
<a href="{{ route('view/user', $asset->assigned_to) }}">{{ $asset->assigneduser->fullName() }}</a>
<a href="{{ route('users.show', $asset->assigned_to) }}">{{ $asset->assigneduser->fullName() }}</a>
</p>
<ul class="list-unstyled">
@ -606,7 +606,7 @@
@if ($log->target instanceof \App\Models\User)
@if ($log->target->deleted_at=='')
<a href="{{ route('view/user', $log->target_id) }}">
<a href="{{ route('users.show', $log->target_id) }}">
{{ $log->target->fullName() }}
</a>
@else

View file

@ -216,7 +216,7 @@
@endcan
@can('users.create')
<li {!! (Request::is('users/create') ? 'class="active"' : '') !!}>
<a href="{{ route('create/user') }}">
<a href="{{ route('users.create') }}">
<i class="fa fa-user fa-fw"></i>
@lang('general.user')</a>
</li>
@ -491,7 +491,7 @@
@endcan
@can('users.view')
<li{!! (Request::is('users*') ? ' class="active"' : '') !!}>
<a href="{{ url('admin/users') }}">
<a href="{{ route('users.index') }}">
<i class="fa fa-users"></i>
<span>@lang('general.people')</span>
</a>

View file

@ -64,7 +64,7 @@
@if (($licensedto->user) && ($licensedto->deleted_at == NULL))
@can('users.view')
<a href="{{ route('view/user', $licensedto->assigned_to) }}">
<a href="{{ route('users.show', $licensedto->assigned_to) }}">
{{ $licensedto->user->fullName() }}
</a>
@else
@ -76,7 +76,7 @@
@elseif ($licensedto->asset)
@if ($licensedto->asset->assigned_to != 0)
@can('users.view')
<a href="{{ route('view/user', $licensedto->asset->assigned_to) }}">
<a href="{{ route('users.show', $licensedto->asset->assigned_to) }}">
{{ $licensedto->asset->assigneduser->fullName() }}
</a>
@else
@ -371,7 +371,7 @@
<td>{{ $log->created_at }}</td>
<td>
@if (isset($log->user_id))
<a href="{{ route('view/user', $log->user_id)}}">{{ $log->user->fullName() }}</a>
<a href="{{ route('users.show', $log->user_id)}}">{{ $log->user->fullName() }}</a>
@endif
</td>
<td>{{ $log->action_type }}</td>
@ -380,7 +380,7 @@
@if (($log->target) && ($log->target->id!='0'))
@if ($log->target_type == 'App\Models\User')
<a href="{{ route('view/user', $log->target_id) }}">
<a href="{{ route('users.show', $log->target_id) }}">
{{ $log->userlog->fullName() }}
</a>
@elseif ($log->target_type == 'App\Models\Asset')

View file

@ -83,7 +83,7 @@
@if ($asset->assigneduser->deleted_at!='')
<del>{{ $asset->assigneduser->fullName() }}</del>
@else
<a href="{{ route('view/user', $asset->assigned_to) }}">
<a href="{{ route('users.show', $asset->assigned_to) }}">
{{ $asset->assigneduser->fullName() }}
</a>
@endif

View file

@ -53,7 +53,7 @@
<td>{{ $asset->serial }}</td>
<td>
@if ($asset->assigned_to != '')
<a href="{{ route('view/user', $asset->assigned_to) }}">
<a href="{{ route('users.show', $asset->assigned_to) }}">
{{ $asset->assigneduser->fullName() }}
</a>
@endif

View file

@ -52,7 +52,7 @@
<td><a href="{{ route('hardware.show', $supplierassets->id) }}">{{ $supplierassets->showAssetName() }}</a></td>
<td>
@if ($supplierassets->assigneduser)
<a href="{{ route('view/user', $supplierassets->assigned_to) }}">
<a href="{{ route('users.show', $supplierassets->assigned_to) }}">
{{ $supplierassets->assigneduser->fullName() }}
</a>
@endif

View file

@ -61,7 +61,7 @@
table, tbody {
border: 1px solid #ccc;
}
.header-name {
cursor: pointer;
}
@ -72,7 +72,7 @@
<div class="col-md-8 col-md-offset-2">
<form class="form-horizontal" method="post" autocomplete="off" id="userForm">
<form class="form-horizontal" method="post" autocomplete="off" action="{{ ($user) ? route('users.update', ['user' => $user->id->id]) : route('users.store') }}" id="userForm">
<!-- CSRF Token -->
<input type="hidden" name="_token" value="{{ csrf_token() }}">

View file

@ -7,7 +7,7 @@ Create a User
@stop
@section('header_right')
<a href="{{ route('users') }}" class="btn btn-default"> {{ trans('general.back') }}</a>
<a href="{{ route('users.index') }}" class="btn btn-default"> {{ trans('general.back') }}</a>
@stop
{{-- Page content --}}

View file

@ -20,13 +20,13 @@
<a href="{{ route('ldap/user') }}" class="btn btn-default pull-right"><span class="fa fa-upload"></span> LDAP</a>
@endif
<a href="{{ route('import/user') }}" class="btn btn-default pull-right" style="margin-right: 5px;"><span class="fa fa-upload"></span> {{ trans('general.import') }}</a>
<a href="{{ route('create/user') }}" class="btn btn-primary pull-right" style="margin-right: 5px;"> {{ trans('general.create') }}</a>
<a href="{{ route('users.create') }}" class="btn btn-primary pull-right" style="margin-right: 5px;"> {{ trans('general.create') }}</a>
@endcan
@if (Input::get('status')=='deleted')
<a class="btn btn-default pull-right" href="{{ url('admin/users') }}" style="margin-right: 5px;">{{ trans('admin/users/table.show_current') }}</a>
<a class="btn btn-default pull-right" href="{{ route('users.index') }}" style="margin-right: 5px;">{{ trans('admin/users/table.show_current') }}</a>
@else
<a class="btn btn-default pull-right" href="{{ url('admin/users?status=deleted') }}" style="margin-right: 5px;">{{ trans('admin/users/table.show_deleted') }}</a>
<a class="btn btn-default pull-right" href="{{ route('users.index', ['status' => 'deleted']) }}" style="margin-right: 5px;">{{ trans('admin/users/table.show_deleted') }}</a>
@endif
@can('users.view')
<a class="btn btn-default pull-right" href="{{ url('admin/users/export') }}" style="margin-right: 5px;">Export</a>

View file

@ -31,10 +31,10 @@
<span class="caret"></span>
</a>
<ul class="dropdown-menu">
<li><a href="{{ route('update/user', $user->id) }}">{{ trans('admin/users/general.edit') }}</a></li>
<li><a href="{{ route('users.edit', $user->id) }}">{{ trans('admin/users/general.edit') }}</a></li>
<li><a href="{{ route('clone/user', $user->id) }}">{{ trans('admin/users/general.clone') }}</a></li>
@if ((Auth::user()->id !== $user->id) && (!config('app.lock_passwords')) && ($user->deleted_at==''))
<li><a href="{{ route('delete/user', $user->id) }}">{{ trans('button.delete') }}</a></li>
<li><a href="{{ route('users.destroy', $user->id) }}">{{ trans('button.delete') }}</a></li>
@endif
</ul>
</li>
@ -93,7 +93,7 @@
@if ($user->manager)
<tr>
<td>Manager</td>
<td><a href="{{ route('view/user', $user->manager->id) }}">{{ $user->manager->fullName() }}</a></td>
<td><a href="{{ route('users.show', $user->manager->id) }}">{{ $user->manager->fullName() }}</a></td>
</tr>
@endif
@ -135,7 +135,7 @@
@can('users.edit')
<div class="col-md-12">
<a href="{{ route('update/user', $user->id) }}" style="width: 100%;" class="btn btn-sm btn-default">{{ trans('admin/users/general.edit') }}</a>
<a href="{{ route('users.edit', $user->id) }}" style="width: 100%;" class="btn btn-sm btn-default">{{ trans('admin/users/general.edit') }}</a>
</div>
<div class="col-md-12" style="padding-top: 5px;">
<a href="{{ route('clone/user', $user->id) }}" style="width: 100%;" class="btn btn-sm btn-default">{{ trans('admin/users/general.clone') }}</a>
@ -146,7 +146,7 @@
@if ($user->deleted_at=='')
<div class="col-md-12" style="padding-top: 5px;">
<a href="{{ route('delete/user', $user->id) }}" style="width: 100%;" class="btn btn-sm btn-warning">{{ trans('button.delete') }}</a>
<a href="{{ route('users.destroy', $user->id) }}" style="width: 100%;" class="btn btn-sm btn-warning">{{ trans('button.delete') }}</a>
</div>
<div class="col-md-12" style="padding-top: 5px;">
<form action="{{ route('users/bulkedit') }}" method="POST">
@ -274,7 +274,7 @@
<tbody>
@foreach ($user->consumables as $consumable)
<tr>
<td><a href="{{ route('view/consumable', $consumable->id) }}">{{ $consumable->name }}</a></td>
<td><a href="{{ route('consumables.show', $consumable->id) }}">{{ $consumable->name }}</a></td>
<td>{{ $consumable->created_at }}</td>
</tr>
@endforeach
@ -354,7 +354,7 @@
</td>
<td>
@can('users.edit')
<a class="btn delete-asset btn-danger btn-sm" href="{{ route('delete/userfile', [$user->id, $file->id]) }}" data-content="Are you sure you wish to delete this file?" data-title="Delete {{ $file->filename }}?"><i class="fa fa-trash icon-white"></i></a>
<a class="btn delete-asset btn-danger btn-sm" href="{{ route('users.destroyfile', [$user->id, $file->id]) }}" data-content="Are you sure you wish to delete this file?" data-title="Delete {{ $file->filename }}?"><i class="fa fa-trash icon-white"></i></a>
@endcan
</td>
</tr>
@ -377,26 +377,15 @@
<th class="col-md-1"></th>
<th class="col-md-2">Date</th>
<th class="col-md-2"><span class="line"></span>{{ trans('table.action') }}</th>
<th class="col-md-3"><span class="line"></span>{{ trans('general.asset') }}</th>
<th class="col-md-2"><span class="line"></span>{{ trans('table.by') }}</th>
<th class="col-md-4"><span class="line"></span>{{ trans('general.asset') }}</th>
<th class="col-md-3"><span class="line"></span>{{ trans('table.by') }}</th>
</tr>
</thead>
<tbody>
@foreach ($userlog as $log)
<tr>
<td class="text-center">
@if ($log->itemType()=="asset")
<i class="fa fa-barcode"></i>
@elseif ($log->itemType()=="accessory")
<i class="fa fa-keyboard-o"></i>
@elseif ($log->itemType()=="consumable")
<i class="fa fa-tint"></i>
@elseif ($log->itemType()=="license")
<i class="fa fa-floppy-o"></i>
@else
<i class="fa fa-times"></i>
@endif
<i class="{{ ($log->parseItemIcon()) }}"></i>
</td>
<td>{{ $log->created_at }}</td>
<td>{{ $log->action_type }}</td>
@ -405,7 +394,9 @@
@if (($log->item) && ($log->itemType()=="asset"))
<a href="{{ route('hardware.show', $log->item_id) }}">{{ $log->item->asset_tag }} - {{ $log->item->showAssetName() }}</a>
@elseif ($log->item)
<a href="{{ route('view/'. $log->itemType(), $log->item_id) }}">{{ $log->item->name }}</a>
<a href="{{ route($log->parseItemRoute().'.show', $log->item_id) }}">
{{ $log->item->name }}
</a>
@else
{{ trans('general.bad_data') }}
@endif
@ -414,7 +405,7 @@
<td>
@if ($log->action_type != 'requested')
@if (isset($log->user))
<a href="{{route('view/user', $log->user_id)}}">{{ $log->user->fullName() }}</a>
<a href="{{route('users.show', $log->user_id)}}">{{ $log->user->fullName() }}</a>
@else
Deleted Admin
@endif

View file

@ -142,58 +142,6 @@ Route::group([ 'prefix' => 'admin','middleware' => ['web','auth']], function ()
});
# User Management
Route::group([ 'prefix' => 'users', 'middleware' => ['web','auth','authorize:users.view']], function () {
Route::get('ldap', ['as' => 'ldap/user', 'uses' => 'UsersController@getLDAP', 'middleware' => ['authorize:users.edit'] ]);
Route::post('ldap', 'UsersController@postLDAP');
Route::get('create', [ 'as' => 'create/user', 'uses' => 'UsersController@getCreate', 'middleware' => ['authorize:users.edit'] ]);
Route::post('create', [ 'uses' => 'UsersController@postCreate', 'middleware' => ['authorize:users.edit'] ]);
Route::get('import', [ 'as' => 'import/user', 'uses' => 'UsersController@getImport', 'middleware' => ['authorize:users.edit'] ]);
Route::post('import', [ 'uses' => 'UsersController@postImport', 'middleware' => ['authorize:users.edit'] ]);
Route::get('export', [ 'uses' => 'UsersController@getExportUserCsv', 'middleware' => ['authorize:users.view'] ]);
Route::get('{userId}/edit', [ 'as' => 'update/user', 'uses' => 'UsersController@getEdit', 'middleware' => ['authorize:users.edit'] ]);
Route::post('{userId}/edit', [ 'uses' => 'UsersController@postEdit', 'middleware' => ['authorize:users.edit'] ]);
Route::get('{userId}/clone', [ 'as' => 'clone/user', 'uses' => 'UsersController@getClone', 'middleware' => ['authorize:users.edit'] ]);
Route::post('{userId}/clone', [ 'uses' => 'UsersController@postCreate', 'middleware' => ['authorize:users.edit'] ]);
Route::get('{userId}/delete', [ 'as' => 'delete/user', 'uses' => 'UsersController@getDelete', 'middleware' => ['authorize:users.edit'] ]);
Route::get('{userId}/restore', [ 'as' => 'restore/user', 'uses' => 'UsersController@getRestore', 'middleware' => ['authorize:users.edit'] ]);
Route::get('{userId}/view', [ 'as' => 'view/user', 'uses' => 'UsersController@getView' , 'middleware' => ['authorize:users.view'] ]);
Route::get('{userId}/unsuspend', [ 'as' => 'unsuspend/user', 'uses' => 'UsersController@getUnsuspend', 'middleware' => ['authorize:users.edit'] ]);
Route::get(
'{userId}/deletefile/{fileId}',
[ 'as' => 'delete/userfile', 'uses' => 'UsersController@getDeleteFile' ]
);
Route::get(
'{userId}/showfile/{fileId}',
[ 'as' => 'show/userfile', 'uses' => 'UsersController@displayFile' ]
);
Route::post(
'bulkedit',
[
'as' => 'users/bulkedit',
'uses' => 'UsersController@postBulkEdit',
'middleware' => ['authorize:users.edit'],
]
);
Route::post(
'bulksave',
[
'as' => 'users/bulksave',
'uses' => 'UsersController@postBulkSave',
'middleware' => ['authorize:users.edit'],
]
);
Route::get('/', [ 'as' => 'users', 'uses' => 'UsersController@getIndex' ]);
});
# Group Management
Route::group([ 'prefix' => 'groups', 'middleware' => ['web','auth','authorize:superadmin'] ], function () {

46
routes/web/users.php Normal file
View file

@ -0,0 +1,46 @@
<?php
# User Management
Route::group([ 'prefix' => 'users', 'middleware' => ['web','auth','authorize:users.view']], function () {
Route::get('ldap', ['as' => 'ldap/user', 'uses' => 'UsersController@getLDAP', 'middleware' => ['authorize:users.edit'] ]);
Route::post('ldap', 'UsersController@postLDAP');
Route::get('import', [ 'as' => 'import/user', 'uses' => 'UsersController@getImport', 'middleware' => ['authorize:users.edit'] ]);
Route::post('import', [ 'uses' => 'UsersController@postImport', 'middleware' => ['authorize:users.edit'] ]);
Route::get('export', [ 'uses' => 'UsersController@getExportUserCsv', 'middleware' => ['authorize:users.view'] ]);
Route::get('{userId}/clone', [ 'as' => 'clone/user', 'uses' => 'UsersController@getClone', 'middleware' => ['authorize:users.edit'] ]);
Route::post('{userId}/clone', [ 'uses' => 'UsersController@postCreate', 'middleware' => ['authorize:users.edit'] ]);
Route::get('{userId}/restore', [ 'as' => 'restore/user', 'uses' => 'UsersController@getRestore', 'middleware' => ['authorize:users.edit'] ]);
Route::get('{userId}/unsuspend', [ 'as' => 'unsuspend/user', 'uses' => 'UsersController@getUnsuspend', 'middleware' => ['authorize:users.edit'] ]);
Route::get(
'{userId}/deletefile/{fileId}',
[ 'as' => 'delete/userfile', 'uses' => 'UsersController@getDeleteFile' ]
);
Route::get(
'{userId}/showfile/{fileId}',
[ 'as' => 'show/userfile', 'uses' => 'UsersController@displayFile' ]
);
Route::post(
'bulkedit',
[
'as' => 'users/bulkedit',
'uses' => 'UsersController@postBulkEdit',
'middleware' => ['authorize:users.edit'],
]
);
Route::post(
'bulksave',
[
'as' => 'users/bulksave',
'uses' => 'UsersController@postBulkSave',
'middleware' => ['authorize:users.edit'],
]
);
});
Route::resource('users', 'UsersController', [
'parameters' => ['user' => 'user_id']
]);