moodle/mod/forum/discuss.php
moodler 02ebf404c8 WARNING: BIG CHANGES!
OK, this is a big check-in with some big changes, and needs work still.

It seems relatively stable, but I need help identifying the rough patches.

1) First grading scales support.  There is a now a new table called "scale"
   that contains grading scales.  There can be site scales (course=0) and
   custom course scales.  These can be used in modules - I've only done
   forums for now but that was the hard one.  Scales can be edited via
   the new item in the course admin menu.

   There is one default scale - the connected/separate knowing one that used
   to be in forum.  To build this I pull data from the language packs
   to create one during the upgrade, or anytime a scales menu is called
   and no scales are found.

2) New roles for course creator and teachers.  I've fixed up the course
   menus and some other things but there's a lot left to do on this to
   make it all smooth.  The idea is that teachers no longer can edit courses
   unless they are also course creators.  The interface for this needs to
   be smoothed out a fair bit and I need help with this.

   The upgrade will upgrade all teachers to be creators, but will default
   the new site config "creatornewcourses" to "no", so that effectively
   these new teachers have the same privileges.

3) Simplified teacher management.  There is no longer an "assign teachers"
   and a "teacher roles" page - it's all on one page in course/teacher.html.


Phew ... time for a shower and then back into it.
2003-08-15 13:59:24 +00:00

122 lines
4.5 KiB
PHP

<?PHP // $Id$
// Displays a post, and all the posts below it.
// If no post is given, displays all posts in a discussion
require_once("../../config.php");
require_once("lib.php");
require_variable($d); // Discussion ID
optional_variable($parent); // If set, then display this post and all children.
optional_variable($mode); // If set, changes the layout of the thread
optional_variable($move); // If set, moves this discussion to another forum
if (! $discussion = get_record("forum_discussions", "id", $d)) {
error("Discussion ID was incorrect or no longer exists");
}
if (! $course = get_record("course", "id", $discussion->course)) {
error("Course ID is incorrect - discussion is faulty");
}
if ($course->category) {
require_login($course->id);
}
if (!empty($move)) {
if (!isteacher($course->id)) {
error("Only teachers can do that!");
}
if ($forum = get_record("forum", "id", $move)) {
set_field("forum_discussions", "forum", $forum->id, "id", $discussion->id);
$discussion->forum = $forum->id;
add_to_log($course->id, "forum", "move discussion", "discuss.php?d=$discussion->id", "$discussion->id");
$discussionmoved = true;
} else {
error("You can't move to that forum - it doesn't exist!");
}
}
if (empty($forum)) {
if (! $forum = get_record("forum", "id", $discussion->forum)) {
notify("Bad forum ID stored in this discussion");
}
}
if (!$cm = get_coursemodule_from_instance("forum", $forum->id, $course->id)) {
//notify("Bad coursemodule for this discussion"); // Only affects navmenu
}
$logparameters = "d=$discussion->id";
if ($parent) {
$logparameters .= "&parent=$parent";
}
add_to_log($course->id, "forum", "view discussion", "discuss.php?$logparameters", "$discussion->id");
unset($SESSION->fromdiscussion);
forum_set_display_mode($mode);
$displaymode = $USER->mode;
if ($parent) {
if (abs($USER->mode) == 1) { // If flat AND parent, then force nested display this time
$displaymode = 3;
}
} else {
$parent = $discussion->firstpost;
$navtail = "$discussion->name";
}
if (! $post = forum_get_post_full($parent)) {
error("Discussion no longer exists", "$CFG->wwwroot/mod/forum/view.php?f=$forum->id");
}
if (empty($navtail)) {
$navtail = "<A HREF=\"discuss.php?d=$discussion->id\">$discussion->name</A> -> $post->subject";
}
$navmiddle = "<A HREF=\"../forum/index.php?id=$course->id\">".get_string("forums", "forum")."</A> -> <A HREF=\"../forum/view.php?f=$forum->id\">$forum->name</A>";
$searchform = forum_print_search_form($course, "", true, "plain");
if ($course->category) {
print_header("$course->shortname: $discussion->name", "$course->fullname",
"<A HREF=../../course/view.php?id=$course->id>$course->shortname</A> ->
$navmiddle -> $navtail", "", "", true, $searchform, navmenu($course, $cm));
} else {
print_header("$course->shortname: $discussion->name", "$course->fullname",
"$navmiddle -> $navtail", "", "", true, $searchform, navmenu($course, $cm));
}
echo "<table width=\"100%\"><tr><td width=\"33%\">&nbsp;</td><td width=\"33%\">";
forum_print_mode_form($discussion->id, $mode);
echo "</td><td width=\"33%\">";
if (isteacher($course->id)) { // Popup menu to allow discussions to be moved to other forums
if ($forums = get_all_instances_in_course("forum", $course)) {
foreach ($forums as $courseforum) {
if ($courseforum->id != $forum->id) {
$url = "discuss.php?d=$discussion->id&move=$courseforum->id";
$forummenu[$url] = $courseforum->name;
}
}
if (!empty($forummenu)) {
echo "<div align=\"right\">";
echo popup_form("$CFG->wwwroot/mod/forum/", $forummenu, "forummenu", "",
get_string("movethisdiscussionto", "forum"), "", "", true);
echo "</div>";
}
}
}
echo "</td></tr></table>";
if (isset($discussionmoved)) {
notify(get_string("discussionmoved", "forum", $forum->name));
}
forum_print_discussion($course, $forum, $discussion, $post, $displaymode);
print_footer($course);
?>