bug 288 : choix d'ordre sur plusieurs criteres, nom et prenom par exemple
authorPascal Corpet <pascal.corpet@m4x.org>
Tue, 8 Feb 2005 16:38:16 +0000 (16:38 +0000)
committerFlorent Bruneau <florent.bruneau@polytechnique.org>
Thu, 26 Jun 2008 21:28:07 +0000 (23:28 +0200)
git-archimport-id: opensource@polytechnique.org--2005/platal--mainline--0.9--patch-460

htdocs/advanced_search.php
htdocs/search.php
include/search.inc.php

index 5318765..11e094a 100644 (file)
@@ -66,7 +66,7 @@ if (!Env::has('rechercher')) {
 
     // {{{ function get_list()
 
-    function get_list($offset, $limit, $order, $order_inv) {
+    function get_list($offset, $limit, $order) {
         if ($with_soundex = Env::has('with_soundex')) {
             $nameField      = new RefWithSoundexSField('name',array('rn.nom1_soundex','rn.nom2_soundex','rn.nom3_soundex'),'recherche_soundex','rn','u.matricule = rn.matricule');
             $firstnameField = new RefWithSoundexSField('firstname',array('rp.prenom1_soundex','rp.prenom2_soundex'),'recherche_soundex','rp','u.matricule = rp.matricule');
@@ -133,7 +133,7 @@ if (!Env::has('rechercher')) {
                 LEFT JOIN  watch_nonins   AS w ON (w.ni_id=u.user_id AND w.uid='.Session::getInt('uid').')
                 '.$globals->search->result_where_statement.'
                 '.(empty($where) ? '' : "WHERE  $where").'
-                 ORDER BY  '.($order?($order.($order_inv?' DESC':'').', '):'')
+                 ORDER BY  '.($order?($order.', '):'')
                        .implode(',',array_filter(array($fields->get_order_statement(), 'promo DESC, NomSortKey, prenom'))).'
                     LIMIT  '.($offset * $limit).','.$limit;
         $liste   = $globals->xdb->iterator($sql);
index bbe3a25..b11b267 100644 (file)
@@ -34,7 +34,7 @@ if (Env::has('quick')) {
     $page->assign('formulaire', 0);
 
     // {{{ get_list
-    function get_list($offset, $limit, $order, $order_inv) {
+    function get_list($offset, $limit, $order) {
         global $globals;
         $qSearch = new QuickSearch('quick');
         $fields  = new SFieldGroup(true, array($qSearch));
@@ -59,7 +59,7 @@ if (Env::has('quick')) {
                 '.$globals->search->result_where_statement.'
                     WHERE  '.$fields->get_where_statement().(logged() && Env::has('nonins') ? ' AND u.perms="pending" AND u.deces=0' : '').'
                    HAVING  mark>0
-                 ORDER BY '.($order?($order.($order_inv?" DESC":"").', '):'')
+                 ORDER BY '.($order?($order.', '):'')
                             .implode(',',array_filter(array($fields->get_order_statement(), 'u.promo DESC, NomSortKey, prenom'))).'
                     LIMIT  '.$offset * $globals->search->per_page.','.$globals->search->per_page;
         $list    = $globals->xdb->iterator($sql);
index 4943204..5402510 100644 (file)
@@ -34,7 +34,7 @@ class XOrgSearch extends XOrgPlugin
     // type of orders : (field name, default ASC, text name, auth)
     var $orders = array(
             'promo'     =>array('promo',  false, 'promotion',             AUTH_PUBLIC),
-            'nom'       =>array('nom',    true,  'nom',                   AUTH_PUBLIC),
+            'nom'       =>array('nom,prenom',   true,  'nom',             AUTH_PUBLIC),
             'date_mod'  =>array('u.date', false, 'dernière modification', AUTH_COOKIE)
         );
 
@@ -86,8 +86,12 @@ class XOrgSearch extends XOrgPlugin
         }
         $order     = $tab[0];
         $order_inv = ($this->get_value('order_inv') != '') == $tab[1];
-       
-        list($list, $total) = call_user_func($this->_callback, $offset, $this->limit, $order, $order_inv);
+
+        if ($order_inv && $order)
+            $sql_order = str_replace(",", " DESC,", $order)." DESC";
+        else $sql_order = $order;
+
+        list($list, $total) = call_user_func($this->_callback, $offset, $this->limit, $sql_order);
         
        $page_max = intval(($total-1)/$this->limit);