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
410493eb
Commit
410493eb
authored
Jun 30, 2015
by
Ad Schellevis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(traffic shaper) toggle api to support direct enable/disable
parent
7baccb7c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
8 deletions
+12
-8
SettingsController.php
...rollers/OPNsense/TrafficShaper/Api/SettingsController.php
+12
-8
No files found.
src/opnsense/mvc/app/controllers/OPNsense/TrafficShaper/Api/SettingsController.php
View file @
410493eb
...
...
@@ -165,9 +165,10 @@ class SettingsController extends ApiControllerBase
/**
* toggle pipe by uuid (enable/disable)
* @param $uuid item unique id
* @param $enabled desired state enabled(1)/disabled(1), leave empty for toggle
* @return array status
*/
public
function
togglePipeAction
(
$uuid
)
public
function
togglePipeAction
(
$uuid
,
$enabled
=
null
)
{
$result
=
array
(
"result"
=>
"failed"
);
...
...
@@ -176,13 +177,14 @@ class SettingsController extends ApiControllerBase
if
(
$uuid
!=
null
)
{
$node
=
$mdlShaper
->
getNodeByReference
(
'pipes.pipe.'
.
$uuid
);
if
(
$node
!=
null
)
{
if
(
$node
->
enabled
->
__toString
()
==
"1"
)
{
$result
[
'result'
]
=
"Disabled"
;
if
(
$enabled
==
"0"
||
$enabled
==
"1"
)
{
$node
->
enabled
=
(
string
)
$enabled
;
}
elseif
(
$node
->
enabled
->
__toString
()
==
"1"
)
{
$node
->
enabled
=
"0"
;
}
else
{
$result
[
'result'
]
=
"Enabled"
;
$node
->
enabled
=
"1"
;
}
$result
[
'result'
]
=
$node
->
enabled
;
// if item has toggled, serialize to config and save
$mdlShaper
->
serializeToConfig
(
$disable_validation
=
true
);
Config
::
getInstance
()
->
save
();
...
...
@@ -346,9 +348,10 @@ class SettingsController extends ApiControllerBase
/**
* toggle queue by uuid (enable/disable)
* @param $uuid item unique id
* @param $enabled desired state enabled(1)/disabled(1), leave empty for toggle
* @return array status
*/
public
function
toggleQueueAction
(
$uuid
)
public
function
toggleQueueAction
(
$uuid
,
$enabled
=
null
)
{
$result
=
array
(
"result"
=>
"failed"
);
...
...
@@ -357,13 +360,14 @@ class SettingsController extends ApiControllerBase
if
(
$uuid
!=
null
)
{
$node
=
$mdlShaper
->
getNodeByReference
(
'queues.queue.'
.
$uuid
);
if
(
$node
!=
null
)
{
if
(
$node
->
enabled
->
__toString
()
==
"1"
)
{
$result
[
'result'
]
=
"Disabled"
;
if
(
$enabled
==
"0"
||
$enabled
==
"1"
)
{
$node
->
enabled
=
(
string
)
$enabled
;
}
elseif
(
$node
->
enabled
->
__toString
()
==
"1"
)
{
$node
->
enabled
=
"0"
;
}
else
{
$result
[
'result'
]
=
"Enabled"
;
$node
->
enabled
=
"1"
;
}
$result
[
'result'
]
=
$node
->
enabled
;
// if item has toggled, serialize to config and save
$mdlShaper
->
serializeToConfig
(
$disable_validation
=
true
);
Config
::
getInstance
()
->
save
();
...
...
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