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


PHP Acl::isAllowed方法代码示例

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


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

示例1: modules

	public static function modules()
	{
		$session = UserSession::get();
		if ($session)
		{
			$user = $session->user();
			if (!Acl::isAllowed($user->username, 'admin'))
			{
				return null;
			}
		}
		else
		{
			return null;
		}	
		
		CoOrg::loadPluginInfo('admin');
		$modules = array();
		foreach (self::$_modules as $m)
		{
			if ($m->isAllowed($user))
			{
				$modules[] = $m;
			}
		}
		usort($modules, array('Admin', 'cmpModule'));
		return $modules;
	}
开发者ID:nathansamson,项目名称:CoOrg,代码行数:28,代码来源:admin.model.php

示例2: in

	public function in($what, $key)
	{
		if ($this->_allowed !== null) return;
		
		if ($what == 'allow')
		{
			$this->_onlyDenied = false;
			if ($key[0] == ':') // Pseudo key
			{
				if ($key == ':loggedIn')
				{
					if (UserSession::get() != null)
					{
						$this->_allowed = true;
					}
				}
			}
			else
			{
				if ($u = UserSession::get())
				{
					if (Acl::isAllowed(UserSession::get()->username, $key))
					{
						$this->_allowed = true;
					}
				}
			}
		}
		else if ($what == 'deny')
		{
			if ($key[0] == ':') // Pseudo key
			{
				if ($key == ':anonymous')
				{
					if (UserSession::get() == null)
					{
						$this->_allowed = false;
					}
				}
			}
			else
			{
				if (Acl::isAllowed(UserSession::get()->username, $key))
				{
					$this->_allowed = false;
				}
			}
		}
		else if ($what == 'owns')
		{
			if ($this->_allowed !== null) return;
			$this->_onlyDenied = false;
			if (UserSession::get())
			{
				$this->_allowed = Acl::owns(UserSession::get()->username, $key) ? true : $this->_allowed;
			}
		}
	}
开发者ID:nathansamson,项目名称:CoOrg,代码行数:58,代码来源:acl.before.php

示例3: testBasicPackage

 /**
  * A basic functional package test example
  *
  * @return void
  */
 public function testBasicPackage()
 {
     // Acl package simple test
     Acl::setup(Config::get('acl::acl'));
     $this->assertFalse(Acl::isAllowed(array('guest'), 'admin_panel'));
     $this->assertFalse(Acl::isAllowed(array('user'), 'admin_panel'));
     $this->assertTrue(Acl::isAllowed(array('admin'), 'admin_panel'));
     // Here we could test other package facades for its basic functionalities...
 }
开发者ID:sgh1986915,项目名称:laravel-bizgym,代码行数:14,代码来源:ExampleTest.php

示例4: run

	public function run($widgetParams, $orient, $request)
	{
		if (UserSession::get() &&
		    Acl::isAllowed(UserSession::get()->username, 'admin'))
		{
			if (substr($request, 0, strpos($request, '/')) == 'admin')
			{
				$this->menu = Admin::modules();
			}
			else
			{
				$this->menu = array(new FakeAdminModule);
			}
			return $this->render('widgets/admin-menu');
		}
	}
开发者ID:nathansamson,项目名称:CoOrg,代码行数:16,代码来源:menu.aside.php

示例5: testGroup

	public function testGroup()
	{
		$group = new UserGroup('Webmasters');
		$group->save();
		$group->grant('someGrant');
		
		$this->assertFalse(Acl::isAllowed('dvorak', 'someGrant'));
		$group->add('dvorak');
		$this->assertTrue(Acl::isAllowed('dvorak', 'someGrant'));
		
		$group = new UserGroup('BadGroup');
		$group->save();
		$group->revoke('someGrant');
		$group->add('dvorak');
		
		$this->assertTrue(Acl::isAllowed('dvorak', 'someGrant')); // Even if dvorak is in a group that has no right he is allowed
	}
开发者ID:nathansamson,项目名称:CoOrg,代码行数:17,代码来源:acl.model.Test.php

示例6: __construct

 /**
  * @param array Array of roles
  */
 public function __construct($roles)
 {
     $resources = dibi::fetchAll('SELECT key_name, name FROM [' . TABLE_RESOURCES . '] ORDER BY name;');
     $privileges = dibi::fetchAll('SELECT key_name, name FROM [' . TABLE_PRIVILEGES . '] ORDER BY name;');
     $acl = new Acl();
     $i = 0;
     foreach ($resources as $res) {
         foreach ($privileges as $pri) {
             foreach ($roles as $role) {
                 if ($acl->isAllowed($role->key_name, $res->key_name, $pri->key_name)) {
                     $this->access[$i]['resource'] = $res->name;
                     $this->access[$i]['privileg'] = $pri->name;
                     $i++;
                     break 1;
                 }
             }
         }
     }
 }
开发者ID:oaki,项目名称:demoshop,代码行数:22,代码来源:AccessModel.php

示例7: __construct

 /**
  * @param array Array of roles
  */
 public function __construct($roles)
 {
     $resources = dibi::fetchAll('SELECT key_name, name FROM [' . self::ACL_RESOURCES_TABLE . '] ORDER BY name;');
     $privileges = dibi::fetchAll('SELECT key_name, name FROM [' . self::ACL_PRIVILEGES_TABLE . '] ORDER BY name;');
     $acl = new Acl();
     $i = 0;
     foreach ($resources as $res) {
         foreach ($privileges as $pri) {
             foreach ($roles as $role) {
                 if (@$acl->isAllowed($role->key_name, $res->key_name, $pri->key_name)) {
                     // @ to repress NOTICE if assertion required and resource property (id, owner_id, ...) not set yet
                     $this->access[$i]['resource'] = $res->name;
                     $this->access[$i]['privileg'] = $pri->name;
                     $i++;
                     break 1;
                 }
             }
         }
     }
 }
开发者ID:radypala,项目名称:maga-website,代码行数:23,代码来源:AccessModel.php

示例8: getControllerName

 /**
  * Returns controller name read from mvc_controller URL parameter
  * (POST has precedence over GET). If mvc_controller is not given,
  * falls back to default controller.
  *
  * @param Request $request
  * @return null
  * @todo currently only cares about first role. Make work for array of roles.
  */
 public function getControllerName(Request $request)
 {
     // Fallback: route to default controller and action.
     $controllerName = $this->defaultControllerName;
     // GET parameter overrides the default controller.
     if ($request->hasGet('mvc_controller')) {
         $controllerName = $request->get('mvc_controller');
     }
     // POST parameter overrides GET parameter.
     if ($request->hasPost('mvc_controller')) {
         $controllerName = $request->post('mvc_controller');
     }
     $roles = $this->authenticationAdapter->getRoles();
     $role = $roles[0];
     // If that controller is not allowed, select authentication controller.
     if (!$this->acl->isAllowed($role, $controllerName)) {
         $controllerName = $this->authenticationControllerName;
     }
     // @todo remember selected controller & action to back-direct later
     // @todo either redirect to auth controller (for anonymous) OR FAIL?
     return $controllerName;
 }
开发者ID:huanganxin,项目名称:MVC,代码行数:31,代码来源:ApplicationController.php

示例9: isAllowed

	public function isAllowed($user)
	{
		return Acl::isAllowed($user->username, 'admin-user');
	}
开发者ID:nathansamson,项目名称:CoOrg,代码行数:4,代码来源:admin.php

示例10: DomainException

        // Always return Not found response for banned user!
        throw new DomainException('acl.banned');
    }
});
Route::filter('can_login', function () {
    if (!Acl::isAllowed(Session::get('roles'), 'login')) {
        return Redirect::to('/')->with('message', 'acl.login');
    }
});
Route::filter('can_register', function () {
    if (!Acl::isAllowed(Session::get('roles'), 'register')) {
        return Redirect::to('/error')->with('error', 'acl.register');
    }
});
Route::filter('can_access_admin_panel', function () {
    if (!Acl::isAllowed(Session::get('roles'), 'admin_panel')) {
        if (Auth::check()) {
            return Redirect::to('/error')->with('error', 'acl.insufficient');
        } else {
            return Redirect::to('/auth/login')->with('error', 'acl.insufficient');
        }
    }
});
/*
 ************************************************
 *              Forum Filters                   *
 *                                              *
 ************************************************
 */
/**
 * | Saas forum filter to determine whether or not a user has the proper groups,
开发者ID:sgh1986915,项目名称:laravel-bizgym,代码行数:31,代码来源:filters.php

示例11: owns

	public function owns($user, $blog)
	{
		return ($blog->authorID == $user || Acl::isAllowed($user, 'blog-admin'));
	}
开发者ID:nathansamson,项目名称:CoOrg,代码行数:4,代码来源:acl.php


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