MDL-19147 - forum - Removed single discussions from the pull down menu for moving...
authorCharles Fulton <mackensen@gmail.com>
Wed, 16 Nov 2011 02:55:21 +0000 (18:55 -0800)
committeradrian@moodle.com <abgreeve@gmail.com>
Thu, 1 Dec 2011 00:54:46 +0000 (08:54 +0800)
mod/forum/discuss.php
mod/forum/lang/en/forum.php

index 0e42828..c4c5316 100644 (file)
             print_error('cannotmovetonotexist', 'forum', $return);
         }
 
+        if ($forumto->type == 'single') {
+            print_error('cannotmovetosingleforum', 'forum', $return);
+        }
+
         if (!$cmto = get_coursemodule_from_instance('forum', $forumto->id, $course->id)) {
             print_error('cannotmovetonotfound', 'forum', $return);
         }
         if (isset($modinfo->instances['forum'])) {
             $forummenu = array();
             $sections = get_all_sections($course->id);
+            // Check forum types and eliminate simple discussions.
+            $forumcheck = $DB->get_records('forum', array('course' => $course->id),'', 'id, type');
             foreach ($modinfo->instances['forum'] as $forumcm) {
                 if (!$forumcm->uservisible || !has_capability('mod/forum:startdiscussion',
                     get_context_instance(CONTEXT_MODULE,$forumcm->id))) {
                     continue;
                 }
-
                 $section = $forumcm->sectionnum;
                 $sectionname = get_section_name($course, $sections[$section]);
                 if (empty($forummenu[$section])) {
                     $forummenu[$section] = array($sectionname => array());
                 }
-                if ($forumcm->instance != $forum->id) {
+                $forumidcompare = $forumcm->instance != $forum->id;
+                $forumtypecheck = $forumcheck[$forumcm->instance]->type !== 'single';
+                if ($forumidcompare and $forumtypecheck) {
                     $url = "/mod/forum/discuss.php?d=$discussion->id&move=$forumcm->instance&sesskey=".sesskey();
                     $forummenu[$section][$sectionname][$url] = format_string($forumcm->name);
                 }
index 19da7f9..7a1dc64 100644 (file)
@@ -64,6 +64,7 @@ $string['cannotmovefromsingleforum'] = 'Cannot move discussion from a simple sin
 $string['cannotmovenotvisible'] = 'Forum not visible';
 $string['cannotmovetonotexist'] = 'You can\'t move to that forum - it doesn\'t exist!';
 $string['cannotmovetonotfound'] = 'Target forum not found in this course.';
+$string['cannotmovetosingleforum'] = 'Cannot move discussion to a simple single discussion forum';
 $string['cannotpurgecachedrss'] = 'Could not purge the cached RSS feeds for the source and/or destination forum(s) - check your file permissionsforums';
 $string['cannotremovesubscriber'] = 'Could not remove subscriber with id {$a} from this forum!';
 $string['cannotreply'] = 'You cannot reply to this post';