From: pdontthink Date: Tue, 23 Dec 2008 02:59:14 +0000 (+0000) Subject: Make all submit button names unique on compose screen X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=61bd57f55a8f10c323506bb2b6288c806aed260b;p=squirrelmail.git Make all submit button names unique on compose screen git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@13383 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- diff --git a/ChangeLog b/ChangeLog index 3616289b..e2fe6db6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -267,6 +267,7 @@ Version 1.5.2 - SVN option widgets. - Add informational type option widget - Add password type option widget + - Make all submit button names unique on compose screen Version 1.5.1 (branched on 2006-02-12) -------------------------------------- diff --git a/functions/forms.php b/functions/forms.php index e49b8a69..4dc55237 100644 --- a/functions/forms.php +++ b/functions/forms.php @@ -336,3 +336,39 @@ function addForm($sAction, $sMethod = 'post', $sName = '', $sEnctype = '', $sCha return $oTemplate->fetch('form.tpl'); } +/** + * Creates unique widget names + * + * Names are formatted as such: "send1", "send2", "send3", etc., + * where "send" in this example is what was given for $base_name + * + * @param string $base_name The name upon which to base the + * returned widget name. + * @param boolean $return_count When TRUE, this function will + * return the last number used to + * create a widget name for $base_name + * (OPTIONAL; default = FALSE). + * + * @return mixed When $return_output is FALSE, a string containing + * the unique widget name; otherwise an integer with + * the last number used to create the last widget + * name for the given $base_name (where 0 (zero) means + * that no such widgets have been created yet). + * + * @since 1.4.18 and 1.5.2 + * + */ +function unique_widget_name($base_name, $return_count=FALSE) +{ + static $counts = array(); + + if (!isset($counts[$base_name])) + $counts[$base_name] = 0; + + if ($return_count) + return $counts[$base_name]; + + ++$counts[$base_name]; + return $base_name . $counts[$base_name]; +} + diff --git a/src/compose.php b/src/compose.php index b2101d4f..ed6c0e6a 100644 --- a/src/compose.php +++ b/src/compose.php @@ -60,7 +60,9 @@ sqsession_unregister('compose_messages'); $oErrorHandler->setDelayedErrors(true); /** SESSION/POST/GET VARS */ -sqgetGlobalVar('send', $send, SQ_POST); +sqgetGlobalVar('send_button_count', $send_button_count, SQ_POST, 1, SQ_TYPE_INT); +for ($i = 1; $i <= $send_button_count; $i++) + if (sqgetGlobalVar('send' . $i, $send, SQ_POST)) break; // Send can only be achieved by setting $_POST var. If Send = true then // retrieve other form fields from $_POST if (isset($send) && $send) { diff --git a/templates/default/compose_body.tpl b/templates/default/compose_body.tpl index f94c3207..ac19ed7f 100644 --- a/templates/default/compose_body.tpl +++ b/templates/default/compose_body.tpl @@ -32,11 +32,12 @@ extract($t); ?> - " /> + " /> - \ No newline at end of file + + diff --git a/templates/default/compose_buttons.tpl b/templates/default/compose_buttons.tpl index d4848ab9..cf2468d4 100644 --- a/templates/default/compose_buttons.tpl +++ b/templates/default/compose_buttons.tpl @@ -70,7 +70,7 @@ extract($t); - " />  + " />