diff --git a/lib/weblib.php b/lib/weblib.php index af6bc989683..8b7226f5f44 100644 --- a/lib/weblib.php +++ b/lib/weblib.php @@ -4167,9 +4167,10 @@ function _print_custom_corners_end($idbase) { * @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 .= '
"; + if ($jsconfirmmessage){ + $jsconfirmmessage = addslashes_js($jsconfirmmessage); + $jsconfirmmessage = 'onclick="'.s('return confirm("'.$jsconfirmmessage.'");').'"'; + } + $output .= '"; if ($return) { return $output;