Commit d61fb7f9 authored by Ad Schellevis's avatar Ad Schellevis

(mvc applications) refactor model search

parent 8a309525
...@@ -210,30 +210,13 @@ class ServiceController extends ApiControllerBase ...@@ -210,30 +210,13 @@ class ServiceController extends ApiControllerBase
*/ */
public function searchTemplatesAction() public function searchTemplatesAction()
{ {
if ($this->request->isPost()) {
$this->sessionClose(); $this->sessionClose();
// fetch query parameters
$itemsPerPage = $this->request->getPost('rowCount', 'int', 9999);
$currentPage = $this->request->getPost('current', 'int', 1);
$sortBy = array("name");
$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("name", "fileid");
$mdlCP = new CaptivePortal(); $mdlCP = new CaptivePortal();
$grid = new UIModelGrid($mdlCP->templates->template); $grid = new UIModelGrid($mdlCP->templates->template);
return $grid->fetch($fields, $itemsPerPage, $currentPage, $sortBy, $sortDescending, $searchPhrase); return $grid->fetchBindRequest(
} else { $this->request,
return array(); array("name", "fileid"),
} "name"
);
} }
} }
...@@ -195,30 +195,13 @@ class SettingsController extends ApiControllerBase ...@@ -195,30 +195,13 @@ class SettingsController extends ApiControllerBase
*/ */
public function searchZonesAction() public function searchZonesAction()
{ {
if ($this->request->isPost()) {
$this->sessionClose(); $this->sessionClose();
// fetch query parameters
$itemsPerPage = $this->request->getPost('rowCount', 'int', 9999);
$currentPage = $this->request->getPost('current', 'int', 1);
$sortBy = array("number");
$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", "description", "zoneid");
$mdlCP = new CaptivePortal(); $mdlCP = new CaptivePortal();
$grid = new UIModelGrid($mdlCP->zones->zone); $grid = new UIModelGrid($mdlCP->zones->zone);
return $grid->fetch($fields, $itemsPerPage, $currentPage, $sortBy, $sortDescending, $searchPhrase); return $grid->fetchBindRequest(
} else { $this->request,
return array(); array("enabled", "description", "zoneid"),
} "description"
);
} }
} }
...@@ -202,24 +202,7 @@ class SettingsController extends ApiControllerBase ...@@ -202,24 +202,7 @@ class SettingsController extends ApiControllerBase
*/ */
public function searchJobsAction() public function searchJobsAction()
{ {
if ($this->request->isPost()) {
$this->sessionClose(); $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( $fields = array(
"enabled", "enabled",
"minutes", "minutes",
...@@ -234,10 +217,10 @@ class SettingsController extends ApiControllerBase ...@@ -234,10 +217,10 @@ class SettingsController extends ApiControllerBase
); );
$mdlCron = new Cron(); $mdlCron = new Cron();
$grid = new UIModelGrid($mdlCron->jobs->job); $grid = new UIModelGrid($mdlCron->jobs->job);
return $grid->fetchBindRequest(
return $grid->fetch($fields, $itemsPerPage, $currentPage, $sortBy, $sortDescending, $searchPhrase); $this->request,
} else { $fields,
return array(); "description"
} );
} }
} }
...@@ -495,31 +495,14 @@ class SettingsController extends ApiControllerBase ...@@ -495,31 +495,14 @@ class SettingsController extends ApiControllerBase
*/ */
public function searchFingerprintAction() public function searchFingerprintAction()
{ {
if ($this->request->isPost()) {
$this->sessionClose(); $this->sessionClose();
// fetch query parameters
$itemsPerPage = $this->request->getPost('rowCount', 'int', 9999);
$currentPage = $this->request->getPost('current', 'int', 1);
$sortBy = array("number");
$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", "action", "description", "fingerprint");
$mdlIDS = $this->getModel(); $mdlIDS = $this->getModel();
$grid = new UIModelGrid($mdlIDS->rules->fingerprint); $grid = new UIModelGrid($mdlIDS->rules->fingerprint);
return $grid->fetch($fields, $itemsPerPage, $currentPage, $sortBy, $sortDescending, $searchPhrase); return $grid->fetchBindRequest(
} else { $this->request,
return array(); array("enabled", "action", "description", "fingerprint"),
} "description"
);
} }
/** /**
......
...@@ -100,32 +100,13 @@ class SettingsController extends ApiControllerBase ...@@ -100,32 +100,13 @@ class SettingsController extends ApiControllerBase
public function searchRemoteBlacklistsAction() public function searchRemoteBlacklistsAction()
{ {
$this->sessionClose(); $this->sessionClose();
// fetch query parameters
$itemsPerPage = $this->request->getPost('rowCount', 'int', 9999);
$currentPage = $this->request->getPost('current', 'int', 1);
$sortBy = array("filename");
$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",
"filename",
"url",
"description"
);
$mdlProxy = new Proxy(); $mdlProxy = new Proxy();
$grid = new UIModelGrid($mdlProxy->forward->acl->remoteACLs->blacklists->blacklist); $grid = new UIModelGrid($mdlProxy->forward->acl->remoteACLs->blacklists->blacklist);
return $grid->fetchBindRequest(
return $grid->fetch($fields, $itemsPerPage, $currentPage, $sortBy, $sortDescending, $searchPhrase); $this->request,
array("enabled", "filename", "url", "description"),
"description"
);
} }
/** /**
......
...@@ -196,32 +196,14 @@ class SettingsController extends ApiControllerBase ...@@ -196,32 +196,14 @@ class SettingsController extends ApiControllerBase
*/ */
public function searchPipesAction() public function searchPipesAction()
{ {
if ($this->request->isPost()) {
$this->sessionClose(); $this->sessionClose();
// fetch query parameters
$itemsPerPage = $this->request->getPost('rowCount', 'int', 9999);
$currentPage = $this->request->getPost('current', 'int', 1);
$sortBy = array("number");
$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","number", "bandwidth","bandwidthMetric","burst","description","mask","origin");
$mdlShaper = new TrafficShaper(); $mdlShaper = new TrafficShaper();
$grid = new UIModelGrid($mdlShaper->pipes->pipe); $grid = new UIModelGrid($mdlShaper->pipes->pipe);
return $grid->fetch($fields, $itemsPerPage, $currentPage, $sortBy, $sortDescending, $searchPhrase); return $grid->fetchBindRequest(
} else { $this->request,
return array(); array("enabled","number", "bandwidth","bandwidthMetric","burst","description","mask","origin"),
} "number"
);
} }
/** /**
...@@ -230,32 +212,14 @@ class SettingsController extends ApiControllerBase ...@@ -230,32 +212,14 @@ class SettingsController extends ApiControllerBase
*/ */
public function searchQueuesAction() public function searchQueuesAction()
{ {
if ($this->request->isPost()) {
$this->sessionClose(); $this->sessionClose();
// fetch query parameters
$itemsPerPage = $this->request->getPost('rowCount', 'int', 9999);
$currentPage = $this->request->getPost('current', 'int', 1);
$sortBy = array("number");
$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","number", "pipe","weight","description","mask","origin");
$mdlShaper = new TrafficShaper(); $mdlShaper = new TrafficShaper();
$grid = new UIModelGrid($mdlShaper->queues->queue); $grid = new UIModelGrid($mdlShaper->queues->queue);
return $grid->fetch($fields, $itemsPerPage, $currentPage, $sortBy, $sortDescending, $searchPhrase); return $grid->fetchBindRequest(
} else { $this->request,
return array(); array("enabled","number", "pipe","weight","description","mask","origin"),
} "number"
);
} }
/** /**
...@@ -379,31 +343,14 @@ class SettingsController extends ApiControllerBase ...@@ -379,31 +343,14 @@ class SettingsController extends ApiControllerBase
*/ */
public function searchRulesAction() public function searchRulesAction()
{ {
if ($this->request->isPost()) {
$this->sessionClose(); $this->sessionClose();
// fetch query parameters
$itemsPerPage = $this->request->getPost('rowCount', 'int', 9999);
$currentPage = $this->request->getPost('current', 'int', 1);
$sortBy = array("sequence");
$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("interface", "proto","source","destination","description","origin","sequence","target");
$mdlShaper = new TrafficShaper(); $mdlShaper = new TrafficShaper();
$grid = new UIModelGrid($mdlShaper->rules->rule); $grid = new UIModelGrid($mdlShaper->rules->rule);
return $grid->fetch($fields, $itemsPerPage, $currentPage, $sortBy, $sortDescending, $searchPhrase); return $grid->fetchBindRequest(
} else { $this->request,
return array(); array("interface", "proto","source","destination","description","origin","sequence","target"),
} "sequence"
);
} }
/** /**
......
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