本文整理汇总了PHP中course_modinfo::build_section_cache方法的典型用法代码示例。如果您正苦于以下问题:PHP course_modinfo::build_section_cache方法的具体用法?PHP course_modinfo::build_section_cache怎么用?PHP course_modinfo::build_section_cache使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类course_modinfo
的用法示例。
在下文中一共展示了course_modinfo::build_section_cache方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: rebuild_course_cache
/**
* Rebuilds the cached list of course activities stored in the database
* @param int $courseid - id of course to rebuild, empty means all
* @param boolean $clearonly - only clear the modinfo fields, gets rebuild automatically on the fly
*/
function rebuild_course_cache($courseid = 0, $clearonly = false)
{
global $COURSE, $SITE, $DB, $CFG;
// Destroy navigation caches
navigation_cache::destroy_volatile_caches();
if (class_exists('format_base')) {
// if file containing class is not loaded, there is no cache there anyway
format_base::reset_course_cache($courseid);
}
if ($clearonly) {
if (empty($courseid)) {
$DB->set_field('course', 'modinfo', null);
$DB->set_field('course', 'sectioncache', null);
} else {
// Clear both fields in one update
$resetobj = (object) array('id' => $courseid, 'modinfo' => null, 'sectioncache' => null);
$DB->update_record('course', $resetobj);
}
// update cached global COURSE too ;-)
if ($courseid == $COURSE->id or empty($courseid)) {
$COURSE->modinfo = null;
$COURSE->sectioncache = null;
}
if ($courseid == $SITE->id) {
$SITE->modinfo = null;
$SITE->sectioncache = null;
}
// reset the fast modinfo cache
get_fast_modinfo($courseid, 0, true);
return;
}
require_once "{$CFG->dirroot}/course/lib.php";
if ($courseid) {
$select = array('id' => $courseid);
} else {
$select = array();
@set_time_limit(0);
// this could take a while! MDL-10954
}
$rs = $DB->get_recordset("course", $select, '', 'id,fullname');
foreach ($rs as $course) {
$modinfo = serialize(get_array_of_activities($course->id));
$sectioncache = serialize(course_modinfo::build_section_cache($course->id));
$updateobj = (object) array('id' => $course->id, 'modinfo' => $modinfo, 'sectioncache' => $sectioncache);
$DB->update_record("course", $updateobj);
// update cached global COURSE too ;-)
if ($course->id == $COURSE->id) {
$COURSE->modinfo = $modinfo;
$COURSE->sectioncache = $sectioncache;
}
if ($course->id == $SITE->id) {
$SITE->modinfo = $modinfo;
$SITE->sectioncache = $sectioncache;
}
}
$rs->close();
// reset the fast modinfo cache
get_fast_modinfo($courseid, 0, true);
}
示例2: rebuild_course_cache
/**
* Rebuilds the cached list of course activities stored in the database
* @param int $courseid - id of course to rebuild, empty means all
* @param boolean $clearonly - only clear the modinfo fields, gets rebuild automatically on the fly
*/
function rebuild_course_cache($courseid=0, $clearonly=false) {
global $COURSE, $DB, $CFG;
if (!$clearonly && !empty($CFG->upgraderunning)) {
debugging('Function rebuild_course_cache() should not be called from upgrade script unless with argument clearonly.',
DEBUG_DEVELOPER);
$clearonly = true;
}
// Destroy navigation caches
navigation_cache::destroy_volatile_caches();
if ($clearonly) {
if (empty($courseid)) {
$DB->set_field('course', 'modinfo', null);
$DB->set_field('course', 'sectioncache', null);
} else {
// Clear both fields in one update
$resetobj = (object)array('id' => $courseid, 'modinfo' => null, 'sectioncache' => null);
$DB->update_record('course', $resetobj);
}
// update cached global COURSE too ;-)
if ($courseid == $COURSE->id or empty($courseid)) {
$COURSE->modinfo = null;
$COURSE->sectioncache = null;
}
// reset the fast modinfo cache
$reset = 'reset';
get_fast_modinfo($reset);
return;
}
require_once("$CFG->dirroot/course/lib.php");
if ($courseid) {
$select = array('id'=>$courseid);
} else {
$select = array();
@set_time_limit(0); // this could take a while! MDL-10954
}
$rs = $DB->get_recordset("course", $select,'','id,fullname');
foreach ($rs as $course) {
$modinfo = serialize(get_array_of_activities($course->id));
$sectioncache = serialize(course_modinfo::build_section_cache($course->id));
$updateobj = (object)array('id' => $course->id,
'modinfo' => $modinfo, 'sectioncache' => $sectioncache);
$DB->update_record("course", $updateobj);
// update cached global COURSE too ;-)
if ($course->id == $COURSE->id) {
$COURSE->modinfo = $modinfo;
$COURSE->sectioncache = $sectioncache;
}
}
$rs->close();
// reset the fast modinfo cache
$reset = 'reset';
get_fast_modinfo($reset);
}