public function execute($filterChain)
 {
     $context = $this->getContext();
     $controller = $context->getController();
     $request = $context->getRequest();
     $user = $context->getUser();
     // get the current action instance
     $actionEntry = $controller->getActionStack()->getLastEntry();
     $actionInstance = $actionEntry->getActionInstance();
     // get the credential required for this action
     $credential = $actionInstance->getCredential();
     $ccp = new CredentialCheckPredicate($credential);
     // TODO: check for predicate availability
     // get the predicate which determines access rules
     if (in_array('getPredicate', get_class_methods(get_class($actionInstance)))) {
         $predicate = $actionInstance->getPredicate();
     } else {
         $predicate = null;
     }
     // credentials can be anything you wish; a string, array, object, etc.
     // as long as you add the same exact data to the user as a credential,
     // it will use it and authorize the user as having the credential
     //
     // NOTE: the nice thing about the Action class is that getCredential()
     //       is vague enough to describe any level of security and can be
     //       used to retrieve such data and should never have to be altered
     if ($user->isAuthenticated()) {
         // the user is authenticated
         if ($credential === null && $predicate === null || $credential != null && $ccp->execute($user) || $predicate != null && $predicate->execute($user)) {
             // the user has access, continue
             $filterChain->execute();
         } else {
             // the user doesn't have access, exit stage left
             $controller->forward(MO_SECURE_MODULE, MO_SECURE_ACTION);
         }
     } else {
         // the user is not authenticated
         $controller->forward(MO_LOGIN_MODULE, MO_LOGIN_ACTION);
     }
 }
 public function __construct($credential, $id)
 {
     parent::__construct($credential);
     $this->id = $id;
     //var_dump($this->affiliates);
 }
 public function __construct($credential)
 {
     parent::__construct($credential);
 }
 public function __construct($credential, $affiliates)
 {
     parent::__construct($credential);
     $this->affiliates = $affiliates;
 }