]> git.mjollnir.org Git - moodle.git/commitdiff
forum MDL-20737 Fixed bug causing exception in forum move to drop down
authorSam Hemelryk <sam@moodle.com>
Wed, 4 Nov 2009 02:46:18 +0000 (02:46 +0000)
committerSam Hemelryk <sam@moodle.com>
Wed, 4 Nov 2009 02:46:18 +0000 (02:46 +0000)
mod/forum/discuss.php

index 241d05e53c256e666511027a02c7040af9112796..523b03c72783bdbd64e14962d4c5526455d037a8 100644 (file)
                 }
             }
             if (!empty($forummenu)) {
+
+                // Check for empty groups... This can occur if there is the forum we are in is
+                // the only forum within its course section.
+                foreach ($forummenu as $key=>$item) {
+                    // If this option is a group and the next option is a group OR it is
+                    // the last item in the array then remove it... or we get an exception
+                    if (strpos($item, '--------------')===0 && (!array_key_exists($key+1, $forummenu) || strpos($forummenu[$key+1], '--------------')===0)) {
+                        // Remember foreach acts on a copy of the array so things
+                        // will not get out of order
+                        unset($forummenu[$key]);
+                    }
+                }
+
                 echo "<div style=\"float:right;\">";
                 $select = html_select::make_popup_form('', '', $forummenu, 'forummenu');
                 $select->nothinglabel = get_string("movethisdiscussionto", "forum");