aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB
diff options
context:
space:
mode:
Diffstat (limited to 'phpBB')
-rw-r--r--phpBB/adm/style/ajax.js78
-rw-r--r--phpBB/includes/acp/acp_permissions.php5
2 files changed, 83 insertions, 0 deletions
diff --git a/phpBB/adm/style/ajax.js b/phpBB/adm/style/ajax.js
index 4ad6b6afa5..42dcbe6de8 100644
--- a/phpBB/adm/style/ajax.js
+++ b/phpBB/adm/style/ajax.js
@@ -62,7 +62,77 @@ phpbb.addAjaxCallback('row_delete', function(res) {
}
});
+/**
+ * Handler for submitting permissions form in chunks
+ * This call will submit permissions forms in chunks of 5 fieldsets.
+ */
+function submitPermissions() {
+ var $form = $('form#set-permissions'),
+ fieldsetList = $form.find('fieldset[id^=perm]'),
+ formDataSets = [],
+ $submitAllButton = $form.find('input[type=submit][name^=action]')[0];
+
+ $.each(fieldsetList, function (key, value) {
+ if (key % 5 === 0) {
+ formDataSets[Math.floor(key / 5)] = $form.find('fieldset#' + value.id + ' input').serialize();
+ } else {
+ formDataSets[Math.floor(key / 5)] += '&' + $form.find('fieldset#' + value.id + ' input').serialize();
+ }
+ });
+
+ // Set proper start values for handling refresh of page
+ var permissionSubmitSize = formDataSets.length,
+ permissionRequestCount = 0,
+ permissionSubmitFailed = false;
+
+ /**
+ * Handler for submitted permissions form chunk
+ *
+ * @param {object} res Object returned by AJAX call
+ */
+ function handlePermissionReturn(res) {
+ permissionRequestCount++;
+ var $dark = $('#darkenwrapper');
+
+ if (res.S_USER_WARNING) {
+ phpbb.alert(res.MESSAGE_TITLE, res.MESSAGE_TEXT);
+ permissionSubmitFailed = true;
+ } else if (!permissionSubmitFailed && res.S_USER_NOTICE) {
+ if (permissionRequestCount >= permissionSubmitSize) {
+ var $alert = phpbb.alert(res.MESSAGE_TITLE, res.MESSAGE_TEXT);
+ // Do not allow closing alert
+ $dark.off('click');
+ $alert.find('.alert_close').hide();
+
+ if (typeof res.REFRESH_DATA !== 'undefined') {
+ setTimeout(function () {
+ window.location = res.REFRESH_DATA.url;
+
+ // Hide the alert even if we refresh the page, in case the user
+ // presses the back button.
+ $dark.fadeOut(phpbb.alertTime, function () {
+ if (typeof $alert !== 'undefined') {
+ $alert.hide();
+ }
+ });
+ }, res.REFRESH_DATA.time * 1000); // Server specifies time in seconds
+ }
+ }
+ }
+ }
+ $.each(formDataSets, function (key, formData) {
+ $.ajax({
+ url: $form.action,
+ type: 'POST',
+ data: formData + '&' + $submitAllButton.name + '=' + encodeURIComponent($submitAllButton.value) +
+ '&creation_time=' + $form.find('input[type=hidden][name=creation_time]')[0].value +
+ '&form_token=' + $form.find('input[type=hidden][name=form_token]')[0].value,
+ success: handlePermissionReturn,
+ error: handlePermissionReturn
+ });
+ });
+}
$('[data-ajax]').each(function() {
var $this = $(this),
@@ -83,6 +153,14 @@ $('[data-ajax]').each(function() {
*/
$(function() {
phpbb.resizeTextArea($('textarea:not(.no-auto-resize)'), {minHeight: 75});
+
+ var $setPermissionsForm = $('form#set-permissions');
+ if ($setPermissionsForm.length) {
+ $setPermissionsForm.on('submit', function (e) {
+ submitPermissions();
+ e.preventDefault();
+ });
+ }
});
diff --git a/phpBB/includes/acp/acp_permissions.php b/phpBB/includes/acp/acp_permissions.php
index 660afb4e93..62e75a2db7 100644
--- a/phpBB/includes/acp/acp_permissions.php
+++ b/phpBB/includes/acp/acp_permissions.php
@@ -755,6 +755,7 @@ class acp_permissions
$this->log_action($mode, 'add', $permission_type, $ug_type, $ug_id, $forum_id);
+ meta_refresh(5, $this->u_action);
trigger_error($user->lang['AUTH_UPDATED'] . adm_back_link($this->u_action));
}
@@ -825,10 +826,12 @@ class acp_permissions
if ($mode == 'setting_forum_local' || $mode == 'setting_mod_local')
{
+ meta_refresh(5, $this->u_action . '&forum_id[]=' . implode('&forum_id[]=', $forum_ids));
trigger_error($user->lang['AUTH_UPDATED'] . adm_back_link($this->u_action . '&forum_id[]=' . implode('&forum_id[]=', $forum_ids)));
}
else
{
+ meta_refresh(5, $this->u_action);
trigger_error($user->lang['AUTH_UPDATED'] . adm_back_link($this->u_action));
}
}
@@ -899,10 +902,12 @@ class acp_permissions
if ($mode == 'setting_forum_local' || $mode == 'setting_mod_local')
{
+ meta_refresh(5, $this->u_action . '&forum_id[]=' . implode('&forum_id[]=', $forum_id));
trigger_error($user->lang['AUTH_UPDATED'] . adm_back_link($this->u_action . '&forum_id[]=' . implode('&forum_id[]=', $forum_id)));
}
else
{
+ meta_refresh(5, $this->u_action);
trigger_error($user->lang['AUTH_UPDATED'] . adm_back_link($this->u_action));
}
}