diff options
-rw-r--r-- | phpBB/adm/style/acp_icons.html | 10 | ||||
-rw-r--r-- | phpBB/adm/style/acp_modules.html | 4 | ||||
-rw-r--r-- | phpBB/adm/style/acp_permission_roles.html | 19 | ||||
-rw-r--r-- | phpBB/adm/style/acp_profile.html | 16 | ||||
-rw-r--r-- | phpBB/adm/style/acp_reasons.html | 16 | ||||
-rw-r--r-- | phpBB/adm/style/ajax.js | 12 | ||||
-rw-r--r-- | phpBB/includes/acp/acp_icons.php | 11 | ||||
-rw-r--r-- | phpBB/includes/acp/acp_modules.php | 8 | ||||
-rw-r--r-- | phpBB/includes/acp/acp_permission_roles.php | 47 | ||||
-rw-r--r-- | phpBB/includes/acp/acp_profile.php | 56 | ||||
-rw-r--r-- | phpBB/includes/acp/acp_reasons.php | 25 |
11 files changed, 131 insertions, 93 deletions
diff --git a/phpBB/adm/style/acp_icons.html b/phpBB/adm/style/acp_icons.html index e96a9b86fa..9117052d87 100644 --- a/phpBB/adm/style/acp_icons.html +++ b/phpBB/adm/style/acp_icons.html @@ -242,10 +242,12 @@ <td style="text-align: center;">{items.CODE}</td> <td style="text-align: center;">{items.EMOTION}</td> <!-- ENDIF --> - <td style="text-align: right; white-space: nowrap;"> - <!-- IF items.S_FIRST_ROW and not U_PREVIOUS_PAGE -->{ICON_MOVE_UP_DISABLED}<!-- ELSE --><a href="{items.U_MOVE_UP}">{ICON_MOVE_UP}</a><!-- ENDIF --> - <!-- IF items.S_LAST_ROW and not U_NEXT_PAGE -->{ICON_MOVE_DOWN_DISABLED}<!-- ELSE --><a href="{items.U_MOVE_DOWN}">{ICON_MOVE_DOWN}</a><!-- ENDIF --> - <a href="{items.U_EDIT}">{ICON_EDIT}</a> <a href="{items.U_DELETE}" data-ajax="row_delete">{ICON_DELETE}</a> + <td class="actions" style="text-align: right;"> + <span class="up-disabled" style="display:none;">{ICON_MOVE_UP_DISABLED}</span> + <span class="up"><a href="{items.U_MOVE_UP}" data-ajax="row_up">{ICON_MOVE_UP}</a></span> + <span class="down-disabled" style="display:none;">{ICON_MOVE_DOWN_DISABLED}</span> + <span class="down"><a href="{items.U_MOVE_DOWN}" data-ajax="row_down">{ICON_MOVE_DOWN}</a></span> + <a href="{items.U_EDIT}">{ICON_EDIT}</a> <a href="{items.U_DELETE}" data-ajax="row_delete">{ICON_DELETE}</a> </td> </tr> <!-- BEGINELSE --> diff --git a/phpBB/adm/style/acp_modules.html b/phpBB/adm/style/acp_modules.html index 5024a950b9..c7688a610c 100644 --- a/phpBB/adm/style/acp_modules.html +++ b/phpBB/adm/style/acp_modules.html @@ -151,9 +151,9 @@ <td style="width: 15%; white-space: nowrap; text-align: center; vertical-align: middle;"> <!-- IF modules.MODULE_ENABLED --><a href="{modules.U_DISABLE}">{L_DISABLE}</a><!-- ELSE --><a href="{modules.U_ENABLE}">{L_ENABLE}</a><!-- ENDIF --> </td> <td class="actions"> <span class="up-disabled" style="display:none;">{ICON_MOVE_UP_DISABLED}</span> - <span class="up"><a href="{modules.U_MOVE_UP}">{ICON_MOVE_UP}</a></span> + <span class="up"><a href="{modules.U_MOVE_UP}" data-ajax="row_up">{ICON_MOVE_UP}</a></span> <span class="down-disabled" style="display:none;">{ICON_MOVE_DOWN_DISABLED}</span> - <span class="down"><a href="{modules.U_MOVE_DOWN}">{ICON_MOVE_DOWN}</a></span> + <span class="down"><a href="{modules.U_MOVE_DOWN}" data-ajax="row_down">{ICON_MOVE_DOWN}</a></span> <a href="{modules.U_EDIT}">{ICON_EDIT}</a> <a href="{modules.U_DELETE}" data-ajax="row_delete">{ICON_DELETE}</a> </td> diff --git a/phpBB/adm/style/acp_permission_roles.html b/phpBB/adm/style/acp_permission_roles.html index b8fdaeb837..b3137f134c 100644 --- a/phpBB/adm/style/acp_permission_roles.html +++ b/phpBB/adm/style/acp_permission_roles.html @@ -157,20 +157,11 @@ <!-- IF roles.ROLE_DESCRIPTION --><br /><span>{roles.ROLE_DESCRIPTION}</span><!-- ENDIF --> </td> <td style="width: 30%; text-align: center; vertical-align: top; white-space: nowrap;"><!-- IF roles.U_DISPLAY_ITEMS --><a href="{roles.U_DISPLAY_ITEMS}">{L_VIEW_ASSIGNED_ITEMS}</a><!-- ELSE -->{L_VIEW_ASSIGNED_ITEMS}<!-- ENDIF --></td> - <td style="width: 80px; text-align: right; vertical-align: top; white-space: nowrap;"> - <!-- IF roles.S_FIRST_ROW && not roles.S_LAST_ROW --> - {ICON_MOVE_UP_DISABLED} - <a href="{roles.U_MOVE_DOWN}">{ICON_MOVE_DOWN}</a> - <!-- ELSEIF not roles.S_FIRST_ROW && not roles.S_LAST_ROW--> - <a href="{roles.U_MOVE_UP}">{ICON_MOVE_UP}</a> - <a href="{roles.U_MOVE_DOWN}">{ICON_MOVE_DOWN}</a> - <!-- ELSEIF roles.S_LAST_ROW && not roles.S_FIRST_ROW --> - <a href="{roles.U_MOVE_UP}">{ICON_MOVE_UP}</a> - {ICON_MOVE_DOWN_DISABLED} - <!-- ELSE --> - {ICON_MOVE_UP_DISABLED} - {ICON_MOVE_DOWN_DISABLED} - <!-- ENDIF --> + <td class="actions"> + <span class="up-disabled" style="display:none;">{ICON_MOVE_UP_DISABLED}</span> + <span class="up"><a href="{roles.U_MOVE_UP}" data-ajax="row_up">{ICON_MOVE_UP}</a></span> + <span class="down-disabled" style="display:none;">{ICON_MOVE_DOWN_DISABLED}</span> + <span class="down"><a href="{roles.U_MOVE_DOWN}" data-ajax="row_down">{ICON_MOVE_DOWN}</a></span> <a href="{roles.U_EDIT}" title="{L_EDIT_ROLE}">{ICON_EDIT}</a> <a href="{roles.U_REMOVE}" title="{L_REMOVE_ROLE}" data-ajax="row_delete">{ICON_DELETE}</a> </td> diff --git a/phpBB/adm/style/acp_profile.html b/phpBB/adm/style/acp_profile.html index a5685668ba..44c9cb6d49 100644 --- a/phpBB/adm/style/acp_profile.html +++ b/phpBB/adm/style/acp_profile.html @@ -200,17 +200,11 @@ <td>{fields.FIELD_TYPE}</td> <td style="text-align: center;"><a href="{fields.U_ACTIVATE_DEACTIVATE}" data-ajax="activate_deactivate">{fields.L_ACTIVATE_DEACTIVATE}</a><!-- IF fields.S_NEED_EDIT --> | <a href="{fields.U_TRANSLATE}" style="color: red;">{L_TRANSLATE}</a><!-- ENDIF --></td> - <td style="width: 80px; text-align: right; white-space: nowrap;"> - <!-- IF fields.S_FIRST_ROW && not fields.S_LAST_ROW --> - {ICON_MOVE_UP_DISABLED} - <a href="{fields.U_MOVE_DOWN}">{ICON_MOVE_DOWN}</a> - <!-- ELSEIF not fields.S_FIRST_ROW && not fields.S_LAST_ROW--> - <a href="{fields.U_MOVE_UP}">{ICON_MOVE_UP}</a> - <a href="{fields.U_MOVE_DOWN}">{ICON_MOVE_DOWN}</a> - <!-- ELSEIF fields.S_LAST_ROW && not fields.S_FIRST_ROW --> - <a href="{fields.U_MOVE_UP}">{ICON_MOVE_UP}</a> - {ICON_MOVE_DOWN_DISABLED} - <!-- ENDIF --> + <td class="actions" style="width: 80px;"> + <span class="up-disabled" style="display:none;">{ICON_MOVE_UP_DISABLED}</span> + <span class="up"><a href="{fields.U_MOVE_UP}" data-ajax="row_up">{ICON_MOVE_UP}</a></span> + <span class="down-disabled" style="display:none;">{ICON_MOVE_DOWN_DISABLED}</span> + <span class="down"><a href="{fields.U_MOVE_DOWN}" data-ajax="row_down">{ICON_MOVE_DOWN}</a></span> <!-- IF not fields.S_NEED_EDIT --> <a href="{fields.U_EDIT}">{ICON_EDIT}</a> <!-- ELSE --> diff --git a/phpBB/adm/style/acp_reasons.html b/phpBB/adm/style/acp_reasons.html index ca3aebb338..d629a9553f 100644 --- a/phpBB/adm/style/acp_reasons.html +++ b/phpBB/adm/style/acp_reasons.html @@ -86,17 +86,11 @@ <br /><span>{reasons.REASON_DESCRIPTION}</span> </td> <td style="width: 100px;">{reasons.REASON_COUNT}</td> - <td style="width: 80px; text-align: right; white-space: nowrap;"> - <!-- IF reasons.S_FIRST_ROW && not reasons.S_LAST_ROW --> - {ICON_MOVE_UP_DISABLED} - <a href="{reasons.U_MOVE_DOWN}">{ICON_MOVE_DOWN}</a> - <!-- ELSEIF not reasons.S_FIRST_ROW && not reasons.S_LAST_ROW--> - <a href="{reasons.U_MOVE_UP}">{ICON_MOVE_UP}</a> - <a href="{reasons.U_MOVE_DOWN}">{ICON_MOVE_DOWN}</a> - <!-- ELSEIF reasons.S_LAST_ROW && not reasons.S_FIRST_ROW --> - <a href="{reasons.U_MOVE_UP}">{ICON_MOVE_UP}</a> - {ICON_MOVE_DOWN_DISABLED} - <!-- ENDIF --> + <td class="actions" style="width: 80px;"> + <span class="up-disabled" style="display:none;">{ICON_MOVE_UP_DISABLED}</span> + <span class="up"><a href="{reasons.U_MOVE_UP}" data-ajax="row_up">{ICON_MOVE_UP}</a></span> + <span class="down-disabled" style="display:none;">{ICON_MOVE_DOWN_DISABLED}</span> + <span class="down"><a href="{reasons.U_MOVE_DOWN}" data-ajax="row_down">{ICON_MOVE_DOWN}</a></span> <a href="{reasons.U_EDIT}">{ICON_EDIT}</a> <!-- IF reasons.U_DELETE --> <a href="{reasons.U_DELETE}" data-ajax="row_delete">{ICON_DELETE}</a> diff --git a/phpBB/adm/style/ajax.js b/phpBB/adm/style/ajax.js index 78fcbd88fd..959580d6c2 100644 --- a/phpBB/adm/style/ajax.js +++ b/phpBB/adm/style/ajax.js @@ -8,7 +8,11 @@ * an item is moved up. It moves the row up or down, and deactivates / * activates any up / down icons that require it (the ones at the top or bottom). */ -phpbb.addAjaxCallback('row_down', function() { +phpbb.addAjaxCallback('row_down', function(res) { + if (typeof res.success === 'undefined' || !res.success) { + return; + } + var el = $(this), tr = el.parents('tr'), trSwap = tr.next(); @@ -16,7 +20,11 @@ phpbb.addAjaxCallback('row_down', function() { tr.insertAfter(trSwap); }); -phpbb.addAjaxCallback('row_up', function() { +phpbb.addAjaxCallback('row_up', function(res) { + if (typeof res.success === 'undefined' || !res.success) { + return; + } + var el = $(this), tr = el.parents('tr'), trSwap = tr.prev(); diff --git a/phpBB/includes/acp/acp_icons.php b/phpBB/includes/acp/acp_icons.php index f9295e2b47..20b1f56182 100644 --- a/phpBB/includes/acp/acp_icons.php +++ b/phpBB/includes/acp/acp_icons.php @@ -832,9 +832,10 @@ class acp_icons WHERE {$fields}_order = $switch_order_id AND {$fields}_id <> $icon_id"; $db->sql_query($sql); + $move_executed = (bool) $db->sql_affectedrows(); // Only update the other entry too if the previous entry got updated - if ($db->sql_affectedrows()) + if ($move_executed) { $sql = "UPDATE $table SET {$fields}_order = $switch_order_id @@ -846,6 +847,14 @@ class acp_icons $cache->destroy('_icons'); $cache->destroy('sql', $table); + if ($request->is_ajax()) + { + $json_response = new \phpbb\json_response; + $json_response->send(array( + 'success' => $move_executed, + )); + } + break; } diff --git a/phpBB/includes/acp/acp_modules.php b/phpBB/includes/acp/acp_modules.php index 100e33044b..c124377ba9 100644 --- a/phpBB/includes/acp/acp_modules.php +++ b/phpBB/includes/acp/acp_modules.php @@ -170,6 +170,14 @@ class acp_modules $this->remove_cache_file(); } + if ($request->is_ajax()) + { + $json_response = new \phpbb\json_response; + $json_response->send(array( + 'success' => ($move_module_name !== false), + )); + } + break; case 'quickadd': diff --git a/phpBB/includes/acp/acp_permission_roles.php b/phpBB/includes/acp/acp_permission_roles.php index 17e48d6576..aca45575d3 100644 --- a/phpBB/includes/acp/acp_permission_roles.php +++ b/phpBB/includes/acp/acp_permission_roles.php @@ -27,6 +27,7 @@ class acp_permission_roles { global $db, $user, $auth, $template, $cache, $phpbb_container; global $config, $phpbb_root_path, $phpbb_admin_path, $phpEx; + global $request; include_once($phpbb_root_path . 'includes/functions_user.' . $phpEx); include_once($phpbb_root_path . 'includes/acp/auth.' . $phpEx); @@ -46,6 +47,11 @@ class acp_permission_roles $form_name = 'acp_permissions'; add_form_key($form_name); + if (!$role_id && in_array($action, array('remove', 'edit', 'move_up', 'move_down'))) + { + trigger_error($user->lang['NO_ROLE_SELECTED'] . adm_back_link($this->u_action), E_USER_WARNING); + } + switch ($mode) { case 'admin_roles': @@ -85,11 +91,6 @@ class acp_permission_roles { case 'remove': - if (!$role_id) - { - trigger_error($user->lang['NO_ROLE_SELECTED'] . adm_back_link($this->u_action), E_USER_WARNING); - } - $sql = 'SELECT * FROM ' . ACL_ROLES_TABLE . ' WHERE role_id = ' . $role_id; @@ -123,10 +124,6 @@ class acp_permission_roles break; case 'edit': - if (!$role_id) - { - trigger_error($user->lang['NO_ROLE_SELECTED'] . adm_back_link($this->u_action), E_USER_WARNING); - } // Get role we edit $sql = 'SELECT * @@ -273,12 +270,7 @@ class acp_permission_roles case 'edit': if ($action == 'edit') - { - if (!$role_id) - { - trigger_error($user->lang['NO_ROLE_SELECTED'] . adm_back_link($this->u_action), E_USER_WARNING); - } - + { $sql = 'SELECT * FROM ' . ACL_ROLES_TABLE . ' WHERE role_id = ' . $role_id; @@ -366,7 +358,18 @@ class acp_permission_roles case 'move_up': case 'move_down': - $order = request_var('order', 0); + $sql = 'SELECT role_order + FROM ' . ACL_ROLES_TABLE . " + WHERE role_id = $role_id"; + $result = $db->sql_query($sql); + $order = $db->sql_fetchfield('role_order'); + $db->sql_freeresult($result); + + if ($order === false || ($order == 0 && $action == 'move_up')) + { + break; + } + $order = (int) $order; $order_total = $order * 2 + (($action == 'move_up') ? -1 : 1); $sql = 'UPDATE ' . ACL_ROLES_TABLE . ' @@ -375,6 +378,14 @@ class acp_permission_roles AND role_order IN ($order, " . (($action == 'move_up') ? $order - 1 : $order + 1) . ')'; $db->sql_query($sql); + if ($request->is_ajax()) + { + $json_response = new \phpbb\json_response; + $json_response->send(array( + 'success' => (bool) $db->sql_affectedrows(), + )); + } + break; } @@ -421,8 +432,8 @@ class acp_permission_roles 'U_EDIT' => $this->u_action . '&action=edit&role_id=' . $row['role_id'], 'U_REMOVE' => $this->u_action . '&action=remove&role_id=' . $row['role_id'], - 'U_MOVE_UP' => $this->u_action . '&action=move_up&order=' . $row['role_order'], - 'U_MOVE_DOWN' => $this->u_action . '&action=move_down&order=' . $row['role_order'], + 'U_MOVE_UP' => $this->u_action . '&action=move_up&role_id=' . $row['role_id'], + 'U_MOVE_DOWN' => $this->u_action . '&action=move_down&role_id=' . $row['role_id'], 'U_DISPLAY_ITEMS' => ($row['role_id'] == $display_item) ? '' : $this->u_action . '&display_item=' . $row['role_id'] . '#assigned_to') ); diff --git a/phpBB/includes/acp/acp_profile.php b/phpBB/includes/acp/acp_profile.php index 4e8145009f..6efd778b12 100644 --- a/phpBB/includes/acp/acp_profile.php +++ b/phpBB/includes/acp/acp_profile.php @@ -39,11 +39,17 @@ class acp_profile $this->tpl_name = 'acp_profile'; $this->page_title = 'ACP_CUSTOM_PROFILE_FIELDS'; + $field_id = $request->variable('field_id', 0); $action = (isset($_POST['create'])) ? 'create' : request_var('action', ''); $error = array(); $s_hidden_fields = ''; + if (!$field_id && in_array($action, array('delete','activate', 'deactivate', 'move_up', 'move_down', 'edit'))) + { + trigger_error($user->lang['NO_FIELD_ID'] . adm_back_link($this->u_action), E_USER_WARNING); + } + // Define some default values for each field type $default_values = array( FIELD_STRING => array('field_length' => 10, 'field_minlen' => 0, 'field_maxlen' => 20, 'field_validation' => '.*', 'field_novalue' => '', 'field_default_value' => ''), @@ -98,12 +104,6 @@ class acp_profile switch ($action) { case 'delete': - $field_id = request_var('field_id', 0); - - if (!$field_id) - { - trigger_error($user->lang['NO_FIELD_ID'] . adm_back_link($this->u_action), E_USER_WARNING); - } if (confirm_box(true)) { @@ -210,12 +210,6 @@ class acp_profile break; case 'activate': - $field_id = request_var('field_id', 0); - - if (!$field_id) - { - trigger_error($user->lang['NO_FIELD_ID'] . adm_back_link($this->u_action), E_USER_WARNING); - } $sql = 'SELECT lang_id FROM ' . LANG_TABLE . " @@ -256,12 +250,6 @@ class acp_profile break; case 'deactivate': - $field_id = request_var('field_id', 0); - - if (!$field_id) - { - trigger_error($user->lang['NO_FIELD_ID'] . adm_back_link($this->u_action), E_USER_WARNING); - } $sql = 'UPDATE ' . PROFILE_FIELDS_TABLE . " SET field_active = 0 @@ -291,7 +279,19 @@ class acp_profile case 'move_up': case 'move_down': - $field_order = request_var('order', 0); + + $sql = 'SELECT field_order + FROM ' . PROFILE_FIELDS_TABLE . " + WHERE field_id = $field_id"; + $result = $db->sql_query($sql); + $field_order = $db->sql_fetchfield('field_order'); + $db->sql_freeresult($result); + + if ($field_order === false || ($field_order == 0 && $action == 'move_up')) + { + break; + } + $field_order = (int) $field_order; $order_total = $field_order * 2 + (($action == 'move_up') ? -1 : 1); $sql = 'UPDATE ' . PROFILE_FIELDS_TABLE . " @@ -299,12 +299,19 @@ class acp_profile WHERE field_order IN ($field_order, " . (($action == 'move_up') ? $field_order - 1 : $field_order + 1) . ')'; $db->sql_query($sql); + if ($request->is_ajax()) + { + $json_response = new \phpbb\json_response; + $json_response->send(array( + 'success' => (bool) $db->sql_affectedrows(), + )); + } + break; case 'create': case 'edit': - $field_id = request_var('field_id', 0); $step = request_var('step', 1); $submit = (isset($_REQUEST['next']) || isset($_REQUEST['prev'])) ? true : false; @@ -316,11 +323,6 @@ class acp_profile // We are editing... we need to grab basic things if ($action == 'edit') { - if (!$field_id) - { - trigger_error($user->lang['NO_FIELD_ID'] . adm_back_link($this->u_action), E_USER_WARNING); - } - $sql = 'SELECT l.*, f.* FROM ' . PROFILE_LANG_TABLE . ' l, ' . PROFILE_FIELDS_TABLE . ' f WHERE l.lang_id = ' . $this->edit_lang_id . " @@ -919,8 +921,8 @@ class acp_profile 'U_EDIT' => $this->u_action . "&action=edit&field_id=$id", 'U_TRANSLATE' => $this->u_action . "&action=edit&field_id=$id&step=3", 'U_DELETE' => $this->u_action . "&action=delete&field_id=$id", - 'U_MOVE_UP' => $this->u_action . "&action=move_up&order={$row['field_order']}", - 'U_MOVE_DOWN' => $this->u_action . "&action=move_down&order={$row['field_order']}", + 'U_MOVE_UP' => $this->u_action . "&action=move_up&field_id=$id", + 'U_MOVE_DOWN' => $this->u_action . "&action=move_down&field_id=$id", 'S_NEED_EDIT' => $s_need_edit) ); diff --git a/phpBB/includes/acp/acp_reasons.php b/phpBB/includes/acp/acp_reasons.php index 71e9108c2c..569bb73ab0 100644 --- a/phpBB/includes/acp/acp_reasons.php +++ b/phpBB/includes/acp/acp_reasons.php @@ -26,6 +26,7 @@ class acp_reasons { global $db, $user, $auth, $template, $cache; global $config, $phpbb_root_path, $phpbb_admin_path, $phpEx; + global $request; $user->add_lang(array('mcp', 'acp/posting')); @@ -280,7 +281,18 @@ class acp_reasons case 'move_up': case 'move_down': - $order = request_var('order', 0); + $sql = 'SELECT reason_order + FROM ' . REPORTS_REASONS_TABLE . " + WHERE reason_id = $reason_id"; + $result = $db->sql_query($sql); + $order = $db->sql_fetchfield('reason_order'); + $db->sql_freeresult($result); + + if ($order === false || ($order == 0 && $action == 'move_up')) + { + break; + } + $order = (int) $order; $order_total = $order * 2 + (($action == 'move_up') ? -1 : 1); $sql = 'UPDATE ' . REPORTS_REASONS_TABLE . ' @@ -288,6 +300,13 @@ class acp_reasons WHERE reason_order IN (' . $order . ', ' . (($action == 'move_up') ? $order - 1 : $order + 1) . ')'; $db->sql_query($sql); + if ($request->is_ajax()) + { + $json_response = new \phpbb\json_response; + $json_response->send(array( + 'success' => (bool) $db->sql_affectedrows(), + )); + } break; } @@ -363,8 +382,8 @@ class acp_reasons 'U_EDIT' => $this->u_action . '&action=edit&id=' . $row['reason_id'], 'U_DELETE' => (!$other_reason) ? $this->u_action . '&action=delete&id=' . $row['reason_id'] : '', - 'U_MOVE_UP' => $this->u_action . '&action=move_up&order=' . $row['reason_order'], - 'U_MOVE_DOWN' => $this->u_action . '&action=move_down&order=' . $row['reason_order']) + 'U_MOVE_UP' => $this->u_action . '&action=move_up&id=' . $row['reason_id'], + 'U_MOVE_DOWN' => $this->u_action . '&action=move_down&id=' . $row['reason_id']) ); } $db->sql_freeresult($result); |