Index: lib/weblib.php =================================================================== RCS file: /cvsroot/moodle/moodle/lib/weblib.php,v retrieving revision 1.1044 diff -u -r1.1044 weblib.php --- lib/weblib.php 15 Mar 2008 15:01:27 -0000 1.1044 +++ lib/weblib.php 18 Mar 2008 15:21:36 -0000 @@ -4208,15 +4208,22 @@ * @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. + * @param boolean $preventdoublesubmit if true, then when the form is submitted, + * the button is disabled to prevent repeat submissions. Default false. * @return string / nothing depending on the $return paramter. */ function print_single_button($link, $options, $label='OK', $method='get', $notusedanymore='', - $return=false, $tooltip='', $disabled = false, $jsconfirmmessage='') { + $return=false, $tooltip='', $disabled = false, $jsconfirmmessage='', $preventdoublesubmit = false) { $output = ''; $link = str_replace('"', '"', $link); //basic XSS protection + if ($preventdoublesubmit) { + $onsubmit = ' onsubmit="var inputs=this.getElementsByTagName(\'input\');inputs[inputs.length-1].disabled=true;"'; + } else { + $onsubmit = ''; + } $output .= '