get rid of js that just does the form submit. Upgrade the button from an input to a button. Use 0 and 1 instead of accept and decline, which allows us to pre-select the current value of ZM_TELEMETRY_DATA. So that if you had previously declined, you won't accidentally accept. This fixes the reported error that choosing decline would cause the setting to not be saved and the privacy popup to happen again.

This commit is contained in:
Isaac Connor 2019-02-19 12:54:12 -05:00
parent eaa7341935
commit 97a888c0db
3 changed files with 18 additions and 29 deletions

View File

@ -19,18 +19,18 @@
//
if ( !canEdit('System') ) {
Warning("Need System permissions to update privacy");
Warning('Need System permissions to update privacy');
return;
}
if ( ($action == 'privacy') && isset($_REQUEST['option']) ) {
switch( $_REQUEST['option'] ) {
case 'decline' :
if ( ($action == 'privacy') && isset($_POST['option']) ) {
switch( $_POST['option'] ) {
case '0' :
dbQuery("UPDATE Config SET Value = '0' WHERE Name = 'ZM_SHOW_PRIVACY'");
dbQuery("UPDATE Config SET Value = '0' WHERE Name = 'ZM_TELEMETRY_DATA'");
$redirect = '?view=console';
break;
case 'accept' :
case '1' :
dbQuery("UPDATE Config SET Value = '0' WHERE Name = 'ZM_SHOW_PRIVACY'");
dbQuery("UPDATE Config SET Value = '1' WHERE Name = 'ZM_TELEMETRY_DATA'");
$redirect = '?view=console';

View File

@ -1,10 +0,0 @@
function submitForm( element ) {
var form = element.form;
if ( form.option.selectedIndex == 0 ) {
form.view.value = currentView;
} else {
form.view.value = 'none';
}
form.submit();
}

View File

@ -18,15 +18,14 @@
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
//
if ( !canEdit( 'System' ) )
{
$view = "error";
if ( !canEdit('System') ) {
$view = 'error';
return;
}
$options = array(
"accept" => translate('Accept'),
"decline" => translate('Decline'),
'1' => translate('Accept'),
'0' => translate('Decline'),
);
$focusWindow = true;
@ -41,31 +40,31 @@ xhtmlHeaders(__FILE__, translate('Privacy') );
</div>
<div id="content">
<form name="contentForm" id="contentForm" method="post" action="?">
<input type="hidden" name="view" value="none"/>
<input type="hidden" name="view" value="privacy"/>
<input type="hidden" name="action" value="privacy"/>
<h6><?php echo translate('PrivacyAbout') ?></h6>
<p><?php echo translate('PrivacyAboutText') ?></p>
<br>
<br/>
<h6><?php echo translate('PrivacyContact') ?></h6>
<p><?php echo translate('PrivacyContactText') ?></p>
<br>
<br/>
<h6><?php echo translate('PrivacyCookies') ?></h6>
<p><?php echo translate('PrivacyCookiesText') ?></p>
<br>
<br/>
<h6><?php echo translate('PrivacyTelemetry') ?></h6>
<p><?php echo translate('PrivacyTelemetryText') ?></p>
<br>
<br/>
<p><?php echo translate('PrivacyTelemetryList') ?></p>
<p><?php echo translate('PrivacyMonitorList') ?></p>
<p><?php echo translate('PrivacyConclusionText') ?></p>
<p><?php echo buildSelect( "option", $options ); ?></p>
<p><?php echo htmlSelect('option', $options, ZM_TELEMETRY_DATA); ?></p>
<div id="contentButtons">
<input type="submit" value="<?php echo translate('Apply') ?>" data-on-click-this="submitForm">
<button type="submit" value="Apply"><?php echo translate('Apply') ?></button>
</div>
</form>
</div>