本文整理汇总了PHP中course_modinfo::get_section_info方法的典型用法代码示例。如果您正苦于以下问题:PHP course_modinfo::get_section_info方法的具体用法?PHP course_modinfo::get_section_info怎么用?PHP course_modinfo::get_section_info使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类course_modinfo
的用法示例。
在下文中一共展示了course_modinfo::get_section_info方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: obtain_dynamic_data
/**
* If dynamic data for this course-module is not yet available, gets it.
*
* This function is automatically called when requesting any course_modinfo property
* that can be modified by modules (have a set_xxx method).
*
* Dynamic data is data which does not come directly from the cache but is calculated at
* runtime based on the current user. Primarily this concerns whether the user can access
* the module or not.
*
* As part of this function, the module's _cm_info_dynamic function from its lib.php will
* be called (if it exists).
* @return void
*/
private function obtain_dynamic_data() {
global $CFG;
$userid = $this->modinfo->get_user_id();
if ($this->state >= self::STATE_BUILDING_DYNAMIC || $userid == -1) {
return;
}
$this->state = self::STATE_BUILDING_DYNAMIC;
if (!empty($CFG->enableavailability)) {
require_once($CFG->libdir. '/conditionlib.php');
// Get availability information
$ci = new condition_info($this);
// Note that the modinfo currently available only includes minimal details (basic data)
// but we know that this function does not need anything more than basic data.
$this->available = $ci->is_available($this->availableinfo, true,
$userid, $this->modinfo);
// Check parent section
$parentsection = $this->modinfo->get_section_info($this->sectionnum);
if (!$parentsection->available) {
// Do not store info from section here, as that is already
// presented from the section (if appropriate) - just change
// the flag
$this->available = false;
}
} else {
$this->available = true;
}
// Update visible state for current user
$this->update_user_visible();
// Let module make dynamic changes at this point
$this->call_mod_function('cm_info_dynamic');
$this->state = self::STATE_DYNAMIC;
}
示例2: obtain_dynamic_data
/**
* If dynamic data for this course-module is not yet available, gets it.
*
* This function is automatically called when constructing course_modinfo, so users don't
* need to call it.
*
* Dynamic data is data which does not come directly from the cache but is calculated at
* runtime based on the current user. Primarily this concerns whether the user can access
* the module or not.
*
* As part of this function, the module's _cm_info_dynamic function from its lib.php will
* be called (if it exists).
* @return void
*/
public function obtain_dynamic_data()
{
global $CFG;
if ($this->state >= self::STATE_DYNAMIC) {
return;
}
$userid = $this->modinfo->get_user_id();
if (!empty($CFG->enableavailability)) {
// Get availability information
$ci = new condition_info($this);
// Note that the modinfo currently available only includes minimal details (basic data)
// so passing it to this function is a bit dangerous as it would cause infinite
// recursion if it tried to get dynamic data, however we know that this function only
// uses basic data.
$this->available = $ci->is_available($this->availableinfo, true, $userid, $this->modinfo);
// Check parent section
$parentsection = $this->modinfo->get_section_info($this->sectionnum);
if (!$parentsection->available) {
// Do not store info from section here, as that is already
// presented from the section (if appropriate) - just change
// the flag
$this->available = false;
}
} else {
$this->available = true;
}
// Update visible state for current user
$this->update_user_visible();
// Let module make dynamic changes at this point
$this->call_mod_function('cm_info_dynamic');
$this->state = self::STATE_DYNAMIC;
}