コード例 #1
0
 public function testWithUserLoggedIn()
 {
     $this->session->set_userdata('pinet_token', $this->lm->genToken(1));
     $this->se->validate(get_controller_meta(), null);
     $this->assertEquals(count($this->se->clips->runWithEnv(Security_Engine::CLIPS_SECURITY_ENV, function ($clips) {
         return $clips->queryFacts('Pinet_User');
     })), 1);
 }
コード例 #2
0
 public function getCurrentConfigurations($obj = null)
 {
     $type = 'action';
     if ($obj == null) {
         $action = get_controller_meta();
     } else {
         if (is_string($obj)) {
             $type = $obj;
             $action = get_controller_meta();
         } else {
             $action = $obj;
         }
     }
     $ret = array();
     $ret[] = $this->getAllMatch($type);
     $c = $this->getMatchController($action->controller, $type);
     $method_same = array();
     $method_match = array();
     $match = null;
     foreach ($c as $conf) {
         $conf->tag = isset($conf->tag) ? json_decode($conf->tag) : array();
         if ($conf->method == $action->method) {
             if ($action->args == $conf->tag) {
                 $match = $conf;
             } else {
                 $method_same[] = $conf;
             }
         } else {
             if (is_regex($conf->method) && preg_match($conf->method, $action->method)) {
                 $method_match[] = $conf;
             }
         }
     }
     if ($method_match) {
         foreach ($method_match as $m) {
             $ret[] = $m;
         }
     }
     $c = $this->getMatchMethod($action->method, $type);
     if (isset($c->id)) {
         $ret[] = $c;
     }
     if ($method_same) {
         foreach ($method_same as $m) {
             $ret[] = $m;
         }
     }
     if ($match) {
         $ret[] = $match;
     }
     return $ret;
 }
コード例 #3
0
function smarty_function_css($params, $template)
{
    $CI =& get_instance();
    foreach ($CI->cssFiles as $css) {
        echo $css->render();
    }
    if (isset($CI->sasscompiler)) {
        $meta = get_controller_meta();
        $CI =& get_instance();
        $suffix = get_default($CI, 'sass_suffix', '');
        $name = $meta->controller . '-' . $meta->method . $suffix . '.css';
        $dir = 'cache/css/';
        if (!file_exists(FCPATH . APPPATH . $dir)) {
            mkdir(FCPATH . APPPATH . $dir, 0755, true);
        }
        $file_name = FCPATH . APPPATH . $dir . $name;
        if (!file_exists($file_name) || get_ci_config('debug_sass')) {
            ci_log('The compiler is ', $CI->sasscompiler);
            file_put_contents($file_name, $CI->sasscompiler->compile());
        }
        return '<link rel="stylesheet" href="' . site_url(APPPATH . $dir . $name) . '">';
    }
}
コード例 #4
0
 public function testGetControllerMeta()
 {
     $meta = get_controller_meta();
     $this->assertEquals($meta->controller, 'Welcome');
     $this->assertEquals($meta->method, 'index');
 }
コード例 #5
0
 public function getActionTarget($action, $subject, $type = 'actions')
 {
     $confs = $this->security_model->getCurrentConfigurations($action);
     $target = null;
     foreach ($confs as $conf) {
         $tmp = $this->security_model->getTarget($subject, $conf);
         if ($tmp) {
             $target = $tmp;
         }
     }
     if ($target) {
         // If we can find the define in database, just return it
         return $target;
     }
     if (is_string($action)) {
         return $this->security_model->getTemplateTarget($subject, get_controller_meta(), $type);
     }
     return $this->security_model->getTemplateTarget($subject, $action, $type);
 }