当前位置: 首页>>代码示例>>PHP>>正文


PHP Role::getAllSessionRoles方法代码示例

本文整理汇总了PHP中Role::getAllSessionRoles方法的典型用法代码示例。如果您正苦于以下问题:PHP Role::getAllSessionRoles方法的具体用法?PHP Role::getAllSessionRoles怎么用?PHP Role::getAllSessionRoles使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Role的用法示例。


在下文中一共展示了Role::getAllSessionRoles方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: post

 /**
  * @url POST import
  */
 public function post()
 {
     try {
         $session = Session::singleton();
         $allowedRoles = (array) Config::get('allowedRolesForExcelImport', 'excelImport');
         if (Config::get('loginEnabled') && !is_null($allowedRoles)) {
             $ok = false;
             $sessionRoles = Role::getAllSessionRoles();
             foreach ($sessionRoles as $role) {
                 if (in_array($role->label, $allowedRoles)) {
                     $ok = true;
                 }
             }
             if (!$ok) {
                 throw new Exception("You do not have access to import excel files", 401);
             }
         }
         if (is_uploaded_file($_FILES['file']['tmp_name'])) {
             // Parse:
             $parser = new ImportExcel($_FILES['file']['tmp_name']);
             $result = $parser->ParseFile();
             unlink($_FILES['file']['tmp_name']);
         } else {
             Notifications::addError('No file uploaded');
         }
         $result = array('notifications' => $result, 'files' => $_FILES);
         return $result;
     } catch (Exception $e) {
         throw new RestException($e->getCode(), $e->getMessage());
     }
 }
开发者ID:4ZP6Capstone2015,项目名称:Capstone,代码行数:34,代码来源:ExcelImportApi.php

示例2: setRole

 public function setRole($roleId = null)
 {
     $roles = Config::get('loginEnabled') ? Role::getAllSessionRoles() : Role::getAllRoleObjects();
     if (empty($roles) || $roleId == 0) {
         $this->role = new Role(0);
     } elseif (is_null($roleId)) {
         $this->role = current($roles);
     } elseif (isset($roleId)) {
         if (!is_int($roleId)) {
             throw new Exception("roleId must be an integer", 400);
         }
         foreach ($roles as $role) {
             if ($role->id == $roleId) {
                 $this->role = $role;
             }
         }
         if (!isset($this->role)) {
             throw new Exception("You do not have access to the selected role", 401);
         }
     } else {
         throw new Exception("No role could be selected", 500);
     }
     if (Config::get('loginEnabled')) {
         $arr = array();
         foreach ($roles as $role) {
             $arr = array_merge($arr, $role->interfaces);
         }
         $this->accessibleInterfaces = array_unique($arr);
     }
     Notifications::addLog("Role " . $this->role->name . " selected", 'SESSION');
     return $this->role->id;
 }
开发者ID:4ZP6Capstone2015,项目名称:Capstone,代码行数:32,代码来源:Session.php

示例3: run

 /**
  * @url GET run
  */
 public function run()
 {
     try {
         $session = Session::singleton();
         $db = Database::singleton();
         $allowedRoles = (array) Config::get('allowedRolesForRunFunction', 'execEngine');
         if (Config::get('loginEnabled') && !is_null($allowedRoles)) {
             $ok = false;
             $sessionRoles = Role::getAllSessionRoles();
             foreach ($sessionRoles as $role) {
                 if (in_array($role->label, $allowedRoles)) {
                     $ok = true;
                 }
             }
             if (!$ok) {
                 throw new Exception("You do not have access to run the exec engine", 401);
             }
         }
         $session->setRole();
         ExecEngine::runAllRules();
         $db->closeTransaction('Run completed', false, true, false);
         $result = array('notifications' => Notifications::getAll());
         return $result;
     } catch (Exception $e) {
         throw new RestException($e->getCode(), $e->getMessage());
     }
 }
开发者ID:4ZP6Capstone2015,项目名称:Capstone,代码行数:30,代码来源:ExecEngineApi.php

示例4: getNavBar

 /**
  * @url GET navBar
  * @param int $roleId
  */
 public function getNavBar($roleId = 0)
 {
     try {
         $session = Session::singleton();
         $session->setRole($roleId);
         // top level interfaces
         foreach ($session->role->getInterfacesForNavBar() as $ifc) {
             $top[] = array('id' => $ifc->id, 'label' => $ifc->label, 'link' => '/' . $ifc->id);
         }
         // new interfaces
         foreach ($session->role->getInterfacesToCreateAtom() as $ifc) {
             $new[] = array('id' => $ifc->id, 'label' => $ifc->label, 'link' => '/' . $ifc->id);
         }
         // roles
         $roles = array();
         $allRoles = Config::get('loginEnabled') ? Role::getAllSessionRoles() : Role::getAllRoleObjects();
         foreach ((array) $allRoles as $role) {
             $roles[] = array('id' => $role->id, 'label' => $role->label);
         }
         return array('top' => $top, 'new' => $new, 'refreshMenu' => $GLOBALS['navBar']['refreshMenu'], 'appMenu' => $GLOBALS['navBar']['appMenu'], 'roleMenu' => $GLOBALS['navBar']['roleMenu'], 'roles' => $roles, 'defaultSettings' => array('notifications' => Notifications::getDefaultSettings()), 'notifications' => Notifications::getAll(), 'session' => array('id' => $session->id, 'loggedIn' => Session::sessionUserLoggedIn(), 'sessionRoles' => $roles), 'sessionVars' => Session::getSessionVars());
     } catch (Exception $e) {
         throw new RestException($e->getCode(), $e->getMessage());
     }
 }
开发者ID:4ZP6Capstone2015,项目名称:Capstone,代码行数:28,代码来源:Api.php


注:本文中的Role::getAllSessionRoles方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。