MDL-2013 - stop resource auto-linking from occuring when resources are hidden

merged from MOODLE_19_STABLE
This commit is contained in:
poltawski 2007-12-26 17:44:45 +00:00
parent e69499c8df
commit 0bf540bb64

View File

@ -32,9 +32,23 @@
if (empty($resourcelist)) {
/// The resources are sorted from long to short so longer ones can be linked first.
/* get all non-hidden resources from this course
* sorted from long to short so longer ones can be
* linked first. And order by section so we try to
* link to the top resource first.
*/
$resource_sql = "SELECT r.id, r.name
FROM {$CFG->prefix}resource r,
{$CFG->prefix}course_modules cm,
{$CFG->prefix}modules m
WHERE m.name = 'resource' AND
cm.module = m.id AND
cm.visible = 1 AND
r.id = cm.instance AND
cm.course = {$courseid}
ORDER BY CHAR_LENGTH(r.name) DESC, cm.section ASC;";
if (!$resources = get_records('resource', 'course', $courseid, 'CHAR_LENGTH(name) DESC', 'id,name')) {
if (!$resources = get_records_sql($resource_sql) ){
$nothingtodo = true;
return $text;
}