X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;ds=sidebyside;f=modules%2Fxnetlists.php;h=d018754113f5e1b4dff0597ec4cc30db439ddc1f;hb=911075226546c6b058eca1e0b889097f79fa6232;hp=a502f02a354794f45281ec2e30779db5d9995c72;hpb=54722967b9b605dca8cff67fc3a050194beba368;p=platal.git diff --git a/modules/xnetlists.php b/modules/xnetlists.php index a502f02..d018754 100644 --- a/modules/xnetlists.php +++ b/modules/xnetlists.php @@ -70,7 +70,7 @@ class XnetListsModule extends ListsModule return $globals->asso('mail_domain'); } - function handler_lists($page) + function handler_lists($page, $order_by = null, $order = null) { global $globals; require_once 'emails.inc.php'; @@ -102,9 +102,44 @@ class XnetListsModule extends ListsModule } $listes = $this->client->get_lists(); + // Default ordering is by ascending names. + if (is_null($order_by) || is_null($order) + || !in_array($order_by, array('list', 'desc', 'nbsub')) + || !in_array($order, array('asc', 'desc'))) { + $order_by = 'list'; + $order = 'asc'; + } + + $compare = function ($a, $b) use ($order_by, $order) + { + switch ($order_by) { + case 'desc': + $a[$order_by] = replace_accent($a[$order_by]); + $b[$order_by] = replace_accent($b[$order_by]); + case 'list': + $res = strcasecmp($a[$order_by], $b[$order_by]); + break; + case 'nbsub': + $res = $a[$order_by] - $b[$order_by]; + break; + default: + $res = 0; + } + + if ($order == 'asc') { + return $res; + } + return $res * -1; + }; + usort($listes, $compare); $page->assign('listes', $listes); + $page->assign('order_by', $order_by); + $page->assign('order', $order); $page->assign('aliases', iterate_list_alias($globals->asso('mail_domain'))); $page->assign('may_update', may_update()); + if (S::suid()) { + $page->trigWarning("Attention : l'affichage des listes de diffusion ne tient pas compte de l'option « Voir le site comme… »."); + } if (count($listes) > 0 && !$globals->asso('has_ml')) { XDB::execute("UPDATE groups