parent
8f1f3ec699
commit
e950bb3395
|
@ -50,16 +50,21 @@ abstract class ObjectsController extends ActionController
|
|||
|
||||
protected function apiRequestHandler()
|
||||
{
|
||||
$request = $this->getRequest();
|
||||
$table = $this->getTable();
|
||||
if ($this->getRequest()->getControllerName() === 'services'
|
||||
if ($request->getControllerName() === 'services'
|
||||
&& $host = $this->params->get('host')
|
||||
) {
|
||||
$host = IcingaHost::load($host, $this->db());
|
||||
$table->getQuery()->where('host_id = ?', $host->get('id'));
|
||||
}
|
||||
|
||||
if ($request->getActionName() === 'templates') {
|
||||
$table->filterObjectType('template');
|
||||
}
|
||||
|
||||
return (new IcingaObjectsHandler(
|
||||
$this->getRequest(),
|
||||
$request,
|
||||
$this->getResponse(),
|
||||
$this->db()
|
||||
))->setTable($table);
|
||||
|
@ -129,6 +134,10 @@ abstract class ObjectsController extends ActionController
|
|||
*/
|
||||
public function templatesAction()
|
||||
{
|
||||
if ($this->getRequest()->isApiRequest()) {
|
||||
$this->apiRequestHandler()->dispatch();
|
||||
return;
|
||||
}
|
||||
$type = $this->getType();
|
||||
|
||||
$shortType = IcingaObject::createByType($type)->getShortTableName();
|
||||
|
|
|
@ -28,6 +28,8 @@ class ObjectsTable extends ZfQueryBasedTable
|
|||
|
||||
protected $showColumns = ['object_name' => 'Name'];
|
||||
|
||||
protected $filterObjectType = 'object';
|
||||
|
||||
protected $type;
|
||||
|
||||
private $auth;
|
||||
|
@ -66,6 +68,12 @@ class ObjectsTable extends ZfQueryBasedTable
|
|||
return $this;
|
||||
}
|
||||
|
||||
public function filterObjectType($type)
|
||||
{
|
||||
$this->filterObjectType = $type;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function addObjectRestriction(ObjectRestriction $restriction)
|
||||
{
|
||||
$this->objectRestrictions[$restriction->getName()] = $restriction;
|
||||
|
@ -143,7 +151,10 @@ class ObjectsTable extends ZfQueryBasedTable
|
|||
|
||||
protected function applyObjectTypeFilter(ZfSelect $query)
|
||||
{
|
||||
return $query->where("o.object_type = 'object'");
|
||||
return $query->where(
|
||||
'o.object_type = ?',
|
||||
$this->filterObjectType
|
||||
);
|
||||
}
|
||||
|
||||
protected function applyRestrictions(ZfSelect $query)
|
||||
|
|
Loading…
Reference in New Issue