MDL-26781 Ensure get_fast_modinfo $cm is compatible with get_record $cm

This commit is contained in:
sam marshall
2011-03-16 15:03:01 +00:00
parent 56babbcb76
commit adaeccb66d
4 changed files with 126 additions and 48 deletions
+16
View File
@@ -1373,6 +1373,8 @@ abstract class admin_setting {
public $plugin; // null means main config table
/** @var bool true indicates this setting does not actually save anything, just information */
public $nosave = false;
/** @var bool if set, indicates that a change to this setting requires rebuild course cache */
public $affectsmodinfo = false;
/**
* Constructor
@@ -1434,6 +1436,14 @@ abstract class admin_setting {
return 'id_s_'.$this->plugin.'_'.$this->name;
}
/**
* @param bool $affectsmodinfo If true, changes to this setting will
* cause the course cache to be rebuilt
*/
public function set_affects_modinfo($affectsmodinfo) {
$this->affectsmodinfo = $affectsmodinfo;
}
/**
* Returns the config if possible
*
@@ -1480,6 +1490,12 @@ abstract class admin_setting {
// store change
set_config($name, $value, $this->plugin);
// Some admin settings affect course modinfo
if ($this->affectsmodinfo) {
// Clear course cache for all courses
rebuild_course_cache(0, true);
}
// log change
$log = new stdClass();
$log->userid = during_initial_install() ? 0 :$USER->id; // 0 as user id during install