From 3269de981ef4c22f5bbdb1fe8ea7bb7a1f317819 Mon Sep 17 00:00:00 2001 From: jamiesensei Date: Sat, 12 Jan 2008 08:47:29 +0000 Subject: [PATCH] MDL-12906 add an optional parameter $jsconfirmmessage parameter to print_single_button --- lib/weblib.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/weblib.php b/lib/weblib.php index af6bc98968..8b7226f5f4 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 .= '
'; @@ -4191,7 +4192,11 @@ function print_single_button($link, $options, $label='OK', $method='get', $targe } else { $disabled = ''; } - $output .= '
"; + if ($jsconfirmmessage){ + $jsconfirmmessage = addslashes_js($jsconfirmmessage); + $jsconfirmmessage = 'onclick="'.s('return confirm("'.$jsconfirmmessage.'");').'"'; + } + $output .= '"; if ($return) { return $output; -- 2.39.5