From: vyshane Date: Thu, 28 Sep 2006 07:29:50 +0000 (+0000) Subject: Fixes for MDL-3975 X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=cef1ce6abf59da433dafc97eeeb93d321ca7ec00;p=moodle.git Fixes for MDL-3975 Changes to discuss.php and post.php so that the single discussion type forums are handled more consistently. --- diff --git a/mod/forum/discuss.php b/mod/forum/discuss.php index 36620ce4f2..4749b0125b 100644 --- a/mod/forum/discuss.php +++ b/mod/forum/discuss.php @@ -136,21 +136,30 @@ } } + if (empty($navtail)) { - $navtail = "id\">".format_string($discussion->name,true)." -> ".format_string($post->subject); + $navtail = "-> id\">". + format_string($discussion->name,true)." -> ". + format_string($post->subject); } - - $navmiddle = "id\">".get_string("forums", "forum")." -> id\">".format_string($forum->name,true).""; + if ($forum->type == 'single') { + $navforum = ''; + } else { + $navforum = "id\">". + format_string($forum->name,true)." "; + } + $navmiddle = "id\">". + get_string("forums", "forum").' -> '.$navforum; $searchform = forum_search_form($course); if ($course->category) { print_header("$course->shortname: ".format_string($discussion->name), "$course->fullname", - "id\">$course->shortname -> - $navmiddle -> $navtail", "", "", true, $searchform, navmenu($course, $cm)); + "id\">$course->shortname -> + $navmiddle $navtail", "", "", true, $searchform, navmenu($course, $cm)); } else { print_header("$course->shortname: ".format_string($discussion->name), "$course->fullname", - "$navmiddle -> $navtail", "", "", true, $searchform, navmenu($course, $cm)); + "$navmiddle $navtail", "", "", true, $searchform, navmenu($course, $cm)); } @@ -199,9 +208,13 @@ echo ""; forum_print_mode_form($discussion->id, $displaymode); - echo ""; - if (has_capability('mod/forum:movediscussions', $modcontext)) { // Popup menu to move discussions to other forums + + if ($forum->type != 'single' + && has_capability('mod/forum:movediscussions', $modcontext)) { + + // Popup menu to move discussions to other forums. The discussion in a + // single discussion forum can't be moved. if ($forums = get_all_instances_in_course("forum", $course)) { if ($course->format == 'weeks') { $strsection = get_string("week"); diff --git a/mod/forum/post.php b/mod/forum/post.php index af28b03f0b..91345776d3 100644 --- a/mod/forum/post.php +++ b/mod/forum/post.php @@ -50,11 +50,13 @@ print_header($course->shortname, $course->fullname, "id\">$course->shortname -> id\">$strforums -> - id\">".format_string($forum->name,true)."", '', '', true, "", navmenu($course, $cm)); + id\">".format_string($forum->name,true)."", + '', '', true, "", navmenu($course, $cm)); } else { print_header($course->shortname, $course->fullname, "id\">$strforums -> - id\">".format_string($forum->name)."", '', '', true, "", navmenu($course, $cm)); + id\">".format_string($forum->name)."", + '', '', true, "", navmenu($course, $cm)); } notice_yesno(get_string('noguestpost', 'forum').'

'.get_string('liketologin'), $wwwroot, $_SERVER['HTTP_REFERER']); @@ -143,9 +145,6 @@ if (forum_update_post($post,$message)) { - add_to_log($course->id, "forum", "update post", - "discuss.php?d=$post->discussion&parent=$post->id", "$post->id", $cm->id); - $timemessage = 2; if (!empty($message)) { // if we're printing stuff about the file upload $timemessage = 4; @@ -155,7 +154,18 @@ if ($subscribemessage = forum_post_subscription($post)) { $timemessage = 4; } - redirect(forum_go_back_to("discuss.php?d=$post->discussion#$post->id"), $message.$subscribemessage, $timemessage); + 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#$post->id"; + } + add_to_log($course->id, "forum", "update post", + "$discussionurl&parent=$post->id", "$post->id", $cm->id); + + redirect(forum_go_back_to("$discussionurl#$post->id"), $message.$subscribemessage, $timemessage); } else { error(get_string("couldnotupdate", "forum"), $errordestination); @@ -167,9 +177,6 @@ $message = ''; if ($post->id = forum_add_new_post($post,$message)) { - add_to_log($course->id, "forum", "add post", - "discuss.php?d=$post->discussion&parent=$post->id", "$post->id", $cm->id); - $timemessage = 2; if (!empty($message)) { // if we're printing stuff about the file upload $timemessage = 4; @@ -185,7 +192,18 @@ $timemessage = 4; } - redirect(forum_go_back_to("discuss.php?d=$post->discussion#$post->id"), $message.$subscribemessage, $timemessage); + 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"; + } + add_to_log($course->id, "forum", "add post", + "$discussionurl&parent=$post->id", "$post->id", $cm->id); + + redirect(forum_go_back_to("$discussionurl#$post->id"), $message.$subscribemessage, $timemessage); } else { error(get_string("couldnotadd", "forum"), $errordestination); @@ -469,7 +487,7 @@ } else { if (! $post->parent) { // post is a discussion topic as well, so delete discussion - if ($forum->type == "single") { + if ($forum->type == 'single') { notice("Sorry, but you are not allowed to delete that discussion!", forum_go_back_to("discuss.php?d=$post->discussion")); } @@ -482,12 +500,20 @@ get_string("deleteddiscussion", "forum"), 1); } else if (forum_delete_post($post, has_capability('mod/forum:deleteanypost', $modcontext))) { - - add_to_log($discussion->course, "forum", "delete post", - "discuss.php?d=$post->discussion", "$post->id", $cm->id); + + 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"; + } + + add_to_log($discussion->course, "forum", "delete post", $discussionurl, "$post->id", $cm->id); $feedback = $replycount ? get_string('deletedposts', 'forum') : get_string('deletedpost', 'forum'); - redirect(forum_go_back_to("discuss.php?d=$post->discussion"), $feedback, 1); + redirect(forum_go_back_to($discussionurl), $feedback, 1); } else { error("An error occurred while deleting record $post->id"); } @@ -660,7 +686,7 @@ $strforums = get_string("modulenameplural", "forum"); - $navmiddle = "id\">$strforums -> id\">".format_string($forum->name,true).""; + $navmiddle = "id\">$strforums -> id\">".format_string($forum->name,true).' '; if (empty($discussion->name)) { if (empty($discussion)) { @@ -668,15 +694,26 @@ } $discussion->name = $forum->name; } - + 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).':'; + } if ($course->category) { - print_header("$course->shortname: ".format_string($discussion->name).": ".format_string($toppost->subject), "$course->fullname", - "id\">$course->shortname -> - $navmiddle -> $navtail", $formstart, "", true, "", navmenu($course, $cm)); + print_header("$course->shortname: $strdiscussionname ". + format_string($toppost->subject), "$course->fullname", + "id\">$course->shortname -> + $navmiddle $navtail", $formstart, "", true, "", navmenu($course, $cm)); } else { - print_header("$course->shortname: ".format_string($discussion->name).": ".format_string($toppost->subject), "$course->fullname", - "$navmiddle -> $navtail", "$formstart", "", true, "", navmenu($course, $cm)); + print_header("$course->shortname: $strdiscussionname ". + format_string($toppost->subject), "$course->fullname", + "$navmiddle $navtail", "$formstart", "", true, "", navmenu($course, $cm)); }