minor things to make wiki more readable
[platal.git] / htdocs / groupex / export-econfiance.php.orig
1 <?php
2 /***************************************************************************
3  *  Copyright (C) 2003-2004 Polytechnique.org                              *
4  *  http://opensource.polytechnique.org/                                   *
5  *                                                                         *
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.                                    *
10  *                                                                         *
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.                           *
15  *                                                                         *
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            *
18  *  Foundation, Inc.,                                                      *
19  *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
20  ***************************************************************************/
21
22
23 /* Script permettant l'export de la liste des membres de la mailing list eConfiance, pour intégration par J-P Figer dans la liste des membres de X-Informatique */
24
25 require_once('xorg.inc.php');
26 require_once('xml-rpc-client.inc.php');
27 require_once('lists.inc.php');
28
29 $cle = $globals->core->econfiance;
30
31 if (isset($_SESSION["chall"]) && $_SESSION["chall"] != "" && $_GET["PASS"] == md5($_SESSION["chall"].$cle)) {
32
33     $res  = $globals->xdb->query("SELECT password FROM auth_user_md5 WHERE user_id=10154");
34     $pass = $res->fetchOneCell();
35
36     $client =& lists_xmlrpc(10154, $pass, "x-econfiance.polytechnique.org");
37     $members = $client->get_members('membres');
38     if(is_array($members)) {
39         $membres = Array();
40         foreach($members[1] as $member) {
41             if(preg_match('/^([^.]*.[^.]*.(\d\d\d\d))@polytechnique.org$/', $member[1], $matches)) {
42                 $membres[] = "a.alias='{$matches[1]}'";
43             }
44         }
45     }
46
47     $where = join(' OR ',$membres);
48
49     $all = $globals->xdb->iterRow(
50             "SELECT  u.prenom,u.nom,a.alias
51                FROM  auth_user_md5 AS u
52          INNER JOIN  aliases       AS a ON ( u.user_id = a.id AND a.type!='homonyme' )
53               WHERE  $where
54            ORDER BY  nom");
55
56     $res = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n\n<membres>\n\n";
57
58     while (list ($prenom1,$nom1,$email1) = $all->next()) {
59             $res .= "<membre>\n";
60             $res .= "\t<nom>$nom1</nom>\n";
61             $res .= "\t<prenom>$prenom1</prenom>\n";
62             $res .= "\t<email>$email1</email>\n";
63             $res .= "</membre>\n\n";
64     }
65
66     $res .= "</membres>\n\n";
67
68     echo $res;
69 }
70
71 ?>