Changes related to new forum type: eachuser and some general forum-related tweaking

This commit is contained in:
martin 2002-06-25 06:47:34 +00:00
parent de8c1874c1
commit e07635f4d0
9 changed files with 69 additions and 15 deletions

View File

@ -63,10 +63,19 @@
}
redirect("view.php?id=$mod->course");
if ($SESSION->returnpage) {
$return = $SESSION->returnpage;
unset($SESSION->returnpage);
redirect($return);
} else {
redirect("view.php?id=$mod->course");
}
exit;
}
if (isset($return)) {
$SESSION->returnpage = $HTTP_REFERER;
}
if (isset($move)) {

View File

@ -11,7 +11,7 @@
<TD WIDTH="15%" VALIGN="TOP">
<?
//if ($news = get_course_news_forum($course->id)) {
//forum_latest_topics($news->id, 5, "minimal", "DESC", false);
//print_forum_latest_topics($news->id, 5, "minimal", "DESC", false);
//}
//echo "<BR><BR>";
@ -93,7 +93,7 @@
<?
if ($social = get_course_social_forum($course->id)) {
forum_latest_topics($social->id, 10, "plain", "DESC", false);
print_forum_latest_topics($social->id, 10, "plain", "DESC", false);
} else {
error("Could not find or create a social forum here");
}

View File

@ -204,7 +204,7 @@
print_simple_box("Latest News", $align="CENTER", $width="100%", $color="$THEME->cellheading");
print_simple_box_start("CENTER", "100%", "#FFFFFF", 3, 0);
echo "<FONT SIZE=1>";
forum_latest_topics($news->id, 5, "minimal", "DESC", false);
print_forum_latest_topics($news->id, 5, "minimal", "DESC", false);
echo "</FONT>";
print_simple_box_end();
}

View File

@ -96,7 +96,7 @@ function print_side_block($heading="", $list=NULL, $footer="", $icons=NULL) {
echo "";
}
echo "</TD>\n<TD WIDTH=100%>";
echo "<P><FONT SIZE=1>$string</FONT></P>";
echo "<P><FONT SIZE=2>$string</FONT></P>";
echo "</TD></TR>\n";
}
}

View File

@ -193,7 +193,7 @@
print_simple_box("Latest News", $align="CENTER", $width="100%", $color="$THEME->cellheading");
print_simple_box_start("CENTER", "100%", "#FFFFFF", 3, 0);
echo "<FONT SIZE=1>";
forum_latest_topics($news->id, 5, "minimal", "DESC", false);
print_forum_latest_topics($news->id, 5, "minimal", "DESC", false);
echo "</FONT>";
print_simple_box_end();
}

View File

@ -87,7 +87,7 @@
}
print_simple_box("$headertext", $align="CENTER", $width="100%", $color="$THEME->cellheading");
echo "<IMG HEIGHT=8 SRC=\"pix/spacer.gif\" ALT=\"\"><BR>";
forum_latest_topics($newsforum->id, $site->format);
print_forum_latest_topics($newsforum->id, $site->format);
}
?>

View File

@ -197,7 +197,7 @@ function update_module_icon($moduleid) {
global $CFG;
if (isteacher($courseid)) {
return "<A TITLE=\"Edit this activity\" HREF=\"$CFG->wwwroot/course/mod.php?update=$moduleid\" TARGET=_top><IMG
return "<A TITLE=\"Edit this activity\" HREF=\"$CFG->wwwroot/course/mod.php?update=$moduleid&return=true\" TARGET=_top><IMG
SRC=\"$CFG->wwwroot/pix/i/edit.gif\" ALIGN=right BORDER=0></A>";
}
}

View File

@ -26,11 +26,38 @@ function forum_unsubscribe($user, $forum) {
}
function get_all_topics($forum="0", $forum_sort="DESC") {
function user_has_posted_discussion($forumid, $userid) {
if ($topics = get_all_topics($forumid, "DESC", $userid)) {
return true;
} else {
return false;
}
}
function user_can_post_discussion($forum) {
// $forum is an object
global $USER;
if ($forum->type == "eachuser") {
return (! user_has_posted_discussion($forum->id, $USER->id));
} else if (isteacher($forum->course)) {
return true;
} else {
return $forum->open;
}
}
function get_all_topics($forum="0", $forum_sort="DESC", $user=0) {
if ($user) {
$userselect = " AND u.id = '$user' ";
} else {
$userselect = "";
}
return get_records_sql("SELECT p.*, u.firstname, u.lastname, u.email, u.picture, u.id as userid
FROM discuss d, discuss_posts p, user u
WHERE d.forum = '$forum' AND p.discuss = d.id AND
p.parent= 0 AND p.user = u.id
p.parent= 0 AND p.user = u.id $userselect
ORDER BY p.created $forum_sort");
}
@ -87,7 +114,7 @@ function get_course_discussion_forum($courseid) {
}
function forum_latest_topics($forum_id=0, $forum_numtopics=5, $forum_style="plain", $forum_sort="DESC") {
function print_forum_latest_topics($forum_id=0, $forum_numtopics=5, $forum_style="plain", $forum_sort="DESC") {
global $CFG, $USER;
if ($forum_id) {
@ -112,7 +139,7 @@ function forum_latest_topics($forum_id=0, $forum_numtopics=5, $forum_style="plai
}
if (! $topics = get_all_topics($forum->id, $forum_sort) ) {
echo "<P><B>There are no discussion topics yet in this forum.</B></P>";
echo "<P ALIGN=CENTER><B>There are no discussion topics yet in this forum.</B></P>";
} else {
@ -147,7 +174,7 @@ function forum_latest_topics($forum_id=0, $forum_numtopics=5, $forum_style="plai
}
}
}
if ($forum->open || $USER->editing) {
if (user_can_post_discussion($forum)) {
echo "<P ALIGN=right>";
echo "<A HREF=\"$CFG->wwwroot/mod/discuss/post.php?forum=$forum->id\">Add a new topic...</A>";
echo "</P>";

View File

@ -50,10 +50,28 @@
} else {
$subtext = "Subscribe to this forum";
}
echo "<DIV ALIGN=RIGHT><FONT SIZE=1><A HREF=\"subscribe.php?id=$forum->id\">$subtext</A></FONT></P>";
echo "<DIV ALIGN=RIGHT><FONT SIZE=1><A HREF=\"subscribe.php?id=$forum->id\">$subtext</A></FONT></DIV>";
}
forum_latest_topics($forum->id, 0);
print_simple_box(text_to_html($forum->intro), "CENTER");
switch ($forum->type) {
case "eachuser":
echo "<P ALIGN=CENTER>";
if (user_can_post_discussion($forum)) {
echo "This forum allows one discussion topic to be posted per person. Click here to <A HREF=\"../discuss/post.php?forum=$forum->id\">post your topic</A>.";
} else {
echo "&nbsp";
}
echo "</P>";
break;
default:
echo "<P>&nbsp;</P>";
break;
}
print_forum_latest_topics($forum->id, 0);
print_footer($course);