$string['addanewdiscussion'] = "Add a new discussion topic";
$string['allowchoice'] = "Allow everyone to choose";
-$string['allowdiscussions'] = "Can a \$a start new discussions?";
+$string['allowdiscussions'] = "Can a \$a post to this forum?";
$string['allowratings'] = "Allow posts to be rated?";
$string['allowsdiscussions'] = "This forum allows each person to start one discussion topic.";
$string['anyfile'] = "Any file";
$string['attachment'] = "Attachment";
$string['bynameondate'] = "by \$a->name - \$a->date";
-$string['canstudentsstart'] = "Can a \$a start new discussions?";
$string['couldnotadd'] = "Could not add your post due to an unknown error";
$string['couldnotdeleteratings'] = "Sorry, that cannot be deleted as people have already rated it";
$string['couldnotdeletereplies'] = "Sorry, that cannot be deleted as people have already responded to it";
$string['nowsubscribed'] = "\$a->name will receive copies of '\$a->forum' by email.";
$string['numposts'] = "\$a posts";
$string['olderdiscussions'] = "Older discussions";
+$string['openmode0'] = "No discussions, no replies";
+$string['openmode1'] = "No discussions, but replies are allowed";
+$string['openmode2'] = "Discussions and replies are allowed";
$string['parentofthispost'] = "Parent of this post";
$string['postadded'] = "Your post was successfully added.<P>You have \$a to edit it if you want to make any changes.";
$string['postmailinfo'] = "This is a copy of a message posted on the \$a website.
-<P ALIGN=CENTER><B>Allowing new discussions</B></P>
+<P ALIGN=CENTER><B>Allowing new posts</B></P>
-<P>For most forums you will want to allow non-teachers to start new
- discussion topics (threads).
+<P>This option allows you to restrict students from posting
+ new content in this forum.
+
+<P>For most forums you will want to leave students unrestricted
+ and choose the first option to allow them to start new discussion
+ topics (threads), and also to post replies within those threads.
<P>Sometimes, however, you will want to disable this ability. For
example, this is useful for the News forum when you only want
teachers to post new items that appear on the course main page.
- Students will still be able to REPLY to existing posts though.
+ In this case you might choose the third option "No discussions, no replies".
+
+<P>Sometimes you might want to only allow teachers to start new
+ discussions, but still allow students to reply within those
+ threads (for example within the news forum on the site home page).
+ In this case you would choose the second option, "No discussions, but
+ replies are allowed".
+
$string['license'] = "GPL License";
$string['livelogs'] = "Live logs from the past hour";
$string['location'] = "Location";
-$string['loggedinas'] = "You are logged in as \$a.";
+$string['loggedinas'] = "You are logged in as \$a ";
$string['loggedinnot'] = "You are not logged in.";
$string['login'] = "Login";
$string['loginas'] = "Login as";
type enum('single','news','general','social','eachuser','teacher') NOT NULL default 'general',
name varchar(255) NOT NULL default '',
intro text NOT NULL,
- open tinyint(1) unsigned NOT NULL default '0',
+ opendiscuss tinyint(1) unsigned NOT NULL default '1',
+ openpost tinyint(1) unsigned NOT NULL default '1',
assessed tinyint(1) unsigned NOT NULL default '0',
forcesubscribe tinyint(1) unsigned NOT NULL default '0',
timemodified int(10) unsigned NOT NULL default '0',
"2" => get_string("postrating2", "forum"),
"1" => get_string("postrating1", "forum") );
+$FORUM_OPEN_MODES = array ("2" => get_string("openmode2", "forum"),
+ "1" => get_string("openmode1", "forum"),
+ "0" => get_string("openmode0", "forum") );
+
$FORUM_SHORT_POST = 300; // Less than this is "short"
$FORUM_LONG_POST = 600; // More than this is "long"
case "news":
$forum->name = get_string("namenews", "forum");
$forum->intro = get_string("intronews", "forum");
- $forum->open = 0;
+ $forum->open = 1; // 0 - no, 1 - posts only, 2 - discuss and post
$forum->assessed = 0;
$forum->forcesubscribe = 1;
break;
case "social":
$forum->name = get_string("namesocial", "forum");
$forum->intro = get_string("introsocial", "forum");
- $forum->open = 1;
+ $forum->open = 2; // 0 - no, 1 - posts only, 2 - discuss and post
$forum->assessed = 0;
$forum->forcesubscribe = 0;
break;
case "teacher":
$forum->name = get_string("nameteacher", "forum");
$forum->intro = get_string("introteacher", "forum");
- $forum->open = 0;
+ $forum->open = 0; // 0 - no, 1 - posts only, 2 - discuss and post
$forum->assessed = 0;
$forum->forcesubscribe = 0;
break;
} else if (isteacher($forum->course)) {
return true;
} else {
- return $forum->open;
+ return ($forum->open == 2);
}
}
+function forum_user_can_post($forum) {
+// $forum is an object
+ global $USER;
+
+ if ($forum->type == "teacher") {
+ return isteacher($forum->course);
+ } else if (isteacher($forum->course)) {
+ return true;
+ } else {
+ return $forum->open;
+ }
+}
function forum_get_discussions($forum="0", $forum_sort="DESC", $user=0) {
if ($user) {
global $USER;
$ownpost = ($USER->id == $post->user);
+ $reply = forum_user_can_post($forum);
- forum_print_post($post, $course->id, $ownpost, $reply=true, $link=false, $rate=false);
+ forum_print_post($post, $course->id, $ownpost, $reply, $link=false, $rate=false);
forum_print_mode_form($discussion->id, $mode);
case -1 : // Flat descending
default:
echo "<UL>";
- forum_print_posts_flat($post->discussion, $course->id, $mode, $forum->assessed);
+ forum_print_posts_flat($post->discussion, $course->id, $mode, $forum->assessed, $reply);
echo "</UL>";
break;
case 2 : // Threaded
- forum_print_posts_threaded($post->id, $course->id, 0, $forum->assessed);
+ forum_print_posts_threaded($post->id, $course->id, 0, $forum->assessed, $reply);
break;
case 3 : // Nested
- forum_print_posts_nested($post->id, $course->id, $forum->assessed);
+ forum_print_posts_nested($post->id, $course->id, $forum->assessed, $reply);
break;
}
}
}
-function forum_print_posts_flat($discussion, $course, $direction, $assessed) {
+function forum_print_posts_flat($discussion, $course, $direction, $assessed, $reply) {
global $USER;
- $reply = true;
$link = false;
if ($direction < 0) {
}
}
-function forum_print_posts_threaded($parent, $course, $depth, $assessed) {
+function forum_print_posts_threaded($parent, $course, $depth, $assessed, $reply) {
global $USER;
- $reply = true;
$link = false;
if ($posts = get_records_sql("SELECT p.*, u.id as userid, u.firstname, u.lastname, u.email, u.picture
echo "</FONT></P></LI>";
}
- forum_print_posts_threaded($post->id, $course, $depth-1, $assessed);
+ forum_print_posts_threaded($post->id, $course, $depth-1, $assessed, $reply);
echo "</UL>\n";
}
} else {
}
}
-function forum_print_posts_nested($parent, $course, $assessed) {
+function forum_print_posts_nested($parent, $course, $assessed, $reply) {
global $USER;
- $reply = true;
$link = false;
if ($posts = get_records_sql("SELECT p.*, u.id as userid, u.firstname, u.lastname, u.email, u.picture
echo "<UL>";
forum_print_post($post, $course, $ownpost, $reply, $link, $assessed);
echo "<BR>";
- forum_print_posts_nested($post->id, $course, $assessed);
+ forum_print_posts_nested($post->id, $course, $assessed, $reply);
echo "</UL>\n";
}
} else {
</tr>
<tr valign=top>
- <td align=right><P><B><? print_string("allowdiscussions", "forum", "$course->student") ?>:</B></P></TD>
+ <td align=right><P><B><? print_string("allowdiscussions", "forum", strtolower("$course->student")) ?>:</B></P></TD>
<td>
- <? $stryes = get_string("yes"); $strno = get_string("no"); ?>
- <input type=radio name=open value=1 <? if ($form->open == 1) echo "CHECKED"; ?> ><?=$stryes ?>
- <input type=radio name=open value=0 <? if ($form->open == 0) echo "CHECKED"; ?> ><?=$strno ?>
+ <? choose_from_menu($FORUM_OPEN_MODES, "open", $form->open, ""); ?>
<? helpbutton("allowdiscussions", get_string("allowdiscussions", "forum"), "forum") ?>
</td>
</tr>
+
<tr>
<td align=right><P><B><? print_string("allowratings", "forum") ?>:</B></P></TD>
<td>
- <input type=radio name=assessed value=1 <? if ($form->assessed == 1) echo "CHECKED"; ?> ><?=$stryes ?>
- <input type=radio name=assessed value=0 <? if ($form->assessed == 0) echo "CHECKED"; ?> ><?=$strno ?>
+ <? $options[0] = get_string("no"); $options[1] = get_string("yes"); ?>
+ <? choose_from_menu($options, "assessed", $form->assessed, ""); ?>
<? helpbutton("ratings", get_string("allowratings", "forum"), "forum") ?>
</td>
</tr>
<tr>
<td align=right><P><B><? print_string("forcesubscribeq", "forum") ?>:</B></P></TD>
<td>
- <input type=radio name=forcesubscribe value=1 <? if ($form->forcesubscribe == 1) echo "CHECKED"; ?> ><?=$stryes ?>
- <input type=radio name=forcesubscribe value=0 <? if ($form->forcesubscribe == 0) echo "CHECKED"; ?> ><?=$strno ?>
+ <? choose_from_menu($options, "forcesubscribe", $form->forcesubscribe, ""); ?>
<? helpbutton("subscription", get_string("forcesubscribeq", "forum"), "forum") ?>
</td>
</tr>
// This fragment is called by /admin/index.php
////////////////////////////////////////////////////////////////////////////////
-$module->version = 2002091000;
+$module->version = 2002100300;
$module->cron = 60;
function forum_upgrade($oldversion) {
}
}
+ if ($oldversion < 2002100300) {
+ execute_sql(" ALTER TABLE `forum` CHANGE `open` `open` TINYINT(2) UNSIGNED DEFAULT '2' NOT NULL ");
+ execute_sql(" UPDATE `forum` SET `open` = 2 WHERE `open` = 1 ");
+ execute_sql(" UPDATE `forum` SET `open` = 1 WHERE `open` = 0 ");
+ }
+
return true;
}