2 /***************************************************************************
3 * Copyright (C) 2003-2004 Polytechnique.org *
4 * http://opensource.polytechnique.org/ *
6 * This program is free software; you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation; either version 2 of the License, or *
9 * (at your option) any later version. *
11 * This program is distributed in the hope that it will be useful, *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14 * GNU General Public License for more details. *
16 * You should have received a copy of the GNU General Public License *
17 * along with this program; if not, write to the Free Software *
19 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
20 ***************************************************************************/
22 // {{{ import class definitions
24 require_once 'platal/xmlrpc-client.inc.php';
27 // {{{ function lists_xmlrpc
29 function &lists_xmlrpc($uid, $pass, $fqdn=null
)
33 $dom = empty($fqdn) ?
$globals->mail
->domain
: $fqdn;
34 $url = "http://$uid:$pass@{$globals->lists->rpchost}:{$globals->lists->rpcport}/$dom";
35 $client = new xmlrpc_client($url);
40 // {{{ function list_sort_owners
42 function list_sort_owners(&$members, $tri_promo = true
) {
47 foreach($members as $mem) {
48 list($m, $dom) = explode('@',$mem);
49 if ($dom == $globals->mail
->domain ||
$dom == $globals->mail
->domain2
) {
50 $res = $globals->xdb
->query('SELECT prenom,IF(nom_usage="", nom, nom_usage), promo
51 FROM auth_user_md5 AS u
52 INNER JOIN aliases AS a ON u.user_id = a.id
53 WHERE a.alias = {?}', $m);
54 if(list($prenom, $nom, $promo) = $res->fetchOneRow()) {
55 $key = $tri_promo ?
$promo : strtoupper($nom{0});
56 $membres[$key][$nom.$m] = Array('n' => "$prenom $nom", 'l' => $m);
58 $membres[0][] = Array('l' => $mem);
61 $res = $globals->xdb
->query('SELECT prenom, nom FROM groupex.membres WHERE email={?}', $mem);
62 if (list($prenom, $nom) = $res->fetchOneRow()) {
63 $key = $tri_promo ?
0 : strtoupper($nom{0});
64 $membres[$key][$nom.$m] = Array('n' => "$prenom $nom", 'l' => $mem);
66 $membres[0][] = Array('l' => $mem);
72 foreach($membres as $key=>$val) ksort($membres[$key]);
77 // {{{ function list_sort_members
79 function list_sort_members(&$members, $tri_promo = true
) {
80 $pi1 = create_function('$arr', 'return $arr[1];');
81 return list_sort_owners(array_map($pi1, $members), $tri_promo);
85 // vim:set et sw=4 sts=4 sws=4 foldmethod=marker: