MDL-43024 course: fixed bug for accessing section options

This commit is contained in:
Marina Glancy 2013-11-22 12:39:55 +11:00
parent f7434db109
commit 724b00b2b6

View file

@ -2426,7 +2426,7 @@ class section_info implements IteratorAggregate {
public function __empty($name) {
if (method_exists($this, 'get_'.$name) ||
property_exists($this, '_'.$name) ||
in_array($name, self::$sectionformatoptions[$this->modinfo->get_course()->format])) {
array_key_exists($name, self::$sectionformatoptions[$this->modinfo->get_course()->format])) {
$value = $this->__get($name);
return empty($value);
}
@ -2451,7 +2451,7 @@ class section_info implements IteratorAggregate {
return $this->cachedformatoptions[$name];
}
// precheck if the option is defined in format to avoid unnecessary DB queries in get_format_options()
if (in_array($name, self::$sectionformatoptions[$this->modinfo->get_course()->format])) {
if (array_key_exists($name, self::$sectionformatoptions[$this->modinfo->get_course()->format])) {
$formatoptions = course_get_format($this->modinfo->get_course())->get_format_options($this);
return $formatoptions[$name];
}