From 0b8d67a3ff5df02447df3375d71f766545d7c32e Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Mon, 19 Jun 2017 06:56:22 +0200 Subject: [PATCH] ObjectRestrictions: new controller extension --- .../Extension/ObjectRestrictions.php | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 library/Director/Web/Controller/Extension/ObjectRestrictions.php diff --git a/library/Director/Web/Controller/Extension/ObjectRestrictions.php b/library/Director/Web/Controller/Extension/ObjectRestrictions.php new file mode 100644 index 00000000..bedb3f18 --- /dev/null +++ b/library/Director/Web/Controller/Extension/ObjectRestrictions.php @@ -0,0 +1,48 @@ +objectRestrictions === null) { + $this->objectRestrictions = $this->loadObjectRestrictions($this->db(), $this->Auth()); + } + + return $this->objectRestrictions; + } + + /** + * @return ObjectRestriction[] + */ + protected function loadObjectRestrictions(Db $db, Auth $auth) + { + return [ + new HostgroupRestriction($db, $auth) + ]; + } + + public function allowsObject(IcingaObject $object) + { + foreach ($this->getObjectRestrictions() as $restriction) { + if (! $restriction->allows($object)) { + return false; + } + } + + return true; + } +}