Index: lib/weblib.php =================================================================== RCS file: /cvsroot/moodle/moodle/lib/weblib.php,v retrieving revision 1.970.2.68 diff -u -r1.970.2.68 weblib.php --- lib/weblib.php 15 Mar 2008 15:00:03 -0000 1.970.2.68 +++ lib/weblib.php 18 Mar 2008 15:21:26 -0000 @@ -4183,14 +4183,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', $target='_self', $return=false, $tooltip='', $disabled = false, $jsconfirmmessage='') { +function print_single_button($link, $options, $label='OK', $method='get', $target='_self', + $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 .= '