Merge remote-tracking branch 'origin/master' into develop

This commit is contained in:
Pierre Goiffon
2019-03-08 14:35:35 +01:00
11 changed files with 70 additions and 25 deletions

View File

@@ -42,7 +42,6 @@ function TestConfig($sContents, $oP)
eval('if(0){'.trim($sSafeContent).'}');
$sNoise = trim(ob_get_contents());
ob_end_clean();
CheckDBPasswordInNewConfig($sSafeContent);
}
catch (Error $e)
{
@@ -78,17 +77,17 @@ function TestConfig($sContents, $oP)
/**
* @param $sSafeContent
*
* @throws \Exception
* @return bool
*/
function CheckDBPasswordInNewConfig($sSafeContent)
function DBPasswordInNewConfigIsOk($sSafeContent)
{
$bIsWindows = (array_key_exists('WINDIR', $_SERVER) || array_key_exists('windir', $_SERVER));
if ($bIsWindows && (preg_match("@'db_pwd' => '[^%!\"]+',@U", $sSafeContent) === 0))
{
// Unsupported Password
throw new Exception("On Windows, database password must not contain %, ! or \" character (backups won't work)...");
return false;
}
return true;
}
/////////////////////////////////////////////////////////////////////
@@ -179,7 +178,14 @@ try
@unlink($sTmpFile);
@chmod($sConfigFile, 0444); // Read-only
$oP->p('<div id="save_result" class="header_message message_ok">'.Dict::S('config-saved').'</div>');
if (DBPasswordInNewConfigIsOk($sConfig))
{
$oP->p('<div id="save_result" class="header_message message_ok">'.Dict::S('config-saved').'</div>');
}
else
{
$oP->p('<div id="save_result" class="header_message message_info">'.Dict::S('config-saved-warning-db-password').'</div>');
}
$sOriginalConfig = str_replace("\r\n", "\n", file_get_contents($sConfigFile));
}
catch (Exception $e)

View File

@@ -35,4 +35,5 @@ Dict::Add('EN US', 'English', 'English', array(
'config-reverted' => 'The configuration has been reverted.',
'config-parse-error' => 'Line %2$d: %1$s.<br/>The file has NOT been updated.',
'config-current-line' => 'Editing line: %1$s',
'config-saved-warning-db-password' => 'Successfully recorded, but the backup won\'t work due to unsupported characters in the database password.',
));

View File

@@ -19,4 +19,5 @@ Dict::Add('FR FR', 'French', 'Français', array(
'config-reverted' => 'Vos modifications ont été écrasées par la version enregistrée.',
'config-parse-error' => 'Ligne %2$d: %1$s.<br/>Le fichier n\'a PAS été modifié.',
'config-current-line' => 'Ligne en édition : %1$s',
'config-saved-warning-db-password' => 'Configuration enregistrée. Les sauvegardes ne fonctionneront pas à cause du format du pot de passe de la base.',
));

View File

@@ -1163,10 +1163,30 @@ class ObjectFormManager extends FormManager
}
elseif ($oAttDef->GetEditClass() === 'CustomFields')
{
if (!empty($value['template_data']) && !empty($value['user_data']))
// We don't update attribute as ormCustomField comparaison is not working as excepted.
// When several templates available, "template_id" is not sent by the portal has it is a read-only select input
// therefore, the TemplateFieldsHandler::CompareValues() doesn't work.
// This use case works in the console as it always send all fields, even hidden and read-only.
// Different templates
if( isset($value['template_id'])
&& ($value['template_id'] != $value['current_template_id']) )
{
$this->oObject->Set($sAttCode, $value);
}
// Same template, different fields
elseif(isset($value['template_id'], $value['template_data'])
&& ($value['template_id'] == $value['current_template_id'])
&& ($value['template_data'] != $value['current_template_data']) )
{
$this->oObject->Set($sAttCode, $value);
}
// Update of current values
elseif(isset($value['user_data']))
{
$this->oObject->Set($sAttCode, $value);
}
// Else don't update! Otherwise we might loose current value
}
else
{