Implement a check on change of language. Make sure that the specified language file exists. Reports errors to UI

This commit is contained in:
Isaac Connor 2022-02-08 13:29:51 -05:00
parent 03f6637060
commit 8cdd96f286
1 changed files with 13 additions and 2 deletions

View File

@ -24,6 +24,8 @@ if ( !canEdit('System') ) {
return; return;
} }
global $error_message;
if ( $action == 'delete' ) { if ( $action == 'delete' ) {
if ( isset($_REQUEST['object']) ) { if ( isset($_REQUEST['object']) ) {
if ( $_REQUEST['object'] == 'server' ) { if ( $_REQUEST['object'] == 'server' ) {
@ -65,10 +67,19 @@ if ( $action == 'delete' ) {
} }
if ( isset($newValue) && ($newValue != $config['Value']) ) { if ( isset($newValue) && ($newValue != $config['Value']) ) {
# Handle special cases first
if ($config['Name'] == 'ZM_LANG_DEFAULT') {
# Verify that the language file exists in the lang directory.
if (!file_exists(ZM_PATH_WEB.'/lang/'.$newValue.'.php')) {
$error_message .= 'Error setting ' . $config['Name'].'. New value ' .$newValue.' not saved because '.ZM_PATH_WEB.'/lang/'.$newValue.'.php doesn\'t exist.<br/>';
ZM\Error($error_message);
continue;
}
}
dbQuery('UPDATE Config SET Value=? WHERE Name=?', array($newValue, $config['Name'])); dbQuery('UPDATE Config SET Value=? WHERE Name=?', array($newValue, $config['Name']));
$changed = true; $changed = true;
} } # end if value changed
} } # end foreach config entry
if ( $changed ) { if ( $changed ) {
switch ( $_REQUEST['tab'] ) { switch ( $_REQUEST['tab'] ) {
case 'system' : case 'system' :