Commit 1eb82cbb authored by Ad Schellevis's avatar Ad Schellevis

(cron) change to new validation behavior

parent 56b17f79
......@@ -91,19 +91,12 @@ class SettingsController extends ApiControllerBase
$valMsgs = $mdlCron->performValidation();
foreach ($valMsgs as $field => $msg) {
$fieldnm = str_replace($node->__reference, "job", $msg->getField());
if ($fieldnm != $msg->getField()) {
// only collect validation errors for the item we're currently editing.
$result["validations"][$fieldnm] = $msg->getMessage();
}
}
if (count($result['validations']) == 0) {
// we've already performed a validation, prevent issues
// from other items in the model reflecting back to us.
$mdlCron->serializeToConfig($disable_validation = true);
// save config if validated correctly
$mdlCron->serializeToConfig();
Config::getInstance()->save();
$result = array("result" => "saved");
}
......@@ -131,19 +124,12 @@ class SettingsController extends ApiControllerBase
foreach ($valMsgs as $field => $msg) {
$fieldnm = str_replace($node->__reference, "job", $msg->getField());
if ($fieldnm != $msg->getField()) {
// only collect validation errors for the item we're currently editing.
$result["validations"][$fieldnm] = $msg->getMessage();
}
}
if (count($result['validations']) == 0) {
// we've already performed a validation, prevent issues from
// other items in the model reflecting back to us.
$mdlCron->serializeToConfig($disable_validation = true);
// save config if validated correctly
$mdlCron->serializeToConfig();
Config::getInstance()->save();
$result = array("result" => "saved");
}
......@@ -153,7 +139,7 @@ class SettingsController extends ApiControllerBase
}
/**
* delete job by uuid
* delete job by uuid ( only if origin is cron)
* @param $uuid item unique id
* @return array status
*/
......@@ -161,13 +147,13 @@ class SettingsController extends ApiControllerBase
{
$result = array("result" => "failed");
if ($this->request->isPost()) {
$mdlCron = new Cron();
if ($uuid != null) {
if ($mdlCron->jobs->job->del($uuid)) {
$node = $mdlCron->getNodeByReference('jobs.job.' . $uuid);
if ($node != null && (string)$node->origin == "cron" && $mdlCron->jobs->job->del($uuid) == true) {
// if item is removed, serialize to config and save
$mdlCron->serializeToConfig($disable_validation = true);
$mdlCron->serializeToConfig();
Config::getInstance()->save();
$result['result'] = 'deleted';
} else {
......@@ -201,7 +187,7 @@ class SettingsController extends ApiControllerBase
$node->enabled = "1";
}
// if item has toggled, serialize to config and save
$mdlCron->serializeToConfig($disable_validation = true);
$mdlCron->serializeToConfig();
Config::getInstance()->save();
}
}
......@@ -216,9 +202,7 @@ class SettingsController extends ApiControllerBase
*/
public function searchJobsAction()
{
// if (!$this->request->isPost()) {
// return array();
// }
if ($this->request->isPost()) {
$this->sessionClose();
// fetch query parameters
$itemsPerPage = $this->request->getPost('rowCount', 'int', 9999);
......@@ -252,5 +236,8 @@ class SettingsController extends ApiControllerBase
$grid = new UIModelGrid($mdlCron->jobs->job);
return $grid->fetch($fields, $itemsPerPage, $currentPage, $sortBy, $sortDescending, $searchPhrase);
} else {
return array();
}
}
}
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