MDL-13155 once more - reverting mod/xx/index.php to use get_all_instances_in_courses() again, should be now nearly the same as in 1.8.x ;-)

This commit is contained in:
skodak
2008-02-05 21:39:52 +00:00
parent f1bd9b5ecf
commit ffd15ec8f6
12 changed files with 144 additions and 171 deletions
+21 -23
View File
@@ -49,7 +49,7 @@
print_header_simple($strdata, '', $navigation, '', '', true, "", navmenu($course));
if (!$cms = get_coursemodules_in_course('data', $course->id, 'm.intro, m.approval, m.rssarticles')) {
if (! $datas = get_all_instances_in_course("data", $course)) {
notice(get_string('thereareno', 'moodle',$strdataplural) , "$CFG->wwwroot/course/view.php?id=$course->id");
}
@@ -82,53 +82,51 @@
$currentsection = "";
$modinfo = get_fast_modinfo($course);
foreach ($modinfo->instances['data'] as $cm) {
if (!$cm->uservisible) {
continue;
}
$cm->intro = $cms[$cm->id]->intro;
$cm->approval = $cms[$cm->id]->approval;
$cm->rssarticles = $cms[$cm->id]->rssarticles;
foreach ($datas as $data) {
$printsection = "";
$class = $cm->visible ? '' : 'class="dimmed"';
$link = "<a $class href=\"view.php?id=$cm->id\">".format_string($cm->name,true)."</a>";
//Calculate the href
if (!$data->visible) {
//Show dimmed if the mod is hidden
$link = "<a class=\"dimmed\" href=\"view.php?id=$data->coursemodule\">".format_string($data->name,true)."</a>";
} else {
//Show normal if the mod is visible
$link = "<a href=\"view.php?id=$data->coursemodule\">".format_string($data->name,true)."</a>";
}
// TODO: add group restricted counts here, and limit unapproved to ppl with approve cap only + link to approval page
$numrecords = count_records_sql('SELECT COUNT(r.id) FROM '.$CFG->prefix.
'data_records r WHERE r.dataid ='.$cm->instance);
'data_records r WHERE r.dataid ='.$data->id);
if ($cm->approval == 1) {
if ($data->approval == 1) {
$numunapprovedrecords = count_records_sql('SELECT COUNT(r.id) FROM '.$CFG->prefix.
'data_records r WHERE r.dataid ='.$cm->instance.
'data_records r WHERE r.dataid ='.$data->id.
' AND r.approved <> 1');
} else {
$numunapprovedrecords = '-';
}
$rsslink = '';
if ($rss && $cm->rssarticles > 0) {
$rsslink = rss_get_link($course->id, $USER->id, 'data', $cm->instance, 'RSS');
if ($rss && $data->rssarticles > 0) {
$rsslink = rss_get_link($course->id, $USER->id, 'data', $data->id, 'RSS');
}
if ($course->format == 'weeks' or $course->format == 'topics') {
if ($cm->sectionnum !== $currentsection) {
if ($cm->sectionnum) {
$printsection = $cm->sectionnum;
if ($data->section !== $currentsection) {
if ($data->section) {
$printsection = $data->section;
}
if ($currentsection !== '') {
$table->data[] = 'hr';
}
$currentsection = $cm->sectionnum;
$currentsection = $data->section;
}
$row = array ($printsection, $link, $cm->intro, $numrecords, $numunapprovedrecords);
$row = array ($printsection, $link, $data->intro, $numrecords, $numunapprovedrecords);
} else {
$row = array ($link, $cm->intro, $numrecords, $numunapprovedrecords);
$row = array ($link, $data->intro, $numrecords, $numunapprovedrecords);
}
if ($rss) {