Commit d3fe1cff authored by Ad Schellevis's avatar Ad Schellevis

(proxy) change to new validation behavior

parent b814e215
...@@ -164,19 +164,12 @@ class SettingsController extends ApiControllerBase ...@@ -164,19 +164,12 @@ class SettingsController extends ApiControllerBase
$valMsgs = $mdlProxy->performValidation(); $valMsgs = $mdlProxy->performValidation();
foreach ($valMsgs as $field => $msg) { foreach ($valMsgs as $field => $msg) {
$fieldnm = str_replace($node->__reference, "blacklist", $msg->getField()); $fieldnm = str_replace($node->__reference, "blacklist", $msg->getField());
if ($fieldnm != $msg->getField()) {
// only collect validation errors for the item we're currently editing.
$result["validations"][$fieldnm] = $msg->getMessage(); $result["validations"][$fieldnm] = $msg->getMessage();
} }
}
if (count($result['validations']) == 0) { if (count($result['validations']) == 0) {
// we've already performed a validation, prevent issues
// from other items in the model reflecting back to us.
$mdlProxy->serializeToConfig($disable_validation = true);
// save config if validated correctly // save config if validated correctly
$mdlProxy->serializeToConfig();
Config::getInstance()->save(); Config::getInstance()->save();
$result = array("result" => "saved"); $result = array("result" => "saved");
} }
...@@ -203,19 +196,12 @@ class SettingsController extends ApiControllerBase ...@@ -203,19 +196,12 @@ class SettingsController extends ApiControllerBase
foreach ($valMsgs as $field => $msg) { foreach ($valMsgs as $field => $msg) {
$fieldnm = str_replace($node->__reference, "blacklist", $msg->getField()); $fieldnm = str_replace($node->__reference, "blacklist", $msg->getField());
if ($fieldnm != $msg->getField()) {
// only collect validation errors for the item we're currently editing.
$result["validations"][$fieldnm] = $msg->getMessage(); $result["validations"][$fieldnm] = $msg->getMessage();
} }
}
if (count($result['validations']) == 0) { if (count($result['validations']) == 0) {
// we've already performed a validation, prevent issues from
// other items in the model reflecting back to us.
$mdlProxy->serializeToConfig($disable_validation = true);
// save config if validated correctly // save config if validated correctly
$mdlProxy->serializeToConfig();
Config::getInstance()->save(); Config::getInstance()->save();
$result = array("result" => "saved"); $result = array("result" => "saved");
} }
...@@ -239,7 +225,7 @@ class SettingsController extends ApiControllerBase ...@@ -239,7 +225,7 @@ class SettingsController extends ApiControllerBase
if ($uuid != null) { if ($uuid != null) {
if ($mdlProxy->forward->acl->remoteACLs->blacklists->blacklist->del($uuid)) { if ($mdlProxy->forward->acl->remoteACLs->blacklists->blacklist->del($uuid)) {
// if item is removed, serialize to config and save // if item is removed, serialize to config and save
$mdlProxy->serializeToConfig($disable_validation = true); $mdlProxy->serializeToConfig();
Config::getInstance()->save(); Config::getInstance()->save();
$result['result'] = 'deleted'; $result['result'] = 'deleted';
} else { } else {
...@@ -273,7 +259,7 @@ class SettingsController extends ApiControllerBase ...@@ -273,7 +259,7 @@ class SettingsController extends ApiControllerBase
$node->enabled = "1"; $node->enabled = "1";
} }
// if item has toggled, serialize to config and save // if item has toggled, serialize to config and save
$mdlProxy->serializeToConfig($disable_validation = true); $mdlProxy->serializeToConfig();
Config::getInstance()->save(); Config::getInstance()->save();
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment