aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/adm/style/ajax.js
diff options
context:
space:
mode:
authorMarc Alexander <admin@m-a-styles.de>2016-11-26 23:31:52 +0100
committerMarc Alexander <admin@m-a-styles.de>2016-11-26 23:34:54 +0100
commitb01b3b8b94ed2f77b9855c53d590bd9e3e734278 (patch)
treea527cca88b58cc617625800b9a90eacf0eb01598 /phpBB/adm/style/ajax.js
parent30b3fbb2cf4fba62ab4deb3cbcb5875e26af8cf4 (diff)
downloadforums-b01b3b8b94ed2f77b9855c53d590bd9e3e734278.tar
forums-b01b3b8b94ed2f77b9855c53d590bd9e3e734278.tar.gz
forums-b01b3b8b94ed2f77b9855c53d590bd9e3e734278.tar.bz2
forums-b01b3b8b94ed2f77b9855c53d590bd9e3e734278.tar.xz
forums-b01b3b8b94ed2f77b9855c53d590bd9e3e734278.zip
[ticket/9590] Preserve selected forums after previous page redirect
Also improved the way the forum ID list is generated when clicking on "Apply all permissions". PHPBB3-9590
Diffstat (limited to 'phpBB/adm/style/ajax.js')
-rw-r--r--phpBB/adm/style/ajax.js47
1 files changed, 28 insertions, 19 deletions
diff --git a/phpBB/adm/style/ajax.js b/phpBB/adm/style/ajax.js
index d95b1d47d6..e9f03baac3 100644
--- a/phpBB/adm/style/ajax.js
+++ b/phpBB/adm/style/ajax.js
@@ -89,14 +89,15 @@ function submitPermissions() {
});
} else {
formDataSets[0] = $form.find('fieldset#' + $submitButton.closest('fieldset.permissions').id).serialize();
- // Add each forum ID to forum ID list to preserve selected forums
- $.each($form.find('input[type=hidden][name^=forum_id]'), function (key, value) {
- if (value.name.match(/^forum_id\[([0-9]+)\]$/)) {
- forumIds.push(value.value);
- }
- });
}
+ // Add each forum ID to forum ID list to preserve selected forums
+ $.each($form.find('input[type=hidden][name^=forum_id]'), function (key, value) {
+ if (value.name.match(/^forum_id\[([0-9]+)\]$/)) {
+ forumIds.push(value.value);
+ }
+ });
+
/**
* Handler for submitted permissions form chunk
*
@@ -110,21 +111,29 @@ function submitPermissions() {
phpbb.alert(res.MESSAGE_TITLE, res.MESSAGE_TEXT);
permissionSubmitFailed = true;
} else if (!permissionSubmitFailed && res.S_USER_NOTICE) {
- // Fill list of selected forums
- if (typeof res.REFRESH_DATA !== 'undefined') {
- $.each(res.REFRESH_DATA.url.split('&'), function (key, value){
- var forumIdMatch = value.match(/^forum_id\[\]=([0-9]+)$/);
- if (forumIdMatch !== null) {
- forumIds.push(forumIdMatch[1]);
- // Remove added forum IDs from refresh URL
- res.REFRESH_DATA.url = res.REFRESH_DATA.url.replace('&' + forumIdMatch[0], '');
- }
- });
- }
-
// Display success message at the end of submitting the form
if (permissionRequestCount >= permissionSubmitSize) {
var $alert = phpbb.alert(res.MESSAGE_TITLE, res.MESSAGE_TEXT);
+ var $alertBoxLink = $alert.find('p.alert_text > a');
+
+ // Create form to submit instead of normal "Back to previous page" link
+ if ($alertBoxLink) {
+ // Remove forum_id[] from URL
+ $alertBoxLink.attr('href', $alertBoxLink.attr('href').replace(/(&forum_id\[\]=[0-9]+)/, ''));
+ var previousPageForm = '<form action="' + $alertBoxLink.attr('href') + '" method="post">';
+ $.each(forumIds, function (key, value) {
+ previousPageForm += '<input type="text" name="forum_id[]" value="' + value + '" />';
+ });
+ previousPageForm += '</form>';
+
+ $alertBoxLink.on('click', function (e) {
+ var $previousPageForm = $(previousPageForm);
+ $('body').append($previousPageForm);
+ e.preventDefault();
+ $previousPageForm.submit();
+ });
+ }
+
// Do not allow closing alert
$dark.off('click');
$alert.find('.alert_close').hide();
@@ -133,7 +142,7 @@ function submitPermissions() {
setTimeout(function () {
// Create forum to submit using POST. This will prevent
// exceeding the maximum length of URLs
- var form = '<form action="' + res.REFRESH_DATA.url + '" method="post">';
+ var form = '<form action="' + res.REFRESH_DATA.url.replace(/(&forum_id\[\]=[0-9]+)/, '') + '" method="post">';
$.each(forumIds, function (key, value) {
form += '<input type="text" name="forum_id[]" value="' + value + '" />';
});