- make sure all sort keys are valid and selectable.

git-svn-id: file:///svn/phpbb/trunk@6477 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
Meik Sievertsen 2006-10-11 10:43:20 +00:00
parent a765165cd1
commit 97c72d7075
2 changed files with 25 additions and 0 deletions

View file

@ -182,6 +182,26 @@ function gen_sort_selects(&$limit_days, &$sort_by_text, &$sort_days, &$sort_key,
$sort_dir_text = array('a' => $user->lang['ASCENDING'], 'd' => $user->lang['DESCENDING']);
// Check if the key is selectable. If not, we reset to the first key found.
// This ensures the values are always valid.
if (!isset($limit_days[$sort_days]))
{
@reset($limit_days);
$sort_days = key($limit_days);
}
if (!isset($sort_by_text[$sort_key]))
{
@reset($sort_by_text);
$sort_key = key($sort_by_text);
}
if (!isset($sort_dir_text[$sort_dir]))
{
@reset($sort_dir_text);
$sort_dir = key($sort_dir_text);
}
$s_limit_days = '<select name="st">';
foreach ($limit_days as $day => $text)
{

View file

@ -576,6 +576,11 @@ function mcp_sorting($mode, &$sort_days, &$sort_key, &$sort_dir, &$sort_by_sql,
break;
}
if (!isset($sort_by_sql[$sort_key]))
{
$sort_key = $default_key;
}
$sort_order_sql = $sort_by_sql[$sort_key] . ' ' . (($sort_dir == 'd') ? 'DESC' : 'ASC');
$s_limit_days = $s_sort_key = $s_sort_dir = $sort_url = '';