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


PHP context::insert_context_record方法代码示例

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


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

示例1: create_level_instances

 /**
  * Create missing context instances at block context level
  * @static
  */
 protected static function create_level_instances()
 {
     global $DB;
     $sql = "SELECT " . CONTEXT_BLOCK . ", bi.id\n                  FROM {block_instances} bi\n                 WHERE NOT EXISTS (SELECT 'x'\n                                     FROM {context} cx\n                                    WHERE bi.id = cx.instanceid AND cx.contextlevel=" . CONTEXT_BLOCK . ")";
     $contextdata = $DB->get_recordset_sql($sql);
     foreach ($contextdata as $context) {
         context::insert_context_record(CONTEXT_BLOCK, $context->id, null);
     }
     $contextdata->close();
 }
开发者ID:alanaipe2015,项目名称:moodle,代码行数:14,代码来源:accesslib.php

示例2: instance

 /**
  * Returns block context instance.
  *
  * @static
  * @param int $instanceid
  * @param int $strictness
  * @return context_block context instance
  */
 public static function instance($instanceid, $strictness = MUST_EXIST)
 {
     global $DB;
     if ($context = context::cache_get(CONTEXT_BLOCK, $instanceid)) {
         return $context;
     }
     if (!($record = $DB->get_record('context', array('contextlevel' => CONTEXT_BLOCK, 'instanceid' => $instanceid)))) {
         if ($bi = $DB->get_record('block_instances', array('id' => $instanceid), 'id,parentcontextid', $strictness)) {
             $parentcontext = context::instance_by_id($bi->parentcontextid);
             $record = context::insert_context_record(CONTEXT_BLOCK, $bi->id, $parentcontext->path);
         }
     }
     if ($record) {
         $context = new context_block($record);
         context::cache_add($context);
         return $context;
     }
     return false;
 }
开发者ID:rolandovanegas,项目名称:moodle,代码行数:27,代码来源:accesslib.php

示例3: instance

    /**
     * Returns costcenter context instance.
     *
     * @static
     * @param int $instanceid
     * @param int $strictness
     * @return context_costcenter context instance
     */
    public static function instance($instanceid, $strictness = MUST_EXIST) {
        global $DB;

        if ($context = context::cache_get(CONTEXT_COSTCENTER, $instanceid)) {
            return $context;
        }

        if (!$record = $DB->get_record('context', array('contextlevel' => CONTEXT_COSTCENTER, 'instanceid' => $instanceid))) {
            if ($costcenter = $DB->get_record('local_costcenter', array('id' => $instanceid), 'id,parentid', $strictness)) {
                if ($costcenter->parentid) {
                    $parentcontext = context_costcenter::instance($costcenter->parentid);
                    $record = context::insert_context_record(CONTEXT_COSTCENTER, $costcenter->id, $parentcontext->path);
                } else {
                    $record = context::insert_context_record(CONTEXT_COSTCENTER, $costcenter->id, '/' . SYSCONTEXTID, 0);
                }
            }
        }

        if ($record) {
            $context = new context_costcenter($record);
            context::cache_add($context);
            return $context;
        }

        return false;
    }
开发者ID:narasimhaeabyas,项目名称:tataaiapro,代码行数:34,代码来源:accesslib.php


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