Admin\Model\AdminUser::getRoleById PHP Method

getRoleById() public static method

public static getRoleById ( $id )
    public static function getRoleById($id)
    {
        $role = self::findFirst(['conditions' => 'id = :id:', 'bind' => ['id' => $id], 'columns' => ['role'], 'cache' => ['key' => HOST_HASH . md5('Admin\\Model\\AdminUser::getRoleById::' . $id), 'lifetime' => 60]]);
        if ($role) {
            return $role->role;
        } else {
            return 'guest';
        }
    }

Usage Example

コード例 #1
0
ファイル: Acl.php プロジェクト: devsnippet/yona-cms
 private function getRole()
 {
     $auth = $this->session->get('auth');
     if (!$auth) {
         $role = 'guest';
     } else {
         if ($auth->admin_session == true) {
             $role = \Admin\Model\AdminUser::getRoleById($auth->id);
         } else {
             $role = 'member';
         }
     }
     return $role;
 }