Index: lib/weblib.php =================================================================== RCS file: /cvsroot/moodle/moodle/lib/weblib.php,v retrieving revision 1.1020 diff -u -r1.1020 weblib.php --- lib/weblib.php 9 Jan 2008 23:15:45 -0000 1.1020 +++ lib/weblib.php 10 Jan 2008 12:29:17 -0000 @@ -4172,9 +4172,10 @@ * @param boolean $return if false, output the form directly, otherwise return the HTML as a string. * @param string $tooltip a tooltip to add to the button as a title attribute. * @param boolean $disabled if true, the button will be disabled. + * @param string $jsconfirmmessage if not empty then display a confirm dialogue with this string as the question. * @return string / nothing depending on the $return paramter. */ -function print_single_button($link, $options, $label='OK', $method='get', $target='_self', $return=false, $tooltip='', $disabled = false) { +function print_single_button($link, $options, $label='OK', $method='get', $target='_self', $return=false, $tooltip='', $disabled = false, $jsconfirmmessage='') { $output = ''; $link = str_replace('"', '"', $link); //basic XSS protection $output .= '
'; @@ -4196,7 +4197,11 @@ } else { $disabled = ''; } - $output .= '
"; + if ($jsconfirmmessage){ + $jsconfirmmessage = addslashes_js($jsconfirmmessage); + $jsconfirmmessage = 'onclick="'.s('return confirm("'.$jsconfirmmessage.'");').'"'; + } + $output .= '"; if ($return) { return $output;