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';
}
$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()) {
<table cellpadding="0" cellspacing="0" class='large'>
<tr>
- <th colspan="2">Liste</th>
- <th>Description</th>
+ <th colspan="2">
+ <a href="{$platal->ns}lists/list/{if $order_by eq 'list' && $order eq 'asc'}desc{else}asc{/if}">
+ {if $order_by eq 'list'}
+ {if $order eq 'desc'}
+ <img src="{$platal->baseurl}images/up.png" alt="" title="Tri décroissant" />
+ {else}
+ <img src="{$platal->baseurl}images/dn.png" alt="" title="Tri croissant" />
+ {/if}
+ {/if}
+ Liste
+ </a>
+ </th>
+ <th>
+ <a href="{$platal->ns}lists/desc/{if $order_by eq 'desc' && $order eq 'asc'}desc{else}asc{/if}">
+ {if $order_by eq 'desc'}
+ {if $order eq 'desc'}
+ <img src="{$platal->baseurl}images/up.png" alt="" title="Tri décroissant" />
+ {else}
+ <img src="{$platal->baseurl}images/dn.png" alt="" title="Tri croissant" />
+ {/if}
+ {/if}
+ Description
+ </a>
+ </th>
<th>Diffusion</th>
<th>Inscription</th>
- <th>Nb</th>
+ <th>
+ <a href="{$platal->ns}lists/nbsub/{if $order_by eq 'nbsub' && $order eq 'asc'}desc{else}asc{/if}">
+ {if $order_by eq 'nbsub'}
+ {if $order eq 'desc'}
+ <img src="{$platal->baseurl}images/up.png" alt="" title="Tri décroissant" />
+ {else}
+ <img src="{$platal->baseurl}images/dn.png" alt="" title="Tri croissant" />
+ {/if}
+ {/if}
+ Nb
+ </a>
+ </th>
<th> </th>
</tr>
{foreach from=$listes item=l}