From 0bc310eb5a9523f9a47ff6940499dfb533fb9e56 Mon Sep 17 00:00:00 2001 From: Russell Smith Date: Thu, 2 May 2013 10:39:26 +1000 Subject: [PATCH] MDL-36482 activities block: Allow mod display without intro's --- course/resources.php | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/course/resources.php b/course/resources.php index 6debe853d08..7a1c2e82c19 100644 --- a/course/resources.php +++ b/course/resources.php @@ -84,7 +84,11 @@ foreach ($modinfo->cms as $cm) { // preload instances foreach ($resources as $modname=>$instances) { - $resources[$modname] = $DB->get_records_list($modname, 'id', $instances, 'id', 'id,name,intro,introformat,timemodified'); + $additionalfields = ''; + if (plugin_supports('mod', $modname, FEATURE_MOD_INTRO)) { + $additionalfields = ',intro,introformat'; + } + $resources[$modname] = $DB->get_records_list($modname, 'id', $instances, 'id', 'id,name'.$additionalfields); } if (!$cms) { @@ -109,8 +113,8 @@ foreach ($cms as $cm) { continue; } $resource = $resources[$cm->modname][$cm->instance]; + $printsection = ''; if ($usesections) { - $printsection = ''; if ($cm->sectionnum !== $currentsection) { if ($cm->sectionnum) { $printsection = get_section_name($course, $cm->sectionnum); @@ -120,8 +124,6 @@ foreach ($cms as $cm) { } $currentsection = $cm->sectionnum; } - } else { - $printsection = ''.userdate($resource->timemodified).""; } $extra = empty($cm->extra) ? '' : $cm->extra; @@ -131,11 +133,17 @@ foreach ($cms as $cm) { $icon = ''.get_string('modulename', $cm->modname).' '; } + if (isset($cm->intro) && isset($cm->introformat)) { + $intro = format_module_intro('resource', $resource, $cm->id); + } else { + $intro = ''; + } + $class = $cm->visible ? '' : 'class="dimmed"'; // hidden modules are dimmed $table->data[] = array ( $printsection, "wwwroot/mod/$cm->modname/view.php?id=$cm->id\">".$icon.format_string($resource->name)."", - format_module_intro('resource', $resource, $cm->id)); + $intro); } echo html_writer::table($table); -- 2.11.4.GIT