2004-09-12 16:24:41 +00:00
|
|
|
<?php // $Id$
|
2002-07-31 14:19:35 +00:00
|
|
|
|
|
|
|
// Edit and save a new post to a discussion
|
|
|
|
|
2005-04-26 20:39:08 +00:00
|
|
|
require_once('../../config.php');
|
|
|
|
require_once('lib.php');
|
2006-11-07 08:48:18 +00:00
|
|
|
require_once('post_form.php');
|
2005-04-26 20:39:08 +00:00
|
|
|
|
|
|
|
$reply = optional_param('reply', 0, PARAM_INT);
|
2005-06-10 19:54:41 +00:00
|
|
|
$forum = optional_param('forum', 0, PARAM_INT);
|
|
|
|
$edit = optional_param('edit', 0, PARAM_INT);
|
|
|
|
$delete = optional_param('delete', 0, PARAM_INT);
|
2006-11-07 08:48:18 +00:00
|
|
|
$prune = optional_param('prune', 0, PARAM_INT);
|
|
|
|
$name = optional_param('name', '', PARAM_CLEAN);
|
|
|
|
$confirm = optional_param('confirm', 0, PARAM_INT);
|
|
|
|
|
|
|
|
|
|
|
|
$page_params=array('reply'=>$reply,
|
|
|
|
'forum'=>$forum,
|
|
|
|
'edit'=>$edit); //these page_params will be passed as hidden variables
|
|
|
|
//later in the form.
|
|
|
|
|
|
|
|
$sitecontext = get_context_instance(CONTEXT_SYSTEM);
|
2006-10-20 06:19:22 +00:00
|
|
|
|
|
|
|
if (has_capability('moodle/legacy:guest', $sitecontext, NULL, false)) {
|
2006-09-14 03:18:37 +00:00
|
|
|
|
2005-03-06 06:20:37 +00:00
|
|
|
$wwwroot = $CFG->wwwroot.'/login/index.php';
|
|
|
|
if (!empty($CFG->loginhttps)) {
|
2006-11-07 08:48:18 +00:00
|
|
|
$wwwroot = str_replace('http', 'https', $wwwroot);
|
2005-03-06 06:20:37 +00:00
|
|
|
}
|
2005-03-06 06:48:48 +00:00
|
|
|
|
2006-10-20 06:19:22 +00:00
|
|
|
if (!empty($forum)) { // User is starting a new discussion in a forum
|
2005-03-06 06:48:48 +00:00
|
|
|
if (! $forum = get_record('forum', 'id', $forum)) {
|
|
|
|
error('The forum number was incorrect');
|
|
|
|
}
|
2005-04-26 20:39:08 +00:00
|
|
|
} else if (!empty($reply)) { // User is writing a new reply
|
2005-03-06 06:48:48 +00:00
|
|
|
if (! $parent = forum_get_post_full($reply)) {
|
|
|
|
error('Parent post ID was incorrect');
|
|
|
|
}
|
|
|
|
if (! $discussion = get_record('forum_discussions', 'id', $parent->discussion)) {
|
|
|
|
error('This post is not part of a discussion!');
|
|
|
|
}
|
|
|
|
if (! $forum = get_record('forum', 'id', $discussion->forum)) {
|
|
|
|
error('The forum number was incorrect');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (! $course = get_record('course', 'id', $forum->course)) {
|
|
|
|
error('The course number was incorrect');
|
|
|
|
}
|
2006-11-07 08:48:18 +00:00
|
|
|
|
2005-03-06 06:48:48 +00:00
|
|
|
if (!$cm = get_coursemodule_from_instance('forum', $forum->id, $course->id)) { // For the logs
|
2006-09-11 03:13:52 +00:00
|
|
|
error('Could not get the course module for the forum instance.');
|
2006-08-08 05:13:06 +00:00
|
|
|
} else {
|
|
|
|
$modcontext = get_context_instance(CONTEXT_MODULE, $cm->id);
|
2005-03-06 06:48:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
$strforums = get_string('modulenameplural', 'forum');
|
2006-10-17 09:10:15 +00:00
|
|
|
if ($course->id != SITEID) {
|
2005-03-06 06:48:48 +00:00
|
|
|
print_header($course->shortname, $course->fullname,
|
|
|
|
"<a href=\"../../course/view.php?id=$course->id\">$course->shortname</a> ->
|
2005-03-13 09:56:10 +00:00
|
|
|
<a href=\"../forum/index.php?id=$course->id\">$strforums</a> ->
|
2006-11-07 08:48:18 +00:00
|
|
|
<a href=\"view.php?f=$forum->id\">".format_string($forum->name, true)."</a>",
|
2006-09-28 07:29:50 +00:00
|
|
|
'', '', true, "", navmenu($course, $cm));
|
2005-03-06 06:48:48 +00:00
|
|
|
} else {
|
|
|
|
print_header($course->shortname, $course->fullname,
|
2005-03-13 09:56:10 +00:00
|
|
|
"<a href=\"../forum/index.php?id=$course->id\">$strforums</a> ->
|
2006-09-28 07:29:50 +00:00
|
|
|
<a href=\"view.php?f=$forum->id\">".format_string($forum->name)."</a>",
|
|
|
|
'', '', true, "", navmenu($course, $cm));
|
2005-03-06 06:48:48 +00:00
|
|
|
}
|
2005-03-06 06:20:37 +00:00
|
|
|
notice_yesno(get_string('noguestpost', 'forum').'<br /><br />'.get_string('liketologin'),
|
|
|
|
$wwwroot, $_SERVER['HTTP_REFERER']);
|
2005-03-17 15:12:07 +00:00
|
|
|
print_footer($course);
|
2005-03-06 06:20:37 +00:00
|
|
|
exit;
|
2002-07-31 14:19:35 +00:00
|
|
|
}
|
2004-07-01 22:29:04 +00:00
|
|
|
require_login(0, false); // Script is useless unless they're logged in
|
2003-01-23 02:50:38 +00:00
|
|
|
|
2006-11-07 08:48:18 +00:00
|
|
|
if (!empty($forum)) { // User is starting a new discussion in a forum
|
2002-07-31 14:19:35 +00:00
|
|
|
if (! $forum = get_record("forum", "id", $forum)) {
|
|
|
|
error("The forum number was incorrect ($forum)");
|
|
|
|
}
|
|
|
|
if (! $course = get_record("course", "id", $forum->course)) {
|
2003-04-24 14:05:47 +00:00
|
|
|
error("The course number was incorrect ($forum->course)");
|
2002-07-31 14:19:35 +00:00
|
|
|
}
|
2006-08-16 03:24:43 +00:00
|
|
|
$coursecontext = get_context_instance(CONTEXT_COURSE, $course->id);
|
2002-08-01 03:50:27 +00:00
|
|
|
if (! forum_user_can_post_discussion($forum)) {
|
2006-10-23 04:55:20 +00:00
|
|
|
if (has_capability('moodle/legacy:guest', $coursecontext, NULL, false)) { // User is a guest here!
|
|
|
|
$SESSION->wantsurl = $FULLME;
|
|
|
|
$SESSION->enrolcancel = $_SERVER['HTTP_REFERER'];
|
|
|
|
redirect($CFG->wwwroot.'/course/enrol.php?id='.$course->id, get_string('youneedtoenrol'));
|
|
|
|
} else {
|
|
|
|
print_error('nopostforum', 'forum');
|
|
|
|
}
|
2002-07-31 14:19:35 +00:00
|
|
|
}
|
2006-11-07 08:48:18 +00:00
|
|
|
|
2004-04-30 01:54:56 +00:00
|
|
|
if ($cm = get_coursemodule_from_instance("forum", $forum->id, $course->id)) {
|
2006-10-26 14:15:46 +00:00
|
|
|
if (!$cm->visible and !has_capability('moodle/course:viewhiddenactivities', $coursecontext)) {
|
2004-04-30 01:54:56 +00:00
|
|
|
error(get_string("activityiscurrentlyhidden"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-11-07 08:48:18 +00:00
|
|
|
$SESSION->fromurl = $_SERVER["HTTP_REFERER"];
|
|
|
|
|
|
|
|
|
2002-07-31 14:19:35 +00:00
|
|
|
// Load up the $post variable.
|
|
|
|
|
|
|
|
$post->course = $course->id;
|
|
|
|
$post->forum = $forum->id;
|
|
|
|
$post->discussion = 0; // ie discussion # not defined yet
|
|
|
|
$post->parent = 0;
|
|
|
|
$post->subject = "";
|
2002-12-23 09:39:26 +00:00
|
|
|
$post->userid = $USER->id;
|
2002-07-31 14:19:35 +00:00
|
|
|
$post->message = "";
|
|
|
|
|
2006-08-08 05:13:06 +00:00
|
|
|
$post->groupid = get_current_group($course->id);
|
|
|
|
if ($post->groupid == 0) {
|
|
|
|
$post->groupid = -1;
|
|
|
|
}
|
|
|
|
|
2002-08-01 03:50:27 +00:00
|
|
|
forum_set_return();
|
|
|
|
|
2006-08-08 05:13:06 +00:00
|
|
|
} else if (!empty($reply)) { // User is writing a new reply
|
2002-07-31 14:19:35 +00:00
|
|
|
|
2002-08-01 03:50:27 +00:00
|
|
|
if (! $parent = forum_get_post_full($reply)) {
|
2004-08-07 02:44:38 +00:00
|
|
|
error("Parent post ID was incorrect");
|
2002-07-31 14:19:35 +00:00
|
|
|
}
|
|
|
|
if (! $discussion = get_record("forum_discussions", "id", $parent->discussion)) {
|
2004-08-07 02:44:38 +00:00
|
|
|
error("This post is not part of a discussion!");
|
2002-07-31 14:19:35 +00:00
|
|
|
}
|
|
|
|
if (! $forum = get_record("forum", "id", $discussion->forum)) {
|
|
|
|
error("The forum number was incorrect ($discussion->forum)");
|
|
|
|
}
|
|
|
|
if (! $course = get_record("course", "id", $discussion->course)) {
|
|
|
|
error("The course number was incorrect ($discussion->course)");
|
|
|
|
}
|
2006-10-20 17:53:50 +00:00
|
|
|
|
2006-08-16 03:24:43 +00:00
|
|
|
$coursecontext = get_context_instance(CONTEXT_COURSE, $course->id);
|
2002-10-25 07:22:59 +00:00
|
|
|
if (! forum_user_can_post($forum)) {
|
2006-10-20 17:53:50 +00:00
|
|
|
if (has_capability('moodle/legacy:guest', $coursecontext, NULL, false)) { // User is a guest here!
|
|
|
|
$SESSION->wantsurl = $FULLME;
|
|
|
|
$SESSION->enrolcancel = $_SERVER['HTTP_REFERER'];
|
|
|
|
redirect($CFG->wwwroot.'/course/enrol.php?id='.$course->id, get_string('youneedtoenrol'));
|
|
|
|
} else {
|
|
|
|
print_error('nopostforum', 'forum');
|
|
|
|
}
|
2002-10-25 07:22:59 +00:00
|
|
|
}
|
2006-11-07 08:48:18 +00:00
|
|
|
|
2004-01-23 12:09:25 +00:00
|
|
|
if ($cm = get_coursemodule_from_instance("forum", $forum->id, $course->id)) {
|
2006-08-08 05:13:06 +00:00
|
|
|
if (groupmode($course, $cm)) { // Make sure user can post here
|
2005-04-13 09:19:48 +00:00
|
|
|
$mygroupid = mygroupid($course->id);
|
2005-11-08 07:19:27 +00:00
|
|
|
if (!((empty($mygroupid) and $discussion->groupid == -1) || (ismember($discussion->groupid)/*$mygroupid == $discussion->groupid*/))) {
|
2004-01-23 12:09:25 +00:00
|
|
|
error("Sorry, but you can not post in this discussion.");
|
|
|
|
}
|
|
|
|
}
|
2006-08-14 05:55:40 +00:00
|
|
|
if (!$cm->visible and !has_capability('moodle/course:manageactivities', $coursecontext)) {
|
2004-04-30 01:54:56 +00:00
|
|
|
error(get_string("activityiscurrentlyhidden"));
|
|
|
|
}
|
2004-01-23 12:09:25 +00:00
|
|
|
}
|
|
|
|
|
2002-07-31 14:19:35 +00:00
|
|
|
// Load up the $post variable.
|
|
|
|
|
|
|
|
$post->course = $course->id;
|
|
|
|
$post->forum = $forum->id;
|
|
|
|
$post->discussion = $parent->discussion;
|
|
|
|
$post->parent = $parent->id;
|
|
|
|
$post->subject = $parent->subject;
|
2002-12-23 09:39:26 +00:00
|
|
|
$post->userid = $USER->id;
|
2002-07-31 14:19:35 +00:00
|
|
|
$post->message = "";
|
|
|
|
|
2004-05-24 10:04:59 +00:00
|
|
|
$strre = get_string('re', 'forum');
|
|
|
|
if (!(substr($post->subject, 0, strlen($strre)) == $strre)) {
|
|
|
|
$post->subject = $strre.' '.$post->subject;
|
2002-07-31 14:19:35 +00:00
|
|
|
}
|
|
|
|
|
2003-06-20 06:35:09 +00:00
|
|
|
unset($SESSION->fromdiscussion);
|
2006-08-08 05:13:06 +00:00
|
|
|
} else if (!empty($edit)) { // User is editing their own post
|
2004-02-18 03:30:05 +00:00
|
|
|
|
2002-08-01 03:50:27 +00:00
|
|
|
if (! $post = forum_get_post_full($edit)) {
|
2002-07-31 14:19:35 +00:00
|
|
|
error("Post ID was incorrect");
|
|
|
|
}
|
|
|
|
if ($post->parent) {
|
2002-08-01 03:50:27 +00:00
|
|
|
if (! $parent = forum_get_post_full($post->parent)) {
|
2002-07-31 14:19:35 +00:00
|
|
|
error("Parent post ID was incorrect ($post->parent)");
|
|
|
|
}
|
|
|
|
}
|
2006-11-07 08:48:18 +00:00
|
|
|
|
2002-07-31 14:19:35 +00:00
|
|
|
if (! $discussion = get_record("forum_discussions", "id", $post->discussion)) {
|
2006-11-07 08:48:18 +00:00
|
|
|
error("This post is not part of a discussion! ($edit)");
|
2002-07-31 14:19:35 +00:00
|
|
|
}
|
|
|
|
if (! $forum = get_record("forum", "id", $discussion->forum)) {
|
|
|
|
error("The forum number was incorrect ($discussion->forum)");
|
|
|
|
}
|
|
|
|
if (! $course = get_record("course", "id", $discussion->course)) {
|
|
|
|
error("The course number was incorrect ($discussion->course)");
|
|
|
|
}
|
2006-09-18 12:48:00 +00:00
|
|
|
if (!$cm = get_coursemodule_from_instance("forum", $forum->id, $course->id)) {
|
2006-09-11 03:13:52 +00:00
|
|
|
error('Could not get the course module for the forum instance.');
|
|
|
|
} else {
|
|
|
|
$modcontext = get_context_instance(CONTEXT_MODULE, $cm->id);
|
|
|
|
}
|
2006-10-21 20:30:27 +00:00
|
|
|
if (!($forum->type == 'news' && !$post->parent && $discussion->timestart > time())) {
|
|
|
|
if (((time() - $post->created) > $CFG->maxeditingtime) and
|
|
|
|
!has_capability('mod/forum:editanypost', $modcontext)) {
|
|
|
|
error( get_string("maxtimehaspassed", "forum", format_time($CFG->maxeditingtime)) );
|
|
|
|
}
|
|
|
|
}
|
2006-09-11 03:13:52 +00:00
|
|
|
if (($post->userid <> $USER->id) and
|
|
|
|
!has_capability('mod/forum:editanypost', $modcontext)) {
|
|
|
|
error("You can't edit other people's posts!");
|
|
|
|
}
|
2002-07-31 14:19:35 +00:00
|
|
|
|
|
|
|
// Load up the $post variable.
|
|
|
|
$post->edit = $edit;
|
|
|
|
|
|
|
|
$post->course = $course->id;
|
|
|
|
$post->forum = $forum->id;
|
|
|
|
|
2003-06-20 06:35:09 +00:00
|
|
|
unset($SESSION->fromdiscussion);
|
2002-07-31 14:19:35 +00:00
|
|
|
|
|
|
|
|
2006-11-07 08:48:18 +00:00
|
|
|
}else if (!empty($delete)) { // User is deleting a post
|
2002-07-31 14:19:35 +00:00
|
|
|
|
2002-08-01 03:50:27 +00:00
|
|
|
if (! $post = forum_get_post_full($delete)) {
|
2002-07-31 14:19:35 +00:00
|
|
|
error("Post ID was incorrect");
|
|
|
|
}
|
|
|
|
if (! $discussion = get_record("forum_discussions", "id", $post->discussion)) {
|
|
|
|
error("This post is not part of a discussion!");
|
|
|
|
}
|
2002-08-05 09:48:17 +00:00
|
|
|
if (! $forum = get_record("forum", "id", $discussion->forum)) {
|
|
|
|
error("The forum number was incorrect ($discussion->forum)");
|
|
|
|
}
|
2006-08-16 03:24:43 +00:00
|
|
|
if (!$cm = get_coursemodule_from_instance("forum", $forum->id, $forum->course)) {
|
2006-09-11 03:13:52 +00:00
|
|
|
error('Could not get the course module for the forum instance.');
|
2006-08-16 03:24:43 +00:00
|
|
|
} else {
|
|
|
|
$modcontext = get_context_instance(CONTEXT_MODULE, $cm->id);
|
|
|
|
}
|
2006-08-14 05:55:40 +00:00
|
|
|
if ( !(($post->userid == $USER->id && has_capability('mod/forum:deleteownpost', $modcontext))
|
|
|
|
|| has_capability('mod/forum:deleteanypost', $modcontext)) ) {
|
2006-08-08 05:13:06 +00:00
|
|
|
error("You can't delete this post!");
|
2002-08-05 09:48:17 +00:00
|
|
|
}
|
2004-07-13 14:11:17 +00:00
|
|
|
if (!empty($forum->course)) {
|
|
|
|
if ($course = get_record('course', 'id', $forum->course)) {
|
|
|
|
if (!empty($course->lang)) {
|
|
|
|
$CFG->courselang = $course->lang;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2002-07-31 14:19:35 +00:00
|
|
|
|
2006-11-07 08:48:18 +00:00
|
|
|
|
2005-04-19 11:25:59 +00:00
|
|
|
$replycount = forum_count_replies($post);
|
|
|
|
|
2006-08-08 05:13:06 +00:00
|
|
|
if (!empty($confirm)) { // User has confirmed the delete
|
2002-07-31 14:19:35 +00:00
|
|
|
|
|
|
|
if ($post->totalscore) {
|
2004-09-21 11:41:58 +00:00
|
|
|
notice(get_string("couldnotdeleteratings", "forum"),
|
2002-08-01 03:50:27 +00:00
|
|
|
forum_go_back_to("discuss.php?d=$post->discussion"));
|
2002-07-31 14:19:35 +00:00
|
|
|
|
2006-08-14 05:55:40 +00:00
|
|
|
} else if ($replycount && !has_capability('mod/forum:deleteanypost', $modcontext)) {
|
2002-09-03 13:11:40 +00:00
|
|
|
error(get_string("couldnotdeletereplies", "forum"),
|
2005-02-14 00:04:09 +00:00
|
|
|
forum_go_back_to("discuss.php?d=$post->discussion"));
|
2002-07-31 14:19:35 +00:00
|
|
|
|
|
|
|
} else {
|
|
|
|
if (! $post->parent) { // post is a discussion topic as well, so delete discussion
|
2006-09-28 07:29:50 +00:00
|
|
|
if ($forum->type == 'single') {
|
2004-09-21 11:41:58 +00:00
|
|
|
notice("Sorry, but you are not allowed to delete that discussion!",
|
2002-08-05 09:48:17 +00:00
|
|
|
forum_go_back_to("discuss.php?d=$post->discussion"));
|
|
|
|
}
|
2002-07-31 14:19:35 +00:00
|
|
|
forum_delete_discussion($discussion);
|
|
|
|
|
2004-09-21 11:41:58 +00:00
|
|
|
add_to_log($discussion->course, "forum", "delete discussion",
|
2004-02-22 11:50:09 +00:00
|
|
|
"view.php?id=$cm->id", "$forum->id", $cm->id);
|
2004-01-31 14:47:57 +00:00
|
|
|
|
2006-11-07 08:48:18 +00:00
|
|
|
redirect("view.php?f=$discussion->forum");
|
2002-07-31 14:19:35 +00:00
|
|
|
|
2006-08-14 05:55:40 +00:00
|
|
|
} else if (forum_delete_post($post, has_capability('mod/forum:deleteanypost', $modcontext))) {
|
2006-11-07 08:48:18 +00:00
|
|
|
|
2006-09-28 07:29:50 +00:00
|
|
|
if ($forum->type == 'single') {
|
|
|
|
// Single discussion forums are an exception. We show
|
|
|
|
// the forum itself since it only has one discussion
|
|
|
|
// thread.
|
|
|
|
$discussionurl = "view.php?f=$forum->id";
|
|
|
|
} else {
|
|
|
|
$discussionurl = "discuss.php?d=$post->discussion";
|
|
|
|
}
|
2006-11-07 08:48:18 +00:00
|
|
|
|
2006-09-28 07:29:50 +00:00
|
|
|
add_to_log($discussion->course, "forum", "delete post", $discussionurl, "$post->id", $cm->id);
|
2004-01-31 14:47:57 +00:00
|
|
|
|
2006-11-07 08:48:18 +00:00
|
|
|
redirect(forum_go_back_to($discussionurl));
|
2002-07-31 14:19:35 +00:00
|
|
|
} else {
|
|
|
|
error("An error occurred while deleting record $post->id");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-08-08 05:13:06 +00:00
|
|
|
} else { // User just asked to delete something
|
2002-07-31 14:19:35 +00:00
|
|
|
|
2002-08-01 03:50:27 +00:00
|
|
|
forum_set_return();
|
2002-07-31 14:19:35 +00:00
|
|
|
|
2005-04-19 11:25:59 +00:00
|
|
|
if ($replycount) {
|
2006-09-11 03:13:52 +00:00
|
|
|
if (!has_capability('mod/forum:deleteanypost', $modcontext)) {
|
2005-04-19 11:25:59 +00:00
|
|
|
error(get_string("couldnotdeletereplies", "forum"),
|
|
|
|
forum_go_back_to("discuss.php?d=$post->discussion"));
|
|
|
|
}
|
|
|
|
print_header();
|
|
|
|
notice_yesno(get_string("deletesureplural", "forum", $replycount+1),
|
2006-08-08 05:13:06 +00:00
|
|
|
"post.php?delete=$delete&confirm=$delete",
|
2005-04-19 11:25:59 +00:00
|
|
|
$_SERVER["HTTP_REFERER"]);
|
|
|
|
|
|
|
|
forum_print_post($post, $course->id, $ownpost=false, $reply=false, $link=false);
|
|
|
|
if (empty($post->edit)) {
|
2005-04-26 16:27:51 +00:00
|
|
|
if (forum_tp_can_track_forums($forum) && forum_tp_is_tracked($forum)) {
|
2005-04-19 11:25:59 +00:00
|
|
|
$user_read_array = forum_tp_get_discussion_read_records($USER->id, $discussion->id);
|
|
|
|
} else {
|
|
|
|
$user_read_array = array();
|
|
|
|
}
|
|
|
|
forum_print_posts_nested($post->id, $course->id, false, false, $user_read_array, $forum->id);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
print_header();
|
|
|
|
notice_yesno(get_string("deletesure", "forum", $replycount),
|
2006-08-08 05:13:06 +00:00
|
|
|
"post.php?delete=$delete&confirm=$delete",
|
2005-04-19 11:25:59 +00:00
|
|
|
$_SERVER["HTTP_REFERER"]);
|
|
|
|
forum_print_post($post, $forum->course, $ownpost=false, $reply=false, $link=false);
|
|
|
|
}
|
2004-09-21 11:41:58 +00:00
|
|
|
|
2002-07-31 14:19:35 +00:00
|
|
|
}
|
2004-09-16 17:13:57 +00:00
|
|
|
print_footer($course);
|
2002-07-31 14:19:35 +00:00
|
|
|
die;
|
|
|
|
|
|
|
|
|
2006-09-11 03:13:52 +00:00
|
|
|
} else if (!empty($prune)) { // Pruning
|
2004-09-21 11:41:58 +00:00
|
|
|
|
2005-04-19 16:05:50 +00:00
|
|
|
if (!$post = forum_get_post_full($prune)) {
|
2004-05-30 17:25:26 +00:00
|
|
|
error("Post ID was incorrect");
|
|
|
|
}
|
2005-04-19 16:05:50 +00:00
|
|
|
if (!$discussion = get_record("forum_discussions", "id", $post->discussion)) {
|
2004-05-30 17:25:26 +00:00
|
|
|
error("This post is not part of a discussion!");
|
|
|
|
}
|
2005-04-19 16:05:50 +00:00
|
|
|
if (!$forum = get_record("forum", "id", $discussion->forum)) {
|
2004-05-30 17:25:26 +00:00
|
|
|
error("The forum number was incorrect ($discussion->forum)");
|
|
|
|
}
|
2006-09-25 05:12:01 +00:00
|
|
|
if ($forum->type == 'single') {
|
|
|
|
error('Discussions from this forum cannot be split');
|
|
|
|
}
|
2004-05-30 17:25:26 +00:00
|
|
|
if (!$post->parent) {
|
|
|
|
error('This is already the first post in the discussion');
|
|
|
|
}
|
2005-04-19 16:05:50 +00:00
|
|
|
if (!$cm = get_coursemodule_from_instance("forum", $forum->id, $forum->course)) { // For the logs
|
2006-09-11 03:13:52 +00:00
|
|
|
error('Could not get the course module for the forum instance.');
|
|
|
|
} else {
|
|
|
|
$modcontext = get_context_instance(CONTEXT_MODULE, $cm->id);
|
|
|
|
}
|
|
|
|
if (!has_capability('mod/forum:splitdiscussions', $modcontext)) {
|
|
|
|
error("You can't split discussions!");
|
2005-04-19 16:05:50 +00:00
|
|
|
}
|
2004-05-30 17:25:26 +00:00
|
|
|
|
2006-08-08 05:13:06 +00:00
|
|
|
if (!empty($name)) { // User has confirmed the prune
|
2004-09-21 11:41:58 +00:00
|
|
|
|
2004-05-30 17:25:26 +00:00
|
|
|
$newdiscussion->course = $discussion->course;
|
|
|
|
$newdiscussion->forum = $discussion->forum;
|
2006-08-08 05:13:06 +00:00
|
|
|
$newdiscussion->name = $name;
|
2004-05-30 17:25:26 +00:00
|
|
|
$newdiscussion->firstpost = $post->id;
|
|
|
|
$newdiscussion->userid = $discussion->userid;
|
|
|
|
$newdiscussion->groupid = $discussion->groupid;
|
|
|
|
$newdiscussion->assessed = $discussion->assessed;
|
|
|
|
$newdiscussion->usermodified = $post->userid;
|
2005-11-10 22:50:03 +00:00
|
|
|
$newdiscussion->timestart = $discussion->timestart;
|
|
|
|
$newdiscussion->timeend = $discussion->timeend;
|
2004-09-21 11:41:58 +00:00
|
|
|
|
2004-05-30 17:25:26 +00:00
|
|
|
if (!$newid = insert_record('forum_discussions', $newdiscussion)) {
|
|
|
|
error('Could not create new discussion');
|
|
|
|
}
|
2004-09-21 11:41:58 +00:00
|
|
|
|
2004-07-08 14:39:15 +00:00
|
|
|
$newpost->id = $post->id;
|
|
|
|
$newpost->parent = 0;
|
2006-08-08 05:13:06 +00:00
|
|
|
$newpost->subject = $name;
|
2004-06-29 03:46:17 +00:00
|
|
|
|
2004-07-08 14:39:15 +00:00
|
|
|
if (!update_record("forum_posts", $newpost)) {
|
2004-06-29 03:46:17 +00:00
|
|
|
error('Could not update the original post');
|
|
|
|
}
|
|
|
|
|
2004-05-30 17:25:26 +00:00
|
|
|
forum_change_discussionid($post->id, $newid);
|
2004-09-21 11:41:58 +00:00
|
|
|
|
2005-04-28 07:42:14 +00:00
|
|
|
// update last post in each discussion
|
|
|
|
forum_discussion_update_last_post($discussion->id);
|
|
|
|
forum_discussion_update_last_post($newid);
|
2004-05-30 17:25:26 +00:00
|
|
|
|
2004-09-21 11:41:58 +00:00
|
|
|
add_to_log($discussion->course, "forum", "prune post",
|
2004-05-30 17:25:26 +00:00
|
|
|
"discuss.php?d=$newid", "$post->id", $cm->id);
|
|
|
|
|
2006-11-07 08:48:18 +00:00
|
|
|
redirect(forum_go_back_to("discuss.php?d=$newid"));
|
2004-05-30 17:25:26 +00:00
|
|
|
|
|
|
|
} else { // User just asked to prune something
|
|
|
|
|
|
|
|
$course = get_record('course', 'id', $forum->course);
|
|
|
|
$strforums = get_string("modulenameplural", "forum");
|
2005-03-26 17:11:30 +00:00
|
|
|
print_header_simple(format_string($discussion->name).": ".format_string($post->subject), "",
|
2004-09-21 11:41:58 +00:00
|
|
|
"<a href=\"../forum/index.php?id=$course->id\">$strforums</a> ->
|
2006-11-07 08:48:18 +00:00
|
|
|
<a href=\"view.php?f=$forum->id\">".format_string($forum->name, true)."</a> ->
|
|
|
|
<a href=\"discuss.php?d=$discussion->id\">".format_string($post->subject, true)."</a> -> ".
|
2004-05-30 17:25:26 +00:00
|
|
|
get_string("prune", "forum"), '', "", true, "", navmenu($course, $cm));
|
2004-09-21 11:41:58 +00:00
|
|
|
|
2004-05-30 17:25:26 +00:00
|
|
|
print_heading(get_string('pruneheading', 'forum'));
|
2004-06-29 03:46:17 +00:00
|
|
|
echo '<center>';
|
2004-09-21 11:41:58 +00:00
|
|
|
|
2004-05-30 17:25:26 +00:00
|
|
|
include('prune.html');
|
2004-09-21 11:41:58 +00:00
|
|
|
|
2004-05-30 17:25:26 +00:00
|
|
|
forum_print_post($post, $forum->course, $ownpost=false, $reply=false, $link=false);
|
2004-09-16 17:13:57 +00:00
|
|
|
echo '</center>';
|
2004-05-30 17:25:26 +00:00
|
|
|
}
|
2004-09-16 17:13:57 +00:00
|
|
|
print_footer($course);
|
2004-05-30 17:25:26 +00:00
|
|
|
die;
|
2002-07-31 14:19:35 +00:00
|
|
|
} else {
|
|
|
|
error("No operation specified");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2006-11-07 08:48:18 +00:00
|
|
|
if (!isset($coursecontext)) {
|
|
|
|
// Has not yet been set by post.php.
|
|
|
|
$coursecontext = get_context_instance(CONTEXT_COURSE, $forum->course);
|
|
|
|
}
|
|
|
|
|
|
|
|
$mform_post = new forum_post_form('post.php', compact('coursecontext', 'forum', 'post'));
|
|
|
|
|
|
|
|
if ($fromform = $mform_post->data_submitted()) {
|
|
|
|
|
|
|
|
|
|
|
|
if (!empty($course->lang)) { // Override current language
|
|
|
|
$CFG->courselang = $course->lang;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (empty($SESSION->fromurl)) {
|
|
|
|
$errordestination = "$CFG->wwwroot/mod/forum/view.php?f=$forum->id";
|
|
|
|
} else {
|
|
|
|
$errordestination = $SESSION->fromurl;
|
|
|
|
}
|
|
|
|
|
|
|
|
// TODO add attachment processing
|
|
|
|
//$fromform->attachment = isset($_FILES['attachment']) ? $_FILES['attachment'] : NULL;
|
|
|
|
|
|
|
|
if (!$cm = get_coursemodule_from_instance("forum", $forum->id, $course->id)) { // For the logs
|
|
|
|
error('Could not get the course module for the forum instance.');
|
|
|
|
}
|
|
|
|
$modcontext = get_context_instance(CONTEXT_MODULE, $cm->id);
|
|
|
|
trusttext_after_edit($fromform->message, $modcontext);
|
|
|
|
|
|
|
|
if ($fromform->edit) { // Updating a post
|
|
|
|
$fromform->id = $fromform->edit;
|
|
|
|
$message = '';
|
|
|
|
|
|
|
|
//fix for bug #4314
|
|
|
|
if (!$realpost = get_record('forum_posts', 'id', $fromform->id)) {
|
|
|
|
$realpost = new object;
|
|
|
|
$realpost->userid = -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// if user has edit any post capability
|
|
|
|
// or has either startnewdiscussion or reply capability and is editting own post
|
|
|
|
// then he can proceed
|
|
|
|
// MDL-7066
|
|
|
|
if ( !(($realpost->userid == $USER->id && (has_capability('mod/forum:replypost', $modcontext)
|
|
|
|
|| has_capability('mod/forum:startdiscussion', $modcontext))) ||
|
|
|
|
has_capability('mod/forum:editanypost', $modcontext)) ) {
|
|
|
|
error("You can not update this post");
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($forum->type == 'news' && !$fromform->parent) {
|
|
|
|
$updatediscussion = new object;
|
|
|
|
$updatediscussion->id = $fromform->discussion;
|
|
|
|
if (empty($fromform->timestartdisabled)) {
|
|
|
|
$updatediscussion->timestart = $fromform->timestart;
|
|
|
|
} else {
|
|
|
|
$updatediscussion->timestart = 0;
|
|
|
|
}
|
|
|
|
if (empty($fromform->timeenddisabled)) {
|
|
|
|
$updatediscussion->timeend = $fromform->timeend;
|
|
|
|
} else {
|
|
|
|
$updatediscussion->timeend = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!update_record('forum_discussions', $updatediscussion)) {
|
|
|
|
error(get_string("couldnotupdate", "forum"), $errordestination);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$updatepost=$fromform; //realpost
|
|
|
|
$updatepost->forum=$forum->id;
|
|
|
|
if (!forum_update_post($updatepost, $message)) {
|
|
|
|
error(get_string("couldnotupdate", "forum"), $errordestination);
|
|
|
|
}
|
|
|
|
|
|
|
|
$timemessage = 2;
|
|
|
|
if (!empty($message)) { // if we're printing stuff about the file upload
|
|
|
|
$timemessage = 4;
|
|
|
|
}
|
|
|
|
$message .= '<br />'.get_string("postupdated", "forum");
|
|
|
|
|
|
|
|
if ($subscribemessage = forum_post_subscription($fromform)) {
|
|
|
|
$timemessage = 4;
|
|
|
|
}
|
|
|
|
if ($forum->type == 'single') {
|
|
|
|
// Single discussion forums are an exception. We show
|
|
|
|
// the forum itself since it only has one discussion
|
|
|
|
// thread.
|
|
|
|
$discussionurl = "view.php?f=$forum->id";
|
|
|
|
} else {
|
|
|
|
$discussionurl = "discuss.php?d=$discussion->id#$fromform->id";
|
|
|
|
}
|
|
|
|
add_to_log($course->id, "forum", "update post",
|
|
|
|
"$discussionurl&parent=$fromform->id", "$fromform->id", $cm->id);
|
|
|
|
|
|
|
|
redirect(forum_go_back_to("$discussionurl"), $message.$subscribemessage, $timemessage);
|
|
|
|
|
|
|
|
exit;
|
|
|
|
|
|
|
|
|
|
|
|
} else if ($fromform->discussion) { // Adding a new post to an existing discussion
|
|
|
|
$message = '';
|
|
|
|
$addpost=$fromform;
|
|
|
|
$addpost->forum=$forum->id;
|
|
|
|
if ($fromform->id = forum_add_new_post($addpost, $message)) {
|
|
|
|
|
|
|
|
$timemessage = 2;
|
|
|
|
if (!empty($message)) { // if we're printing stuff about the file upload
|
|
|
|
$timemessage = 4;
|
|
|
|
}
|
|
|
|
$message .= '<br />'.get_string("postadded", "forum", format_time($CFG->maxeditingtime));
|
|
|
|
|
|
|
|
if ($subscribemessage = forum_post_subscription($fromform)) {
|
|
|
|
$timemessage = 4;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!empty($fromform->mailnow)) {
|
|
|
|
$message .= get_string("postmailnow", "forum");
|
|
|
|
$timemessage = 4;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($forum->type == 'single') {
|
|
|
|
// Single discussion forums are an exception. We show
|
|
|
|
// the forum itself since it only has one discussion
|
|
|
|
// thread.
|
|
|
|
$discussionurl = "view.php?f=$forum->id";
|
|
|
|
} else {
|
|
|
|
$discussionurl = "discuss.php?d=$discussion->id";
|
|
|
|
}
|
|
|
|
add_to_log($course->id, "forum", "add post",
|
|
|
|
"$discussionurl&parent=$fromform->id", "$fromform->id", $cm->id);
|
|
|
|
|
|
|
|
redirect(forum_go_back_to("$discussionurl#$fromform->id"), $message.$subscribemessage, $timemessage);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
error(get_string("couldnotadd", "forum"), $errordestination);
|
|
|
|
}
|
|
|
|
exit;
|
|
|
|
|
|
|
|
} else { // Adding a new discussion
|
|
|
|
$fromform->mailnow = empty($fromform->mailnow) ? 0 : 1;
|
|
|
|
$discussion = $fromform;
|
|
|
|
$discussion->name = $fromform->subject;
|
|
|
|
$discussion->intro = $fromform->message;
|
|
|
|
$newstopic = false;
|
|
|
|
|
|
|
|
if ($forum->type == 'news' && !$fromform->parent) {
|
|
|
|
$newstopic = true;
|
|
|
|
}
|
|
|
|
if ($newstopic && empty($fromform->timestartdisabled)) {
|
|
|
|
$discussion->timestart = $fromform->timestart;
|
|
|
|
} else {
|
|
|
|
$discussion->timestart = 0;
|
|
|
|
}
|
|
|
|
if ($newstopic && empty($fromform->timeenddisabled)) {
|
|
|
|
$discussion->timeend = $fromform->timeend;
|
|
|
|
} else {
|
|
|
|
$discussion->timeend = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
$message = '';
|
|
|
|
if ($discussion->id = forum_add_discussion($discussion, $message)) {
|
|
|
|
|
|
|
|
add_to_log($course->id, "forum", "add discussion",
|
|
|
|
"discuss.php?d=$discussion->id", "$discussion->id", $cm->id);
|
|
|
|
|
|
|
|
$timemessage = 2;
|
|
|
|
if (!empty($message)) { // if we're printing stuff about the file upload
|
|
|
|
$timemessage = 4;
|
|
|
|
}
|
|
|
|
$message .= '<br />'.get_string("postadded", "forum", format_time($CFG->maxeditingtime));
|
|
|
|
|
|
|
|
if ($fromform->mailnow) {
|
|
|
|
$message .= get_string("postmailnow", "forum");
|
|
|
|
$timemessage = 4;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($subscribemessage = forum_post_subscription($discussion)) {
|
|
|
|
$timemessage = 4;
|
|
|
|
}
|
|
|
|
|
|
|
|
redirect(forum_go_back_to("view.php?f=$fromform->forum"), $message.$subscribemessage, $timemessage);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
error(get_string("couldnotadd", "forum"), $errordestination);
|
|
|
|
}
|
|
|
|
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-07-31 14:19:35 +00:00
|
|
|
|
2004-09-21 11:41:58 +00:00
|
|
|
// To get here they need to edit a post, and the $post
|
2002-07-31 14:19:35 +00:00
|
|
|
// variable will be loaded with all the particulars,
|
|
|
|
// so bring up the form.
|
|
|
|
|
|
|
|
// $course, $forum are defined. $discussion is for edit and reply only.
|
|
|
|
|
2005-02-16 10:40:48 +00:00
|
|
|
$cm = get_coursemodule_from_instance("forum", $forum->id, $course->id);
|
|
|
|
|
|
|
|
require_login($course->id, false, $cm);
|
2002-07-31 14:19:35 +00:00
|
|
|
|
2006-08-27 20:45:04 +00:00
|
|
|
$modcontext = get_context_instance(CONTEXT_MODULE, $cm->id);
|
2002-11-10 08:43:44 +00:00
|
|
|
|
2002-07-31 14:19:35 +00:00
|
|
|
if ($post->discussion) {
|
2002-12-20 14:44:14 +00:00
|
|
|
if (! $toppost = get_record("forum_posts", "discussion", $post->discussion, "parent", 0)) {
|
2002-07-31 14:19:35 +00:00
|
|
|
error("Could not find top parent of post $post->id");
|
|
|
|
}
|
|
|
|
} else {
|
2005-01-19 13:16:29 +00:00
|
|
|
$toppost->subject = ($forum->type == "news") ? get_string("addanewtopic", "forum") :
|
2004-12-14 06:26:43 +00:00
|
|
|
get_string("addanewdiscussion", "forum");
|
2002-07-31 14:19:35 +00:00
|
|
|
}
|
|
|
|
|
2006-11-07 08:48:18 +00:00
|
|
|
|
2002-07-31 14:19:35 +00:00
|
|
|
|
|
|
|
if ($post->parent) {
|
2006-11-07 08:48:18 +00:00
|
|
|
$navtail = ' -> <a href="discuss.php?d='.$discussion->id.'">'.format_string($toppost->subject, true).'</a> -> '.
|
2006-10-17 09:10:15 +00:00
|
|
|
get_string('editing', 'forum');
|
2002-07-31 14:19:35 +00:00
|
|
|
} else {
|
2006-10-17 09:10:15 +00:00
|
|
|
$navtail = ' -> '.format_string($toppost->subject);
|
2002-07-31 14:19:35 +00:00
|
|
|
}
|
|
|
|
|
2002-12-29 17:32:32 +00:00
|
|
|
if (empty($post->edit)) {
|
2006-10-17 09:10:15 +00:00
|
|
|
$post->edit = '';
|
2002-12-29 17:32:32 +00:00
|
|
|
}
|
|
|
|
|
2002-09-03 13:11:40 +00:00
|
|
|
$strforums = get_string("modulenameplural", "forum");
|
|
|
|
|
2002-10-10 07:27:57 +00:00
|
|
|
|
2006-11-07 08:48:18 +00:00
|
|
|
$navmiddle = "<a href=\"../forum/index.php?id=$course->id\">$strforums</a> -> <a href=\"view.php?f=$forum->id\">".format_string($forum->name, true).'</a> ';
|
2002-07-31 14:19:35 +00:00
|
|
|
|
2005-01-29 09:49:42 +00:00
|
|
|
if (empty($discussion->name)) {
|
2005-04-21 08:11:07 +00:00
|
|
|
if (empty($discussion)) {
|
|
|
|
$discussion = new object;
|
|
|
|
}
|
2002-12-29 17:32:32 +00:00
|
|
|
$discussion->name = $forum->name;
|
|
|
|
}
|
2006-09-28 07:29:50 +00:00
|
|
|
if ($forum->type == 'single') {
|
|
|
|
// There is only one discussion thread for this forum type. We should
|
|
|
|
// not show the discussion name (same as forum name in this case) in
|
|
|
|
// the breadcrumbs.
|
|
|
|
$strdiscussionname = '';
|
|
|
|
$navtail = '';
|
|
|
|
} else {
|
|
|
|
// Show the discussion name in the breadcrumbs.
|
|
|
|
$strdiscussionname = format_string($discussion->name).':';
|
|
|
|
}
|
2006-10-17 09:10:15 +00:00
|
|
|
if ($course->id != SITEID) {
|
2006-09-28 07:29:50 +00:00
|
|
|
print_header("$course->shortname: $strdiscussionname ".
|
|
|
|
format_string($toppost->subject), "$course->fullname",
|
|
|
|
"<a href=\"../../course/view.php?id=$course->id\">$course->shortname</a> ->
|
2006-11-07 08:48:18 +00:00
|
|
|
$navmiddle $navtail", $mform_post->focus(), "", true, "", navmenu($course, $cm));
|
2005-01-19 13:16:29 +00:00
|
|
|
|
2002-07-31 14:19:35 +00:00
|
|
|
} else {
|
2006-09-28 07:29:50 +00:00
|
|
|
print_header("$course->shortname: $strdiscussionname ".
|
|
|
|
format_string($toppost->subject), "$course->fullname",
|
2006-11-07 08:48:18 +00:00
|
|
|
"$navmiddle $navtail", $mform_post->focus(), "", true, "", navmenu($course, $cm));
|
2002-07-31 14:19:35 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2006-01-16 04:57:48 +00:00
|
|
|
// checkup
|
2006-08-14 07:37:53 +00:00
|
|
|
if (!empty($parent) && !forum_user_can_see_post($forum, $discussion, $post)) {
|
2006-01-16 04:57:48 +00:00
|
|
|
error("You cannot reply to this post");
|
|
|
|
}
|
2006-08-08 05:13:06 +00:00
|
|
|
if (empty($parent) && !forum_user_can_post_discussion($forum)) {
|
2006-01-16 04:57:48 +00:00
|
|
|
error("You cannot start a new discussion in this forum");
|
|
|
|
}
|
|
|
|
|
2006-08-14 05:55:40 +00:00
|
|
|
if ($forum->type == 'qanda' && !has_capability('mod/forum:viewqandawithoutposting', $modcontext) &&
|
2006-11-07 08:48:18 +00:00
|
|
|
!forum_user_has_posted($forum->id, $discussion->id, $USER->id)) {
|
|
|
|
notify(get_string('qandanotify', 'forum'));
|
2006-01-16 04:57:48 +00:00
|
|
|
}
|
|
|
|
|
2006-01-16 08:42:09 +00:00
|
|
|
forum_check_throttling($forum);
|
|
|
|
|
2003-04-24 14:05:47 +00:00
|
|
|
if (!empty($parent)) {
|
2002-08-01 03:50:27 +00:00
|
|
|
forum_print_post($parent, $course->id, $ownpost=false, $reply=false, $link=false);
|
2003-12-12 08:46:24 +00:00
|
|
|
if (empty($post->edit)) {
|
2005-04-26 16:27:51 +00:00
|
|
|
if (forum_tp_can_track_forums($forum) && forum_tp_is_tracked($forum)) {
|
2005-01-29 09:49:42 +00:00
|
|
|
$user_read_array = forum_tp_get_discussion_read_records($USER->id, $discussion->id);
|
|
|
|
} else {
|
|
|
|
$user_read_array = array();
|
|
|
|
}
|
2006-08-14 05:55:40 +00:00
|
|
|
if ($forum->type != 'qanda' || forum_user_can_see_discussion($forum, $discussion, $modcontext)) {
|
2006-01-16 04:57:48 +00:00
|
|
|
forum_print_posts_threaded($parent->id, $course->id, 0, false, false, $user_read_array, $discussion->forum);
|
|
|
|
}
|
2003-12-12 08:46:24 +00:00
|
|
|
}
|
2006-11-07 08:48:18 +00:00
|
|
|
$heading=get_string("yourreply", "forum");
|
2002-07-31 14:19:35 +00:00
|
|
|
} else {
|
2004-12-14 06:26:43 +00:00
|
|
|
$forum->intro = trim($forum->intro);
|
|
|
|
if (!empty($forum->intro)) {
|
|
|
|
print_simple_box(format_text($forum->intro), 'center');
|
|
|
|
}
|
2006-01-16 04:57:48 +00:00
|
|
|
if ($forum->type == 'qanda') {
|
2006-11-07 08:48:18 +00:00
|
|
|
$heading=get_string('yournewquestion', 'forum');
|
2006-01-16 04:57:48 +00:00
|
|
|
} else {
|
2006-11-07 08:48:18 +00:00
|
|
|
$heading=get_string('yournewtopic', 'forum');
|
2006-01-16 04:57:48 +00:00
|
|
|
}
|
2002-07-31 14:19:35 +00:00
|
|
|
}
|
|
|
|
|
2006-04-05 02:15:10 +00:00
|
|
|
if ($USER->id != $post->userid) { // Not the original author, so add a message to the end
|
|
|
|
$data->date = userdate($post->modified);
|
|
|
|
if ($post->format == FORMAT_HTML) {
|
|
|
|
$data->name = '<a href="'.$CFG->wwwroot.'/user/view.php?id='.$USER->id.'&course='.$post->course.'">'.
|
|
|
|
fullname($USER).'</a>';
|
|
|
|
$post->message .= '<p>(<span class="edited">'.get_string('editedby', 'forum', $data).'</span>)</p>';
|
|
|
|
} else {
|
|
|
|
$data->name = fullname($USER);
|
|
|
|
$post->message .= "\n\n(".get_string('editedby', 'forum', $data).')';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-11-07 08:48:18 +00:00
|
|
|
//load data into form
|
|
|
|
$subscribe=(isset($post->forum)&&forum_is_subscribed($USER->id, $post->forum)) ||
|
|
|
|
(!empty($USER->autosubscribe));
|
|
|
|
|
|
|
|
|
2006-11-08 06:22:58 +00:00
|
|
|
trusttext_prepare_edit($post->message, $post->format, can_use_html_editor(), $modcontext);
|
|
|
|
|
|
|
|
$mform_post->set_defaults(array( 'general'=>$heading,
|
|
|
|
'subject'=>$post->subject,
|
2006-11-07 08:48:18 +00:00
|
|
|
'message'=>$post->message,
|
|
|
|
'subscribe'=>$subscribe?1:0,
|
|
|
|
'mailnow'=>!empty($post->mailnow),
|
|
|
|
'userid'=>$post->userid,
|
|
|
|
'parent'=>$post->parent,
|
|
|
|
'discussion'=>$post->discussion,
|
|
|
|
'course'=>$course->id)+
|
|
|
|
|
|
|
|
$page_params+
|
|
|
|
|
|
|
|
(isset($post->format)?array(
|
|
|
|
'format'=>$post->format):
|
|
|
|
array())+
|
|
|
|
|
|
|
|
(isset($post->groupid)?array(
|
|
|
|
'groupid'=>$post->groupid):
|
|
|
|
array())+
|
|
|
|
|
|
|
|
(isset($discussion->timestart)?
|
|
|
|
array('timestart'=>$discussion->timestart):
|
|
|
|
array('timestart'=>0))+
|
|
|
|
|
|
|
|
(isset($discussion->timeend)?
|
|
|
|
array('timeend'=>$discussion->timeend):
|
|
|
|
array('timeend'=>0))+
|
|
|
|
|
|
|
|
(isset($discussion->timestartdisabled)?
|
|
|
|
array('timestartdisabled'=>$discussion->timestartdisabled):
|
|
|
|
array('timestartdisabled'=>1))+
|
|
|
|
|
|
|
|
(isset($discussion->timeenddisabled)?
|
|
|
|
array('timeenddisabled'=>$discussion->timeenddisabled):
|
|
|
|
array('timeenddisabled'=>1))+
|
|
|
|
|
|
|
|
(isset($discussion->id)?
|
|
|
|
array('discussion'=>$discussion->id):
|
|
|
|
array()));
|
|
|
|
|
|
|
|
|
|
|
|
$mform_post->display();
|
2002-07-31 14:19:35 +00:00
|
|
|
|
2003-11-03 16:49:37 +00:00
|
|
|
|
2002-07-31 14:19:35 +00:00
|
|
|
print_footer($course);
|
|
|
|
|
|
|
|
|
2006-09-14 07:13:08 +00:00
|
|
|
?>
|