$string['deletesure'] = 'Are you sure you want to delete this post?';
$string['discussion'] = 'Discussion';
$string['discussionmoved'] = 'This discussion has been moved to \'$a\'.';
-$string['discussions'] = 'Discussions';
+$string['discussionname'] = 'Discussion name';
$string['discussionsstartedby'] = 'Discussions started by $a';
$string['discussionsstartedbyrecent'] = 'Discussions recently started by $a';
$string['discussthistopic'] = 'Discuss this topic';
$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['postincontext'] = 'See this post in context';
-$string['postmailinfo'] = 'This is a copy of a message posted on the $a website.\r
+$string['postmailinfo'] = 'This is a copy of a message posted on the $a website.
+
To add your reply via the website, click on this link:';
$string['postrating1'] = 'Mostly Separate Knowing';
$string['postrating2'] = 'Separate and Connected';
$string['posts'] = 'Posts';
$string['postupdated'] = 'Your post was updated';
$string['processingpost'] = 'Processing post $a';
+$string['prune'] = 'Break off';
+$string['pruneheading'] = 'Break off post and move to a new discussion';
$string['rate'] = 'Rate';
$string['rating'] = 'Rating';
$string['ratingeveryone'] = 'Everyone can rate posts';
$postdata = "p.*";
}
- return get_records_sql("SELECT $postdata, d.timemodified, d.usermodified,
+ return get_records_sql("SELECT $postdata, d.name, d.timemodified, d.usermodified,
u.firstname, u.lastname, u.email, u.picture
FROM {$CFG->prefix}forum_discussions d,
{$CFG->prefix}forum_posts p,
}
}
if ($reply) {
- $output .= " | <a target=\"_blank\" href=\"$CFG->wwwroot/mod/forum/post.php?reply=$post->id\">".get_string("replyforum", "forum")."</a>";
+ $output .= "<a target=\"_blank\" href=\"$CFG->wwwroot/mod/forum/post.php?reply=$post->id\">".get_string("replyforum", "forum")."</a>";
}
$output .= " ";
} else {
echo "<a href=\"$CFG->wwwroot/mod/forum/post.php?edit=$post->id\">$stredit</a> | ";
}
}
+
+ if (isteacheredit($courseid) and $post->parent) {
+ echo "<a href=\"$CFG->wwwroot/mod/forum/post.php?prune=$post->id\" title=\"".get_string('pruneheading', 'forum').'">'.
+ get_string("prune", "forum")."</a> | ";
+ }
+
if ($ownpost or $isteacher) {
if (!record_exists("forum_posts", "parent", $post->id)) {
echo "<a href=\"$CFG->wwwroot/mod/forum/post.php?delete=$post->id\">$strdelete</a>";
} else {
$ownpost=false;
}
+ // Use discussion name instead of subject of first post
+ $discussion->subject = $discussion->name;
+
switch ($forum_style) {
case "minimal":
if (!empty($CFG->filterall)) {
return;
}
+function forum_change_discussionid($postid, $discussionid) {
+/// recursively sets the discussion field to $discussionid on $postid and all its children
+/// used when pruning a post
+ set_field('forum_posts', 'discussion', $discussionid, 'id', $postid);
+ if ($posts = get_records('forum_posts', 'parent', $postid)) {
+ foreach ($posts as $post) {
+ forum_change_discussionid($post->id, $discussionid);
+ }
+ }
+ return true;
+}
+
?>
die;
+ } else if (isset($prune)) { // Teacher is pruning
+
+ if (! $post = forum_get_post_full($prune)) {
+ error("Post ID was incorrect");
+ }
+ if (! $discussion = get_record("forum_discussions", "id", $post->discussion)) {
+ error("This post is not part of a discussion!");
+ }
+ if (! $forum = get_record("forum", "id", $discussion->forum)) {
+ error("The forum number was incorrect ($discussion->forum)");
+ }
+ if (!isteacher($forum->course)) {
+ error("You can't prune discussions!");
+ }
+ if (!$post->parent) {
+ error('This is already the first post in the discussion');
+ }
+
+ if (isset($_REQUEST['name'])) { // User has confirmed the prune
+
+ $newdiscussion->course = $discussion->course;
+ $newdiscussion->forum = $discussion->forum;
+ $newdiscussion->name = $name;
+ $newdiscussion->firstpost = $post->id;
+ $newdiscussion->userid = $discussion->userid;
+ $newdiscussion->groupid = $discussion->groupid;
+ $newdiscussion->assessed = $discussion->assessed;
+ $newdiscussion->usermodified = $post->userid;
+
+ if (!$newid = insert_record('forum_discussions', $newdiscussion)) {
+ error('Could not create new discussion');
+ }
+
+ set_field('forum_posts', 'parent', 0, 'id', $post->id);
+ forum_change_discussionid($post->id, $newid);
+
+ // set timemodified to time of last post in each discussion
+ $lastpost = get_record_sql("SELECT MAX(modified) AS time
+ FROM {$CFG->prefix}forum_posts
+ WHERE discussion = '$discussion->id'");
+ set_field('forum_discussions', 'timemodified', $lastpost->time, 'id', $discussion->id);
+ $lastpost = get_record_sql("SELECT MAX(modified) AS time
+ FROM {$CFG->prefix}forum_posts
+ WHERE discussion = '$newid'");
+ set_field('forum_discussions', 'timemodified', $lastpost->time, 'id', $newid);
+
+
+ if (!$cm = get_coursemodule_from_instance("forum", $forum->id, $forum->course)) { // For the logs
+ $cm->id = 0;
+ }
+ add_to_log($discussion->course, "forum", "prune post",
+ "discuss.php?d=$newid", "$post->id", $cm->id);
+
+ redirect(forum_go_back_to("discuss.php?d=$newid"),
+ get_string("prunedpost", "forum"), 1);
+
+ } else { // User just asked to prune something
+
+ $course = get_record('course', 'id', $forum->course);
+ $strforums = get_string("modulenameplural", "forum");
+ print_header("$course->shortname: $discussion->name: $post->subject", "$course->fullname",
+ "<A HREF=../../course/view.php?id=$course->id>$course->shortname</A> ->
+ <A HREF=\"../forum/index.php?id=$course->id\">$strforums</A> ->
+ <A HREF=\"view.php?f=$forum->id\">$forum->name</A> ->
+ <A HREF=\"discuss.php?d=$discussion->id\">$post->subject</A> -> ".
+ get_string("prune", "forum"), '', "", true, "", navmenu($course, $cm));
+
+ print_heading(get_string('pruneheading', 'forum'));
+ echo '<CENTER>';
+
+ include('prune.html');
+
+ forum_print_post($post, $forum->course, $ownpost=false, $reply=false, $link=false);
+ }
+
+ die;
+
+
} else {
error("No operation specified");
--- /dev/null
+<form name="prune" method="get" action="post.php" enctype="multipart/form-data">
+<table border="0" cellpadding="5">
+<tr valign="top">
+ <td align=right><p><b><?php print_string("discussionname", "forum"); ?>:</b></p></td>
+ <td>
+ <input type="text" name="name" size=60 value="<?php p($post->subject) ?>">
+ </td>
+</tr>
+
+
+<tr>
+ <td align=center colspan=2>
+ <input type="hidden" name=prune value="<?php p($prune) ?>">
+ <input type="hidden" name=confirm value="<?php p($prune) ?>">
+ <input type="submit" value="<?php print_string('prune', 'forum'); ?>">
+ </td>
+
+</tr>
+</table>
+</form>