Make possible to disable sending a chat to email

This commit is contained in:
Fedor A. Fetisov 2021-05-16 02:09:45 +03:00
parent 0317979c92
commit 6dae66540d
9 changed files with 51 additions and 2 deletions

View File

@ -44,6 +44,17 @@
} }
), ),
/**
* Override Backbone.Marionette.ItemView.serializeData to pass some
* extra fields to template.
* @returns {Object} Template data
*/
serializeData: function() {
var data = this.model.toJSON();
data.user = Mibew.Objects.Models.user.toJSON();
return data;
},
/** /**
* Load and display send mail window * Load and display send mail window
*/ */

View File

@ -411,6 +411,7 @@ function setup_chatview_for_user(
'defaultName' => (bool) (getlocal("Guest") != $thread->userName), 'defaultName' => (bool) (getlocal("Guest") != $thread->userName),
'canPost' => true, 'canPost' => true,
'isAgent' => false, 'isAgent' => false,
'canSendEmail' => (bool) (Settings::get('usercansendemail') == "1"),
); );
// Set link to send mail page // Set link to send mail page

View File

@ -19,6 +19,7 @@
namespace Mibew\Controller\Chat; namespace Mibew\Controller\Chat;
use Mibew\Http\Exception\AccessDeniedException;
use Mibew\Http\Exception\NotFoundException; use Mibew\Http\Exception\NotFoundException;
use Mibew\Mail\Template as MailTemplate; use Mibew\Mail\Template as MailTemplate;
use Mibew\Mail\Utils as MailUtils; use Mibew\Mail\Utils as MailUtils;
@ -41,6 +42,12 @@ class MailController extends AbstractController
*/ */
public function showFormAction(Request $request) public function showFormAction(Request $request)
{ {
// Check whether this feature is enabled at all
if (!Settings::get('usercansendemail')) {
throw new AccessDeniedException();
}
$page = array( $page = array(
// Use errors list stored in the request. We need to do so to have // Use errors list stored in the request. We need to do so to have
// an ability to pass the request from the "submitForm" action. // an ability to pass the request from the "submitForm" action.
@ -85,6 +92,12 @@ class MailController extends AbstractController
*/ */
public function submitFormAction(Request $request) public function submitFormAction(Request $request)
{ {
// Check whether this feature is enabled at all
if (!Settings::get('usercansendemail')) {
throw new AccessDeniedException();
}
$errors = array(); $errors = array();
$thread_id = $request->attributes->get('thread_id'); $thread_id = $request->attributes->get('thread_id');

View File

@ -116,6 +116,7 @@ class FeaturesController extends AbstractController
return array( return array(
'enableban', 'enableban',
'usercanchangename', 'usercanchangename',
'usercansendemail',
'enablegroups', 'enablegroups',
'enablegroupsisolation', 'enablegroupsisolation',
'enablestatistics', 'enablestatistics',

View File

@ -86,6 +86,7 @@ class Settings
'enablessl' => '0', 'enablessl' => '0',
'forcessl' => '0', 'forcessl' => '0',
'usercanchangename' => '1', 'usercanchangename' => '1',
'usercansendemail' => '1',
'enablegroups' => '0', 'enablegroups' => '0',
'enablegroupsisolation' => '0', 'enablegroupsisolation' => '0',
'enablestatistics' => '1', 'enablestatistics' => '1',

View File

@ -1 +1,3 @@
{{#if user.canSendEmail}}
<div class="tpl-image" title="{{l10n "Send chat history by e-mail"}}"></div> <div class="tpl-image" title="{{l10n "Send chat history by e-mail"}}"></div>
{{/if}}

View File

@ -1 +1,3 @@
{{#if user.canSendEmail}}
<div class="tpl-image" title="{{l10n "Send chat history by e-mail"}}"></div> <div class="tpl-image" title="{{l10n "Send chat history by e-mail"}}"></div>
{{/if}}

View File

@ -42,6 +42,15 @@
<br clear="all"/> <br clear="all"/>
</div> </div>
<div class="field">
<label for="user-can-send-email" class="field-label">{{l10n "Allows users to send chat history by email"}}</label>
<div class="field-value">
<input id="user-can-send-email" type="checkbox" name="usercansendemail" value="on"{{#if formusercansendemail}} checked="checked"{{/if}}{{#unless canmodify}} disabled="disabled"{{/unless}}/>
</div>
<label for="user-can-send-email" class="field-description"> &mdash; {{l10n "Turn off to disable user's ability to send chat history by email"}}</label>
<br clear="all"/>
</div>
<div class="field"> <div class="field">
<label for="enable-ssl" class="field-label">{{l10n "Allow secure connections (SSL)"}}</label> <label for="enable-ssl" class="field-label">{{l10n "Allow secure connections (SSL)"}}</label>
<div class="field-value"> <div class="field-value">

View File

@ -42,6 +42,15 @@
<br clear="all"/> <br clear="all"/>
</div> </div>
<div class="field">
<label for="user-can-send-email" class="field-label">{{l10n "Allows users to send chat history by email"}}</label>
<div class="field-value">
<input id="user-can-send-email" type="checkbox" name="usercansendemail" value="on"{{#if formusercansendemail}} checked="checked"{{/if}}{{#unless canmodify}} disabled="disabled"{{/unless}}/>
</div>
<label for="user-can-send-email" class="field-description"> &mdash; {{l10n "Turn off to disable user's ability to send chat history by email"}}</label>
<br clear="all"/>
</div>
<div class="field"> <div class="field">
<label for="enable-ssl" class="field-label">{{l10n "Allow secure connections (SSL)"}}</label> <label for="enable-ssl" class="field-label">{{l10n "Allow secure connections (SSL)"}}</label>
<div class="field-value"> <div class="field-value">