Пример #1
0
 /**
  * Return all functions that are accessible by this User
  */
 function accessible($handler = '')
 {
     $min_access_level = $this->minAccessLevel();
     $sf = new SiteFunction();
     $access = $sf->also('Access');
     $access->clause('access_level', $min_access_level, Clause::GTE);
     if ($handler) {
         $sf->clauseSafe('handler', $handler);
     }
     $funcs = $sf->fetch();
     return $funcs;
 }
 function loadHandler($handler)
 {
     $sf = new SiteFunction();
     $sf->noForeign();
     $sf->clauseSafe('handler', $handler);
     if ($sf->id()) {
         $ret = $sf->getHandler();
     } else {
         if (class_exists(str_replace('Application', 'Setup', constant('APPLICATION')))) {
             $class_name = str_replace('Application', 'Setup', constant('APPLICATION'));
             $ret = new $class_name();
         } else {
             $ret = Application::loadHandler($handler);
         }
     }
     return $ret;
 }
 function authorise($handler)
 {
     $sf = new SiteFunction();
     $sf->clauseSafe('handler', $handler);
     $sf->noForeign();
     if ($sf->get('access_id') == 2) {
         $ret = true;
     } else {
         if ($sf->id()) {
             $ret = false;
         } else {
             if ($handler == str_replace('Application', 'Setup', constant('APPLICATION'))) {
                 $ret = true;
             } else {
                 $ret = $this->authorise(str_replace('Application', 'Setup', constant('APPLICATION')));
             }
         }
     }
     return $ret;
 }
 protected function editSiteFunction()
 {
     if ($site_function_id = Application::param('select_site_function_id')) {
         $site_function = new SiteFunction();
         $site_function->clauseSafe('site_function_id', $site_function_id);
         $site_function->noForeign();
         $this->site_function_to_edit = $site_function;
     } else {
         $this->failed = 'Could not get site function to edit';
     }
 }