Skip to content

Commit

Permalink
bug 2659: Possible misconfiguration of ORDER BY + missing language st…
Browse files Browse the repository at this point in the history
…ring

git-svn-id: http://piwigo.org/svn/trunk@15950 68402e56-0260-453c-a942-63ccdbb3a9ee
  • Loading branch information
mistic100 committed Jun 22, 2012
1 parent 0252fed commit 8f40368
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 14 deletions.
42 changes: 28 additions & 14 deletions admin/configuration.php
Expand Up @@ -145,25 +145,39 @@
if ( !isset($conf['order_by_custom']) and !isset($conf['order_by_inside_category_custom']) )
{
if ( !empty($_POST['order_by']) )
{
// limit to the number of available parameters
$order_by = $order_by_inside_category = array_slice($_POST['order_by'], 0, ceil(count($sort_fields)/2));

// there is no rank outside categories
unset($order_by[ array_search('rank ASC', $order_by) ]);

// must define a default order_by if user want to order by rank only
if ( count($order_by) == 0 )
{
foreach ($_POST['order_by'] as $i => $val)
{
if (empty($val)) unset($_POST['order_by'][$i]);
}
if ( !count($_POST['order_by']) )
{
array_push($page['errors'], l10n('No order field selected'));
}
else
{
$order_by = array('id ASC');
// limit to the number of available parameters
$order_by = $order_by_inside_category = array_slice($_POST['order_by'], 0, ceil(count($sort_fields)/2));

// there is no rank outside categories
if ( ($i = array_search('rank ASC', $order_by)) !== false)
{
unset($order_by[$i]);
}

// must define a default order_by if user want to order by rank only
if ( count($order_by) == 0 )
{
$order_by = array('id ASC');
}

$_POST['order_by'] = 'ORDER BY '.implode(', ', $order_by);
$_POST['order_by_inside_category'] = 'ORDER BY '.implode(', ', $order_by_inside_category);
}

$_POST['order_by'] = 'ORDER BY '.implode(', ', $order_by);
$_POST['order_by_inside_category'] = 'ORDER BY '.implode(', ', $order_by_inside_category);
}
else
{
array_push($page['errors'], l10n('No field selected'));
array_push($page['errors'], l10n('No order field selected'));
}
}

Expand Down
1 change: 1 addition & 0 deletions language/en_UK/admin.lang.php
Expand Up @@ -462,6 +462,7 @@
$lang['No results'] = "No results";
$lang['No user to send notifications by mail.'] = "No user to be notified by mail.";
$lang['no write access'] = "no write access";
$lang['No order field selected'] = 'No order field selected';
$lang['none'] = "none";
$lang['None'] = 'None';
$lang['nothing'] = "nothing";
Expand Down
1 change: 1 addition & 0 deletions language/fr_FR/admin.lang.php
Expand Up @@ -922,4 +922,5 @@
$lang['Sharpen'] = 'Renforcer la netteté';
$lang['Edit photo'] = 'Éditer la photo';
$lang['create a new site'] = 'créer un nouveau site';
$lang['No order field selected'] = 'Aucun critère de tri sélectionné';
?>

0 comments on commit 8f40368

Please sign in to comment.