diff options
author | Madhura Jayaratne <madhura.cj@gmail.com> | 2015-05-08 13:10:47 +0300 |
---|---|---|
committer | Madhura Jayaratne <madhura.cj@gmail.com> | 2015-05-08 13:10:47 +0300 |
commit | 470d61abafc0f32293374eeee26696a3c482566c (patch) | |
tree | 604d7c64bcaa9f291434dfc7514b77e85cec88da | |
parent | 34c2837894d712ae0148be6aad385d3b3f77995a (diff) |
bug #4894 Deleting without confirmation
Signed-off-by: Madhura Jayaratne <madhura.cj@gmail.com>
-rw-r--r-- | ChangeLog | 1 | ||||
-rw-r--r-- | js/functions.js | 23 | ||||
-rw-r--r-- | js/sql.js | 20 | ||||
-rw-r--r-- | libraries/DisplayResults.class.php | 2 | ||||
-rw-r--r-- | libraries/Util.class.php | 40 |
5 files changed, 56 insertions, 30 deletions
@@ -4,6 +4,7 @@ phpMyAdmin - ChangeLog 4.4.7.0 (not yet released) - bug #4876 Settings issues (Favorite tables shown twice in Settings) - bug #4896 Non-styled error page when following results link +- bug #4894 Deleting without confirmation 4.4.6.0 (2015-05-07) - bug #4890 webkitStorageInfo and webkitIndexedDB is deprecated diff --git a/js/functions.js b/js/functions.js index a81062617d..45b59a0147 100644 --- a/js/functions.js +++ b/js/functions.js @@ -3823,13 +3823,10 @@ AJAX.registerOnload('functions.js', function () { * Enables the text generated by PMA_Util::linkOrButton() to be clickable */ $(document).on('click', 'a.formLinkSubmit', function (e) { - - if ($(this).attr('href').indexOf('=') != -1) { - var data = $(this).attr('href').substr($(this).attr('href').indexOf('#') + 1).split('=', 2); - $(this).parents('form').append('<input type="hidden" name="' + data[0] + '" value="' + data[1] + '"/>'); + if (! $(this).hasClass('requireConfirm')) { + submitFormLink($(this)); + return false; } - $(this).parents('form').submit(); - return false; }); if ($('#update_recent_tables').length) { @@ -3866,6 +3863,20 @@ AJAX.registerOnload('functions.js', function () { } }); // end of $() +/** + * Submits the form placed in place of a link due to the excessive url length + * + * @param $link anchor + * @returns {Boolean} + */ +function submitFormLink($link) +{ + if ($link.attr('href').indexOf('=') != -1) { + var data = $link.attr('href').substr($link.attr('href').indexOf('#') + 1).split('=', 2); + $link.parents('form').append('<input type="hidden" name="' + data[0] + '" value="' + data[1] + '"/>'); + } + $link.parents('form').submit(); +} /** * Initializes slider effect. @@ -155,14 +155,18 @@ AJAX.registerOnload('sql.js', function () { var $link = $(this); $link.PMA_confirm(question, $link.attr('href'), function (url) { $msgbox = PMA_ajaxShowMessage(); - $.get(url, {'ajax_request': true, 'is_js_confirmed': true}, function (data) { - if (data.success) { - PMA_ajaxShowMessage(data.message); - $link.closest('tr').remove(); - } else { - PMA_ajaxShowMessage(data.error, false); - } - }); + if ($link.hasClass('formLinkSubmit')) { + submitFormLink($link); + } else { + $.get(url, {'ajax_request': true, 'is_js_confirmed': true}, function (data) { + if (data.success) { + PMA_ajaxShowMessage(data.message); + $link.closest('tr').remove(); + } else { + PMA_ajaxShowMessage(data.error, false); + } + }); + } }); }); diff --git a/libraries/DisplayResults.class.php b/libraries/DisplayResults.class.php index 8b983fb3de..f15e72ca63 100644 --- a/libraries/DisplayResults.class.php +++ b/libraries/DisplayResults.class.php @@ -5550,7 +5550,7 @@ class PMA_DisplayResults $ajax = PMA_Response::getInstance()->isAjax() ? ' ajax' : ''; $ret .= 'center" ' . ' >' . PMA_Util::linkOrButton( - $del_url, $del_str, array('class' => 'delete_row' . $ajax), false + $del_url, $del_str, array('class' => 'delete_row requireConfirm' . $ajax), false ) . '<div class="hide">' . $js_conf . '</div>' . '</td>'; diff --git a/libraries/Util.class.php b/libraries/Util.class.php index 1521fd32ae..9ac202bcbf 100644 --- a/libraries/Util.class.php +++ b/libraries/Util.class.php @@ -1797,15 +1797,6 @@ class PMA_Util $tag_params['target'] = htmlentities($target); } - $tag_params_strings = array(); - foreach ($tag_params as $par_name => $par_value) { - // htmlspecialchars() only on non javascript - $par_value = /*overload*/mb_substr($par_name, 0, 2) == 'on' - ? $par_value - : htmlspecialchars($par_value); - $tag_params_strings[] = $par_name . '="' . $par_value . '"'; - } - $displayed_message = ''; // Add text if not already added if (stristr($message, '<img') @@ -1841,6 +1832,15 @@ class PMA_Util if (($url_length <= $GLOBALS['cfg']['LinkLengthLimit']) && $in_suhosin_limits ) { + $tag_params_strings = array(); + foreach ($tag_params as $par_name => $par_value) { + // htmlspecialchars() only on non javascript + $par_value = /*overload*/mb_substr($par_name, 0, 2) == 'on' + ? $par_value + : htmlspecialchars($par_value); + $tag_params_strings[] = $par_name . '="' . $par_value . '"'; + } + // no whitespace within an <a> else Safari will make it part of the link $ret = "\n" . '<a href="' . $url . '" ' . implode(' ', $tag_params_strings) . '>' @@ -1850,11 +1850,6 @@ class PMA_Util // or after the hidden fields // IE will display them all - // add class=link to submit button - if (empty($tag_params['class'])) { - $tag_params['class'] = 'link'; - } - if (! isset($query_parts)) { $query_parts = self::splitURLQuery($url); } @@ -1886,7 +1881,22 @@ class PMA_Util . htmlspecialchars(urldecode($eachval)) . '" />'; } // end while - $ret .= "\n" . '<a href="' . $submit_link . '" class="formLinkSubmit" ' + if (empty($tag_params['class'])) { + $tag_params['class'] = 'formLinkSubmit'; + } else { + $tag_params['class'] .= ' formLinkSubmit'; + } + + $tag_params_strings = array(); + foreach ($tag_params as $par_name => $par_value) { + // htmlspecialchars() only on non javascript + $par_value = /*overload*/mb_substr($par_name, 0, 2) == 'on' + ? $par_value + : htmlspecialchars($par_value); + $tag_params_strings[] = $par_name . '="' . $par_value . '"'; + } + + $ret .= "\n" . '<a href="' . $submit_link . '" ' . implode(' ', $tag_params_strings) . '>' . $message . ' ' . $displayed_message . '</a>' . "\n"; |