some fixes

git-svn-id: file:///svn/phpbb/trunk@6478 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
Meik Sievertsen 2006-10-11 13:48:30 +00:00
parent 97c72d7075
commit 99d968dd2e
5 changed files with 69 additions and 54 deletions

View file

@ -136,7 +136,7 @@ class acp_icons
}
$after_txt = ($mode == 'smilies') ? $row['code'] : $row['icons_url'];
$order_list = '<option value="' . ($row[$fields . '_order']) . '"' . $selected . '>' . sprintf($user->lang['AFTER_' . $lang], ' -&gt; ' . htmlspecialchars($after_txt)) . '</option>' . $order_list;
$order_list = '<option value="' . ($row[$fields . '_order'] + 1) . '"' . $selected . '>' . sprintf($user->lang['AFTER_' . $lang], ' -&gt; ' . htmlspecialchars($after_txt)) . '</option>' . $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 . '&amp;action=edit&amp;id=' . $row[$fields . '_id'],
'U_DELETE' => $this->u_action . '&amp;action=delete&amp;id=' . $row[$fields . '_id'],
'U_MOVE_UP' => $this->u_action . '&amp;action=move_up&amp;order=' . $row[$fields . '_order'],
'U_MOVE_DOWN' => $this->u_action . '&amp;action=move_down&amp;order=' . $row[$fields . '_order'])
'U_MOVE_UP' => $this->u_action . '&amp;action=move_up&amp;id=' . $row[$fields . '_id'],
'U_MOVE_DOWN' => $this->u_action . '&amp;action=move_down&amp;id=' . $row[$fields . '_id'])
);
if (!$spacer && !$row['display_on_posting'])

View file

@ -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)
{

View file

@ -328,12 +328,14 @@ $errored = false;
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" dir="<?php echo $lang['DIRECTION']; ?>">
<html xmlns="http://www.w3.org/1999/xhtml" dir="<?php echo $lang['DIRECTION']; ?>" lang="<?php echo $lang['USER_LANG']; ?>" xml:lang="<?php echo $lang['USER_LANG']; ?>">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo $lang['DIRECTION']; ?>" />
<meta http-equiv="Content-Style-Type" content="text/css" />
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<meta http-equiv="content-language" content="<?php echo $lang['USER_LANG']; ?>" />
<meta http-equiv="content-style-type" content="text/css" />
<meta http-equiv="imagetoolbar" content="no" />
<title><?php echo $lang['UPDATING_TO_LATEST_STABLE']; ?></title>
<link href="../adm/style/admin.css" rel="stylesheet" type="text/css" media="screen" />

View file

@ -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);

View file

@ -268,7 +268,7 @@
<!-- IF postrow.S_ROW_COUNT is even --><tr class="row1"><!-- ELSE --><tr class="row2"><!-- ENDIF -->
<td nowrap="nowrap">&nbsp;</td>
<td><div class="gensmall" style="float: left;">&nbsp;<!-- IF postrow.U_PROFILE --><a href="{postrow.U_PROFILE}">{PROFILE_IMG}</a> <!-- ENDIF --> <!-- IF postrow.U_PM --><a href="{postrow.U_PM}">{PM_IMG}</a> <!-- ENDIF --> <!-- IF postrow.U_EMAIL --><a href="{postrow.U_EMAIL}">{EMAIL_IMG}</a> <!-- ENDIF -->&nbsp;</div> <div class="gensmall" style="float:right"><!-- IF postrow.U_QUOTE --><a href="{postrow.U_QUOTE}">{QUOTE_IMG}</a> <!-- ENDIF --> <!-- IF postrow.U_EDIT --><a href="{postrow.U_EDIT}">{EDIT_IMG}</a> <!-- ENDIF -->&nbsp;</div></td>
<td><div class="gensmall" style="float: left;">&nbsp;<!-- IF postrow.U_PROFILE --><a href="{postrow.U_PROFILE}">{PROFILE_IMG}</a> <!-- ENDIF --> <!-- IF postrow.U_PM --><a href="{postrow.U_PM}">{PM_IMG}</a> <!-- ENDIF --> <!-- IF postrow.U_EMAIL --><a href="{postrow.U_EMAIL}">{EMAIL_IMG}</a> <!-- ENDIF -->&nbsp;</div> <div class="gensmall" style="float:right"><!-- IF postrow.U_EDIT --><a href="{postrow.U_EDIT}">{EDIT_IMG}</a> <!-- ENDIF --> <!-- IF postrow.U_QUOTE --><a href="{postrow.U_QUOTE}">{QUOTE_IMG}</a> <!-- ENDIF --> &nbsp;</div></td>
</tr>
<!-- ENDIF -->