diff --git a/src/mibew/js/source/chat/model_views/controls/send_mail.js b/src/mibew/js/source/chat/model_views/controls/send_mail.js index ff0e863d..cfadc8c3 100644 --- a/src/mibew/js/source/chat/model_views/controls/send_mail.js +++ b/src/mibew/js/source/chat/model_views/controls/send_mail.js @@ -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 */ diff --git a/src/mibew/libs/chat.php b/src/mibew/libs/chat.php index b390096e..330315af 100644 --- a/src/mibew/libs/chat.php +++ b/src/mibew/libs/chat.php @@ -411,6 +411,7 @@ function setup_chatview_for_user( 'defaultName' => (bool) (getlocal("Guest") != $thread->userName), 'canPost' => true, 'isAgent' => false, + 'canSendEmail' => (bool) (Settings::get('usercansendemail') == "1"), ); // Set link to send mail page diff --git a/src/mibew/libs/classes/Mibew/Controller/Chat/MailController.php b/src/mibew/libs/classes/Mibew/Controller/Chat/MailController.php index 970dd276..8216798c 100644 --- a/src/mibew/libs/classes/Mibew/Controller/Chat/MailController.php +++ b/src/mibew/libs/classes/Mibew/Controller/Chat/MailController.php @@ -19,6 +19,7 @@ namespace Mibew\Controller\Chat; +use Mibew\Http\Exception\AccessDeniedException; use Mibew\Http\Exception\NotFoundException; use Mibew\Mail\Template as MailTemplate; use Mibew\Mail\Utils as MailUtils; @@ -41,6 +42,12 @@ class MailController extends AbstractController */ public function showFormAction(Request $request) { + + // Check whether this feature is enabled at all + if (!Settings::get('usercansendemail')) { + throw new AccessDeniedException(); + } + $page = array( // Use errors list stored in the request. We need to do so to have // an ability to pass the request from the "submitForm" action. @@ -85,6 +92,12 @@ class MailController extends AbstractController */ public function submitFormAction(Request $request) { + + // Check whether this feature is enabled at all + if (!Settings::get('usercansendemail')) { + throw new AccessDeniedException(); + } + $errors = array(); $thread_id = $request->attributes->get('thread_id'); diff --git a/src/mibew/libs/classes/Mibew/Controller/Settings/FeaturesController.php b/src/mibew/libs/classes/Mibew/Controller/Settings/FeaturesController.php index cf7ca62e..640d211f 100644 --- a/src/mibew/libs/classes/Mibew/Controller/Settings/FeaturesController.php +++ b/src/mibew/libs/classes/Mibew/Controller/Settings/FeaturesController.php @@ -116,6 +116,7 @@ class FeaturesController extends AbstractController return array( 'enableban', 'usercanchangename', + 'usercansendemail', 'enablegroups', 'enablegroupsisolation', 'enablestatistics', diff --git a/src/mibew/libs/classes/Mibew/Settings.php b/src/mibew/libs/classes/Mibew/Settings.php index d88af1cf..f264dd91 100644 --- a/src/mibew/libs/classes/Mibew/Settings.php +++ b/src/mibew/libs/classes/Mibew/Settings.php @@ -86,6 +86,7 @@ class Settings 'enablessl' => '0', 'forcessl' => '0', 'usercanchangename' => '1', + 'usercansendemail' => '1', 'enablegroups' => '0', 'enablegroupsisolation' => '0', 'enablestatistics' => '1', diff --git a/src/mibew/styles/chats/dark/templates_src/client_side/chat/controls/send_mail.handlebars b/src/mibew/styles/chats/dark/templates_src/client_side/chat/controls/send_mail.handlebars index ba204486..7e50c8d3 100644 --- a/src/mibew/styles/chats/dark/templates_src/client_side/chat/controls/send_mail.handlebars +++ b/src/mibew/styles/chats/dark/templates_src/client_side/chat/controls/send_mail.handlebars @@ -1 +1,3 @@ -
\ No newline at end of file +{{#if user.canSendEmail}} +
+{{/if}} \ No newline at end of file diff --git a/src/mibew/styles/chats/default/templates_src/client_side/chat/controls/send_mail.handlebars b/src/mibew/styles/chats/default/templates_src/client_side/chat/controls/send_mail.handlebars index ba204486..7e50c8d3 100644 --- a/src/mibew/styles/chats/default/templates_src/client_side/chat/controls/send_mail.handlebars +++ b/src/mibew/styles/chats/default/templates_src/client_side/chat/controls/send_mail.handlebars @@ -1 +1,3 @@ -
\ No newline at end of file +{{#if user.canSendEmail}} +
+{{/if}} \ No newline at end of file diff --git a/src/mibew/styles/pages/dark/templates_src/server_side/settings_features.handlebars b/src/mibew/styles/pages/dark/templates_src/server_side/settings_features.handlebars index 7289d118..bbef35dd 100644 --- a/src/mibew/styles/pages/dark/templates_src/server_side/settings_features.handlebars +++ b/src/mibew/styles/pages/dark/templates_src/server_side/settings_features.handlebars @@ -42,6 +42,15 @@
+
+ +
+ +
+ +
+
+
diff --git a/src/mibew/styles/pages/default/templates_src/server_side/settings_features.handlebars b/src/mibew/styles/pages/default/templates_src/server_side/settings_features.handlebars index 7289d118..bbef35dd 100644 --- a/src/mibew/styles/pages/default/templates_src/server_side/settings_features.handlebars +++ b/src/mibew/styles/pages/default/templates_src/server_side/settings_features.handlebars @@ -42,6 +42,15 @@
+
+ +
+ +
+ +
+
+