/** * Require an authenticated user * * @param Lynx_Registry $registry */ public function __construct(Lynx_Registry $registry) { parent::__construct($registry); $this->_template->setCurrentTemplate('lynx'); $this->_template->addScript('jquery.min'); require_once 'Lynx/Auth/Auth_Db.php'; require_once 'Lynx/Acl/Acl_Rbac_Db.php'; $this->_auth = new Lynx_Auth_Db($registry->get('database')); #$_SESSION['Lynx_Auth_ID'] = 'b4764fae-3fc5-11df-bc54-001fe25a4467'; if (!empty($_SESSION['Lynx_Auth_ID'])) { // load the user by ID $this->_auth->setAuthenticated(TRUE)->loadByKey($_SESSION['Lynx_Auth_ID']); } $this->_acl = Lynx_Acl_Rbac_Db::getInstance($registry->get('database'), $this->_auth); #$this->_acl = Lynx_Acl_Rbac::getInstance($this->_auth); }
/** * @params Lynx_Auth_Abstract Instance of a class the extends Lynx_Auth_Abstract */ public static function getInstance() { $args = func_get_args(); if (func_num_args() != 2) { throw new Exception(__METHOD__ . ' requires Lynx_Databaes and Lynx_Auth_Abstract'); } if (!$args[0] instanceof Lynx_Auth_Abstract && !$args[0] instanceof Lynx_Database) { throw new Exception('Arguement 1 of ' . __METHOD__ . ' must be of type Lynx_Auth_Abstract'); } if (!$args[1] instanceof Lynx_Auth_Abstract && !$args[1] instanceof Lynx_Database) { throw new Exception('Arguement 2 of ' . __METHOD__ . ' must be of type Lynx_Database'); } if ($args[0] instanceof Lynx_Database) { $db = $args[0]; } else { $db = $args[1]; } if ($args[0] instanceof Lynx_Auth_Abstract) { $auth = $args[0]; } else { $auth = $args[1]; } if (self::$_instance == NULL) { self::$_instance = new Lynx_Acl_Rbac_Db($db, $auth); } return self::$_instance; }