Exemplo n.º 1
0
 /**
  * function to get the instantiated self object or
  * create a new one (singleton pattern)
  */
 public static function getNomad_GateKeeper()
 {
     if (is_null(self::$_self)) {
         $gateKeeper = __CLASS__;
         self::$_self = new $gateKeeper();
     }
     return self::$_self;
 }
Exemplo n.º 2
0
 /**
  * @param Nomad_View    $view
  * @param Nomad_Request $request
  */
 public function __construct(Nomad_View $view, Nomad_Request $request)
 {
     $this->request = $request;
     $this->view = $view;
     //Check permissions on the controller level (if Nomad_GateKeeper is present)
     $application = Nomad_Application::getInstance();
     if (isset($application->Nomad_GateKeeper)) {
         $controllerName = $request->getController() . 'Controller';
         $pageName = $request->getPage() . 'Page';
         if (!Nomad_GateKeeper::getNomad_GateKeeper()->checkPermissions($controllerName, $pageName)) {
             $application->halt(403);
         }
     }
 }
Exemplo n.º 3
0
 public function listPage()
 {
     $this->view->role = Nomad_GateKeeper::getNomad_GateKeeper()->getRole();
 }
Exemplo n.º 4
0
 public function getFullName()
 {
     Nomad_GateKeeper::getNomad_GateKeeper()->checkPermissions(__CLASS__, __FUNCTION__);
     return $this->_firstName . ' ' . $this->_lastName;
 }
Exemplo n.º 5
0
 /**
  * Renders the container and all child containers.
  * @return string
  */
 public function render()
 {
     if (!empty($this->_allowedRoles)) {
         $currentRoles = Nomad_GateKeeper::getNomad_GateKeeper()->getRole();
         if (!$this->_hasIntersection($currentRoles, $this->_flattenArray($this->_allowedRoles))) {
             $this->_permitted = FALSE;
         }
     }
     if ($this->_permitted && $this->_display) {
         $html = "<{$this->_tag} id='{$this->_name}'";
         if (is_array($this->_attributes)) {
             foreach ($this->_attributes as $attribute => $value) {
                 $html .= " {$attribute}='{$value}' ";
             }
         }
         $html .= $this->_isSelfClosingTag ? "/>" : ">";
         $html .= $this->_innerText;
         if (is_array($this->_children)) {
             foreach ($this->_children as $key => $child) {
                 $html .= $child->render();
             }
         }
         $html .= $this->_isSelfClosingTag ? "" : "</{$this->_tag}>";
         return $html;
     }
 }