mirror of
https://github.com/moodle/moodle.git
synced 2025-08-07 01:46:45 +02:00
MDL-27001 'Show description' feature part 2 - Automatic support for modules that don't have a get_coursemodule_info function
If a module doesn't have module_get_coursemodule_info function, but it does have 'intro' and 'introformat' fields in its main table, then all it needs to do is return true for FEATURE_SHOW_DESCRIPTIONS and everything is handled automatically.
This commit is contained in:
parent
8c40662e22
commit
b3a89232d9
1 changed files with 16 additions and 1 deletions
|
@ -1122,7 +1122,7 @@ function get_array_of_activities($courseid) {
|
||||||
|
|
||||||
include_once("$CFG->dirroot/mod/$modname/lib.php");
|
include_once("$CFG->dirroot/mod/$modname/lib.php");
|
||||||
|
|
||||||
if (function_exists($functionname)) {
|
if ($hasfunction = function_exists($functionname)) {
|
||||||
if ($info = $functionname($rawmods[$seq])) {
|
if ($info = $functionname($rawmods[$seq])) {
|
||||||
if (!empty($info->icon)) {
|
if (!empty($info->icon)) {
|
||||||
$mod[$seq]->icon = $info->icon;
|
$mod[$seq]->icon = $info->icon;
|
||||||
|
@ -1157,6 +1157,21 @@ function get_array_of_activities($courseid) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// When there is no modname_get_coursemodule_info function,
|
||||||
|
// but showdescriptions is enabled, then we use the 'intro'
|
||||||
|
// and 'introformat' fields in the module table
|
||||||
|
if (!$hasfunction && $rawmods[$seq]->showdescription) {
|
||||||
|
if ($modvalues = $DB->get_record($rawmods[$seq]->modname,
|
||||||
|
array('id' => $rawmods[$seq]->instance), 'name, intro, introformat')) {
|
||||||
|
// Set content from intro and introformat. Filters are disabled
|
||||||
|
// because we filter it with format_text at display time
|
||||||
|
$mod[$seq]->content = format_module_intro($rawmods[$seq]->modname,
|
||||||
|
$modvalues, $rawmods[$seq]->id, false);
|
||||||
|
|
||||||
|
// To save making another query just below, put name in here
|
||||||
|
$mod[$seq]->name = $modvalues->name;
|
||||||
|
}
|
||||||
|
}
|
||||||
if (!isset($mod[$seq]->name)) {
|
if (!isset($mod[$seq]->name)) {
|
||||||
$mod[$seq]->name = $DB->get_field($rawmods[$seq]->modname, "name", array("id"=>$rawmods[$seq]->instance));
|
$mod[$seq]->name = $DB->get_field($rawmods[$seq]->modname, "name", array("id"=>$rawmods[$seq]->instance));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue