1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-05-07 08:05:25 +02:00

Merge pull request #1920 from prototech/ticket/12038

[ticket/12038] AJAXify move up/down buttons for various ACP pages.
This commit is contained in:
Nathan Guse 2013-12-30 11:23:22 -08:00
commit b186d31ce6
11 changed files with 131 additions and 93 deletions

View File

@ -242,10 +242,12 @@
<td style="text-align: center;">{items.CODE}</td> <td style="text-align: center;">{items.CODE}</td>
<td style="text-align: center;">{items.EMOTION}</td> <td style="text-align: center;">{items.EMOTION}</td>
<!-- ENDIF --> <!-- ENDIF -->
<td style="text-align: right; white-space: nowrap;"> <td class="actions" style="text-align: right;">
<!-- 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 -->&nbsp; <span class="up-disabled" style="display:none;">{ICON_MOVE_UP_DISABLED}</span>
<!-- 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 --> <span class="up"><a href="{items.U_MOVE_UP}" data-ajax="row_up">{ICON_MOVE_UP}</a></span>
&nbsp;<a href="{items.U_EDIT}">{ICON_EDIT}</a> <a href="{items.U_DELETE}" data-ajax="row_delete">{ICON_DELETE}</a> <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> </td>
</tr> </tr>
<!-- BEGINELSE --> <!-- BEGINELSE -->

View File

@ -151,9 +151,9 @@
<td style="width: 15%; white-space: nowrap; text-align: center; vertical-align: middle;">&nbsp;<!-- IF modules.MODULE_ENABLED --><a href="{modules.U_DISABLE}">{L_DISABLE}</a><!-- ELSE --><a href="{modules.U_ENABLE}">{L_ENABLE}</a><!-- ENDIF -->&nbsp;</td> <td style="width: 15%; white-space: nowrap; text-align: center; vertical-align: middle;">&nbsp;<!-- IF modules.MODULE_ENABLED --><a href="{modules.U_DISABLE}">{L_DISABLE}</a><!-- ELSE --><a href="{modules.U_ENABLE}">{L_ENABLE}</a><!-- ENDIF -->&nbsp;</td>
<td class="actions"> <td class="actions">
<span class="up-disabled" style="display:none;">{ICON_MOVE_UP_DISABLED}</span> <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-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_EDIT}">{ICON_EDIT}</a>
<a href="{modules.U_DELETE}" data-ajax="row_delete">{ICON_DELETE}</a> <a href="{modules.U_DELETE}" data-ajax="row_delete">{ICON_DELETE}</a>
</td> </td>

View File

@ -157,20 +157,11 @@
<!-- IF roles.ROLE_DESCRIPTION --><br /><span>{roles.ROLE_DESCRIPTION}</span><!-- ENDIF --> <!-- IF roles.ROLE_DESCRIPTION --><br /><span>{roles.ROLE_DESCRIPTION}</span><!-- ENDIF -->
</td> </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: 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;"> <td class="actions">
<!-- IF roles.S_FIRST_ROW && not roles.S_LAST_ROW --> <span class="up-disabled" style="display:none;">{ICON_MOVE_UP_DISABLED}</span>
{ICON_MOVE_UP_DISABLED} <span class="up"><a href="{roles.U_MOVE_UP}" data-ajax="row_up">{ICON_MOVE_UP}</a></span>
<a href="{roles.U_MOVE_DOWN}">{ICON_MOVE_DOWN}</a> <span class="down-disabled" style="display:none;">{ICON_MOVE_DOWN_DISABLED}</span>
<!-- ELSEIF not roles.S_FIRST_ROW && not roles.S_LAST_ROW--> <span class="down"><a href="{roles.U_MOVE_DOWN}" data-ajax="row_down">{ICON_MOVE_DOWN}</a></span>
<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 -->
<a href="{roles.U_EDIT}" title="{L_EDIT_ROLE}">{ICON_EDIT}</a> <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> <a href="{roles.U_REMOVE}" title="{L_REMOVE_ROLE}" data-ajax="row_delete">{ICON_DELETE}</a>
</td> </td>

View File

@ -200,17 +200,11 @@
<td>{fields.FIELD_TYPE}</td> <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="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;"> <td class="actions" style="width: 80px;">
<!-- IF fields.S_FIRST_ROW && not fields.S_LAST_ROW --> <span class="up-disabled" style="display:none;">{ICON_MOVE_UP_DISABLED}</span>
{ICON_MOVE_UP_DISABLED} <span class="up"><a href="{fields.U_MOVE_UP}" data-ajax="row_up">{ICON_MOVE_UP}</a></span>
<a href="{fields.U_MOVE_DOWN}">{ICON_MOVE_DOWN}</a> <span class="down-disabled" style="display:none;">{ICON_MOVE_DOWN_DISABLED}</span>
<!-- ELSEIF not fields.S_FIRST_ROW && not fields.S_LAST_ROW--> <span class="down"><a href="{fields.U_MOVE_DOWN}" data-ajax="row_down">{ICON_MOVE_DOWN}</a></span>
<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 -->
<!-- IF not fields.S_NEED_EDIT --> <!-- IF not fields.S_NEED_EDIT -->
<a href="{fields.U_EDIT}">{ICON_EDIT}</a> <a href="{fields.U_EDIT}">{ICON_EDIT}</a>
<!-- ELSE --> <!-- ELSE -->

View File

@ -86,17 +86,11 @@
<br /><span>{reasons.REASON_DESCRIPTION}</span> <br /><span>{reasons.REASON_DESCRIPTION}</span>
</td> </td>
<td style="width: 100px;">{reasons.REASON_COUNT}</td> <td style="width: 100px;">{reasons.REASON_COUNT}</td>
<td style="width: 80px; text-align: right; white-space: nowrap;"> <td class="actions" style="width: 80px;">
<!-- IF reasons.S_FIRST_ROW && not reasons.S_LAST_ROW --> <span class="up-disabled" style="display:none;">{ICON_MOVE_UP_DISABLED}</span>
{ICON_MOVE_UP_DISABLED} <span class="up"><a href="{reasons.U_MOVE_UP}" data-ajax="row_up">{ICON_MOVE_UP}</a></span>
<a href="{reasons.U_MOVE_DOWN}">{ICON_MOVE_DOWN}</a> <span class="down-disabled" style="display:none;">{ICON_MOVE_DOWN_DISABLED}</span>
<!-- ELSEIF not reasons.S_FIRST_ROW && not reasons.S_LAST_ROW--> <span class="down"><a href="{reasons.U_MOVE_DOWN}" data-ajax="row_down">{ICON_MOVE_DOWN}</a></span>
<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 -->
<a href="{reasons.U_EDIT}">{ICON_EDIT}</a> <a href="{reasons.U_EDIT}">{ICON_EDIT}</a>
<!-- IF reasons.U_DELETE --> <!-- IF reasons.U_DELETE -->
<a href="{reasons.U_DELETE}" data-ajax="row_delete">{ICON_DELETE}</a> <a href="{reasons.U_DELETE}" data-ajax="row_delete">{ICON_DELETE}</a>

View File

@ -8,7 +8,11 @@
* an item is moved up. It moves the row up or down, and deactivates / * 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). * 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), var el = $(this),
tr = el.parents('tr'), tr = el.parents('tr'),
trSwap = tr.next(); trSwap = tr.next();
@ -16,7 +20,11 @@ phpbb.addAjaxCallback('row_down', function() {
tr.insertAfter(trSwap); 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), var el = $(this),
tr = el.parents('tr'), tr = el.parents('tr'),
trSwap = tr.prev(); trSwap = tr.prev();

View File

@ -832,9 +832,10 @@ class acp_icons
WHERE {$fields}_order = $switch_order_id WHERE {$fields}_order = $switch_order_id
AND {$fields}_id <> $icon_id"; AND {$fields}_id <> $icon_id";
$db->sql_query($sql); $db->sql_query($sql);
$move_executed = (bool) $db->sql_affectedrows();
// Only update the other entry too if the previous entry got updated // Only update the other entry too if the previous entry got updated
if ($db->sql_affectedrows()) if ($move_executed)
{ {
$sql = "UPDATE $table $sql = "UPDATE $table
SET {$fields}_order = $switch_order_id SET {$fields}_order = $switch_order_id
@ -846,6 +847,14 @@ class acp_icons
$cache->destroy('_icons'); $cache->destroy('_icons');
$cache->destroy('sql', $table); $cache->destroy('sql', $table);
if ($request->is_ajax())
{
$json_response = new \phpbb\json_response;
$json_response->send(array(
'success' => $move_executed,
));
}
break; break;
} }

View File

@ -170,6 +170,14 @@ class acp_modules
$this->remove_cache_file(); $this->remove_cache_file();
} }
if ($request->is_ajax())
{
$json_response = new \phpbb\json_response;
$json_response->send(array(
'success' => ($move_module_name !== false),
));
}
break; break;
case 'quickadd': case 'quickadd':

View File

@ -27,6 +27,7 @@ class acp_permission_roles
{ {
global $db, $user, $auth, $template, $cache, $phpbb_container; global $db, $user, $auth, $template, $cache, $phpbb_container;
global $config, $phpbb_root_path, $phpbb_admin_path, $phpEx; 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/functions_user.' . $phpEx);
include_once($phpbb_root_path . 'includes/acp/auth.' . $phpEx); include_once($phpbb_root_path . 'includes/acp/auth.' . $phpEx);
@ -46,6 +47,11 @@ class acp_permission_roles
$form_name = 'acp_permissions'; $form_name = 'acp_permissions';
add_form_key($form_name); 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) switch ($mode)
{ {
case 'admin_roles': case 'admin_roles':
@ -85,11 +91,6 @@ class acp_permission_roles
{ {
case 'remove': case 'remove':
if (!$role_id)
{
trigger_error($user->lang['NO_ROLE_SELECTED'] . adm_back_link($this->u_action), E_USER_WARNING);
}
$sql = 'SELECT * $sql = 'SELECT *
FROM ' . ACL_ROLES_TABLE . ' FROM ' . ACL_ROLES_TABLE . '
WHERE role_id = ' . $role_id; WHERE role_id = ' . $role_id;
@ -123,10 +124,6 @@ class acp_permission_roles
break; break;
case 'edit': 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 // Get role we edit
$sql = 'SELECT * $sql = 'SELECT *
@ -273,12 +270,7 @@ class acp_permission_roles
case 'edit': case 'edit':
if ($action == '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 * $sql = 'SELECT *
FROM ' . ACL_ROLES_TABLE . ' FROM ' . ACL_ROLES_TABLE . '
WHERE role_id = ' . $role_id; WHERE role_id = ' . $role_id;
@ -366,7 +358,18 @@ class acp_permission_roles
case 'move_up': case 'move_up':
case 'move_down': 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); $order_total = $order * 2 + (($action == 'move_up') ? -1 : 1);
$sql = 'UPDATE ' . ACL_ROLES_TABLE . ' $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) . ')'; AND role_order IN ($order, " . (($action == 'move_up') ? $order - 1 : $order + 1) . ')';
$db->sql_query($sql); $db->sql_query($sql);
if ($request->is_ajax())
{
$json_response = new \phpbb\json_response;
$json_response->send(array(
'success' => (bool) $db->sql_affectedrows(),
));
}
break; break;
} }
@ -421,8 +432,8 @@ class acp_permission_roles
'U_EDIT' => $this->u_action . '&amp;action=edit&amp;role_id=' . $row['role_id'], 'U_EDIT' => $this->u_action . '&amp;action=edit&amp;role_id=' . $row['role_id'],
'U_REMOVE' => $this->u_action . '&amp;action=remove&amp;role_id=' . $row['role_id'], 'U_REMOVE' => $this->u_action . '&amp;action=remove&amp;role_id=' . $row['role_id'],
'U_MOVE_UP' => $this->u_action . '&amp;action=move_up&amp;order=' . $row['role_order'], 'U_MOVE_UP' => $this->u_action . '&amp;action=move_up&amp;role_id=' . $row['role_id'],
'U_MOVE_DOWN' => $this->u_action . '&amp;action=move_down&amp;order=' . $row['role_order'], 'U_MOVE_DOWN' => $this->u_action . '&amp;action=move_down&amp;role_id=' . $row['role_id'],
'U_DISPLAY_ITEMS' => ($row['role_id'] == $display_item) ? '' : $this->u_action . '&amp;display_item=' . $row['role_id'] . '#assigned_to') 'U_DISPLAY_ITEMS' => ($row['role_id'] == $display_item) ? '' : $this->u_action . '&amp;display_item=' . $row['role_id'] . '#assigned_to')
); );

View File

@ -39,11 +39,17 @@ class acp_profile
$this->tpl_name = 'acp_profile'; $this->tpl_name = 'acp_profile';
$this->page_title = 'ACP_CUSTOM_PROFILE_FIELDS'; $this->page_title = 'ACP_CUSTOM_PROFILE_FIELDS';
$field_id = $request->variable('field_id', 0);
$action = (isset($_POST['create'])) ? 'create' : request_var('action', ''); $action = (isset($_POST['create'])) ? 'create' : request_var('action', '');
$error = array(); $error = array();
$s_hidden_fields = ''; $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 // Define some default values for each field type
$default_values = array( $default_values = array(
FIELD_STRING => array('field_length' => 10, 'field_minlen' => 0, 'field_maxlen' => 20, 'field_validation' => '.*', 'field_novalue' => '', 'field_default_value' => ''), 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) switch ($action)
{ {
case 'delete': 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)) if (confirm_box(true))
{ {
@ -210,12 +210,6 @@ class acp_profile
break; break;
case 'activate': 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 $sql = 'SELECT lang_id
FROM ' . LANG_TABLE . " FROM ' . LANG_TABLE . "
@ -256,12 +250,6 @@ class acp_profile
break; break;
case 'deactivate': 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 . " $sql = 'UPDATE ' . PROFILE_FIELDS_TABLE . "
SET field_active = 0 SET field_active = 0
@ -291,7 +279,19 @@ class acp_profile
case 'move_up': case 'move_up':
case 'move_down': 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); $order_total = $field_order * 2 + (($action == 'move_up') ? -1 : 1);
$sql = 'UPDATE ' . PROFILE_FIELDS_TABLE . " $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) . ')'; WHERE field_order IN ($field_order, " . (($action == 'move_up') ? $field_order - 1 : $field_order + 1) . ')';
$db->sql_query($sql); $db->sql_query($sql);
if ($request->is_ajax())
{
$json_response = new \phpbb\json_response;
$json_response->send(array(
'success' => (bool) $db->sql_affectedrows(),
));
}
break; break;
case 'create': case 'create':
case 'edit': case 'edit':
$field_id = request_var('field_id', 0);
$step = request_var('step', 1); $step = request_var('step', 1);
$submit = (isset($_REQUEST['next']) || isset($_REQUEST['prev'])) ? true : false; $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 // We are editing... we need to grab basic things
if ($action == 'edit') 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.* $sql = 'SELECT l.*, f.*
FROM ' . PROFILE_LANG_TABLE . ' l, ' . PROFILE_FIELDS_TABLE . ' f FROM ' . PROFILE_LANG_TABLE . ' l, ' . PROFILE_FIELDS_TABLE . ' f
WHERE l.lang_id = ' . $this->edit_lang_id . " WHERE l.lang_id = ' . $this->edit_lang_id . "
@ -919,8 +921,8 @@ class acp_profile
'U_EDIT' => $this->u_action . "&amp;action=edit&amp;field_id=$id", 'U_EDIT' => $this->u_action . "&amp;action=edit&amp;field_id=$id",
'U_TRANSLATE' => $this->u_action . "&amp;action=edit&amp;field_id=$id&amp;step=3", 'U_TRANSLATE' => $this->u_action . "&amp;action=edit&amp;field_id=$id&amp;step=3",
'U_DELETE' => $this->u_action . "&amp;action=delete&amp;field_id=$id", 'U_DELETE' => $this->u_action . "&amp;action=delete&amp;field_id=$id",
'U_MOVE_UP' => $this->u_action . "&amp;action=move_up&amp;order={$row['field_order']}", 'U_MOVE_UP' => $this->u_action . "&amp;action=move_up&amp;field_id=$id",
'U_MOVE_DOWN' => $this->u_action . "&amp;action=move_down&amp;order={$row['field_order']}", 'U_MOVE_DOWN' => $this->u_action . "&amp;action=move_down&amp;field_id=$id",
'S_NEED_EDIT' => $s_need_edit) 'S_NEED_EDIT' => $s_need_edit)
); );

View File

@ -26,6 +26,7 @@ class acp_reasons
{ {
global $db, $user, $auth, $template, $cache; global $db, $user, $auth, $template, $cache;
global $config, $phpbb_root_path, $phpbb_admin_path, $phpEx; global $config, $phpbb_root_path, $phpbb_admin_path, $phpEx;
global $request;
$user->add_lang(array('mcp', 'acp/posting')); $user->add_lang(array('mcp', 'acp/posting'));
@ -280,7 +281,18 @@ class acp_reasons
case 'move_up': case 'move_up':
case 'move_down': 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); $order_total = $order * 2 + (($action == 'move_up') ? -1 : 1);
$sql = 'UPDATE ' . REPORTS_REASONS_TABLE . ' $sql = 'UPDATE ' . REPORTS_REASONS_TABLE . '
@ -288,6 +300,13 @@ class acp_reasons
WHERE reason_order IN (' . $order . ', ' . (($action == 'move_up') ? $order - 1 : $order + 1) . ')'; WHERE reason_order IN (' . $order . ', ' . (($action == 'move_up') ? $order - 1 : $order + 1) . ')';
$db->sql_query($sql); $db->sql_query($sql);
if ($request->is_ajax())
{
$json_response = new \phpbb\json_response;
$json_response->send(array(
'success' => (bool) $db->sql_affectedrows(),
));
}
break; break;
} }
@ -363,8 +382,8 @@ class acp_reasons
'U_EDIT' => $this->u_action . '&amp;action=edit&amp;id=' . $row['reason_id'], 'U_EDIT' => $this->u_action . '&amp;action=edit&amp;id=' . $row['reason_id'],
'U_DELETE' => (!$other_reason) ? $this->u_action . '&amp;action=delete&amp;id=' . $row['reason_id'] : '', 'U_DELETE' => (!$other_reason) ? $this->u_action . '&amp;action=delete&amp;id=' . $row['reason_id'] : '',
'U_MOVE_UP' => $this->u_action . '&amp;action=move_up&amp;order=' . $row['reason_order'], 'U_MOVE_UP' => $this->u_action . '&amp;action=move_up&amp;id=' . $row['reason_id'],
'U_MOVE_DOWN' => $this->u_action . '&amp;action=move_down&amp;order=' . $row['reason_order']) 'U_MOVE_DOWN' => $this->u_action . '&amp;action=move_down&amp;id=' . $row['reason_id'])
); );
} }
$db->sql_freeresult($result); $db->sql_freeresult($result);