1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-08-29 11:10:18 +02:00

[ticket/12038] Do not rely on stale order value to move items.

This makes it possible to move the items more than once with AJAX.

PHPBB3-12038
This commit is contained in:
Cesar G
2013-12-06 12:50:16 -08:00
parent 823d2b697a
commit 3ccc8add10
3 changed files with 53 additions and 48 deletions

View File

@@ -281,7 +281,17 @@ 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');
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 . '
@@ -371,8 +381,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);