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
|
|
|
|
2006-11-09 23:04:55 +00:00
|
|
|
$reply = optional_param('reply', 0, PARAM_INT);
|
|
|
|
$forum = optional_param('forum', 0, PARAM_INT);
|
|
|
|
$edit = optional_param('edit', 0, PARAM_INT);
|
|
|
|
$delete = optional_param('delete', 0, PARAM_INT);
|
|
|
|
$prune = optional_param('prune', 0, PARAM_INT);
|
|
|
|
$name = optional_param('name', '', PARAM_CLEAN);
|
2006-11-07 08:48:18 +00:00
|
|
|
$confirm = optional_param('confirm', 0, PARAM_INT);
|
|
|
|
|
|
|
|
|
2006-11-09 23:04:55 +00:00
|
|
|
//these page_params will be passed as hidden variables later in the form.
|
|
|
|
$page_params = array('reply'=>$reply, 'forum'=>$forum, 'edit'=>$edit);
|
2006-11-07 08:48:18 +00:00
|
|
|
|
|
|
|
$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)) {
|
2007-08-22 19:36:24 +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
|
|
|
}
|
|
|
|
|
2007-03-27 05:15:46 +00:00
|
|
|
if (!get_referer()) { // No referer - probably coming in via email See MDL-9052
|
|
|
|
require_login();
|
|
|
|
}
|
2007-04-16 21:12:29 +00:00
|
|
|
|
2007-10-12 15:55:49 +00:00
|
|
|
$navigation = build_navigation('', $cm);
|
2007-04-16 21:12:29 +00:00
|
|
|
print_header($course->shortname, $course->fullname, $navigation, '' , '', true, "", navmenu($course, $cm));
|
|
|
|
|
2005-03-06 06:20:37 +00:00
|
|
|
notice_yesno(get_string('noguestpost', 'forum').'<br /><br />'.get_string('liketologin'),
|
2007-03-05 05:47:27 +00:00
|
|
|
$wwwroot, get_referer(false));
|
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
|
|
|
}
|
2006-11-09 23:04:55 +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"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-07-05 04:40:48 +00:00
|
|
|
if (isset($_SERVER["HTTP_REFERER"])) {
|
|
|
|
$SESSION->fromurl = $_SERVER["HTTP_REFERER"];
|
|
|
|
} else {
|
|
|
|
$SESSION->fromurl = '';
|
|
|
|
}
|
2006-11-07 08:48:18 +00:00
|
|
|
|
|
|
|
|
2002-07-31 14:19:35 +00:00
|
|
|
// Load up the $post variable.
|
|
|
|
|
2006-11-09 23:04:55 +00:00
|
|
|
$post = new object();
|
|
|
|
$post->course = $course->id;
|
|
|
|
$post->forum = $forum->id;
|
2002-07-31 14:19:35 +00:00
|
|
|
$post->discussion = 0; // ie discussion # not defined yet
|
2006-11-09 23:04:55 +00:00
|
|
|
$post->parent = 0;
|
|
|
|
$post->subject = '';
|
|
|
|
$post->userid = $USER->id;
|
|
|
|
$post->message = '';
|
2002-07-31 14:19:35 +00:00
|
|
|
|
2007-08-20 10:52:59 +00:00
|
|
|
if ($groupmode = groups_get_activity_groupmode($cm)) {
|
|
|
|
$post->groupid = groups_get_activity_group($cm);
|
|
|
|
if (empty($post->groupid)) {
|
2007-07-05 04:40:48 +00:00
|
|
|
$post->groupid = -1; //TODO: why -1??
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
$post->groupid = -1; //TODO: why -1??
|
2006-08-08 05:13:06 +00:00
|
|
|
}
|
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)");
|
|
|
|
}
|
2007-10-07 13:31:41 +00:00
|
|
|
if (! $cm = get_coursemodule_from_instance("forum", $forum->id, $course->id)) {
|
|
|
|
error("Incorrect cm");
|
|
|
|
}
|
2006-10-20 17:53:50 +00:00
|
|
|
|
2006-08-16 03:24:43 +00:00
|
|
|
$coursecontext = get_context_instance(CONTEXT_COURSE, $course->id);
|
2007-10-07 13:31:41 +00:00
|
|
|
$modcontext = get_context_instance(CONTEXT_MODULE, $cm->id);
|
2006-12-04 08:09:22 +00:00
|
|
|
|
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
|
|
|
|
2007-10-07 13:31:41 +00:00
|
|
|
if (groupmode($course, $cm)) { // Make sure user can post here
|
|
|
|
$mygroupid = mygroupid($course->id);
|
|
|
|
if (!((empty($mygroupid) and $discussion->groupid == -1)
|
|
|
|
|| (groups_is_member($discussion->groupid)/*$mygroupid == $discussion->groupid*/)
|
|
|
|
|| has_capability('moodle/site:accessallgroups', $modcontext, NULL, false) )) {
|
|
|
|
print_error('nopostdiscussion', 'forum');
|
2004-04-30 01:54:56 +00:00
|
|
|
}
|
2004-01-23 12:09:25 +00:00
|
|
|
}
|
2008-01-30 21:00:58 +00:00
|
|
|
if (!$cm->visible and !has_capability('moodle/course:viewhiddenactivities', $coursecontext)) {
|
2007-10-07 13:31:41 +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.
|
|
|
|
|
2006-11-09 23:04:55 +00:00
|
|
|
$post = new object();
|
|
|
|
$post->course = $course->id;
|
|
|
|
$post->forum = $forum->id;
|
2002-07-31 14:19:35 +00:00
|
|
|
$post->discussion = $parent->discussion;
|
2006-11-09 23:04:55 +00:00
|
|
|
$post->parent = $parent->id;
|
|
|
|
$post->subject = $parent->subject;
|
|
|
|
$post->userid = $USER->id;
|
|
|
|
$post->message = '';
|
2002-07-31 14:19:35 +00:00
|
|
|
|
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-11-09 23:04:55 +00:00
|
|
|
|
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
|
|
|
|
|
|
|
|
2006-11-09 23:04:55 +00:00
|
|
|
// Load up the $post variable.
|
|
|
|
$post->edit = $edit;
|
|
|
|
$post->course = $course->id;
|
2002-07-31 14:19:35 +00:00
|
|
|
$post->forum = $forum->id;
|
|
|
|
|
2006-11-09 23:04:55 +00:00
|
|
|
trusttext_prepare_edit($post->message, $post->format, can_use_html_editor(), $modcontext);
|
|
|
|
|
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
|
|
|
}
|
2007-01-27 19:56:08 +00:00
|
|
|
if (!$course = get_record('course', 'id', $forum->course)) {
|
|
|
|
error('Incorrect course');
|
|
|
|
}
|
|
|
|
|
|
|
|
require_login($course, false, $cm);
|
|
|
|
$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
|
|
|
}
|
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",
|
2007-03-15 14:10:29 +00:00
|
|
|
$CFG->wwwroot.'/mod/forum/discuss.php?d='.$post->discussion.'#p'.$post->id);
|
2005-04-19 11:25:59 +00:00
|
|
|
|
|
|
|
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",
|
2007-03-15 14:10:29 +00:00
|
|
|
$CFG->wwwroot.'/mod/forum/discuss.php?d='.$post->discussion.'#p'.$post->id);
|
2005-04-19 11:25:59 +00:00
|
|
|
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
|
|
|
|
2006-11-09 23:04:55 +00:00
|
|
|
$newdiscussion = new object();
|
|
|
|
$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;
|
2004-05-30 17:25:26 +00:00
|
|
|
$newdiscussion->usermodified = $post->userid;
|
2006-11-09 23:04:55 +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
|
|
|
|
2006-11-09 23:04:55 +00:00
|
|
|
$newpost = new object();
|
|
|
|
$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);
|
2007-04-16 21:12:29 +00:00
|
|
|
|
2007-07-05 04:55:24 +00:00
|
|
|
$navlinks = array();
|
2007-07-05 04:40:48 +00:00
|
|
|
$navlinks[] = array('name' => format_string($post->subject, true), 'link' => "discuss.php?d=$discussion->id", 'type' => 'title');
|
|
|
|
$navlinks[] = array('name' => get_string("prune", "forum"), 'link' => '', 'type' => 'title');
|
2007-10-12 15:55:49 +00:00
|
|
|
$navigation = build_navigation($navlinks, $cm);
|
2007-04-16 21:12:29 +00:00
|
|
|
print_header_simple(format_string($discussion->name).": ".format_string($post->subject), "", $navigation, '', "", 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);
|
|
|
|
}
|
|
|
|
|
2006-11-12 18:36:00 +00:00
|
|
|
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);
|
|
|
|
|
2006-12-28 15:43:47 +00:00
|
|
|
$mform_post = new mod_forum_post_form('post.php', array('course'=>$course, 'coursecontext'=>$coursecontext, 'modcontext'=>$modcontext, 'forum'=>$forum, 'post'=>$post));
|
2006-11-07 08:48:18 +00:00
|
|
|
|
2007-01-12 18:52:09 +00:00
|
|
|
if ($fromform = $mform_post->get_data()) {
|
2006-11-07 08:48:18 +00:00
|
|
|
|
|
|
|
|
2007-01-27 19:56:08 +00:00
|
|
|
require_login($course, false, $cm);
|
2006-11-07 08:48:18 +00:00
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
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");
|
|
|
|
}
|
|
|
|
|
2008-01-24 20:33:50 +00:00
|
|
|
$updatepost = $fromform; //realpost
|
|
|
|
$updatepost->forum = $forum->id;
|
2006-11-07 08:48:18 +00:00
|
|
|
if (!forum_update_post($updatepost, $message)) {
|
|
|
|
error(get_string("couldnotupdate", "forum"), $errordestination);
|
|
|
|
}
|
2007-11-28 05:08:51 +00:00
|
|
|
|
|
|
|
// MDL-11818
|
|
|
|
if (($forum->type == 'single') && ($updatepost->parent == '0')){ // updating first post of single discussion type -> updating forum intro
|
|
|
|
$forum->intro = $updatepost->message;
|
|
|
|
$forum->timemodified = time();
|
|
|
|
if (!update_record("forum", $forum)) {
|
|
|
|
error(get_string("couldnotupdate", "forum"), $errordestination);
|
|
|
|
}
|
|
|
|
}
|
2006-11-07 08:48:18 +00:00
|
|
|
|
|
|
|
$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 {
|
2007-03-15 14:10:29 +00:00
|
|
|
$discussionurl = "discuss.php?d=$discussion->id#p$fromform->id";
|
2006-11-07 08:48:18 +00:00
|
|
|
}
|
|
|
|
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;
|
|
|
|
}
|
2007-03-01 06:01:43 +00:00
|
|
|
|
2006-11-07 08:48:18 +00:00
|
|
|
if ($subscribemessage = forum_post_subscription($fromform)) {
|
|
|
|
$timemessage = 4;
|
|
|
|
}
|
|
|
|
|
2007-03-02 19:41:31 +00:00
|
|
|
if (!empty($fromform->mailnow)) {
|
2006-11-07 08:48:18 +00:00
|
|
|
$message .= get_string("postmailnow", "forum");
|
|
|
|
$timemessage = 4;
|
2007-03-01 06:01:43 +00:00
|
|
|
} else {
|
|
|
|
$message .= '<br />'.get_string("postadded", "forum", format_time($CFG->maxeditingtime));
|
2006-11-07 08:48:18 +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=$discussion->id";
|
|
|
|
}
|
|
|
|
add_to_log($course->id, "forum", "add post",
|
|
|
|
"$discussionurl&parent=$fromform->id", "$fromform->id", $cm->id);
|
|
|
|
|
2007-03-12 05:19:21 +00:00
|
|
|
redirect(forum_go_back_to("$discussionurl#p$fromform->id"), $message.$subscribemessage, $timemessage);
|
2006-11-07 08:48:18 +00:00
|
|
|
|
|
|
|
} 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;
|
|
|
|
}
|
2006-12-09 11:42:57 +00:00
|
|
|
$discussion->timestart = $fromform->timestart;
|
|
|
|
$discussion->timeend = $fromform->timeend;
|
2006-11-07 08:48:18 +00:00
|
|
|
|
|
|
|
$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;
|
|
|
|
}
|
2007-03-01 06:01:43 +00:00
|
|
|
|
2006-11-07 08:48:18 +00:00
|
|
|
if ($fromform->mailnow) {
|
|
|
|
$message .= get_string("postmailnow", "forum");
|
|
|
|
$timemessage = 4;
|
2007-03-01 06:01:43 +00:00
|
|
|
} else {
|
|
|
|
$message .= '<br />'.get_string("postadded", "forum", format_time($CFG->maxeditingtime));
|
|
|
|
}
|
2006-11-07 08:48:18 +00:00
|
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
2007-04-16 21:12:29 +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 = '';
|
|
|
|
} else {
|
|
|
|
// Show the discussion name in the breadcrumbs.
|
|
|
|
$strdiscussionname = format_string($discussion->name).':';
|
|
|
|
}
|
2007-03-16 01:46:17 +00:00
|
|
|
|
|
|
|
$forcefocus = empty($reply) ? NULL : 'message';
|
|
|
|
|
2007-10-12 15:55:49 +00:00
|
|
|
$navlinks = array();
|
|
|
|
if ($post->parent) {
|
|
|
|
$navlinks[] = array('name' => format_string($toppost->subject, true), 'link' => "discuss.php?d=$discussion->id", 'type' => 'title');
|
|
|
|
$navlinks[] = array('name' => get_string('editing', 'forum'), 'link' => '', 'type' => 'title');
|
|
|
|
} else {
|
|
|
|
$navlinks[] = array('name' => format_string($toppost->subject), 'link' => '', 'type' => 'title');
|
|
|
|
}
|
|
|
|
$navigation = build_navigation($navlinks, $cm);
|
2007-04-16 21:12:29 +00:00
|
|
|
|
|
|
|
print_header("$course->shortname: $strdiscussionname ".
|
|
|
|
format_string($toppost->subject), $course->fullname,
|
|
|
|
$navigation, $mform_post->focus($forcefocus), "", true, "", navmenu($course, $cm));
|
|
|
|
|
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-12-05 08:15:01 +00:00
|
|
|
if (empty($parent) && empty($edit) && !forum_user_can_post_discussion($forum)) {
|
2006-01-16 04:57:48 +00:00
|
|
|
error("You cannot start a new discussion in this forum");
|
|
|
|
}
|
|
|
|
|
2007-02-13 05:25:45 +00:00
|
|
|
if ($forum->type == 'qanda'
|
|
|
|
&& !has_capability('mod/forum:viewqandawithoutposting', $modcontext)
|
|
|
|
&& !empty($discussion->id)
|
|
|
|
&& !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)) {
|
2008-01-28 03:23:38 +00:00
|
|
|
forum_print_posts_threaded($parent->id, $course->id, 0, false, false, $user_read_array, $discussion->forum, $modcontext);
|
2006-01-16 04:57:48 +00:00
|
|
|
}
|
2003-12-12 08:46:24 +00:00
|
|
|
}
|
2006-11-09 23:04:55 +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)) {
|
2007-01-11 08:06:15 +00:00
|
|
|
print_box(format_text($forum->intro), 'generalbox', 'intro');
|
2004-12-14 06:26:43 +00:00
|
|
|
}
|
2006-01-16 04:57:48 +00:00
|
|
|
if ($forum->type == 'qanda') {
|
2006-11-09 23:04:55 +00:00
|
|
|
$heading = get_string('yournewquestion', 'forum');
|
2006-01-16 04:57:48 +00:00
|
|
|
} else {
|
2006-11-09 23:04:55 +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));
|
|
|
|
|
|
|
|
|
2007-01-12 18:52:09 +00:00
|
|
|
$mform_post->set_data(array( 'general'=>$heading,
|
2006-11-08 06:22:58 +00:00
|
|
|
'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())+
|
|
|
|
|
2008-01-24 20:33:50 +00:00
|
|
|
(isset($discussion->timestart)?array(
|
2006-12-10 18:33:07 +00:00
|
|
|
'timestart'=>$discussion->timestart):
|
|
|
|
array())+
|
|
|
|
|
|
|
|
(isset($discussion->timeend)?array(
|
|
|
|
'timeend'=>$discussion->timeend):
|
|
|
|
array())+
|
|
|
|
|
2006-11-07 08:48:18 +00:00
|
|
|
(isset($post->groupid)?array(
|
|
|
|
'groupid'=>$post->groupid):
|
|
|
|
array())+
|
|
|
|
|
|
|
|
(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
|
|
|
?>
|