diff --git a/phpBB/includes/acp/acp_icons.php b/phpBB/includes/acp/acp_icons.php index f49338e8f1..c4747a2e42 100644 --- a/phpBB/includes/acp/acp_icons.php +++ b/phpBB/includes/acp/acp_icons.php @@ -136,7 +136,7 @@ class acp_icons } $after_txt = ($mode == 'smilies') ? $row['code'] : $row['icons_url']; - $order_list = '' . $order_list; + $order_list = '' . $order_list; } } $db->sql_freeresult($result); @@ -242,11 +242,32 @@ class acp_icons ); } + // Image_order holds the 'new' order value if (!empty($image_order[$image])) { $img_sql = array_merge($img_sql, array( - $fields . '_order' => $image_order[$image] . '.5') + $fields . '_order' => $image_order[$image]) ); + + // Since we always add 'after' an item, we just need to increase all following + the current by one + $sql = "UPDATE $table + SET {$fields}_order = {$fields}_order + 1 + WHERE {$fields}_order >= {$image_order[$image]}"; + $db->sql_query($sql); + + // If we adjust the order, we need to adjust all other orders too - they became inaccurate... + foreach ($image_order as $_image => $_order) + { + if ($_image == $image) + { + continue; + } + + if ($_order >= $image_order[$image]) + { + $image_order[$_image]++; + } + } } if ($action == 'modify') @@ -261,45 +282,6 @@ class acp_icons $sql = "INSERT INTO $table " . $db->sql_build_array('INSERT', $img_sql); $db->sql_query($sql); } - - $update = false; - - if ($action == 'modify' && !empty($image_order[$image])) - { - $update = true; - - $sql = "SELECT {$fields}_order - FROM $table - WHERE {$fields}_id = " . $image_id[$image]; - $result = $db->sql_query($sql); - $order_old = (int) $db->sql_fetchfield($fields . '_order'); - $db->sql_freeresult($result); - - if ($order_old == $image_order[$image]) - { - $update = false; - } - - if ($order_old > $image_order[$image]) - { - $sign = '+'; - $where = $fields . '_order >= ' . $image_order[$image] . " AND {$fields}_order < $order_old"; - } - else if ($order_old < $image_order[$image]) - { - $sign = '-'; - $where = "{$fields}_order > $order_old AND {$fields}_order < " . $image_order[$image]; - $sql[$fields . '_order'] = $image_order[$image] - 1; - } - } - - if ($update) - { - $sql = "UPDATE $table - SET {$fields}_order = {$fields}_order $sign 1 - WHERE $where"; - $db->sql_query($sql); - } } } @@ -562,14 +544,40 @@ class acp_icons case 'move_up': case 'move_down': - $image_order = request_var('order', 0); - $order_total = $image_order * 2 + (($action == 'move_up') ? -1 : 1); + // Get current order id... + $sql = "SELECT {$fields}_order as current_order + FROM $table + WHERE {$fields}_id = $icon_id"; + $result = $db->sql_query($sql); + $current_order = (int) $db->sql_fetchfield('current_order'); + $db->sql_freeresult($result); - $sql = 'UPDATE ' . $table . ' - SET ' . $fields . "_order = $order_total - " . $fields . '_order - WHERE ' . $fields . "_order IN ($image_order, " . (($action == 'move_up') ? $image_order - 1 : $image_order + 1) . ')'; + if ($current_order == 0 && $action == 'move_up') + { + break; + } + + // on move_down, switch position with next order_id... + // on move_up, switch position with previous order_id... + $switch_order_id = ($action == 'move_down') ? $current_order + 1 : $current_order - 1; + + // + $sql = "UPDATE $table + SET {$fields}_order = $current_order + WHERE {$fields}_order = $switch_order_id + AND {$fields}_id <> $icon_id"; $db->sql_query($sql); + // Only update the other entry too if the previous entry got updated + if ($db->sql_affectedrows()) + { + $sql = "UPDATE $table + SET {$fields}_order = $switch_order_id + WHERE {$fields}_order = $current_order + AND {$fields}_id = $icon_id"; + $db->sql_query($sql); + } + $cache->destroy('icons'); $cache->destroy('sql', $table); @@ -640,8 +648,8 @@ class acp_icons 'EMOTION' => (isset($row['emotion'])) ? $row['emotion'] : '', 'U_EDIT' => $this->u_action . '&action=edit&id=' . $row[$fields . '_id'], 'U_DELETE' => $this->u_action . '&action=delete&id=' . $row[$fields . '_id'], - 'U_MOVE_UP' => $this->u_action . '&action=move_up&order=' . $row[$fields . '_order'], - 'U_MOVE_DOWN' => $this->u_action . '&action=move_down&order=' . $row[$fields . '_order']) + 'U_MOVE_UP' => $this->u_action . '&action=move_up&id=' . $row[$fields . '_id'], + 'U_MOVE_DOWN' => $this->u_action . '&action=move_down&id=' . $row[$fields . '_id']) ); if (!$spacer && !$row['display_on_posting']) diff --git a/phpBB/includes/functions_messenger.php b/phpBB/includes/functions_messenger.php index 0edf294063..836345d1b9 100644 --- a/phpBB/includes/functions_messenger.php +++ b/phpBB/includes/functions_messenger.php @@ -530,7 +530,7 @@ class queue } $package_size = $data_ary['package_size']; - $num_items = (sizeof($data_ary['data']) < $package_size) ? sizeof($data_ary['data']) : $package_size; + $num_items = (!$package_size || sizeof($data_ary['data']) < $package_size) ? sizeof($data_ary['data']) : $package_size; switch ($object) { diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index e622e226ad..155ab2350e 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -328,12 +328,14 @@ $errored = false; ?> - + - - + + + + <?php echo $lang['UPDATING_TO_LATEST_STABLE']; ?> diff --git a/phpBB/posting.php b/phpBB/posting.php index f6941369a7..aae7f4d5a1 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -131,6 +131,11 @@ $result = $db->sql_query($sql); $post_data = $db->sql_fetchrow($result); $db->sql_freeresult($result); +if (!$post_data) +{ + trigger_error(($mode == 'post' || $mode == 'bump' || $mode == 'reply') ? 'NO_TOPIC' : 'NO_POST'); +} + if ($mode == 'popup') { upload_popup($post_data['forum_style']); @@ -683,7 +688,7 @@ if ($submit || $preview || $refresh) } // Validate username - if (($post_data['username'] && !$user->data['is_registered']) || ($mode == 'edit' && $post_data['username'] && $post_data['post_username'] != $post_data['username'])) + if (($post_data['username'] && !$user->data['is_registered']) || ($mode == 'edit' && $post_data['username'] && $post_data['post_username'] && $post_data['post_username'] != $post_data['username'])) { include($phpbb_root_path . 'includes/functions_user.' . $phpEx); diff --git a/phpBB/styles/subSilver/template/viewtopic_body.html b/phpBB/styles/subSilver/template/viewtopic_body.html index d429fd8889..b1bfe3ccca 100644 --- a/phpBB/styles/subSilver/template/viewtopic_body.html +++ b/phpBB/styles/subSilver/template/viewtopic_body.html @@ -268,7 +268,7 @@   -
 {PROFILE_IMG} {PM_IMG} {EMAIL_IMG}  
{QUOTE_IMG} {EDIT_IMG}  
+
 {PROFILE_IMG} {PM_IMG} {EMAIL_IMG}  
{EDIT_IMG} {QUOTE_IMG}