本文整理匯總了PHP中ca_users::s_user_action_access_cache方法的典型用法代碼示例。如果您正苦於以下問題:PHP ca_users::s_user_action_access_cache方法的具體用法?PHP ca_users::s_user_action_access_cache怎麽用?PHP ca_users::s_user_action_access_cache使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類ca_users
的用法示例。
在下文中一共展示了ca_users::s_user_action_access_cache方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: testBooleanOperators
public function testBooleanOperators()
{
$vo_acr = AccessRestrictions::load(true);
// OR
$va_access_restrictions = array("administrate/setup/list_editor/ListEditorController" => array("default" => array("operator" => "OR", "actions" => array("can_edit_ca_lists", "can_create_ca_lists", "can_delete_ca_lists"))));
$vo_acr->opa_acr = $va_access_restrictions;
// no role -> can't access controller
$this->opt_role->setMode(ACCESS_WRITE);
$this->opt_role->setRoleActions(array());
$this->opt_role->update();
ca_users::$s_user_action_access_cache = array();
$vb_access = $vo_acr->userCanAccess($this->opt_user->getPrimaryKey(), array("administrate", "setup", "list_editor"), "ListEditor", "Edit");
$this->assertFalse($vb_access);
// has one of the OR-ed roles -> can access controller
$this->opt_role->setMode(ACCESS_WRITE);
$va_actions = $va_access_restrictions["administrate/setup/list_editor/ListEditorController"]["default"]["actions"];
$this->opt_role->setRoleActions(array($va_actions[array_rand($va_actions)]));
$this->opt_role->update();
ca_users::$s_user_action_access_cache = array();
$vb_access = $vo_acr->userCanAccess($this->opt_user->getPrimaryKey(), array("administrate", "setup", "list_editor"), "ListEditor", "Edit");
$this->assertTrue($vb_access);
// AND
$va_access_restrictions = array("administrate/setup/list_editor/ListEditorController" => array("default" => array("operator" => "AND", "actions" => array("can_edit_ca_lists", "can_create_ca_lists", "can_delete_ca_lists"))));
$vo_acr->opa_acr = $va_access_restrictions;
// no role -> can't access controller
$this->opt_role->setMode(ACCESS_WRITE);
$this->opt_role->setRoleActions(array());
$this->opt_role->update();
ca_users::$s_user_action_access_cache = array();
$vb_access = $vo_acr->userCanAccess($this->opt_user->getPrimaryKey(), array("administrate", "setup", "list_editor"), "ListEditor", "Edit");
$this->assertFalse($vb_access);
// has one of the AND-ed roles -> can't access controller
$this->opt_role->setMode(ACCESS_WRITE);
$va_actions = $va_access_restrictions["administrate/setup/list_editor/ListEditorController"]["default"]["actions"];
$this->opt_role->setRoleActions(array($va_actions[array_rand($va_actions)]));
$this->opt_role->update();
ca_users::$s_user_action_access_cache = array();
$vb_access = $vo_acr->userCanAccess($this->opt_user->getPrimaryKey(), array("administrate", "setup", "list_editor"), "ListEditor", "Edit");
$this->assertFalse($vb_access);
// has all AND-ed roles -> can access controller
$this->opt_role->setMode(ACCESS_WRITE);
$this->opt_role->setRoleActions($va_actions);
$this->opt_role->update();
ca_users::$s_user_action_access_cache = array();
$vb_access = $vo_acr->userCanAccess($this->opt_user->getPrimaryKey(), array("administrate", "setup", "list_editor"), "ListEditor", "Edit");
$this->assertTrue($vb_access);
}