function forum_print_post(&$post, $courseid, $ownpost=false, $reply=false, $link=false,
$ratings=NULL, $footer="", $highlight="") {
+
global $THEME, $USER, $CFG;
static $stredit, $strdelete, $strreply, $strparent, $threadedmode;
echo "</p>";
echo "<div align=right><p align=right>";
+
+ $ratingsmenuused = false;
if (!empty($ratings) and !empty($USER->id)) {
$useratings = true;
if ($ratings->assesstimestart and $ratings->assesstimefinish) {
forum_print_ratings_mean($post->id, $ratings->scale);
if ($USER->id != $post->userid) {
forum_print_rating_menu($post->id, $USER->id, $ratings->scale);
+ $ratingsmenuused = true;
}
} else if ($USER->id == $post->userid) {
forum_print_ratings_mean($post->id, $ratings->scale);
} else if (!empty($ratings->allow) ) {
forum_print_rating_menu($post->id, $USER->id, $ratings->scale);
+ $ratingsmenuused = true;
}
}
}
} else {
$replystring = get_string("repliesmany", "forum", $post->replies);
}
- echo "<a href=\"$CFG->wwwroot/mod/forum/discuss.php?d=$post->discussion\"><b>".get_string("discussthistopic", "forum")."</b></a> ($replystring) ";
+ echo "<a href=\"$CFG->wwwroot/mod/forum/discuss.php?d=$post->discussion\"><b>".
+ get_string("discussthistopic", "forum")."</b></a> ($replystring) ";
}
echo "</p>";
if ($footer) {
}
echo "</div>";
echo "</td></tr>\n</table>\n\n";
+
+ return $ratingsmenuused;
}
$reply = forum_user_can_post($forum);
$ratings = NULL;
+ $ratingsmenuused = false;
if ($forum->assessed and !empty($USER->id)) {
if ($ratings->scale = make_grades_menu($forum->scale)) {
$ratings->assesstimestart = $forum->assesstimestart;
}
}
- forum_print_post($post, $course->id, $ownpost, $reply, $link=false, $ratings);
+ if (forum_print_post($post, $course->id, $ownpost, $reply, $link=false, $ratings)) {
+ $ratingsmenuused = true;
+ }
switch ($mode) {
case FORUM_MODE_FLATOLDEST :
case FORUM_MODE_FLATNEWEST :
default:
echo "<ul>";
- forum_print_posts_flat($post->discussion, $course->id, $mode, $ratings, $reply);
+ if (forum_print_posts_flat($post->discussion, $course->id, $mode, $ratings, $reply)) {
+ $ratingsmenuused = true;
+ }
echo "</ul>";
break;
case FORUM_MODE_THREADED :
- forum_print_posts_threaded($post->id, $course->id, 0, $ratings, $reply);
+ if (forum_print_posts_threaded($post->id, $course->id, 0, $ratings, $reply)) {
+ $ratingsmenuused = true;
+ }
break;
case FORUM_MODE_NESTED :
- forum_print_posts_nested($post->id, $course->id, $ratings, $reply);
+ if (forum_print_posts_nested($post->id, $course->id, $ratings, $reply)) {
+ $ratingsmenuused = true;
+ }
break;
}
- if ($ratings) {
+ if ($ratingsmenuused) {
echo "<center><input type=\"submit\" value=\"".get_string("sendinratings", "forum")."\">";
if ($forum->scale < 0) {
if ($scale = get_record("scale", "id", abs($forum->scale))) {
global $USER;
$link = false;
+ $ratingsmenuused = false;
if ($direction < 0) {
$sort = "ORDER BY created DESC";
if ($posts = forum_get_discussion_posts($discussion, $sort)) {
foreach ($posts as $post) {
$ownpost = ($USER->id == $post->userid);
- forum_print_post($post, $course, $ownpost, $reply, $link, $ratings);
+ if (forum_print_post($post, $course, $ownpost, $reply, $link, $ratings)) {
+ $ratingsmenuused = true;
+ }
}
- } else {
- return;
}
+
+ return $ratingsmenuused;
}
function forum_print_posts_threaded($parent, $course, $depth, $ratings, $reply) {
global $USER;
$link = false;
+ $ratingsmenuused = false;
if ($posts = forum_get_child_posts($parent)) {
foreach ($posts as $post) {
echo "<ul>";
if ($depth > 0) {
$ownpost = ($USER->id == $post->userid);
- forum_print_post($post, $course, $ownpost, $reply, $link, $ratings); // link=true?
+ if (forum_print_post($post, $course, $ownpost, $reply, $link, $ratings)) {
+ $ratingsmenuused = true;
+ }
echo "<br />";
} else {
$by->name = "$post->firstname $post->lastname";
echo "</font></p></li>";
}
- forum_print_posts_threaded($post->id, $course, $depth-1, $ratings, $reply);
+ if (forum_print_posts_threaded($post->id, $course, $depth-1, $ratings, $reply)) {
+ $ratingsmenuused = true;
+ }
echo "</ul>\n";
}
- } else {
- return;
}
+ return $ratingsmenuused;
}
function forum_print_posts_nested($parent, $course, $ratings, $reply) {
global $USER;
$link = false;
+ $ratingsmenuused = false;
if ($posts = forum_get_child_posts($parent)) {
foreach ($posts as $post) {
$ownpost = ($USER->id == $post->userid);
}
- echo "<UL>";
- forum_print_post($post, $course, $ownpost, $reply, $link, $ratings);
- echo "<BR>";
- forum_print_posts_nested($post->id, $course, $ratings, $reply);
- echo "</UL>\n";
+ echo "<ul>";
+ if (forum_print_post($post, $course, $ownpost, $reply, $link, $ratings)) {
+ $ratingsmenuused = true;
+ }
+ echo "<br />";
+ if (forum_print_posts_nested($post->id, $course, $ratings, $reply)) {
+ $ratingsmenuused = true;
+ }
+ echo "</ul>\n";
}
- } else {
- return;
}
+ return $ratingsmenuused;
}
function forum_set_display_mode($mode=0) {