本文整理汇总了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);
}