mirror of
https://github.com/freescout-helpdesk/freescout.git
synced 2024-11-24 11:22:42 +01:00
Mailbox permissions
This commit is contained in:
parent
8d16c6ec76
commit
c869b9a22d
@ -5,6 +5,7 @@ namespace App\Http\Controllers;
|
||||
use Illuminate\Http\Request;
|
||||
use Validator;
|
||||
use App\Mailbox;
|
||||
use App\User;
|
||||
|
||||
class MailboxesController extends Controller
|
||||
{
|
||||
@ -129,6 +130,28 @@ class MailboxesController extends Controller
|
||||
|
||||
$this->authorize('update', $mailbox);
|
||||
|
||||
return view('mailboxes/permissions', ['mailbox' => $mailbox]);
|
||||
$users = User::where('role', '!=', User::ROLE_ADMIN)->get();
|
||||
|
||||
return view('mailboxes/permissions', ['mailbox' => $mailbox, 'users' => $users, 'mailbox_users' => $mailbox->users]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Save mailbox permissions
|
||||
*
|
||||
* @param int $id
|
||||
* @param \Illuminate\Http\Request $request
|
||||
*/
|
||||
public function permissionsSave($id, Request $request)
|
||||
{
|
||||
$mailbox = Mailbox::findOrFail($id);
|
||||
|
||||
$this->authorize('update', $mailbox);
|
||||
|
||||
$mailbox->users()->sync($request->users);
|
||||
|
||||
//$mailbox->save();
|
||||
|
||||
\Session::flash('flash_success', __('Mailbox permissions saved!'));
|
||||
return redirect()->route('mailboxes.permissions', ['id' => $id]);
|
||||
}
|
||||
}
|
||||
|
10
public/css/style.css
vendored
10
public/css/style.css
vendored
@ -469,4 +469,14 @@ a h4 {
|
||||
border-radius: 0 0 4px 4px;
|
||||
padding: 0 50px 40px;
|
||||
text-align: center;
|
||||
}
|
||||
#permissions-fields .control-group {
|
||||
display: inline-block;
|
||||
vertical-align: top;
|
||||
width: 200px;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
#permissions-fields .control-label {
|
||||
margin-top: 0;
|
||||
margin-bottom: 0;
|
||||
}
|
10
public/js/main.js
vendored
10
public/js/main.js
vendored
@ -44,4 +44,14 @@ function mailboxUpdateInit(from_name_custom)
|
||||
$('#from_name_custom_container').addClass('hidden');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function mailboxPermissionsInit()
|
||||
{
|
||||
$('.sel-all').click(function(event) {
|
||||
$("#permissions-fields input").attr('checked', 'checked');
|
||||
});
|
||||
$('.sel-none').click(function(event) {
|
||||
$("#permissions-fields input").removeAttr('checked');
|
||||
});
|
||||
}
|
@ -21,25 +21,28 @@
|
||||
<p class="help-block">{{ __('Administrators have access to all mailboxes and are not listed here.') }}</p>
|
||||
</div>
|
||||
<div class="col-xs-12">
|
||||
<form class="form-horizontal" method="POST" action="">
|
||||
<form method="POST" action="">
|
||||
{{ csrf_field() }}
|
||||
|
||||
<p><a href="javascript:void(0)" class="selAll">all</a> / <a href="javascript:void(0)" class="selNone">none</a></p>
|
||||
<p><a href="javascript:void(0)" class="sel-all">{{ __('all') }}</a> / <a href="javascript:void(0)" class="sel-none">{{ __('none') }}</a></p>
|
||||
|
||||
<div class="form-group{{ $errors->has('name') ? ' has-error' : '' }}">
|
||||
<div class="col-xs-12">
|
||||
<input id="name" type="text" class="form-control input-sized" name="name" value="{{ old('name', $mailbox->name) }}" maxlength="40" required autofocus>
|
||||
|
||||
@include('partials/field_error', ['field'=>'name'])
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<div class="col-xs-12">
|
||||
<button type="submit" class="btn btn-primary">
|
||||
{{ __('Save') }}
|
||||
</button>
|
||||
</div>
|
||||
<fieldset id="permissions-fields">
|
||||
@foreach ($users as $user)
|
||||
<div class="control-group">
|
||||
<div class="controls">
|
||||
<label class="control-label checkbox" for="user-{{ $user->id }}">
|
||||
<input type="checkbox" name="users[]" id="user-{{ $user->id }}" value="{{ $user->id }}" @if ($mailbox_users->contains($user)) checked="checked" @endif> {{ $user->first_name }} {{ $user->last_name }}
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
@endforeach
|
||||
</fieldset>
|
||||
<div class="form-group margin-top">
|
||||
|
||||
<button type="submit" class="btn btn-primary">
|
||||
{{ __('Save') }}
|
||||
</button>
|
||||
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
@ -51,5 +54,5 @@
|
||||
|
||||
@section('javascript')
|
||||
@parent
|
||||
mailboxUpdateInit('{{ App\Mailbox::FROM_NAME_CUSTOM }}');
|
||||
mailboxPermissionsInit();
|
||||
@endsection
|
Loading…
Reference in New Issue
Block a user