Add warnings about need for button regeneration

This commit is contained in:
Fedor A. Fetisov 2018-10-17 19:35:51 +03:00
parent f9b6eeb92c
commit fc2c9d791a
4 changed files with 25 additions and 2 deletions

View File

@ -55,6 +55,7 @@ class FeaturesController extends AbstractController
$page['canmodify'] = is_capable(CAN_ADMINISTRATE, $operator);
$page['stored'] = $request->query->get('stored');
$page['regeneratebutton'] = $request->query->get('regenerate');
$page['title'] = getlocal('Messenger settings');
$page['menuid'] = 'settings';
$page = array_merge($page, prepare_menu($operator));
@ -77,10 +78,15 @@ class FeaturesController extends AbstractController
{
csrf_check_token($request);
$regenerate_button = false;
// Update options in the database.
$options = $this->getOptionsList();
foreach ($options as $opt) {
$value = $request->request->get($opt) == 'on' ? '1' : '0';
if (($opt === 'enabletracking') && (Settings::get($opt) != $value)) {
$regenerate_button = true;
}
Settings::set($opt, $value);
}
@ -94,7 +100,7 @@ class FeaturesController extends AbstractController
// Redirect the current operator to the same page using GET method.
$redirect_to = $this->generateUrl(
'settings_features',
array('stored' => true)
array('stored' => true, 'regenerate' => $regenerate_button)
);
return $this->redirect($redirect_to);

View File

@ -83,6 +83,7 @@ class PerformanceController extends AbstractController
$page['enabletracking'] = Settings::get('enabletracking');
$page['stored'] = $request->query->get('stored');
$page['regeneratebutton'] = $request->query->get('regenerate');
$page['title'] = getlocal("Messenger settings");
$page['menuid'] = "settings";
@ -107,6 +108,8 @@ class PerformanceController extends AbstractController
$errors = array();
$params = array();
$regenerate_button = false;
$params['online_timeout'] = $request->request->get('onlinetimeout');
if (!is_numeric($params['online_timeout'])) {
$errors[] = wrong_field("Operator online time threshold");
@ -141,6 +144,10 @@ class PerformanceController extends AbstractController
$params['updatefrequency_tracking'] = $request->request->get('frequencytracking');
if (!is_numeric($params['updatefrequency_tracking'])) {
$errors[] = wrong_field("Tracking refresh time");
} else {
if (Settings::get('updatefrequency_tracking') != $params['updatefrequency_tracking']) {
$regenerate_button = true;
}
}
$params['visitors_limit'] = $request->request->get('visitorslimit');
@ -177,7 +184,7 @@ class PerformanceController extends AbstractController
}
// Redirect the current operator to the same page using get method.
$redirect_to = $this->generateUrl('settings_performance', array('stored' => true));
$redirect_to = $this->generateUrl('settings_performance', array('stored' => true, 'regenerate' => $regenerate_button));
return $this->redirect($redirect_to);
}

View File

@ -13,6 +13,11 @@
<div id="form-message">{{l10n "Features activated"}}</div>
{{/if}}
{{#if regeneratebutton}}
<br/>
<div id="form-message"><img src="{{asset "@CurrentStyle/images/dash/warning.png"}}" alt="" class="warning" /> {{l10n "<a href=\"{0}\">Regenerate the chat button</a> for options to take effect" (route "button_code")}}</div>
{{/if}}
<form name="features" method="post" action="{{route "settings_features_save"}}">
{{csrfTokenInput}}
<input type="hidden" name="sent" value="true"/>

View File

@ -13,6 +13,11 @@
<div id="form-message">{{l10n "Changes saved"}}</div>
{{/if}}
{{#if regeneratebutton}}
<br/>
<div id="form-message"><img src="{{asset "@CurrentStyle/images/dash/warning.png"}}" alt="" class="warning" /> {{l10n "<a href=\"{0}\">Regenerate the chat button</a> for options to take effect" (route "button_code")}}</div>
{{/if}}
<form name="performance" method="post" action="{{route "settings_performance_save"}}">
{{csrfTokenInput}}