]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-20995 Blog entries correctly displayed in activity reports
authorNicolas Connault <nicolasconnault@gmail.com>
Fri, 30 Oct 2009 07:27:19 +0000 (07:27 +0000)
committerNicolas Connault <nicolasconnault@gmail.com>
Fri, 30 Oct 2009 07:27:19 +0000 (07:27 +0000)
course/report/outline/index.php
course/reset_form.php

index dd845717404d02a93bc65ad3f18ee3c4af902354..19ba73e5df25e6d32fea9945a06ae466b7b139c4 100644 (file)
@@ -31,6 +31,7 @@
     $strlast           = get_string('lastaccess');
     $strreports        = get_string('reports');
     $strviews          = get_string('views');
+    $strrelatedblogentries = get_string('relatedblogentries', 'blog');
 
     $PAGE->set_title($course->shortname .': '. $stractivityreport);
     $PAGE->set_heading($course->fullname);
         print_error('logfilenotavailable');
     }
 
-    echo '<div class="loginfo">'.get_string('computedfromlogs', 'admin', userdate($logstart)).'</div>';
+    echo $OUTPUT->container(get_string('computedfromlogs', 'admin', userdate($logstart)), 'loginfo');
+
+    $outlinetable = new html_table();
+    $outlinetable->add_class('generaltable boxaligncenter');
+    $outlinetable->cellpadding = 5;
+    $outlinetable->id = 'outlinetable';
+    $outlinetable->head = array($stractivity, $strviews);
+
+    if ($CFG->useblogassociations) {
+        $outlinetable->head[] = $strrelatedblogentries;
+    }
 
-    echo '<table id="outlinetable" class="generaltable boxaligncenter" cellpadding="5"><tr>';
-    echo '<th class="header c0" scope="col">'.$stractivity.'</th>';
-    echo '<th class="header c1" scope="col">'.$strviews.'</th>';
     if ($showlastaccess) {
-        echo '<th class="header c2" scope="col">'.$strlast.'</th>';
+        $outlinetable->head[] = $strlast;
     }
-    echo '</tr>';
 
     $modinfo = get_fast_modinfo($course);
 
@@ -63,7 +70,6 @@
           GROUP BY cm.id";
     $views = $DB->get_records_sql($sql, array($course->id));
 
-    $ri = 0;
     $prevsecctionnum = 0;
     foreach ($modinfo->sections as $sectionnum=>$section) {
         foreach ($section as $cmid) {
                 continue;
             }
             if ($prevsecctionnum != $sectionnum) {
-                echo '<tr class="r'.$ri++.' section"><td colspan="3"><h3>';
+                $sectionrow = new html_table_row();
+                $sectionrow->add_class('section');
+                $sectioncell = new html_table_cell();
+                $sectioncell->colspan = count($outlinetable->head);
+
+                $sectiontitle = '';
                 switch ($course->format) {
-                    case 'weeks': print_string('week'); break;
-                    case 'topics': print_string('topic'); break;
-                    default: print_string('section'); break;
+                    case 'weeks': $sectiontitle = get_string('week'); break;
+                    case 'topics': $sectiontitle = get_string('topic'); break;
+                    default: $sectiontitle = get_string('section'); break;
                 }
-                echo ' '.$sectionnum.'</h3></td></tr>';
+
+                $sectioncell->text = $OUTPUT->heading($sectiontitle . ' ' . $sectionnum, 3);
+                $sectionrow->cells[] = $sectioncell;
+                $outlinetable->data[] = $sectionrow;
 
                 $prevsecctionnum = $sectionnum;
             }
 
             $dimmed = $cm->visible ? '' : 'class="dimmed"';
             $modulename = get_string('modulename', $cm->modname);
-            echo '<tr class="r'.$ri++.'">';
-            echo "<td class=\"cell c0 actvity\"><img src=\"" . $OUTPUT->mod_icon_url('icon', $cm->modname) . "\" class=\"icon\" alt=\"$modulename\" />";
-            echo "<a $dimmed title=\"$modulename\" href=\"$CFG->wwwroot/mod/$cm->modname/view.php?id=$cm->id\">".format_string($cm->name)."</a></td>";
-            echo "<td class=\"cell c1 numviews\">";
+
+            $reportrow = new html_table_row();
+            $activitycell = new html_table_cell();
+            $activitycell->add_class('activity');
+
+            $activityicon = html_image::make($OUTPUT->mod_icon_url('icon', $cm->modname));
+            $activityicon->add_class('icon');
+            $activityicon->alt = $modulename;
+
+            $activitylink = html_link::make("$CFG->wwwroot/mod/$cm->modname/view.php?id=$cm->id", format_string($cm->name));
+            if (!$cm->visible) {
+                $activitylink->add_class('dimmed');
+            }
+
+            $activitycell->text = $OUTPUT->image($activityicon) . $OUTPUT->link($activitylink);
+
+            $reportrow->cells[] = $activitycell;
+
+            $numviewscell = new html_table_cell();
+            $numviewscell->add_class('numviews');
+
             if (!empty($views[$cm->id]->numviews)) {
-                echo $views[$cm->id]->numviews;
+                $numviewscell->text = $views[$cm->id]->numviews;
             } else {
-                echo '-';
+                $numviewscell->text = '-';
             }
-            echo "</td>";
+
+            $reportrow->cells[] = $numviewscell;
+
+            if ($CFG->useblogassociations) {
+                $blogcell = new html_table_cell();
+                $blogcell->add_class('blog');
+                if ($blogcount = blog_get_associated_count($course->id, $cm->id)) {
+                    $blogcell->text = $OUTPUT->link(html_link::make('/blog/index.php?modid='.$cm->id, $blogcount));
+                } else {
+                    $blogcell->text = '-';
+                }
+                $reportrow->cells[] = $blogcell;
+            }
+
             if ($showlastaccess) {
-                echo "<td class=\"cell c2 lastaccess\">";
+                $lastaccesscell = new html_table_cell();
+                $lastaccesscell->add_class('lastaccess');
+
                 if (isset($views[$cm->id]->lasttime)) {
                     $timeago = format_time(time() - $views[$cm->id]->lasttime);
-                    echo userdate($views[$cm->id]->lasttime)." ($timeago)";
+                    $lastaccesscell->text = userdate($views[$cm->id]->lasttime)." ($timeago)";
                 }
-                echo "</td>";
+                $reportrow->cells[] = $lastaccesscell;
             }
-            echo '</tr>';
+            $outlinetable->data[] = $reportrow;
         }
     }
-    echo '</table>';
+    echo $OUTPUT->table($outlinetable);
 
     echo $OUTPUT->footer();
 
index 10da1c9890f51de990e6a53ee9e19bdb25c23b42..88b19793ffbf1a2c39bb9bb9ddfabac3cf5f30d1 100644 (file)
@@ -14,6 +14,8 @@ class course_reset_form extends moodleform {
         $mform->addElement('checkbox', 'reset_events', get_string('deleteevents', 'calendar'));
         $mform->addElement('checkbox', 'reset_logs', get_string('deletelogs'));
         $mform->addElement('checkbox', 'reset_notes', get_string('deletenotes', 'notes'));
+        $mform->addElement('checkbox', 'delete_blog_associations', get_string('deleteblogassociations', 'blog'));
+        $mform->setHelpButton('delete_blog_associations', array('deleteblogassociations', get_string('deleteblogassociations', 'blog'), 'blog'));
 
 
         $mform->addElement('header', 'rolesheader', get_string('roles'));