/** * Returns the single instance of this class. * * @return Snep_Acl */ public static function getInstance() { if (self::$instance === null) { self::$instance = new self(); } return self::$instance; }
/** * Adds user role on Snep Acl and register plugin for permission check before * dispatch. */ protected function _initAcl() { $acl = Snep_Acl::getInstance(); $auth = Zend_Auth::getInstance(); if ($auth->hasIdentity()) { $acl->addRole((string) $auth->getIdentity()); $role = $auth->getIdentity(); if ($role == "admin") { $acl->allow("admin"); } } else { $role = 'guest'; } $front = Zend_Controller_Front::getInstance(); require_once 'modules/default/model/AclPlugin.php'; $front->registerPlugin(new AclPlugin($acl, $role)); }
public function indexAction() { $exten = $this->getRequest()->getParam("exten"); if ($exten === null) { throw new Zend_Controller_Action_Exception('Page not found.', 404); } try { PBX_Usuarios::get($exten); } catch (PBX_Exception_NotFound $ex) { throw new Zend_Controller_Action_Exception($this->view->translate("Extension %s does not exists.", $exten), 404); } $this->view->exten = $exten; $this->view->breadcrumb = Snep_Breadcrumb::renderPath(array("Manage", "Extensions", "Permissions")); $resources = array(); foreach (Snep_Acl::getInstance()->getResources() as $resource) { $res_tree = explode("_", $resource); $resource = array(); while ($element = array_pop($res_tree)) { $resource = array($element => $resource); } $resources = array_merge_recursive($resources, $resource); } $this->view->resources = $resources; }
/** * Take care of module registering details. * * @param Snep_Module_Descriptor $module */ protected function registerModule($path) { $info = simplexml_load_file($path . "/info.xml"); $pathinfo = pathinfo($path); $descriptor = $this->parseInfo($pathinfo['filename'], $info); $this->registeredModules[] = $descriptor; // Adding module lib to include path if (is_dir($path . "/lib")) { set_include_path(implode(PATH_SEPARATOR, array("{$path}/lib", get_include_path()))); foreach (scandir("{$path}/lib") as $namespace) { if (is_dir("{$path}/lib/{$namespace}")) { Zend_Loader_Autoloader::getInstance()->registerNamespace($namespace . "_"); } } } // Parsing and registering module resources if (file_exists("{$path}/resources.xml")) { Snep_Acl::getInstance()->addResource($descriptor->getModuleId()); $this->loadResources(simplexml_load_file("{$path}/resources.xml"), $descriptor->getModuleId()); } // Finding and registering module Rule Actions. require_once "PBX/Rule/Actions.php"; $actions = PBX_Rule_Actions::getInstance(); if (is_dir($path . "/actions")) { foreach (scandir($path . "/actions") as $file) { if (substr($file, -4) == ".php") { require_once $path . "/actions/" . $file; $classname = basename($file, '.php'); if (class_exists($classname)) { $actions->registerAction($classname); } } } } }