本文整理汇总了PHP中Permission::flush_permission_cache方法的典型用法代码示例。如果您正苦于以下问题:PHP Permission::flush_permission_cache方法的具体用法?PHP Permission::flush_permission_cache怎么用?PHP Permission::flush_permission_cache使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Permission
的用法示例。
在下文中一共展示了Permission::flush_permission_cache方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: activateState
function activateState($state)
{
// We always just set the $_GET variable rather than store in Session - this always works, has highest priority
// in Subsite::currentSubsiteID() and doesn't persist unlike Subsite::changeSubsite
$_GET['SubsiteID'] = $state;
Permission::flush_permission_cache();
}
示例2: testFrontendBlogPostRequiresPermission
function testFrontendBlogPostRequiresPermission()
{
// get valid SecurityID (from comments form, would usually be copy/pasted)
$blogEntry = $this->objFromFixture('BlogEntry', 'entry1');
$response = $this->get($blogEntry->RelativeLink());
$securityID = Session::get('SecurityID');
// without login
$data = array('Title' => 'Disallowed', 'Author' => 'Disallowed', 'BlogPost' => 'Disallowed', 'action_postblog' => 'Post blog entry', 'SecurityID' => $securityID);
$response = $this->post('blog/BlogEntryForm', $data);
$this->assertFalse(DataObject::get_one('BlogEntry', sprintf("\"Title\" = 'Disallowed'")));
// with login
$blogEditor = $this->objFromFixture('Member', 'blog_editor');
$this->session()->inst_set('loggedInAs', $blogEditor->ID);
Permission::flush_permission_cache();
$data = array('Title' => 'Allowed', 'Author' => 'Allowed', 'BlogPost' => 'Allowed', 'action_postblog' => 'Post blog entry', 'SecurityID' => $securityID);
$response = $this->post('blog/BlogEntryForm', $data);
$this->assertType('BlogEntry', DataObject::get_one('BlogEntry', sprintf("\"Title\" = 'Allowed'")));
}
示例3: onBeforeWrite
public function onBeforeWrite()
{
parent::onBeforeWrite();
// Just in case we've altered someone's permissions
Permission::flush_permission_cache();
}
示例4: onAfterWrite
public function onAfterWrite()
{
parent::onAfterWrite();
Permission::flush_permission_cache();
if ($this->isChanged('Password')) {
MemberPassword::log($this);
}
}
示例5: tearDown
public function tearDown()
{
Security::setDefaultAdmin($this->defaultUsername, $this->defaultPassword);
Permission::flush_permission_cache();
parent::tearDown();
}
示例6: changeSubsite
/**
* Switch to another subsite.
*
* @param int|Subsite $subsite Either the ID of the subsite, or the subsite object itself
*/
static function changeSubsite($subsite)
{
if (is_object($subsite)) {
$subsiteID = $subsite->ID;
} else {
$subsiteID = $subsite;
}
Session::set('SubsiteID', (int) $subsiteID);
// Set locale
if (is_object($subsite) && $subsite->Language != '') {
if (isset(i18n::$likely_subtags[$subsite->Language])) {
i18n::set_locale(i18n::$likely_subtags[$subsite->Language]);
}
}
// Only bother flushing caches if we've actually changed
if ($subsiteID != self::currentSubsiteID()) {
Permission::flush_permission_cache();
}
}
示例7: changeSubsite
/**
* Switch to another subsite through storing the subsite identifier in the current PHP session.
* Only takes effect when {@link Subsite::$use_session_subsiteid} is set to TRUE.
*
* @param int|Subsite $subsite Either the ID of the subsite, or the subsite object itself
*/
public static function changeSubsite($subsite)
{
// Session subsite change only meaningful if the session is active.
// Otherwise we risk setting it to wrong value, e.g. if we rely on currentSubsiteID.
if (!Subsite::$use_session_subsiteid) {
return;
}
if (is_object($subsite)) {
$subsiteID = $subsite->ID;
} else {
$subsiteID = $subsite;
}
Session::set('SubsiteID', (int) $subsiteID);
// Set locale
if (is_object($subsite) && $subsite->Language != '') {
$locale = i18n::get_locale_from_lang($subsite->Language);
if ($locale) {
i18n::set_locale($locale);
}
}
Permission::flush_permission_cache();
}