2 /***************************************************************************
3 * Copyright (C) 2003-2011 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 // {{{ function list_sort_owners
24 function list_sort_owners($members, $tri_promo = true
)
28 // $membres' structure is the following: $sortKey => $key => $listMember
31 foreach($members as $member) {
32 $user = User
::getSilent($member);
34 $membres[0][$member] = array('name' => null
, 'email' => $member, 'category' => null
, 'uid' => null
, 'lost' => null
, 'hasProfile' => null
);
36 $hasProfile = $user->hasProfile();
38 $name = $user->directoryName();
39 $category = $user->category();
40 $key = $tri_promo ?
($category ?
$category : 'AAAAA') : strtoupper($name{0});
42 $category = 'extérieurs';
44 $membres[$key][$name] = array('name' => $name, 'email' => $member, 'category' => $category,
45 'uid' => $uid, 'lost' => $user->lost
, 'hasProfile' => $hasProfile);
50 foreach($membres as &$membre) {
51 uksort($membre, 'strcasecmp');
57 // {{{ list_extract_member
59 function _list_extract_member($member)
64 function list_extract_members($members)
66 return array_map('_list_extract_member', $members);
70 // {{{ function list_sort_members
72 function list_sort_members($members, $tri_promo = true
)
74 $m = list_extract_members($members);
75 return list_sort_owners($m, $tri_promo);
79 // {{{ function list_fetch_basic_info
81 function list_fetch_basic_info($members)
84 foreach ($members as $member) {
85 $user = User
::getSilent($member);
87 $res[] = $member . ',,';
89 $res[] = $user->forlifeEmail() . ',' . $user->directoryName() . ',' . $user->promo();
96 // {{{ function list_header_decode
98 function _list_header_decode($charset, $c, $str) {
99 $s = ($c == 'Q' ||
$c == 'q') ?
quoted_printable_decode($str) : base64_decode($str);
100 $s = iconv($charset, 'UTF-8', $s);
101 return str_replace('_', ' ', $s);
104 function list_header_decode($value) {
106 return "[pas de sujet]";
108 $val = preg_replace('/(=\?[^?]*\?[BQbq]\?[^?]*\?=) (=\?[^?]*\?[BQbq]\?[^?]*\?=)/', '\1\2', $value);
109 return preg_replace('/=\?([^?]*)\?([BQbq])\?([^?]*)\?=/e', '_list_header_decode("\1", "\2", "\3")', $val);
113 // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: