Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
OpnSense
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kulya
OpnSense
Commits
1eb82cbb
Commit
1eb82cbb
authored
Jul 02, 2015
by
Ad Schellevis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(cron) change to new validation behavior
parent
56b17f79
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
43 additions
and
56 deletions
+43
-56
SettingsController.php
.../app/controllers/OPNsense/Cron/Api/SettingsController.php
+43
-56
No files found.
src/opnsense/mvc/app/controllers/OPNsense/Cron/Api/SettingsController.php
View file @
1eb82cbb
...
...
@@ -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
();
}
$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
();
}
$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,41 +202,42 @@ class SettingsController extends ApiControllerBase
*/
public
function
searchJobsAction
()
{
// if (!$this->request->isPost()) {
// return array();
// }
$this
->
sessionClose
();
// fetch query parameters
$itemsPerPage
=
$this
->
request
->
getPost
(
'rowCount'
,
'int'
,
9999
);
$currentPage
=
$this
->
request
->
getPost
(
'current'
,
'int'
,
1
);
$sortBy
=
array
(
"description"
);
$sortDescending
=
false
;
if
(
$this
->
request
->
hasPost
(
'sort'
)
&&
is_array
(
$this
->
request
->
getPost
(
"sort"
)))
{
$sortBy
=
array_keys
(
$this
->
request
->
getPost
(
"sort"
));
if
(
$this
->
request
->
getPost
(
"sort"
)[
$sortBy
[
0
]]
==
"desc"
)
{
$sortDescending
=
true
;
if
(
$this
->
request
->
isPost
())
{
$this
->
sessionClose
();
// fetch query parameters
$itemsPerPage
=
$this
->
request
->
getPost
(
'rowCount'
,
'int'
,
9999
);
$currentPage
=
$this
->
request
->
getPost
(
'current'
,
'int'
,
1
);
$sortBy
=
array
(
"description"
);
$sortDescending
=
false
;
if
(
$this
->
request
->
hasPost
(
'sort'
)
&&
is_array
(
$this
->
request
->
getPost
(
"sort"
)))
{
$sortBy
=
array_keys
(
$this
->
request
->
getPost
(
"sort"
));
if
(
$this
->
request
->
getPost
(
"sort"
)[
$sortBy
[
0
]]
==
"desc"
)
{
$sortDescending
=
true
;
}
}
}
$searchPhrase
=
$this
->
request
->
getPost
(
'searchPhrase'
,
'string'
,
''
);
// create model and fetch query resuls
$fields
=
array
(
"enabled"
,
"minutes"
,
"hours"
,
"days"
,
"months"
,
"weekdays"
,
"description"
,
"command"
,
"origin"
,
"cronPermissions"
);
$mdlCron
=
new
Cron
();
$grid
=
new
UIModelGrid
(
$mdlCron
->
jobs
->
job
);
$searchPhrase
=
$this
->
request
->
getPost
(
'searchPhrase'
,
'string'
,
''
);
// create model and fetch query resuls
$fields
=
array
(
"enabled"
,
"minutes"
,
"hours"
,
"days"
,
"months"
,
"weekdays"
,
"description"
,
"command"
,
"origin"
,
"cronPermissions"
);
$mdlCron
=
new
Cron
();
$grid
=
new
UIModelGrid
(
$mdlCron
->
jobs
->
job
);
return
$grid
->
fetch
(
$fields
,
$itemsPerPage
,
$currentPage
,
$sortBy
,
$sortDescending
,
$searchPhrase
);
return
$grid
->
fetch
(
$fields
,
$itemsPerPage
,
$currentPage
,
$sortBy
,
$sortDescending
,
$searchPhrase
);
}
else
{
return
array
();
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment