From d32f9c02ce13b47161f89f9e2d15db5bd2894424 Mon Sep 17 00:00:00 2001 From: "Fedor A. Fetisov" Date: Thu, 16 Aug 2018 19:10:43 +0300 Subject: [PATCH] Add optional privacy link to pre-chat survey Fixes #227 --- src/mibew/js/source/features.js | 12 +++++++++ src/mibew/libs/chat.php | 7 +++++ .../Settings/FeaturesController.php | 26 +++++++++++++++++++ src/mibew/libs/classes/Mibew/Settings.php | 2 ++ .../client_side/survey/form.handlebars | 6 +++++ .../server_side/settings_features.handlebars | 18 +++++++++++++ 6 files changed, 71 insertions(+) diff --git a/src/mibew/js/source/features.js b/src/mibew/js/source/features.js index 18aa5019..e7f7b7ea 100644 --- a/src/mibew/js/source/features.js +++ b/src/mibew/js/source/features.js @@ -49,6 +49,14 @@ } } + function updatePrivacyPolicy() { + if ($("#enable-privacy-policy").is(":checked")) { + $(".under-privacy-policy").show(); + } else { + $(".under-privacy-policy").hide(); + } + } + $(function() { $("#enable-presurvey").change(function() { updateSurvey(); @@ -62,9 +70,13 @@ $("#enable-tracking").change(function() { updateTracking(); }); + $("#enable-privacy-policy").change(function() { + updatePrivacyPolicy(); + }); updateSurvey(); updateSSL(); updateGroups(); updateTracking(); + updatePrivacyPolicy(); }); })(jQuery); diff --git a/src/mibew/libs/chat.php b/src/mibew/libs/chat.php index abb8a929..80561910 100644 --- a/src/mibew/libs/chat.php +++ b/src/mibew/libs/chat.php @@ -221,6 +221,12 @@ function setup_survey($name, $email, $group_id, $info, $referrer) 'title' => $data['page.title'] ); + // Set privacy policy link (if needed) + if (Settings::get('enableprivacypolicy') + && strcmp('', Settings::get('privacypolicy'))) { + $data['survey']['surveyForm']['privacyPolicyUrl'] = Settings::get('privacypolicy'); + } + if (Settings::get('enablegroups') == '1' && Settings::get('surveyaskgroup') == '1') { $data['survey']['surveyForm']['groups'] = prepare_groups_select($group_id); @@ -438,6 +444,7 @@ function setup_chatview_for_user( ? $asset_url_generator->generate($operator['vcavatar']) : ''; + return $data; } diff --git a/src/mibew/libs/classes/Mibew/Controller/Settings/FeaturesController.php b/src/mibew/libs/classes/Mibew/Controller/Settings/FeaturesController.php index fe2220a1..77df9260 100644 --- a/src/mibew/libs/classes/Mibew/Controller/Settings/FeaturesController.php +++ b/src/mibew/libs/classes/Mibew/Controller/Settings/FeaturesController.php @@ -47,6 +47,12 @@ class FeaturesController extends AbstractController $page['form' . $opt] = (Settings::get($opt) == '1'); } + // Load all needed featured values and fill the form. + $values = $this->getValuesList(); + foreach ($values as $val) { + $page['form' . $val] = Settings::get($val); + } + $page['canmodify'] = is_capable(CAN_ADMINISTRATE, $operator); $page['stored'] = $request->query->get('stored'); $page['title'] = getlocal('Messenger settings'); @@ -78,6 +84,13 @@ class FeaturesController extends AbstractController Settings::set($opt, $value); } + // Update featured values in the database. + $values = $this->getValuesList(); + foreach ($values as $val) { + $value = $request->request->get($val); + Settings::set($val, $value); + } + // Redirect the current operator to the same page using GET method. $redirect_to = $this->generateUrl( 'settings_features', @@ -110,8 +123,21 @@ class FeaturesController extends AbstractController 'enablepopupnotification', 'showonlineoperators', 'enablecaptcha', + 'enableprivacypolicy', 'trackoperators', 'autocheckupdates', ); } + + /** + * Returns list with names of all featured values. + * + * @return array Featured values names. + */ + protected function getValuesList() + { + return array( + 'privacypolicy', + ); + } } diff --git a/src/mibew/libs/classes/Mibew/Settings.php b/src/mibew/libs/classes/Mibew/Settings.php index bea6e67b..d0a14507 100644 --- a/src/mibew/libs/classes/Mibew/Settings.php +++ b/src/mibew/libs/classes/Mibew/Settings.php @@ -98,6 +98,8 @@ class Settings 'autocheckupdates' => '1', /* Check updates automatically */ 'showonlineoperators' => '0', 'enablecaptcha' => '0', + 'enableprivacypolicy' => '0', + 'privacypolicy' => '', 'online_timeout' => 30, /* Timeout (in seconds) when online operator becomes offline */ 'connection_timeout' => 30, /* Timeout (in seconds) from the last ping when messaging window disconnects */ 'updatefrequency_operator' => 2, diff --git a/src/mibew/styles/chats/default/templates_src/client_side/survey/form.handlebars b/src/mibew/styles/chats/default/templates_src/client_side/survey/form.handlebars index cec9c3f1..092bd220 100644 --- a/src/mibew/styles/chats/default/templates_src/client_side/survey/form.handlebars +++ b/src/mibew/styles/chats/default/templates_src/client_side/survey/form.handlebars @@ -42,7 +42,13 @@ {{/if}} + {{#if privacyPolicyUrl}} + + {{{l10n "Please note that by starting the chat you're explicitly agree with the Privacy Policy" privacyPolicyUrl}}} + + {{/if}} +
{{l10n "Start Chat"}}
 
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 86723908..3408d7e2 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 @@ -143,6 +143,24 @@
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+
+