• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

PHP get_cache_flags函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中get_cache_flags函数的典型用法代码示例。如果您正苦于以下问题:PHP get_cache_flags函数的具体用法?PHP get_cache_flags怎么用?PHP get_cache_flags使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: ntlmsso_finish

 /**
  * Find the session set by ntlmsso_magic(), validate it and
  * call authenticate_user_login() to authenticate the user through
  * the auth machinery.
  *
  * It is complemented by a similar check in user_login().
  *
  * If it succeeds, it never returns.
  *
  */
 function ntlmsso_finish()
 {
     global $CFG, $USER, $SESSION;
     $key = sesskey();
     $cf = get_cache_flags($this->pluginconfig . '/ntlmsess');
     if (!isset($cf[$key]) || $cf[$key] === '') {
         return false;
     }
     $username = $cf[$key];
     // Here we want to trigger the whole authentication machinery
     // to make sure no step is bypassed...
     $user = authenticate_user_login($username, $key);
     if ($user) {
         complete_user_login($user);
         // Cleanup the key to prevent reuse...
         // and to allow re-logins with normal credentials
         unset_cache_flag($this->pluginconfig . '/ntlmsess', $key);
         // Redirection
         if (user_not_fully_set_up($USER)) {
             $urltogo = $CFG->wwwroot . '/user/edit.php';
             // We don't delete $SESSION->wantsurl yet, so we get there later
         } else {
             if (isset($SESSION->wantsurl) and strpos($SESSION->wantsurl, $CFG->wwwroot) === 0) {
                 $urltogo = $SESSION->wantsurl;
                 // Because it's an address in this site
                 unset($SESSION->wantsurl);
             } else {
                 // No wantsurl stored or external - go to homepage
                 $urltogo = $CFG->wwwroot . '/';
                 unset($SESSION->wantsurl);
             }
         }
         // We do not want to redirect if we are in a PHPUnit test.
         if (!PHPUNIT_TEST) {
             redirect($urltogo);
         }
     }
     // Should never reach here.
     return false;
 }
开发者ID:jeffthestampede,项目名称:excelsior,代码行数:50,代码来源:auth.php


示例2: mark_dirty

 /**
  * Mark a context as dirty (with timestamp) so as to force reloading of the context.
  */
 public function mark_dirty()
 {
     global $CFG, $USER, $ACCESSLIB_PRIVATE;
     if (during_initial_install()) {
         return;
     }
     // only if it is a non-empty string
     if (is_string($this->_path) && $this->_path !== '') {
         set_cache_flag('accesslib/dirtycontexts', $this->_path, 1, time() + $CFG->sessiontimeout);
         if (isset($ACCESSLIB_PRIVATE->dirtycontexts)) {
             $ACCESSLIB_PRIVATE->dirtycontexts[$this->_path] = 1;
         } else {
             if (CLI_SCRIPT) {
                 $ACCESSLIB_PRIVATE->dirtycontexts = array($this->_path => 1);
             } else {
                 if (isset($USER->access['time'])) {
                     $ACCESSLIB_PRIVATE->dirtycontexts = get_cache_flags('accesslib/dirtycontexts', $USER->access['time'] - 2);
                 } else {
                     $ACCESSLIB_PRIVATE->dirtycontexts = array($this->_path => 1);
                 }
                 // flags not loaded yet, it will be done later in $context->reload_if_dirty()
             }
         }
     }
 }
开发者ID:rolandovanegas,项目名称:moodle,代码行数:28,代码来源:accesslib.php


示例3: mark_context_dirty

/**
 * Mark a context as dirty (with timestamp) so as to force reloading of the context.
 *
 * @deprecated since 2.2, use $context->mark_dirty() instead
 * @see context::mark_dirty()
 * @param string $path context path
 */
function mark_context_dirty($path)
{
    global $CFG, $USER, $ACCESSLIB_PRIVATE;
    debugging('mark_context_dirty() is deprecated, please use $context->mark_dirty() instead.', DEBUG_DEVELOPER);
    if (during_initial_install()) {
        return;
    }
    // only if it is a non-empty string
    if (is_string($path) && $path !== '') {
        set_cache_flag('accesslib/dirtycontexts', $path, 1, time() + $CFG->sessiontimeout);
        if (isset($ACCESSLIB_PRIVATE->dirtycontexts)) {
            $ACCESSLIB_PRIVATE->dirtycontexts[$path] = 1;
        } else {
            if (CLI_SCRIPT) {
                $ACCESSLIB_PRIVATE->dirtycontexts = array($path => 1);
            } else {
                if (isset($USER->access['time'])) {
                    $ACCESSLIB_PRIVATE->dirtycontexts = get_cache_flags('accesslib/dirtycontexts', $USER->access['time'] - 2);
                } else {
                    $ACCESSLIB_PRIVATE->dirtycontexts = array($path => 1);
                }
                // flags not loaded yet, it will be done later in $context->reload_if_dirty()
            }
        }
    }
}
开发者ID:Hirenvaghasiya,项目名称:moodle,代码行数:33,代码来源:deprecatedlib.php


示例4: test_everything_in_accesslib


//.........这里部分代码省略.........
                        if (($cap->captype === 'write') or ($cap->riskbitmask & (RISK_XSS | RISK_CONFIG | RISK_DATALOSS))) {
                            $this->assertFalse(has_capability($cap->name, $context, $userid));
                        }
                        $this->assertFalse(isset($allowed[$userid]));
                    } else {
                        if (is_siteadmin($userid)) {
                            $this->assertTrue(has_capability($cap->name, $context, $userid, true));
                        }
                        $hascap = has_capability($cap->name, $context, $userid, false);
                        $this->assertSame($hascap, isset($allowed[$userid]), "Capability result mismatch user:$userid, context:$context->id, $cap->name, hascap: ".(int)$hascap." ");
                        if (isset($enrolled[$userid])) {
                            $this->assertSame(isset($allowed[$userid]), isset($enrolledwithcap[$userid]), "Enrolment with capability result mismatch user:$userid, context:$context->id, $cap->name, hascap: ".(int)$hascap." ");
                        }
                    }
                }
            }
        }
        // Back to nobody
        $USER = new stdClass();
        $USER->id = 0;
        unset($contexts);
        unset($userids);
        unset($capabilities);

        // Now let's do all the remaining tests that break our carefully prepared fake site



        // ======= $context->mark_dirty() =======================================

        $DB->delete_records('cache_flags', array());
        accesslib_clear_all_caches(false);
        $systemcontext->mark_dirty();
        $dirty = get_cache_flags('accesslib/dirtycontexts', time()-2);
        $this->assertTrue(isset($dirty[$systemcontext->path]));
        $this->assertTrue(isset($ACCESSLIB_PRIVATE->dirtycontexts[$systemcontext->path]));


        // ======= $context->reload_if_dirty(); =================================

        $DB->delete_records('cache_flags', array());
        accesslib_clear_all_caches(false);
        load_all_capabilities();
        $context = context_course::instance($testcourses[2]);
        $page = $DB->get_record('page', array('course'=>$testcourses[2]));
        $pagecontext = context_module::instance($page->id);

        $context->mark_dirty();
        $this->assertTrue(isset($ACCESSLIB_PRIVATE->dirtycontexts[$context->path]));
        $USER->access['test'] = true;
        $context->reload_if_dirty();
        $this->assertFalse(isset($USER->access['test']));

        $context->mark_dirty();
        $this->assertTrue(isset($ACCESSLIB_PRIVATE->dirtycontexts[$context->path]));
        $USER->access['test'] = true;
        $pagecontext->reload_if_dirty();
        $this->assertFalse(isset($USER->access['test']));


        // ======= context_helper::build_all_paths() ============================

        $oldcontexts = $DB->get_records('context', array(), 'id');
        $DB->set_field_select('context', 'path', NULL, "contextlevel <> ".CONTEXT_SYSTEM);
        $DB->set_field_select('context', 'depth', 0, "contextlevel <> ".CONTEXT_SYSTEM);
        context_helper::build_all_paths();
开发者ID:numbas,项目名称:moodle,代码行数:67,代码来源:accesslib_test.php


示例5: get_dirty_contexts

/**
 * Fetch recent dirty contexts to know cheaply whether our $USER->access
 * is stale and needs to be reloaded.
 *
 * Uses cache_flags
 * @param int $time
 * @return array of dirty contexts
 */
function get_dirty_contexts($time)
{
    return get_cache_flags('accesslib/dirtycontexts', $time - 2);
}
开发者ID:nicolasconnault,项目名称:moodle2.0,代码行数:12,代码来源:accesslib.php


示例6: ntlmsso_finish

 /**
  * Find the session set by ntlmsso_magic(), validate it and 
  * call authenticate_user_login() to authenticate the user through
  * the auth machinery.
  * 
  * It is complemented by a similar check in user_login().
  * 
  * If it succeeds, it never returns. 
  *
  */
 function ntlmsso_finish()
 {
     global $CFG, $USER, $SESSION;
     $key = sesskey();
     $cf = get_cache_flags('auth/ldap/ntlmsess');
     if (!isset($cf[$key]) || $cf[$key] === '') {
         return false;
     }
     $username = $cf[$key];
     // Here we want to trigger the whole authentication machinery
     // to make sure no step is bypassed...
     $user = authenticate_user_login($username, $key);
     if ($user) {
         add_to_log(SITEID, 'user', 'login', "view.php?id={$USER->id}&course=" . SITEID, $user->id, 0, $user->id);
         $USER = complete_user_login($user);
         // Cleanup the key to prevent reuse...
         // and to allow re-logins with normal credentials
         unset_cache_flag('auth/ldap/ntlmsess', $key);
         /// Redirection
         if (user_not_fully_set_up($USER)) {
             $urltogo = $CFG->wwwroot . '/user/edit.php';
             // We don't delete $SESSION->wantsurl yet, so we get there later
         } else {
             if (isset($SESSION->wantsurl) and strpos($SESSION->wantsurl, $CFG->wwwroot) === 0) {
                 $urltogo = $SESSION->wantsurl;
                 /// Because it's an address in this site
                 unset($SESSION->wantsurl);
             } else {
                 // no wantsurl stored or external - go to homepage
                 $urltogo = $CFG->wwwroot . '/';
                 unset($SESSION->wantsurl);
             }
         }
         redirect($urltogo);
     }
     // Should never reach here.
     return false;
 }
开发者ID:arshanam,项目名称:Moodle-ITScholars-LMS,代码行数:48,代码来源:auth.php


示例7: test_everything_in_accesslib


//.........这里部分代码省略.........
                     if ($userid == 0) {
                         $CFG->forcelogin = true;
                         $this->assertFalse(has_capability($cap->name, $context, $userid));
                         unset($CFG->forcelogin);
                     }
                     if ($cap->captype === 'write' or $cap->riskbitmask & (RISK_XSS | RISK_CONFIG | RISK_DATALOSS)) {
                         $this->assertFalse(has_capability($cap->name, $context, $userid));
                     }
                     $this->assertFalse(isset($allowed[$userid]));
                 } else {
                     if (is_siteadmin($userid)) {
                         $this->assertTrue(has_capability($cap->name, $context, $userid, true));
                     }
                     $hascap = has_capability($cap->name, $context, $userid, false);
                     $this->assertIdentical($hascap, isset($allowed[$userid]), "Capability result mismatch user:{$userid}, context:{$context->id}, {$cap->name}, hascap: " . (int) $hascap . " ");
                     if (isset($enrolled[$userid])) {
                         $this->assertIdentical(isset($allowed[$userid]), isset($enrolledwithcap[$userid]), "Enrolment with capability result mismatch user:{$userid}, context:{$context->id}, {$cap->name}, hascap: " . (int) $hascap . " ");
                     }
                 }
             }
         }
     }
     // Back to nobody
     $USER = new stdClass();
     $USER->id = 0;
     unset($contexts);
     unset($users);
     unset($capabilities);
     // Now let's do all the remaining tests that break our carefully prepared fake site
     // ======= $context->mark_dirty() =======================================
     $DB->delete_records('cache_flags', array());
     accesslib_clear_all_caches(false);
     $systemcontext->mark_dirty();
     $dirty = get_cache_flags('accesslib/dirtycontexts', time() - 2);
     $this->assertTrue(isset($dirty[$systemcontext->path]));
     $this->assertTrue(isset($ACCESSLIB_PRIVATE->dirtycontexts[$systemcontext->path]));
     // ======= $context->reload_if_dirty(); =================================
     $DB->delete_records('cache_flags', array());
     accesslib_clear_all_caches(false);
     load_all_capabilities();
     $context = context_course::instance($testcourses[2]);
     $page = $DB->get_record('page', array('course' => $testcourses[2]));
     $pagecontext = context_module::instance($page->id);
     $context->mark_dirty();
     $this->assertTrue(isset($ACCESSLIB_PRIVATE->dirtycontexts[$context->path]));
     $USER->access['test'] = true;
     $context->reload_if_dirty();
     $this->assertFalse(isset($USER->access['test']));
     $context->mark_dirty();
     $this->assertTrue(isset($ACCESSLIB_PRIVATE->dirtycontexts[$context->path]));
     $USER->access['test'] = true;
     $pagecontext->reload_if_dirty();
     $this->assertFalse(isset($USER->access['test']));
     // ======= context_helper::build_all_paths() ============================
     $oldcontexts = $DB->get_records('context', array(), 'id');
     $DB->set_field_select('context', 'path', NULL, "contextlevel <> " . CONTEXT_SYSTEM);
     $DB->set_field_select('context', 'depth', 0, "contextlevel <> " . CONTEXT_SYSTEM);
     context_helper::build_all_paths();
     $newcontexts = $DB->get_records('context', array(), 'id');
     $this->assertIdentical($oldcontexts, $newcontexts);
     unset($oldcontexts);
     unset($newcontexts);
     // ======= $context->reset_paths() ======================================
     $context = context_course::instance($testcourses[2]);
     $children = $context->get_child_contexts();
     $context->reset_paths(false);
开发者ID:rolandovanegas,项目名称:moodle,代码行数:67,代码来源:fulltestaccesslib.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP get_cache_function函数代码示例发布时间:2022-05-15
下一篇:
PHP get_cache_flag函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap