Ignore:
Timestamp:
Jun 22, 2012, 11:42:52 PM (12 years ago)
Author:
mistic100
Message:

merge r15950 from trunk
bug 2659: Possible misconfiguration of ORDER BY + missing language string

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.4/admin/configuration.php

    r14649 r15951  
    146146      {
    147147        if ( !empty($_POST['order_by']) )
    148         {         
    149           // limit to the number of available parameters
    150           $order_by = $order_by_inside_category = array_slice($_POST['order_by'], 0, ceil(count($sort_fields)/2));
    151          
    152           // there is no rank outside categories
    153           unset($order_by[ array_search('rank ASC', $order_by) ]);
    154          
    155           // must define a default order_by if user want to order by rank only
    156           if ( count($order_by) == 0 )
     148        {
     149          foreach ($_POST['order_by'] as $i => $val)
    157150          {
    158             $order_by = array('id ASC');
     151            if (empty($val)) unset($_POST['order_by'][$i]);
    159152          }
    160          
    161           $_POST['order_by'] = 'ORDER BY '.implode(', ', $order_by);
    162           $_POST['order_by_inside_category'] = 'ORDER BY '.implode(', ', $order_by_inside_category);
     153          if ( !count($_POST['order_by']) )
     154          {
     155            array_push($page['errors'], l10n('No order field selected'));
     156          }
     157          else
     158          {
     159            // limit to the number of available parameters
     160            $order_by = $order_by_inside_category = array_slice($_POST['order_by'], 0, ceil(count($sort_fields)/2));
     161           
     162            // there is no rank outside categories
     163            if ( ($i = array_search('rank ASC', $order_by)) !== false)
     164            {
     165              unset($order_by[$i]);
     166            }
     167           
     168            // must define a default order_by if user want to order by rank only
     169            if ( count($order_by) == 0 )
     170            {
     171              $order_by = array('id ASC');
     172            }
     173           
     174            $_POST['order_by'] = 'ORDER BY '.implode(', ', $order_by);
     175            $_POST['order_by_inside_category'] = 'ORDER BY '.implode(', ', $order_by_inside_category);
     176          }
    163177        }
    164178        else
    165179        {
    166           array_push($page['errors'], l10n('No field selected'));
     180          array_push($page['errors'], l10n('No order field selected'));
    167181        }
    168182      }
Note: See TracChangeset for help on using the changeset viewer.