Example #1
0
 /**
  * @param  array  $params   plugin parameters for the current action
  * @return null or jSelectorAct  if action should change
  */
 public function beforeAction($params)
 {
     $selector = null;
     $aclok = true;
     if (isset($params['jacl.right'])) {
         $aclok = jAcl::check($params['jacl.right'][0], $params['jacl.right'][1]);
     } elseif (isset($params['jacl.rights.and'])) {
         $aclok = true;
         foreach ($params['jacl.rights.and'] as $right) {
             if (!jAcl::check($right[0], $right[1])) {
                 $aclok = false;
                 break;
             }
         }
     } elseif (isset($params['jacl.rights.or'])) {
         $aclok = false;
         foreach ($params['jacl.rights.or'] as $right) {
             if (jAcl::check($right[0], $right[1])) {
                 $aclok = true;
                 break;
             }
         }
     }
     if (!$aclok) {
         if ($this->config['on_error'] == 1 || !$GLOBALS['gJCoord']->request->isAllowedResponse('jResponseRedirect')) {
             throw new jException($this->config['error_message']);
         } else {
             $selector = new jSelectorAct($this->config['on_error_action']);
         }
     }
     return $selector;
 }
 public function testCheck()
 {
     //jAcl::check($subject, $value, $resource=null)
     $this->assertTrue(jAcl::check('super.cms', 'LIST'));
     $this->assertTrue(jAcl::check('super.cms', 'UPDATE'));
     $this->assertFalse(jAcl::check('super.cms', 'CREATE'));
     $this->assertFalse(jAcl::check('super.cms', 'READ'));
     $this->assertFalse(jAcl::check('super.cms', 'DELETE'));
     $this->assertTrue(jAcl::check('admin.access', 'TRUE'));
     $this->assertFalse(jAcl::check('admin.access', 'FALSE'));
     $this->assertTrue(jAcl::check('super.cms', 'LIST', 154));
     $this->assertTrue(jAcl::check('super.cms', 'UPDATE', 154));
     $this->assertFalse(jAcl::check('super.cms', 'CREATE', 154));
     $this->assertFalse(jAcl::check('super.cms', 'READ', 154));
     $this->assertTrue(jAcl::check('super.cms', 'DELETE', 154));
     // avec une ressource non repertoriƩe
     $this->assertTrue(jAcl::check('super.cms', 'LIST', 22));
     $this->assertTrue(jAcl::check('super.cms', 'UPDATE', 22));
     $this->assertFalse(jAcl::check('super.cms', 'CREATE', 22));
     $this->assertFalse(jAcl::check('super.cms', 'READ', 22));
     $this->assertFalse(jAcl::check('super.cms', 'DELETE', 22));
     $this->assertFalse(jAcl::check('foo', 'bar'));
     $this->assertFalse(jAcl::check('foo', 'bar', 'baz'));
 }