From ad9ab4dfe5c058d053cbe4df76e2a3da9a757424 Mon Sep 17 00:00:00 2001 From: Petr Skoda Date: Sun, 13 Feb 2011 11:52:09 +0100 Subject: [PATCH] MDL-26131 fix several collapsible_region issues 1/ the $default was not passed from print_collapsible_region() 2/ incorrect php docs describing $userpref 3/ missing empty() check on $userpref --- lib/weblib.php | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/lib/weblib.php b/lib/weblib.php index 69b13a4bad7..15ea95c8e8a 100644 --- a/lib/weblib.php +++ b/lib/weblib.php @@ -1967,7 +1967,7 @@ function get_separator() { * @return string|void If $return is false, returns nothing, otherwise returns a string of HTML. */ function print_collapsible_region($contents, $classes, $id, $caption, $userpref = '', $default = false, $return = false) { - $output = print_collapsible_region_start($classes, $id, $caption, $userpref, true, true); + $output = print_collapsible_region_start($classes, $id, $caption, $userpref, $default, true); $output .= $contents; $output .= print_collapsible_region_end(true); @@ -1983,21 +1983,20 @@ function print_collapsible_region($contents, $classes, $id, $caption, $userpref * be clicked to expand or collapse the region. If JavaScript is off, then the region * will always be expanded. * - * @global object * @param string $classes class names added to the div that is output. * @param string $id id added to the div that is output. Must not be blank. * @param string $caption text displayed at the top. Clicking on this will cause the region to expand or contract. - * @param boolean $userpref the name of the user preference that stores the user's preferred default state. + * @param string $userpref the name of the user preference that stores the user's preferred default state. * (May be blank if you do not wish the state to be persisted. * @param boolean $default Initial collapsed state to use if the user_preference it not set. * @param boolean $return if true, return the HTML as a string, rather than printing it. * @return string|void if $return is false, returns nothing, otherwise returns a string of HTML. */ -function print_collapsible_region_start($classes, $id, $caption, $userpref = false, $default = false, $return = false) { +function print_collapsible_region_start($classes, $id, $caption, $userpref = '', $default = false, $return = false) { global $CFG, $PAGE, $OUTPUT; // Work out the initial state. - if (is_string($userpref)) { + if (!empty($userpref) and is_string($userpref)) { user_preference_allow_ajax_update($userpref, PARAM_BOOL); $collapsed = get_user_preferences($userpref, $default); } else {