From: Pascal Corpet Date: Tue, 8 Feb 2005 16:38:16 +0000 (+0000) Subject: bug 288 : choix d'ordre sur plusieurs criteres, nom et prenom par exemple X-Git-Tag: xorg/old~300 X-Git-Url: http://git.polytechnique.org/?a=commitdiff_plain;h=180aaabc0b502196be53863bf1c47a0f6d6a7172;p=platal.git bug 288 : choix d'ordre sur plusieurs criteres, nom et prenom par exemple git-archimport-id: opensource@polytechnique.org--2005/platal--mainline--0.9--patch-460 --- diff --git a/htdocs/advanced_search.php b/htdocs/advanced_search.php index 5318765..11e094a 100644 --- a/htdocs/advanced_search.php +++ b/htdocs/advanced_search.php @@ -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); diff --git a/htdocs/search.php b/htdocs/search.php index bbe3a25..b11b267 100644 --- a/htdocs/search.php +++ b/htdocs/search.php @@ -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); diff --git a/include/search.inc.php b/include/search.inc.php index 4943204..5402510 100644 --- a/include/search.inc.php +++ b/include/search.inc.php @@ -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);