1
0
mirror of https://github.com/freescout-helpdesk/freescout.git synced 2024-11-24 19:33:07 +01:00

Merge pull request #756 from injektion/mailbox-managers

Issue 490: Mailbox Managers and per user management permissions
This commit is contained in:
FreeScout 2020-09-25 13:00:30 +03:00 committed by GitHub
commit 168e4427dc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 374 additions and 54 deletions

View File

@ -89,7 +89,7 @@ class MailboxesController extends Controller
{
$mailbox = Mailbox::findOrFail($id);
//$this->authorize('update', $mailbox);
if (!auth()->user()->can('update', $mailbox)) {
if (!auth()->user()->can('updateSettings', $mailbox)) {
$accessible_route = \Eventy::filter('mailbox.accessible_settings_route', '', auth()->user(), $mailbox);
if ($accessible_route) {
return redirect()->route($accessible_route, ['id' => $mailbox->id]);
@ -98,9 +98,17 @@ class MailboxesController extends Controller
}
}
$user = auth()->user();
$mailbox_user = $user->mailboxesWithSettings()->where('mailbox_id', $id)->first();
if (!$mailbox_user && $user->isAdmin()) {
// Admin may not be connected to the mailbox yet
$user->mailboxes()->attach($id);
$mailbox_user = $user->mailboxesWithSettings()->where('mailbox_id', $id)->first();
}
//$mailboxes = Mailbox::all()->except($id);
return view('mailboxes/update', ['mailbox' => $mailbox, 'flashes' => $this->mailboxActiveWarning($mailbox)]);
return view('mailboxes/update', ['mailbox' => $mailbox, 'mailbox_user' => $mailbox_user, 'flashes' => $this->mailboxActiveWarning($mailbox)]);
}
/**
@ -113,7 +121,15 @@ class MailboxesController extends Controller
{
$mailbox = Mailbox::findOrFail($id);
$this->authorize('update', $mailbox);
$this->authorize('updateSettings', $mailbox);
// if not admin, the text only fields don't pass so spike them into the request.
if (!auth()->user()->isAdmin()) {
$request->merge([
'name' => $mailbox->name,
'email' => $mailbox->email
]);
}
$validator = Validator::make($request->all(), [
'name' => 'required|string|max:40',
@ -124,7 +140,6 @@ class MailboxesController extends Controller
'ticket_status' => 'required|integer',
'template' => 'required|integer',
'ticket_assignee' => 'required|integer',
'signature' => 'nullable|string',
]);
//event(new Registered($user = $this->create($request->all())));
@ -151,24 +166,23 @@ class MailboxesController extends Controller
{
$mailbox = Mailbox::findOrFail($id);
$this->authorize('update', $mailbox);
$this->authorize('updatePermissions', $mailbox);
$users = User::nonDeleted()->where('role', '!=', User::ROLE_ADMIN)->get();
$users = User::sortUsers($users);
$admins = User::nonDeleted()
->select(['users.*', 'mailbox_user.hide'])
$managers = User::nonDeleted()
->select(['users.*', 'mailbox_user.hide', 'mailbox_user.access'])
->leftJoin('mailbox_user', function ($join) use ($mailbox) {
$join->on('mailbox_user.user_id', '=', 'users.id');
$join->where('mailbox_user.mailbox_id', $mailbox->id);
})
->where('role', User::ROLE_ADMIN)->get();
$admins = User::sortUsers($admins);
})->get();
$managers = User::sortUsers($managers);
return view('mailboxes/permissions', [
'mailbox' => $mailbox,
'users' => $users,
'admins' => $admins,
'managers' => $managers,
'mailbox_users' => $mailbox->users,
]);
}
@ -182,7 +196,7 @@ class MailboxesController extends Controller
public function permissionsSave($id, Request $request)
{
$mailbox = Mailbox::findOrFail($id);
$this->authorize('update', $mailbox);
$this->authorize('updatePermissions', $mailbox);
$mailbox->users()->sync($request->users);
$mailbox->syncPersonalFolders($request->users);
@ -196,10 +210,22 @@ class MailboxesController extends Controller
$admin->mailboxes()->attach($id);
$mailbox_user = $admin->mailboxesWithSettings()->where('mailbox_id', $id)->first();
}
$mailbox_user->settings->hide = (isset($request->admins[$admin->id]['hide']) ? (int)$request->admins[$admin->id]['hide'] : false);
$mailbox_user->settings->hide = (isset($request->managers[$admin->id]['hide']) ? (int)$request->managers[$admin->id]['hide'] : false);
$mailbox_user->settings->save();
}
// Sets the mailbox_user.access JSON array
$mailbox_users = $mailbox->users;
foreach ($mailbox_users as $mailbox_user) {
$access = Array();
$mailbox_with_settings = $mailbox_user->mailboxesWithSettings()->where('mailbox_id', $id)->first();
foreach (\App\Mailbox::$USER_ACCESS_PERMISSIONS as $label=>$perm) {
if (!empty($request->managers[$mailbox_user->id]['access'][$perm])) $access[] = $request->managers[$mailbox_user->id]['access'][$perm];
}
$mailbox_with_settings->settings->access = json_encode($access);
$mailbox_with_settings->settings->save();
}
\Session::flash('flash_success_floating', __('Mailbox permissions saved!'));
return redirect()->route('mailboxes.permissions', ['id' => $id]);
@ -410,7 +436,7 @@ class MailboxesController extends Controller
public function autoReply($id)
{
$mailbox = Mailbox::findOrFail($id);
$this->authorize('update', $mailbox);
$this->authorize('updateAutoReply', $mailbox);
if (!$mailbox->auto_reply_subject) {
$mailbox->auto_reply_subject = 'Re: {%subject%}';
@ -428,7 +454,8 @@ class MailboxesController extends Controller
{
$mailbox = Mailbox::findOrFail($id);
$this->authorize('update', $mailbox);
// $this->authorize('update', $mailbox);
$this->authorize('updateAutoReply', $mailbox);
$request->merge([
'auto_reply_enabled' => ($request->filled('auto_reply_enabled') ?? false),
@ -462,6 +489,54 @@ class MailboxesController extends Controller
return redirect()->route('mailboxes.auto_reply', ['id' => $id]);
}
/**
* Auto reply settings.
*/
public function emailSignature($id)
{
$mailbox = Mailbox::findOrFail($id);
$this->authorize('updateAutoReply', $mailbox);
if (!$mailbox->auto_reply_subject) {
$mailbox->auto_reply_subject = 'Re: {%subject%}';
}
return view('mailboxes/email_signature', [
'mailbox' => $mailbox,
]);
}
/**
* Save auto reply settings.
*/
public function emailSignatureSave($id, Request $request)
{
$mailbox = Mailbox::findOrFail($id);
$this->authorize('updateEmailSignature', $mailbox);
$validator = Validator::make($request->all(), [
'signature' => 'nullable|string',
]);
//event(new Registered($user = $this->create($request->all())));
if ($validator->fails()) {
return redirect()->route('mailboxes.email_signature', ['id' => $id])
->withErrors($validator)
->withInput();
}
$mailbox->fill($request->all());
$mailbox->save();
\Session::flash('flash_success_floating', __('Mailbox settings saved'));
return redirect()->route('mailboxes.email_signature', ['id' => $id]);
}
/**
* Users ajax controller.
*/

View File

@ -97,6 +97,16 @@ class Mailbox extends Model
const DEFAULT_SIGNATURE = '<br><span style="color:#808080;">--<br>
{%mailbox.name%}</span>';
/**
* Mailbox User Access Permissions.
*/
public static $USER_ACCESS_PERMISSIONS = [
'Edit Mailbox' => 'edit',
'Permissions' => 'perm',
'Auto Replies' => 'auto',
'Email Signature' => 'sig'
];
/**
* Default values.
*/
@ -162,7 +172,8 @@ class Mailbox extends Model
return $this->belongsToMany('App\User')->as('settings')
->withPivot('after_send')
->withPivot('hide')
->withPivot('mute');
->withPivot('mute')
->withPivot('access');
}
/**
@ -552,6 +563,7 @@ class Mailbox extends Model
$settings->after_send = MailboxUser::AFTER_SEND_NEXT;
$settings->hide = false;
$settings->mute = false;
$settings->access = false;
return $settings;
}
@ -564,6 +576,7 @@ class Mailbox extends Model
$this->after_send = $settings->after_send;
$this->hide = $settings->hide;
$this->mute = $settings->mute;
$this->access = $settings->access;
}
/**
@ -690,7 +703,7 @@ class Mailbox extends Model
public static function findOrFailWithSettings($id, $user_id)
{
return Mailbox::select(['mailboxes.*', 'mailbox_user.hide', 'mailbox_user.mute'])
return Mailbox::select(['mailboxes.*', 'mailbox_user.hide', 'mailbox_user.mute', 'mailbox_user.access'])
->where('mailboxes.id', $id)
->leftJoin('mailbox_user', function ($join) use ($user_id) {
$join->on('mailbox_user.mailbox_id', '=', 'mailboxes.id');

View File

@ -78,7 +78,76 @@ class MailboxPolicy
*/
public function update(User $user, Mailbox $mailbox)
{
if ($user->isAdmin()) {
if ($user->isAdmin() || $user->canManageMailbox($mailbox->id)) {
return true;
} else {
return false;
}
}
/**
* Determine whether the user can update the mailbox auto reply.
*
* @param \App\User $user
* @param \App\Mailbox $mailbox
*
* @return mixed
*/
public function updateAutoReply(User $user, Mailbox $mailbox)
{
if ($user->isAdmin() || $user->hasManageMailboxPermission($mailbox->id, 'auto')) {
return true;
} else {
return false;
}
}
/**
* Determine whether the user can update the mailbox Permissions.
*
* @param \App\User $user
* @param \App\Mailbox $mailbox
*
* @return mixed
*/
public function updatePermissions(User $user, Mailbox $mailbox)
{
if ($user->isAdmin() || $user->hasManageMailboxPermission($mailbox->id, 'perm')) {
return true;
} else {
return false;
}
}
/**
* Determine whether the user can update the mailbox Permissions.
*
* @param \App\User $user
* @param \App\Mailbox $mailbox
*
* @return mixed
*/
public function updateSettings(User $user, Mailbox $mailbox)
{
if ($user->isAdmin() || $user->hasManageMailboxPermission($mailbox->id, 'edit')) {
return true;
} else {
return false;
}
}
/**
* Determine whether the user can update the mailbox Email Signature.
*
* @param \App\User $user
* @param \App\Mailbox $mailbox
*
* @return mixed
*/
public function updateEmailSignature(User $user, Mailbox $mailbox)
{
if ($user->isAdmin() || $user->hasManageMailboxPermission($mailbox->id, 'sig')) {
return true;
} else {
return false;

View File

@ -52,7 +52,7 @@ class UserPolicy
*/
public function update(User $user, User $model)
{
if ($user->isAdmin() || $user->id == $model->id) {
if ($user->isAdmin() || $user->id == $model->id || $user->canManageMailbox($model->id)) {
return true;
} else {
return false;
@ -103,6 +103,8 @@ class UserPolicy
{
if ($user->isAdmin() || \Eventy::filter('user.can_view_mailbox_menu', false, $user)) {
return true;
} else if ($user->hasManageMailboxAccess()) {
return true;
} else {
return false;
}

View File

@ -142,7 +142,8 @@ class User extends Authenticatable
return $this->belongsToMany('App\Mailbox')->as('settings')
->withPivot('after_send')
->withPivot('hide')
->withPivot('mute');
->withPivot('mute')
->withPivot('access');
}
/**
@ -244,13 +245,13 @@ class User extends Authenticatable
$user = $this;
if ($this->isAdmin()) {
$query = Mailbox::select(['mailboxes.*', 'mailbox_user.hide', 'mailbox_user.mute'])
$query = Mailbox::select(['mailboxes.*', 'mailbox_user.hide', 'mailbox_user.mute', 'mailbox_user.access'])
->leftJoin('mailbox_user', function ($join) use ($user) {
$join->on('mailbox_user.mailbox_id', '=', 'mailboxes.id');
$join->where('mailbox_user.user_id', $user->id);
});
} else {
$query = Mailbox::select(['mailboxes.*', 'mailbox_user.hide', 'mailbox_user.mute'])
$query = Mailbox::select(['mailboxes.*', 'mailbox_user.hide', 'mailbox_user.mute', 'mailbox_user.access'])
->join('mailbox_user', function ($join) use ($user) {
$join->on('mailbox_user.mailbox_id', '=', 'mailboxes.id');
$join->where('mailbox_user.user_id', $user->id);
@ -281,6 +282,52 @@ class User extends Authenticatable
return in_array($mailbox_id, $ids);
}
/**
* Check to see if the user can manage any mailboxes
*/
public function hasManageMailboxAccess() {
if ($this->isAdmin()) {
return true;
} else {
$mailboxes = $this->mailboxesCanViewWithSettings();
foreach ($mailboxes as $mailbox) {
if ($mailbox->access) {
if (!empty(json_decode($mailbox->access))) {
return true;
}
}
};
}
}
/**
* Check to see if the user can manage a specific mailbox
*/
public function canManageMailbox($mailbox_id)
{
if ($this->isAdmin()) {
return true;
} else {
$mailbox = $this->mailboxesCanViewWithSettings()->where('id', $mailbox_id)->first();
if ($mailbox->access) {
if (!empty(json_decode($mailbox->access))) {
return true;
}
};
}
}
public function hasManageMailboxPermission($mailbox_id, $perm) {
if ($this->isAdmin()) {
return true;
} else {
$mailbox = $this->mailboxesCanViewWithSettings()->where('id', $mailbox_id)->first();
if (in_array($perm, json_decode($mailbox->access))) return true;
}
}
/**
* Generate random password for the user.
*

View File

@ -0,0 +1,32 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class AddAccessColumnToMailboxUserTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('mailbox_user', function (Blueprint $table) {
$table->text('access')->nullable();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('mailbox_user', function (Blueprint $table) {
$table->dropColumn('access');
});
}
}

View File

@ -0,0 +1,53 @@
@extends('layouts.app')
@section('title_full', __('Edit Mailbox').' - '.$mailbox->name)
@section('body_attrs')@parent data-mailbox_id="{{ $mailbox->id }}"@endsection
@section('sidebar')
@include('partials/sidebar_menu_toggle')
@include('mailboxes/sidebar_menu')
@endsection
@section('content')
<div class="section-heading">
{{ __('Email Signature') }}
</div>
@include('partials/flash_messages')
<div class="row-container form-container">
<div class="row">
<div class="col-xs-12">
<form class="form-horizontal margin-top" method="POST" action="">
{{ csrf_field() }}
<div class="form-group{{ $errors->has('signature') ? ' has-error' : '' }}">
<label for="signature" class="col-sm-2 control-label">{{ __('Email Signature') }}</label>
<div class="col-md-9 signature-editor">
<textarea id="signature" class="form-control" name="signature" rows="8">{{ old('signature', $mailbox->signature) }}</textarea>
@include('partials/field_error', ['field'=>'signature'])
</div>
</div>
<div class="form-group">
<div class="col-sm-6 col-sm-offset-2">
<button type="submit" class="btn btn-primary">
{{ __('Save') }}
</button>
</div>
</div>
</form>
</div>
</div>
</div>
@endsection
@include('partials/editor')
@section('javascript')
@parent
mailboxUpdateInit('{{ App\Mailbox::FROM_NAME_CUSTOM }}');
@endsection

View File

@ -22,7 +22,7 @@
<p class="block-help">{{ __('Administrators have access to all mailboxes and are not listed here.') }}</p>
</div>
<div class="col-xs-12">
{{ csrf_field() }}
<p><a href="javascript:void(0)" class="sel-all">{{ __('all') }}</a> / <a href="javascript:void(0)" class="sel-none">{{ __('none') }}</a></p>
@ -42,30 +42,46 @@
</div>
<div class="col-xs-12 margin-top">
<h3> {{ __('Administrators') }}:</h3>
<h3> {{ __('Access Settings') }}:</h3>
</div>
<div class="col-md-11 col-lg-9">
<table class="table">
<tr class="table-header-nb">
<th>&nbsp;</th>
<th class="text-center">{{ __('Hide from Assign list') }}</th>
<th class="text-center"> {{ __('Hide from Assign list') }}</th>
@foreach (\App\Mailbox::$USER_ACCESS_PERMISSIONS as $label=>$perm)
<th class="text-center"> {{ __($label) }}</th>
@endforeach
</tr>
<fieldset id="permissions-fields">
@foreach ($admins as $admin)
@foreach ($managers as $mailbox_user)
<tr>
<td>{{ $admin->getFullName() }}</td>
<td class="text-center"><input type="checkbox" name="admins[{{ $admin->id }}][hide]" value="1" @if (!empty($admin->hide)) checked="checked" @endif></td>
<td>{{ $mailbox_user->getFullName() }}
@if ($mailbox_user->isAdmin())
({{ __('Administrator') }})
<td class="text-center"><input type="checkbox" name="managers[{{ $mailbox_user->id }}][hide]" value="1" @if (!empty($mailbox_user->hide)) checked="checked" @endif></td>
<td class="text-center"></td>
<td class="text-center"></td>
<td class="text-center"></td>
@else
<td></td>
@foreach (\App\Mailbox::$USER_ACCESS_PERMISSIONS as $label=>$perm)
<td class="text-center"><input type="checkbox" name="managers[{{ $mailbox_user->id }}][access][{{ $perm }}]" value="{{ $perm }}" @if (!empty($mailbox_user->access) && in_array($perm, json_decode($mailbox_user->access))) checked="checked" @endif></td>
@endforeach
@endif
</td>
</tr>
@endforeach
</fieldset>
</table>
<div class="form-group margin-top">
<button type="submit" class="btn btn-primary">
{{ __('Save') }}
</button>
</div>
</div>
</form>
@ -76,4 +92,4 @@
@section('javascript')
@parent
permissionsInit();
@endsection
@endsection

View File

@ -1,11 +1,22 @@
@if (Auth::user()->can('update', $mailbox))
<li @if (Route::currentRouteName() == 'mailboxes.update')class="active"@endif><a href="{{ route('mailboxes.update', ['id'=>$mailbox->id]) }}"><i class="glyphicon glyphicon-pencil"></i> {{ __('Edit Mailbox') }}</a></li>
<li @if (Route::currentRouteName() == 'mailboxes.connection' || Route::currentRouteName() == 'mailboxes.connection.incoming')class="active"@endif><a href="{{ route('mailboxes.connection', ['id'=>$mailbox->id]) }}"><i class="glyphicon glyphicon-transfer"></i> {{ __('Connection Settings') }}</a></li>
<li @if (Route::currentRouteName() == 'mailboxes.permissions')class="active"@endif><a href="{{ route('mailboxes.permissions', ['id'=>$mailbox->id]) }}"><i class="glyphicon glyphicon-ok"></i> {{ __('Permissions') }}</a></li>
<li @if (Route::currentRouteName() == 'mailboxes.auto_reply')class="active"@endif><a href="{{ route('mailboxes.auto_reply', ['id'=>$mailbox->id]) }}"><i class="glyphicon glyphicon-share"></i> {{ __('Auto Reply') }}</a></li>
@if (Auth::user()->isAdmin() || Auth::user()->hasManageMailboxPermission($mailbox->id, 'edit'))
<li @if (Route::currentRouteName() == 'mailboxes.update')class="active"@endif><a href="{{ route('mailboxes.update', ['id'=>$mailbox->id]) }}"><i class="glyphicon glyphicon-pencil"></i> {{ __('Edit Mailbox') }}</a></li>
@endif
@if (Auth::user()->isAdmin())
<li @if (Route::currentRouteName() == 'mailboxes.connection' || Route::currentRouteName() == 'mailboxes.connection.incoming')class="active"@endif><a href="{{ route('mailboxes.connection', ['id'=>$mailbox->id]) }}"><i class="glyphicon glyphicon-transfer"></i> {{ __('Connection Settings') }}</a></li>
@endif
@if (Auth::user()->isAdmin() || Auth::user()->hasManageMailboxPermission($mailbox->id, 'perm'))
<li @if (Route::currentRouteName() == 'mailboxes.permissions')class="active"@endif><a href="{{ route('mailboxes.permissions', ['id'=>$mailbox->id]) }}"><i class="glyphicon glyphicon-ok"></i> {{ __('Permissions') }}</a></li>
@endif
@if (Auth::user()->isAdmin() || Auth::user()->hasManageMailboxPermission($mailbox->id, 'auto'))
<li @if (Route::currentRouteName() == 'mailboxes.auto_reply')class="active"@endif><a href="{{ route('mailboxes.auto_reply', ['id'=>$mailbox->id]) }}"><i class="glyphicon glyphicon-share"></i> {{ __('Auto Reply') }}</a></li>
@endif
@if (Auth::user()->isAdmin() || Auth::user()->hasManageMailboxPermission($mailbox->id, 'sig'))
<li @if (Route::currentRouteName() == 'mailboxes.email_signature')class="active"@endif><a href="{{ route('mailboxes.email_signature', ['id'=>$mailbox->id]) }}"><i class="glyphicon glyphicon-bullhorn"></i> {{ __('Email Signature') }}</a></li>
@endif
@endif
@action('mailboxes.settings.menu', $mailbox)
@if (!empty($is_dropdown) && Auth::user()->isAdmin())
<li class="divider"></li>
<li><a href="#" class="mailbox-mute-trigger" @if ($mailbox->mute) data-mute="0" @else data-mute="1" @endif data-mailbox-id="{{ $mailbox->id }}" data-loading-text="{{ __('Processing') }}…"><i class="glyphicon glyphicon-volume-off"></i> <span class="mute-text-1 @if ($mailbox->mute) hidden @endif">{{ __('Mute Notifications') }}</span><span class="mute-text-0 @if (!$mailbox->mute) hidden @endif">{{ __('Unmute Notifications') }}</span></a></li>
@endif
@endif

View File

@ -26,8 +26,11 @@
<label for="name" class="col-sm-2 control-label">{{ __('Mailbox Name') }}</label>
<div class="col-sm-6">
<input id="name" type="text" class="form-control input-sized" name="name" value="{{ old('name', $mailbox->name) }}" maxlength="40" required autofocus>
@if (Auth::user()->isAdmin())
<input id="name" type="text" class="form-control input-sized" name="name" value="{{ old('name', $mailbox->name) }}" maxlength="40" required autofocus>
@else
{{ old('name', $mailbox->name) }}
@endif
@include('partials/field_error', ['field'=>'name'])
</div>
</div>
@ -36,7 +39,11 @@
<label for="email" class="col-sm-2 control-label">{{ __('Email Address') }}</label>
<div class="col-sm-6">
@if (Auth::user()->isAdmin())
<input id="email" type="email" class="form-control input-sized" name="email" value="{{ old('email', $mailbox->email) }}" maxlength="128" required autofocus>
@else
{{ old('email', $mailbox->email) }}
@endif
@include('partials/field_error', ['field'=>'email'])
</div>
</div>
@ -50,7 +57,7 @@
<i class="glyphicon glyphicon-info-sign icon-info" data-toggle="popover" data-trigger="hover" data-html="true" data-placement="left" data-content="{{ __('Aliases are other email addresses that also forward to your mailbox address. Separate each email with a comma.') }}"></i>
</div>
@include('partials/field_error', ['field'=>'aliases'])
</div>
</div>
@ -64,7 +71,7 @@
<i class="glyphicon glyphicon-info-sign icon-info" data-toggle="popover" data-trigger="hover" data-html="true" data-placement="left" data-content="{{ __('Send a copy of all outgoing replies to specific external addresses.') }} {{ __('Separate each email with a comma.') }}"></i>
</div>
@include('partials/field_error', ['field'=>'auto_bcc'])
</div>
</div>
@ -111,13 +118,13 @@
</div>
@action('mailbox.update.after_ticket_status', $mailbox)
{{-- Email Template option hidden until somebody needs it --}}
<div class="form-group{{ $errors->has('template') ? ' has-error' : '' }}" style="display:none">
<label for="template" class="col-sm-2 control-label">{{ __('Email Template') }} (todo)</label>
<div class="col-sm-6">
<div class="controls">
{{-- Afer implementing remove readonly--}}
<label for="template_plain" class="radio inline plain"><input type="radio" name="template" value="{{ App\Mailbox::TEMPLATE_PLAIN }}" disabled="disabled" class="disabled" id="template_plain" @if (old('template', $mailbox->template) == App\Mailbox::TEMPLATE_PLAIN || !$mailbox->template)checked="checked"@endif> {{ __('Plain Template') }}</label>
@ -155,27 +162,20 @@
<i class="glyphicon glyphicon-info-sign icon-info" data-toggle="popover" data-trigger="hover" data-html="true" data-placement="left" data-content="{{ __('This text will be added to the beginning of each email reply sent to a customer.') }}"></i>
</div>
@include('partials/field_error', ['field'=>'before_reply'])
</div>
</div>
<div class="form-group{{ $errors->has('signature') ? ' has-error' : '' }}">
<label for="signature" class="col-sm-2 control-label">{{ __('Email Signature') }}</label>
<div class="col-md-9 signature-editor">
<textarea id="signature" class="form-control" name="signature" rows="8">{{ old('signature', $mailbox->signature) }}</textarea>
@include('partials/field_error', ['field'=>'signature'])
</div>
</div>
<div class="form-group">
<div class="col-sm-6 col-sm-offset-2">
<button type="submit" class="btn btn-primary">
{{ __('Save') }}
</button>
@if (auth()->user()->isAdmin())
<a href="#" data-trigger="modal" data-modal-body="#delete_mailbox_modal" data-modal-no-footer="true" data-modal-title="{{ __('Delete the :mailbox_name mailbox?', ['mailbox_name' => $mailbox->name]) }}" data-modal-on-show="deleteMailboxModal" class="btn btn-link text-danger">{{ __('Delete mailbox') }}</a>
@endif
</div>
</div>
</form>
@ -203,4 +203,4 @@
@section('javascript')
@parent
mailboxUpdateInit('{{ App\Mailbox::FROM_NAME_CUSTOM }}');
@endsection
@endsection

View File

@ -75,6 +75,8 @@ Route::get('/mailbox/connection-settings/{id}/incoming', 'MailboxesController@co
Route::post('/mailbox/connection-settings/{id}/incoming', 'MailboxesController@connectionIncomingSave')->name('mailboxes.connection.incoming.save');
Route::get('/mailbox/settings/{id}/auto-reply', 'MailboxesController@autoReply')->name('mailboxes.auto_reply');
Route::post('/mailbox/settings/{id}/auto-reply', 'MailboxesController@autoReplySave')->name('mailboxes.auto_reply.save');
Route::get('/mailbox/settings/{id}/email-signature', 'MailboxesController@emailSignature')->name('mailboxes.email_signature');
Route::post('/mailbox/settings/{id}/email-signature', 'MailboxesController@emailSignatureSave')->name('mailboxes.email_signature.save');
Route::post('/mailbox/ajax', ['uses' => 'MailboxesController@ajax', 'laroute' => true])->name('mailboxes.ajax');
// Customers