I think JMY will be happy :
[platal.git] / htdocs.net / groupe / annuaire-admin.php
1 <?php
2
3 require_once 'xnet.inc.php';
4 require_once 'lists.inc.php';
5 require_once 'xnet/mail.inc.php';
6
7 new_groupadmin_page('xnet/groupe/annuaire-admin.tpl');
8 $client =& lists_xmlrpc(Session::getInt('uid'), Session::get('password'), $globals->asso('mail_domain'));
9 $lists = $client->get_lists();
10 if (!$lists) $lists = array();
11 $listes = array_map(create_function('$arr', 'return $arr["list"];'), $lists);
12
13 $subscribers = array();
14
15 foreach ($listes as $list) {
16 list(,$members) = $client->get_members($list);
17 $mails = array_map(create_function('$arr', 'return $arr[1];'), $members);
18 $subscribers = array_unique(array_merge($subscribers, $mails));
19 }
20
21 $not_in_group_x = array();
22 $not_in_group_ext = array();
23
24 foreach ($subscribers as $mail) {
25 $res = $globals->xdb->query(
26 'SELECT COUNT(*)
27 FROM groupex.membres AS m
28 LEFT JOIN auth_user_md5 AS u ON (m.uid=u.user_id AND m.uid<50000)
29 LEFT JOIN aliases AS a ON (a.id=u.user_id and a.type="a_vie")
30 WHERE asso_id = {?} AND
31 (m.email = {?} OR CONCAT(a.alias, "@polytechnique.org") = {?})',
32 $globals->asso('id'), $mail, $mail);
33 if ($res->fetchOneCell() == 0) {
34 if (strstr($mail, '@polytechnique.org') === false) {
35 $not_in_group_ext[] = $mail;
36 } else {
37 $not_in_group_x = $mail;
38 }
39 }
40 }
41
42 $page->assign('not_in_group_ext', $not_in_group_ext);
43 $page->assign('not_in_group_x', $not_in_group_x);
44 $page->assign('lists', $lists);
45 $page->run();
46
47 ?>