https://rt-wiki.bestpractical.com/index.php?title=PreventDoubleUpdate&feed=atom&action=historyPreventDoubleUpdate - Revision history2024-03-29T05:01:57ZRevision history for this page on the wikiMediaWiki 1.37.2https://rt-wiki.bestpractical.com/index.php?title=PreventDoubleUpdate&diff=2641&oldid=prevAdmin: 3 revisions imported2016-04-06T20:20:29Z<p>3 revisions imported</p>
<p><b>New page</b></p><div>Occasionally if the server is slow, a user will click the "Update Ticket" button multiple times. This will result in multiple transactions. I prevent this using some Javascript code (adapted from code in an article at [http://www.netlobo.com/disable_form_buttons.html Netlobo.com]). Note that this hack is only to prevent an RT user from mistakenly posting several responses. It will not prevent a malicious user from making multiple updates. This has been tested with RT 3.8.8 in Firefox 3, Google Chrome 8, and Internet Explorer 8.<br />
<br />
Create a javascript file called [local]/html/NoAuth/js/disableSubmit.js with the following:<br />
function disableSubmit(whichButton)<br />
{<br />
if (document.getElementById)<br />
{<br />
// this is the way the standards work<br />
document.getElementById(whichButton).style.visibility = 'hidden';<br />
}<br />
// else, old browser.<br />
}<br />
<br />
<br />
<br />
<br />
Add the bolded line to your [local]/html/Elements/HeaderJavascript file:<br />
<script type="text/javascript" src="<%RT->Config->Get('WebPath')%>/NoAuth/js/scriptaculous/scriptaculous.js?load=effects,controls"></script><br />
'''''<script type="text/javascript" src="<%RT->Config->Get('WebPath')%>/NoAuth/js/disableSubmit.js"></script>'''''<br />
<br />
% if ( RT->Config->Get('MessageBoxRichText', $session{'CurrentUser'}) ) {<br />
<br />
<br />
<br />
<br />
Modify the line in [local]/html/Ticket/Update.html. Original text:<br />
'''''<& /Elements/Submit, Label => loc('Update Ticket'), Name => 'SubmitTicket' &>'''''<br />
% if ($TicketObj->CurrentUserHasRight('ShowOutgoingEmail')) {<br />
<&|/Widgets/TitleBox, title => loc('Scrips and Recipients') &><br />
<& /Ticket/Elements/PreviewScrips, TicketObj => $TicketObj, %ARGS &><br />
</&><br />
Change to the following:<br />
'''''<& /Elements/Submit, Label => loc('Update Ticket'), Name => 'SubmitTicket', OnClick => "javascript:disableSubmit('mFormSubmit')", id => 'mFormSubmit' &>'''''<br />
% if ($TicketObj->CurrentUserHasRight('ShowOutgoingEmail')) {<br />
<&|/Widgets/TitleBox, title => loc('Scrips and Recipients') &><br />
<& /Ticket/Elements/PreviewScrips, TicketObj => $TicketObj, %ARGS &><br />
<br />
<br />
<br />
<br />
Now (after restarting the http server), clicking the "Update Ticket" button should cause the button to disappear and the ticket to update.</div>Adminhttps://rt-wiki.bestpractical.com/index.php?title=PreventDoubleUpdate&diff=2639&oldid=prev173.10.126.249 at 16:26, 20 December 20102010-12-20T16:26:26Z<p></p>
<p><b>New page</b></p><div>Occasionally if the server is slow, a user will click the "Update Ticket" button multiple times. This will result in multiple transactions. I prevent this using Javascript. Note that this hack is only to prevent an RT user from mistakenly posting several responses. It will not prevent a malicious user from making multiple updates. This has been tested with RT 3.8.8 in Firefox 3, Google Chrome 8, and Internet Explorer 8.<br />
<br />
Create a javascript file called [local]/html/NoAuth/js/disableSubmit.js with the following:<br />
function disableSubmit(whichButton)<br />
{<br />
if (document.getElementById)<br />
{<br />
// this is the way the standards work<br />
document.getElementById(whichButton).style.visibility = 'hidden';<br />
}<br />
// else, old browser.<br />
}<br />
<br />
<br />
<br />
<br />
Add the bolded line to your [local]/html/Elements/HeaderJavascript file:<br />
<script type="text/javascript" src="<%RT->Config->Get('WebPath')%>/NoAuth/js/scriptaculous/scriptaculous.js?load=effects,controls"></script><br />
'''<script type="text/javascript" src="<%RT->Config->Get('WebPath')%>/NoAuth/js/disableSubmit.js"></script><br />
'''<br />
% if ( RT->Config->Get('MessageBoxRichText', $session{'CurrentUser'}) ) {<br />
<br />
<br />
<br />
<br />
Modify the line in [local]/html/Ticket/Update.html. Original text:<br />
'''<& /Elements/Submit, Label => loc('Update Ticket'), Name => 'SubmitTicket' &>'''<br />
% if ($TicketObj->CurrentUserHasRight('ShowOutgoingEmail')) {<br />
<&|/Widgets/TitleBox, title => loc('Scrips and Recipients') &><br />
<& /Ticket/Elements/PreviewScrips, TicketObj => $TicketObj, %ARGS &><br />
</&><br />
Change to the following:<br />
'''<& /Elements/Submit, Label => loc('Update Ticket'), Name => 'SubmitTicket', OnClick => "javascript:disableSubmit('mFormSubmit')", id => 'mFormSubmit' &>'''<br />
% if ($TicketObj->CurrentUserHasRight('ShowOutgoingEmail')) {<br />
<&|/Widgets/TitleBox, title => loc('Scrips and Recipients') &><br />
<& /Ticket/Elements/PreviewScrips, TicketObj => $TicketObj, %ARGS &><br />
<br />
<br />
<br />
<br />
Now (after restarting the http server), clicking the "Update Ticket" button should cause the button to disappear and the ticket to update.</div>173.10.126.249