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


PHP external_api::contextrestriction方法代码示例

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


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

示例1: validate_context

 /**
  * Makes sure user may execute functions in this context.
  * @param object $context
  * @return void
  */
 protected static function validate_context($context)
 {
     global $CFG;
     if (empty($context)) {
         throw new invalid_parameter_exception('Context does not exist');
     }
     if (empty(self::$contextrestriction)) {
         self::$contextrestriction = get_context_instance(CONTEXT_SYSTEM);
     }
     $rcontext = self::$contextrestriction;
     if ($rcontext->contextlevel == $context->contextlevel) {
         if ($rcontext->id != $context->id) {
             throw new restricted_context_exception();
         }
     } else {
         if ($rcontext->contextlevel > $context->contextlevel) {
             throw new restricted_context_exception();
         } else {
             $parents = get_parent_contexts($context);
             if (!in_array($rcontext->id, $parents)) {
                 throw new restricted_context_exception();
             }
         }
     }
     if ($context->contextlevel >= CONTEXT_COURSE) {
         list($context, $course, $cm) = get_context_info_array($context->id);
         require_login($course, false, $cm, false, true);
     }
 }
开发者ID:vuchannguyen,项目名称:web,代码行数:34,代码来源:externallib.php

示例2: validate_context

 /**
  * Makes sure user may execute functions in this context.
  *
  * @param stdClass $context
  * @since Moodle 2.0
  */
 public static function validate_context($context)
 {
     global $CFG, $PAGE;
     if (empty($context)) {
         throw new invalid_parameter_exception('Context does not exist');
     }
     if (empty(self::$contextrestriction)) {
         self::$contextrestriction = context_system::instance();
     }
     $rcontext = self::$contextrestriction;
     if ($rcontext->contextlevel == $context->contextlevel) {
         if ($rcontext->id != $context->id) {
             throw new restricted_context_exception();
         }
     } else {
         if ($rcontext->contextlevel > $context->contextlevel) {
             throw new restricted_context_exception();
         } else {
             $parents = $context->get_parent_context_ids();
             if (!in_array($rcontext->id, $parents)) {
                 throw new restricted_context_exception();
             }
         }
     }
     $PAGE->reset_theme_and_output();
     list($unused, $course, $cm) = get_context_info_array($context->id);
     require_login($course, false, $cm, false, true);
     $PAGE->set_context($context);
 }
开发者ID:jackdaniels79,项目名称:moodle,代码行数:35,代码来源:externallib.php

示例3: set_context_restriction

 /**
  * Set context restriction for all following subsequent function calls.
  * @param stdClass $contex
  * @return void
  */
 public static function set_context_restriction($context)
 {
     self::$contextrestriction = $context;
 }
开发者ID:rboyatt,项目名称:mahara,代码行数:9,代码来源:lib.php


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