Make hooks respect module permissions

refs #12396
This commit is contained in:
Alexander A. Klimov 2016-10-20 18:28:19 +02:00
parent 00880710ed
commit 4d2e6d2d87

View File

@ -4,6 +4,7 @@
namespace Icinga\Application\Modules; namespace Icinga\Application\Modules;
use Exception; use Exception;
use Icinga\Authentication\Auth;
use Zend_Controller_Router_Route; use Zend_Controller_Router_Route;
use Zend_Controller_Router_Route_Abstract; use Zend_Controller_Router_Route_Abstract;
use Zend_Controller_Router_Route_Regex; use Zend_Controller_Router_Route_Regex;
@ -1282,6 +1283,7 @@ class Module
*/ */
protected function provideHook($name, $implementation = null, $key = null) protected function provideHook($name, $implementation = null, $key = null)
{ {
if (Auth::getInstance()->hasPermission('module/' . $this->name)) {
if ($implementation === null) { if ($implementation === null) {
$implementation = $name; $implementation = $name;
} }
@ -1295,6 +1297,8 @@ class Module
} }
Hook::register($name, $class, $class); Hook::register($name, $class, $class);
}
return $this; return $this;
} }