Automatic installer.php lang files by installer_builder (20070310)
[moodle.git] / mod / forum / report.php
blobe0b32458726be86dba96b49715f1c38afb9e1df3
1 <?php // $Id$
3 // For a given post, shows a report of all the ratings it has
5 require_once("../../config.php");
6 require_once("lib.php");
8 $id = required_param('id',PARAM_INT);
9 $sort = optional_param('sort', '', PARAM_RAW);
11 if (! $post = get_record("forum_posts", "id", $id)) {
12 error("Post ID was incorrect");
15 if (! $discussion = get_record("forum_discussions", "id", $post->discussion)) {
16 error("Discussion ID was incorrect");
19 if (! $forum = get_record("forum", "id", $discussion->forum)) {
20 error("Forum ID was incorrect");
23 if (! $course = get_record("course", "id", $forum->course)) {
24 error("Course ID was incorrect");
27 if (!isteacher($course->id) and $USER->id != $post->userid) {
28 error("You can only look at results for posts you own");
31 switch ($sort) {
32 case 'time': $sqlsort = "r.time ASC"; break;
33 case 'firstname': $sqlsort = "u.firstname ASC"; break;
34 case 'rating': $sqlsort = "r.rating ASC"; break;
35 default: $sqlsort = "r.time ASC";
38 $scalemenu = make_grades_menu($forum->scale);
40 $strratings = get_string("ratings", "forum");
41 $strrating = get_string("rating", "forum");
42 $strname = get_string("name");
43 $strtime = get_string("time");
45 print_header("$strratings: ".format_string($post->subject));
47 if (!$ratings = forum_get_ratings($post->id, $sqlsort)) {
48 error("No ratings for this post: \"".format_string($post->subject)."\"");
50 } else {
51 echo "<table border=\"0\" cellpadding=\"3\" cellspacing=\"3\" class=\"generalbox\" width=\"100%\">";
52 echo "<tr>";
53 echo "<th>&nbsp;</th>";
54 echo "<th><a href=\"report.php?id=$post->id&amp;sort=firstname\">$strname</a>";
55 echo "<th width=\"100%\"><a href=\"report.php?id=$post->id&amp;sort=rating\">$strrating</a>";
56 echo "<th><a href=\"report.php?id=$post->id&amp;sort=time\">$strtime</a>";
57 foreach ($ratings as $rating) {
58 if (isteacher($discussion->course, $rating->id)) {
59 echo '<tr class="forumpostheadertopic">';
60 } else {
61 echo '<tr class="forumpostheader">';
63 echo "<td>";
64 print_user_picture($rating->id, $forum->course, $rating->picture);
65 echo '<td nowrap="nowrap"><p><font size="-1">'.fullname($rating).'</p>';
66 echo '<td nowrap="nowrap" align="center"><p><font size="-1">'.$scalemenu[$rating->rating]."</p>";
67 echo '<td nowrap="nowrap" align="center"><p><font size="-1">'.userdate($rating->time)."</p>";
68 echo "</tr>\n";
70 echo "</table>";
71 echo "<br />";
74 close_window_button();