New feature to allow teachers to move a discussion from one forum

to another.

A simple popup menu now appears when teachers view any discussion.

Includes a new log entry to log when a discussion is moved.
This commit is contained in:
moodler 2003-04-24 08:45:27 +00:00
parent 2a40936834
commit 1fc49f0019
8 changed files with 57 additions and 8 deletions

View File

@ -54,6 +54,7 @@ $string['modeflatnewestfirst'] = "Display replies flat, with newest first";
$string['modenested'] = "Display replies in nested form";
$string['modethreaded'] = "Display replies in threaded form";
$string['more'] = "more";
$string['movethisdiscussionto'] = "Move this discussion to ... ";
$string['namenews'] = "News forum";
$string['namesocial'] = "Social forum";
$string['nameteacher'] = "Teacher forum";

View File

@ -4,6 +4,8 @@ function forum_upgrade($oldversion) {
// This function does anything necessary to upgrade
// older versions to match current functionality
global $CFG;
if ($oldversion < 2002073008) {
execute_sql("DELETE FROM modules WHERE name = 'discuss' ");
execute_sql("ALTER TABLE `discuss` RENAME `forum_discussions` ");
@ -56,6 +58,9 @@ function forum_upgrade($oldversion) {
execute_sql("ALTER TABLE `forum_subscriptions` CHANGE `user` `userid` INT(10) UNSIGNED DEFAULT '0' NOT NULL ");
}
if ($oldversion < 2003042402) {
execute_sql("INSERT INTO {$CFG->prefix}log_display VALUES ('forum', 'move discussion', 'forum_discussions', 'name')");
}
return true;
}

View File

@ -90,6 +90,7 @@ INSERT INTO prefix_log_display VALUES ('forum', 'update', 'forum', 'name');
INSERT INTO prefix_log_display VALUES ('forum', 'add discussion', 'forum_discussions', 'name');
INSERT INTO prefix_log_display VALUES ('forum', 'add post', 'forum_posts', 'subject');
INSERT INTO prefix_log_display VALUES ('forum', 'update post', 'forum_posts', 'subject');
INSERT INTO prefix_log_display VALUES ('forum', 'move discussion', 'forum_discussions', 'name');
INSERT INTO prefix_log_display VALUES ('forum', 'view subscribers', 'forum', 'name');
INSERT INTO prefix_log_display VALUES ('forum', 'view discussion', 'forum_discussions', 'name');
INSERT INTO prefix_log_display VALUES ('forum', 'view forum', 'forum', 'name');

View File

@ -6,6 +6,10 @@ function forum_upgrade($oldversion) {
global $CFG;
if ($oldversion < 2003042402) {
execute_sql("INSERT INTO {$CFG->prefix}log_display VALUES ('forum', 'move discussion', 'forum_discussions', 'name')");
}
return true;
}

View File

@ -83,6 +83,7 @@ INSERT INTO prefix_log_display VALUES ('forum', 'update', 'forum', 'name');
INSERT INTO prefix_log_display VALUES ('forum', 'add discussion', 'forum_discussions', 'name');
INSERT INTO prefix_log_display VALUES ('forum', 'add post', 'forum_posts', 'subject');
INSERT INTO prefix_log_display VALUES ('forum', 'update post', 'forum_posts', 'subject');
INSERT INTO prefix_log_display VALUES ('forum', 'move discussion', 'forum_discussions', 'name');
INSERT INTO prefix_log_display VALUES ('forum', 'view subscribers', 'forum', 'name');
INSERT INTO prefix_log_display VALUES ('forum', 'view discussion', 'forum_discussions', 'name');
INSERT INTO prefix_log_display VALUES ('forum', 'view forum', 'forum', 'name');

View File

@ -9,6 +9,7 @@
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");
@ -18,19 +19,38 @@
error("Course ID is incorrect - discussion is faulty");
}
if (! $forum = get_record("forum", "id", $discussion->forum)) {
notify("Bad forum ID stored in this discussion");
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");
} 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
}
if ($course->category) {
require_login($course->id);
$logparameters = "d=$discussion->id";
if ($parent) {
$logparameters .= "&parent=$parent";
}
add_to_log($course->id, "forum", "view discussion", "discuss.php?".$_SERVER["QUERY_STRING"], "$discussion->id");
add_to_log($course->id, "forum", "view discussion", "discuss.php?$logparameters", "$discussion->id");
unset($SESSION->fromdiscussion);
@ -68,6 +88,23 @@
"$navmiddle -> $navtail", "", "", true, $searchform, navmenu($course, $cm));
}
if (isteacher($course->id)) { // Popup menu to allow discussions to be moved to other forums
if ($forums = get_all_instances_in_course("forum", $course->id, "cw.section ASC")) {
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>";
}
}
}
forum_print_discussion($course, $forum, $discussion, $post, $displaymode);
print_footer($course);

View File

@ -9,7 +9,7 @@
$form->intro = "";
}
if (empty($form->open)) {
$form->open = "";
$form->open = 2;
}
if (empty($form->assessed)) {
$form->assessed = "";

View File

@ -5,7 +5,7 @@
// This fragment is called by /admin/index.php
////////////////////////////////////////////////////////////////////////////////
$module->version = 2002122300;
$module->version = 2003042402;
$module->cron = 60;
?>