Commit | Line | Data |
---|---|---|
0337d704 | 1 | <?php |
2 | /*************************************************************************** | |
8d84c630 | 3 | * Copyright (C) 2003-2009 Polytechnique.org * |
0337d704 | 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 | // {{{ function user_clear_all_subs() | |
23 | /** kills the inscription of a user. | |
24 | * we still keep his birthdate, adresses, and personnal stuff | |
25 | * kills the entreprises, mentor, emails and lists subscription stuff | |
26 | */ | |
27 | function user_clear_all_subs($user_id, $really_del=true) | |
28 | { | |
043bbacf | 29 | // keep datas in : aliases, adresses, tels, profile_education, binets_ins, contacts, groupesx_ins, homonymes, identification_ax, photo |
0337d704 | 30 | // delete in : auth_user_md5, auth_user_quick, competences_ins, emails, entreprises, langues_ins, mentor, |
31 | // mentor_pays, mentor_secteurs, newsletter_ins, perte_pass, requests, user_changes, virtual_redirect, watch_sub | |
32 | // + delete maillists | |
33 | ||
34 | global $globals; | |
d56cb887 VZ |
35 | $uid = intval($user_id); |
36 | $user = User::getSilent($uid); | |
37 | list($alias) = explode('@', $user->forlifeEmail()); | |
0337d704 | 38 | |
f9cddbef | 39 | $tables_to_clear = array('uid' => array('competences_ins', 'profile_job', 'langues_ins', 'profile_mentor_country', |
5fecdf6d | 40 | 'profile_mentor_sector', 'profile_mentor', 'perte_pass', 'watch_sub'), |
425f432d | 41 | 'user_id' => array('requests', 'user_changes')); |
42 | ||
0337d704 | 43 | if ($really_del) { |
b235d980 | 44 | array_push($tables_to_clear['uid'], 'emails', 'groupex.membres', 'contacts', 'adresses', 'profile_phones', |
425f432d | 45 | 'photo', 'perte_pass', 'langues_ins', 'forums.abos', 'forums.profils'); |
46 | array_push($tables_to_clear['user_id'], 'newsletter_ins', 'auth_user_quick', 'binets_ins'); | |
787bb3d7 | 47 | $tables_to_clear['id'] = array('aliases'); |
425f432d | 48 | $tables_to_clear['contact'] = array('contacts'); |
425f432d | 49 | XDB::execute("UPDATE auth_user_md5 |
50 | SET date_ins = 0, promo_sortie = 0, nom_usage = '', password = '', perms = 'pending', | |
eeb2ec0f SJ |
51 | nationalite = '', nationalite2 = '', nationalite3 = '', cv = '', section = 0, |
52 | date = 0, smtppass = '', mail_storage = '' | |
425f432d | 53 | WHERE user_id = {?}", $uid); |
54 | XDB::execute("DELETE virtual.* FROM virtual INNER JOIN virtual_redirect AS r USING(vid) WHERE redirect = {?}", | |
55 | $alias.'@'.$globals->mail->domain); | |
56 | XDB::execute("DELETE virtual.* FROM virtual INNER JOIN virtual_redirect AS r USING(vid) WHERE redirect = {?}", | |
57 | $alias.'@'.$globals->mail->domain2); | |
58 | } else { | |
59 | XDB::execute("UPDATE auth_user_md5 SET password='',smtppass='' WHERE user_id={?}", $uid); | |
60 | XDB::execute("UPDATE auth_user_quick SET watch_flags='' WHERE user_id={?}", $uid); | |
0337d704 | 61 | } |
62 | ||
08cce2ff | 63 | XDB::execute("DELETE FROM virtual_redirect WHERE redirect = {?}", $alias.'@'.$globals->mail->domain); |
64 | XDB::execute("DELETE FROM virtual_redirect WHERE redirect = {?}", $alias.'@'.$globals->mail->domain2); | |
65 | ||
425f432d | 66 | foreach ($tables_to_clear as $key=>&$tables) { |
67 | foreach ($tables as $table) { | |
68 | XDB::execute("DELETE FROM $table WHERE $key={?}", $uid); | |
69 | } | |
70 | } | |
9bb8bf21 | 71 | |
c53b5964 | 72 | $mmlist = new MMList(S::v('uid'), S::v('password')); |
9bb8bf21 | 73 | $mmlist->kill($alias, $really_del); |
84270653 VZ |
74 | |
75 | // Deactivates, when available, the Google Apps account of the user. | |
76 | if ($globals->mailstorage->googleapps_domain) { | |
77 | require_once 'googleapps.inc.php'; | |
14870e88 | 78 | if (GoogleAppsAccount::account_status($uid)) { |
d56cb887 | 79 | $account = new GoogleAppsAccount($user); |
14870e88 VZ |
80 | $account->suspend(); |
81 | } | |
84270653 | 82 | } |
0337d704 | 83 | } |
84 | ||
85 | // }}} | |
8b10988d | 86 | // {{{ function has_user_right() |
87 | function has_user_right($pub, $view = 'private') { | |
88 | if ($pub == $view) return true; | |
787bb3d7 | 89 | // all infos available for private |
8b10988d | 90 | if ($view == 'private') return true; |
787bb3d7 | 91 | // public infos available for all |
8b10988d | 92 | if ($pub == 'public') return true; |
93 | // here we have view = ax or public, and pub = ax or private, and pub != view | |
787bb3d7 | 94 | return false; |
8b10988d | 95 | } |
96 | // }}} | |
0baf0741 | 97 | // {{{ function get_not_registered_user() |
98 | ||
99 | function get_not_registered_user($login, $iterator = false) | |
100 | { | |
101 | global $globals; | |
102 | @list($login, $domain) = explode('@', $login); | |
103 | if ($domain && $domain != $globals->mail->domain && $domain != $globals->mail->domain2) { | |
104 | return null; | |
105 | } | |
106 | @list($prenom, $nom, $promo) = explode('.', $login); | |
d2c88226 SJ |
107 | $where = 'REPLACE(REPLACE(REPLACE(nom, " ", ""), "-", ""), "\'", "") |
108 | LIKE CONCAT("%", REPLACE(REPLACE(REPLACE({?}, " ", ""), "-", ""), "\'", ""), "%") | |
109 | AND REPLACE(REPLACE(REPLACE(prenom, " ", ""), "-", ""), "\'", "") | |
110 | LIKE CONCAT("%", REPLACE(REPLACE(REPLACE({?}, " ", ""), "-", ""), "\'", ""), "%")'; | |
0baf0741 | 111 | if ($promo) { |
112 | if (preg_match('/^[0-9]{2}$/', $promo)) { | |
113 | $where .= 'AND MOD(promo, 100) = {?}'; | |
114 | } elseif (preg_match('/^[0-9]{4}$/', $promo)) { | |
115 | $where .= 'AND promo = {?}'; | |
116 | } | |
117 | } | |
118 | $sql = "SELECT user_id, nom, prenom, promo | |
119 | FROM auth_user_md5 | |
1555e55e | 120 | WHERE $where AND perms = 'pending' |
787bb3d7 | 121 | ORDER BY promo, nom, prenom"; |
0baf0741 | 122 | if ($iterator) { |
123 | return XDB::iterator($sql, $nom, $prenom, $promo); | |
124 | } else { | |
125 | $res = XDB::query($sql, $nom, $prenom, $promo); | |
126 | return $res->fetchAllAssoc(); | |
127 | } | |
128 | } | |
129 | ||
130 | // }}} | |
9039c94d | 131 | // {{{ function get_user_details_pro() |
132 | ||
8b10988d | 133 | function get_user_details_pro($uid, $view = 'private') |
9039c94d | 134 | { |
f9cddbef SJ |
135 | $sql = "SELECT en.name AS entreprise, s.name as secteur, f.fonction_fr as fonction, |
136 | j.description AS poste, gp.pays AS countrytxt, gr.name AS region, | |
137 | j.id AS entrid, j.pub, j.email, j.email_pub, j.url AS w_web, en.url AS web, | |
138 | e.adr1, e.adr2, e.adr3, e.postcode, e.city, e.adr_pub | |
139 | FROM profile_job AS j | |
140 | LEFT JOIN entreprises AS e ON (e.entrid = j.id AND e.uid = j.uid) | |
141 | LEFT JOIN profile_job_enum AS en ON (j.jobid = en.id) | |
142 | LEFT JOIN profile_job_subsubsector_enum AS s ON (j.subsubsectorid = s.id) | |
143 | LEFT JOIN fonctions_def AS f ON (j.functionid = f.id) | |
144 | LEFT JOIN geoloc_pays AS gp ON (gp.a2 = e.country) | |
145 | LEFT JOIN geoloc_region AS gr ON (gr.a2 = e.country AND gr.region = e.region) | |
146 | WHERE j.uid = {?} | |
147 | ORDER BY j.id"; | |
08cce2ff | 148 | $res = XDB::query($sql, $uid); |
8b10988d | 149 | $all_pro = $res->fetchAllAssoc(); |
150 | foreach ($all_pro as $i => $pro) { | |
151 | if (!has_user_right($pro['pub'], $view)) | |
152 | unset($all_pro[$i]); | |
153 | else { | |
154 | if (!has_user_right($pro['adr_pub'], $view)) { | |
dd502514 | 155 | if ($pro['adr1'] == '' && |
156 | $pro['adr2'] == '' && | |
157 | $pro['adr3'] == '' && | |
158 | $pro['postcode'] == '' && | |
159 | $pro['city'] == '' && | |
160 | $pro['countrytxt'] == '' && | |
161 | $pro['region'] == '') { | |
162 | $all_pro[$i]['adr_pub'] = $view; | |
163 | } else { | |
164 | $all_pro[$i]['adr1'] = ''; | |
165 | $all_pro[$i]['adr2'] = ''; | |
166 | $all_pro[$i]['adr3'] = ''; | |
167 | $all_pro[$i]['postcode'] = ''; | |
168 | $all_pro[$i]['city'] = ''; | |
169 | $all_pro[$i]['countrytxt'] = ''; | |
170 | $all_pro[$i]['region'] = ''; | |
171 | } | |
8b10988d | 172 | } |
bde2be3b GB |
173 | $sql = "SELECT pub AS tel_pub, tel_type, display_tel AS tel, comment |
174 | FROM profile_phones AS t | |
175 | WHERE uid = {?} AND link_type = 'pro' AND link_id = {?} | |
176 | ORDER BY link_id, tel_type DESC, tel_id"; | |
177 | $restel = XDB::iterator($sql, $uid, $pro['entrid']); | |
178 | while ($nexttel = $restel->next()) { | |
179 | if (has_user_right($nexttel['tel_pub'], $view)) { | |
180 | if (!isset($all_pro[$i]['tels'])) { | |
181 | $all_pro[$i]['tels'] = array($nexttel); | |
182 | } else { | |
183 | $all_pro[$i]['tels'][] = $nexttel; | |
184 | } | |
dd502514 | 185 | } |
8b10988d | 186 | } |
187 | if (!has_user_right($pro['email_pub'], $view)) { | |
dd502514 | 188 | if ($pro['email'] == '') |
189 | $all_pro[$i]['email_pub'] = $view; | |
190 | else | |
191 | $all_pro[$i]['email'] = ''; | |
8b10988d | 192 | } |
193 | if ($all_pro[$i]['adr1'] == '' && | |
194 | $all_pro[$i]['adr2'] == '' && | |
195 | $all_pro[$i]['adr3'] == '' && | |
196 | $all_pro[$i]['postcode'] == '' && | |
197 | $all_pro[$i]['city'] == '' && | |
198 | $all_pro[$i]['countrytxt'] == '' && | |
199 | $all_pro[$i]['region'] == '' && | |
200 | $all_pro[$i]['entreprise'] == '' && | |
201 | $all_pro[$i]['fonction'] == '' && | |
202 | $all_pro[$i]['secteur'] == '' && | |
203 | $all_pro[$i]['poste'] == '' && | |
bde2be3b | 204 | (!isset($all_pro[$i]['tels'])) && |
8b10988d | 205 | $all_pro[$i]['email'] == '') |
206 | unset($all_pro[$i]); | |
207 | } | |
208 | } | |
209 | if (!count($all_pro)) return false; | |
210 | return $all_pro; | |
9039c94d | 211 | } |
212 | ||
213 | // }}} | |
433336f3 | 214 | // {{{ function get_user_details_adr() |
215 | ||
8b10988d | 216 | function get_user_details_adr($uid, $view = 'private') { |
8b10988d | 217 | $sql = "SELECT a.adrid, a.adr1,a.adr2,a.adr3,a.postcode,a.city, |
218 | gp.pays AS countrytxt,a.region, a.regiontxt, | |
219 | FIND_IN_SET('active', a.statut) AS active, a.adrid, | |
220 | FIND_IN_SET('res-secondaire', a.statut) AS secondaire, | |
5d42c993 | 221 | FIND_IN_SET('courrier', a.statut) AS courier, |
646a4582 | 222 | a.pub, gp.display, a.comment |
8b10988d | 223 | FROM adresses AS a |
224 | LEFT JOIN geoloc_pays AS gp ON (gp.a2=a.country) | |
225 | WHERE uid= {?} AND NOT FIND_IN_SET('pro',a.statut) | |
226 | ORDER BY NOT FIND_IN_SET('active',a.statut), FIND_IN_SET('temporaire',a.statut), FIND_IN_SET('res-secondaire',a.statut)"; | |
08cce2ff | 227 | $res = XDB::query($sql, $uid); |
8b10988d | 228 | $all_adr = $res->fetchAllAssoc(); |
229 | $adrid_index = array(); | |
230 | foreach ($all_adr as $i => $adr) { | |
231 | if (!has_user_right($adr['pub'], $view)) | |
232 | unset($all_adr[$i]); | |
233 | else | |
234 | $adrid_index[$adr['adrid']] = $i; | |
235 | } | |
787bb3d7 | 236 | |
bde2be3b | 237 | $sql = "SELECT link_id AS adrid, pub AS tel_pub, tel_type, display_tel AS tel, tel_id AS telid, comment |
b235d980 | 238 | FROM profile_phones AS t |
5e4417a9 GB |
239 | WHERE uid = {?} AND link_type = 'address' |
240 | ORDER BY link_id, tel_type DESC, tel_id"; | |
08cce2ff | 241 | $restel = XDB::iterator($sql, $uid); |
8b10988d | 242 | while ($nexttel = $restel->next()) { |
243 | if (has_user_right($nexttel['tel_pub'], $view)) { | |
244 | $adrid = $nexttel['adrid']; | |
245 | unset($nexttel['adrid']); | |
246 | if (isset($adrid_index[$adrid])) { | |
787bb3d7 | 247 | if (!isset($all_adr[$adrid_index[$adrid]]['tels'])) |
8b10988d | 248 | $all_adr[$adrid_index[$adrid]]['tels'] = array($nexttel); |
249 | else | |
250 | $all_adr[$adrid_index[$adrid]]['tels'][] = $nexttel; | |
251 | } | |
252 | } | |
253 | } | |
254 | return $all_adr; | |
255 | } | |
433336f3 | 256 | |
257 | // }}} | |
0337d704 | 258 | // {{{ function get_user_details() |
259 | ||
8b10988d | 260 | function &get_user_details($login, $from_uid = '', $view = 'private') |
0337d704 | 261 | { |
d1319488 | 262 | $reqsql = "SELECT u.user_id, d.promo, u.prenom, u.nom, u.nom_usage, u.date, u.cv, |
f6c71069 | 263 | u.perms IN ('admin','user','disabled') AS inscrit, FIND_IN_SET('femme', u.flags) AS sexe, u.deces != 0 AS dcd, u.deces, |
bde2be3b GB |
264 | q.profile_nick AS nickname, q.profile_from_ax, q.profile_freetext AS freetext, |
265 | q.profile_freetext_pub AS freetext_pub, | |
078dc884 | 266 | q.profile_medals_pub AS medals_pub, co.corps_pub AS corps_pub, |
eeb2ec0f SJ |
267 | IF(gp1.nat='',gp1.pays,gp1.nat) AS nationalite, gp1.a2 AS iso3166_1, |
268 | IF(gp2.nat='',gp2.pays,gp2.nat) AS nationalite2, gp2.a2 AS iso3166_2, | |
269 | IF(gp3.nat='',gp3.pays,gp3.nat) AS nationalite3, gp3.a2 AS iso3166_3, | |
0337d704 | 270 | a.alias AS forlife, a2.alias AS bestalias, |
271 | c.uid IS NOT NULL AS is_contact, | |
272 | s.text AS section, p.x, p.y, p.pub AS photo_pub, | |
dd502514 | 273 | u.matricule_ax, |
d9caac6f | 274 | m.expertise != '' AS is_referent, |
cd5bd7dc | 275 | (COUNT(e.email) > 0 OR FIND_IN_SET('googleapps', u.mail_storage) > 0) AS actif, |
dd6fce1e | 276 | d.public_name, d.private_name |
fb2c09c9 SJ |
277 | FROM auth_user_md5 AS u |
278 | INNER JOIN auth_user_quick AS q USING(user_id) | |
279 | INNER JOIN aliases AS a ON (u.user_id = a.id AND a.type = 'a_vie') | |
280 | INNER JOIN aliases AS a2 ON (u.user_id = a2.id AND FIND_IN_SET('bestalias', a2.flags)) | |
281 | LEFT JOIN contacts AS c ON (c.uid = {?} and c.contact = u.user_id) | |
282 | LEFT JOIN profile_corps AS co ON (co.uid = u.user_id) | |
283 | LEFT JOIN geoloc_pays AS gp1 ON (gp1.a2 = u.nationalite) | |
284 | LEFT JOIN geoloc_pays AS gp2 ON (gp2.a2 = u.nationalite2) | |
285 | LEFT JOIN geoloc_pays AS gp3 ON (gp3.a2 = u.nationalite3) | |
286 | INNER JOIN sections AS s ON (s.id = u.section) | |
287 | LEFT JOIN photo AS p ON (p.uid = u.user_id) | |
5fecdf6d | 288 | LEFT JOIN profile_mentor AS m ON (m.uid = u.user_id) |
fb2c09c9 | 289 | LEFT JOIN emails AS e ON (e.uid = u.user_id AND e.flags='active') |
d1319488 | 290 | INNER JOIN profile_display AS d ON (d.pid = u.user_id) |
d9caac6f | 291 | WHERE a.alias = {?} |
292 | GROUP BY u.user_id"; | |
08cce2ff | 293 | $res = XDB::query($reqsql, $from_uid, $login); |
0337d704 | 294 | $user = $res->fetchOneAssoc(); |
295 | $uid = $user['user_id']; | |
8b10988d | 296 | // hide orange status, cv, nickname, section |
297 | if (!has_user_right('private', $view)) { | |
8b10988d | 298 | $user['cv'] = ''; |
299 | $user['nickname'] = ''; | |
300 | $user['section'] = ''; | |
301 | } | |
1052148d | 302 | |
8b10988d | 303 | // hide freetext |
dd502514 | 304 | if (!has_user_right($user['freetext_pub'], $view)) { |
305 | if ($user['freetext'] == '') | |
306 | $user['freetext_pub'] = $view; | |
307 | else | |
308 | $user['freetext'] = ''; | |
309 | } | |
0337d704 | 310 | |
bde2be3b GB |
311 | $sql = "SELECT pub AS tel_pub, tel_type, display_tel AS tel, comment |
312 | FROM profile_phones AS t | |
313 | WHERE uid = {?} AND link_type = 'user' | |
314 | ORDER BY tel_type DESC, tel_id"; | |
315 | $restel = XDB::iterator($sql, $uid); | |
316 | while ($nexttel = $restel->next()) { | |
317 | if (has_user_right($nexttel['tel_pub'], $view)) { | |
318 | if (!isset($user['tels'])) { | |
319 | $user['tels'] = array($nexttel); | |
320 | } else { | |
321 | $user['tels'][] = $nexttel; | |
322 | } | |
323 | } | |
324 | } | |
325 | ||
8b10988d | 326 | $user['adr_pro'] = get_user_details_pro($uid, $view); |
327 | $user['adr'] = get_user_details_adr($uid, $view); | |
0337d704 | 328 | |
8b10988d | 329 | if (has_user_right('private', $view)) { |
330 | $sql = "SELECT text | |
331 | FROM binets_ins | |
332 | LEFT JOIN binets_def ON binets_ins.binet_id = binets_def.id | |
333 | WHERE user_id = {?}"; | |
08cce2ff | 334 | $res = XDB::query($sql, $uid); |
8b10988d | 335 | $user['binets'] = $res->fetchColumn(); |
336 | $user['binets_join'] = join(', ', $user['binets']); | |
787bb3d7 | 337 | |
b37aacd9 FB |
338 | $res = XDB::iterRow("SELECT a.diminutif, a.nom, a.site |
339 | FROM groupex.asso AS a | |
340 | LEFT JOIN groupex.membres AS m ON (m.asso_id = a.id) | |
341 | WHERE m.uid = {?} AND (a.cat = 'GroupesX' OR a.cat = 'Institutions') | |
342 | AND pub = 'public'", $uid); | |
8b10988d | 343 | $user['gpxs'] = Array(); |
ae2f9e35 | 344 | $user['gpxs_name'] = Array(); |
b37aacd9 FB |
345 | while (list($gxd, $gxt, $gxu) = $res->next()) { |
346 | if (!$gxu) { | |
347 | $gxu = 'http://www.polytechnique.net/' . $gxd; | |
348 | } | |
349 | $user['gpxs'][] = '<span title="' . pl_entities($gxt) . "\"><a href=\"$gxu\">$gxd</a></span>"; | |
ae2f9e35 | 350 | $user['gpxs_name'][] = $gxt; |
787bb3d7 | 351 | } |
8b10988d | 352 | $user['gpxs_join'] = join(', ', $user['gpxs']); |
79a5acea | 353 | } |
0337d704 | 354 | |
1504ac45 SJ |
355 | $res = XDB::iterRow("SELECT en.name AS name, en.url AS url, d.degree AS degree, |
356 | ed.grad_year AS grad_year, f.field AS field, ed.program AS program | |
043bbacf | 357 | FROM profile_education AS ed |
c7eac294 SJ |
358 | LEFT JOIN profile_education_enum AS en ON (en.id = ed.eduid) |
359 | LEFT JOIN profile_education_degree_enum AS d ON (d.id = ed.degreeid) | |
360 | LEFT JOIN profile_education_field_enum AS f ON (f.id = ed.fieldid) | |
aafd3025 | 361 | WHERE uid = {?} AND NOT FIND_IN_SET('primary', flags) |
043bbacf SJ |
362 | ORDER BY ed.grad_year", $uid); |
363 | ||
1504ac45 | 364 | if (list($name, $url, $degree, $grad_year, $field, $program) = $res->next()) { |
c7eac294 SJ |
365 | require_once('education.func.inc.php'); |
366 | $user['education'][] = education_fmt($name, $url, $degree, $grad_year, $field, $program, $user['sexe'], true); | |
043bbacf | 367 | } |
1504ac45 | 368 | while (list($name, $url, $degree, $grad_year, $field, $program) = $res->next()) { |
c7eac294 | 369 | $user['education'][] = education_fmt($name, $url, $degree, $grad_year, $field, $program, $user['sexe'], true); |
0337d704 | 370 | } |
0337d704 | 371 | |
078dc884 SJ |
372 | if (has_user_right($user['corps_pub'], $view)) { |
373 | $res = XDB::query("SELECT e1.name AS original, e2.name AS current, r.name AS rank | |
374 | FROM profile_corps AS c | |
375 | LEFT JOIN profile_corps_enum AS e1 ON (c.original_corpsid = e1.id) | |
376 | LEFT JOIN profile_corps_enum AS e2 ON (c.current_corpsid = e2.id) | |
377 | LEFT JOIN profile_corps_rank_enum AS r ON (c.rankid = r.id) | |
378 | WHERE c.uid = {?} AND c.original_corpsid != 1", $uid); | |
379 | if ($res = $res->fetchOneRow()) { | |
380 | list($original, $current, $rank) = $res; | |
381 | $user['corps'] = "Corps d'origine : " . $original . ", corps actuel : " . $current . ", grade : " . $rank; | |
382 | } | |
383 | } | |
384 | ||
8b10988d | 385 | if (has_user_right($user['medals_pub'], $view)) { |
5e70bf24 | 386 | $res = XDB::iterator("SELECT m.id, m.text AS medal, m.type, s.gid, g.text AS grade |
ae2f9e35 | 387 | FROM profile_medals_sub AS s |
388 | INNER JOIN profile_medals AS m ON ( s.mid = m.id ) | |
389 | LEFT JOIN profile_medals_grades AS g ON ( s.mid = g.mid AND s.gid = g.gid ) | |
390 | WHERE s.uid = {?}", $uid); | |
8b10988d | 391 | $user['medals'] = Array(); |
392 | while ($tmp = $res->next()) { | |
393 | $user['medals'][] = $tmp; | |
394 | } | |
0337d704 | 395 | } |
396 | ||
d1a2252a | 397 | $user['networking'] = Array(); |
dc6378df | 398 | $res = XDB::iterator("SELECT n.address, n.pub, m.network_type AS type, m.name, m.filter, m.link |
d1a2252a GB |
399 | FROM profile_networking AS n |
400 | INNER JOIN profile_networking_enum AS m ON (n.network_type = m.network_type) | |
401 | WHERE n.uid = {?}", $uid); | |
402 | while($network = $res->next()) | |
403 | { | |
404 | if (has_user_right($network['pub'], $view)) { | |
dc6378df | 405 | $network['link'] = str_replace('%s', $network['address'], $network['link']); |
d1a2252a GB |
406 | $user['networking'][] = $network; |
407 | } | |
408 | } | |
409 | ||
0337d704 | 410 | return $user; |
411 | } | |
dd502514 | 412 | // }}} |
413 | // {{{ function add_user_address() | |
414 | function add_user_address($uid, $adrid, $adr) { | |
08cce2ff | 415 | XDB::execute( |
dd502514 | 416 | "INSERT INTO adresses (`uid`, `adrid`, `adr1`, `adr2`, `adr3`, `postcode`, `city`, `country`, `datemaj`, `pub`) ( |
417 | SELECT u.user_id, {?}, {?}, {?}, {?}, {?}, {?}, gp.a2, NOW(), {?} | |
418 | FROM auth_user_md5 AS u | |
419 | LEFT JOIN geoloc_pays AS gp ON (gp.pays LIKE {?} OR gp.country LIKE {?} OR gp.a2 LIKE {?}) | |
420 | WHERE u.user_id = {?} | |
421 | LIMIT 1)", | |
422 | $adrid, $adr['adr1'], $adr['adr2'], $adr['adr3'], $adr['postcode'], $adr['city'], $adr['pub'], $adr['countrytxt'], $adr['countrytxt'], $adr['countrytxt'], $uid); | |
423 | if (isset($adr['tels']) && is_array($adr['tels'])) { | |
424 | $telid = 0; | |
425 | foreach ($adr['tels'] as $tel) if ($tel['tel']) { | |
b235d980 | 426 | add_user_tel($uid, 'address', $adrid, $telid, $tel); |
dd502514 | 427 | $telid ++; |
428 | } | |
429 | } | |
430 | } | |
431 | // }}} | |
432 | // {{{ function update_user_address() | |
433 | function update_user_address($uid, $adrid, $adr) { | |
dd502514 | 434 | // update address |
08cce2ff | 435 | XDB::execute( |
787bb3d7 | 436 | "UPDATE adresses AS a LEFT JOIN geoloc_pays AS gp ON (gp.pays = {?}) |
dd502514 | 437 | SET `adr1` = {?}, `adr2` = {?}, `adr3` = {?}, |
438 | `postcode` = {?}, `city` = {?}, a.`country` = gp.a2, `datemaj` = NOW(), `pub` = {?} | |
439 | WHERE adrid = {?} AND uid = {?}", | |
440 | $adr['country_txt'], | |
441 | $adr['adr1'], $adr['adr2'], $adr['adr3'], | |
442 | $adr['postcode'], $adr['city'], $adr['pub'], $adrid, $uid); | |
443 | if (isset($adr['tels']) && is_array($adr['tels'])) { | |
b235d980 | 444 | $res = XDB::query("SELECT tel_id FROM profile_phones WHERE uid = {?} AND link_type = 'address' AND link_id = {?} ORDER BY tel_id", $uid, $adrid); |
dd502514 | 445 | $telids = $res->fetchColumn(); |
446 | foreach ($adr['tels'] as $tel) { | |
447 | if (isset($tel['telid']) && isset($tel['remove']) && $tel['remove']) { | |
b235d980 | 448 | remove_user_tel($uid, 'address', $adrid, $tel['telid']); |
dd502514 | 449 | if (isset($telids[$tel['telid']])) unset($telids[$tel['telid']]); |
450 | } else if (isset($tel['telid'])) { | |
b235d980 | 451 | update_user_tel($uid, 'address', $adrid, $tel['telid'], $tel); |
dd502514 | 452 | } else { |
453 | for ($telid = 0; isset($telids[$telid]) && ($telids[$telid] == $telid); $telid++); | |
b235d980 | 454 | add_user_tel($uid, 'address', $adrid, $telid, $tel); |
dd502514 | 455 | } |
456 | } | |
457 | } | |
458 | } | |
459 | // }}} | |
460 | // {{{ function remove_user_address() | |
461 | function remove_user_address($uid, $adrid) { | |
08cce2ff | 462 | XDB::execute("DELETE FROM adresses WHERE adrid = {?} AND uid = {?}", $adrid, $uid); |
b235d980 | 463 | XDB::execute("DELETE FROM profile_phones WHERE link_id = {?} AND uid = {?} AND link_type = 'address'", $adrid, $uid); |
dd502514 | 464 | } |
465 | // }}} | |
466 | // {{{ function add_user_tel() | |
b235d980 | 467 | function add_user_tel($uid, $link_type, $link_id, $telid, $tel) { |
5e4417a9 GB |
468 | require('profil.func.inc.php'); |
469 | $fmt_phone = format_phone_number($tel['tel']); | |
470 | $disp_phone = format_display_number($fmt_phone, $error); | |
b235d980 GB |
471 | XDB::execute("INSERT INTO profile_phones (uid, link_type, link_id, tel_id, tel_type, search_tel, display_tel, pub) |
472 | VALUES ({?}, {?}, {?}, {?}, {?}, {?}, {?}, {?})", | |
473 | $uid, $link_type, $link_id, $telid, $tel['tel_type'], $fmt_phone, $disp_phone, $tel['tel_pub']); | |
dd502514 | 474 | } |
475 | // }}} | |
476 | // {{{ function update_user_tel() | |
b235d980 | 477 | function update_user_tel($uid, $link_type, $link_id, $telid, $tel) { |
5e4417a9 GB |
478 | require('profil.func.inc.php'); |
479 | $fmt_phone = format_phone_number($tel['tel']); | |
480 | $disp_phone = format_display_number($fmt_phone, $error); | |
b235d980 GB |
481 | XDB::execute("UPDATE profile_phones SET search_tel = {?}, display_tel = {?}, tel_type = {?}, pub = {?} |
482 | WHERE link_type = {?} AND tel_id = {?} AND link_id = {?} AND uid = {?}", | |
5e4417a9 | 483 | $fmt_phone, $disp_phone, $tel['tel_type'], $tel['tel_pub'], |
b235d980 | 484 | $link_type, $telid, $link_id, $uid); |
dd502514 | 485 | } |
486 | // }}} | |
487 | // {{{ function remove_user_tel() | |
b235d980 GB |
488 | function remove_user_tel($uid, $link_type, $link_id, $telid) { |
489 | XDB::execute("DELETE FROM profile_phones WHERE tel_id = {?} AND link_id = {?} AND uid = {?} AND link_type = {?}", | |
490 | $telid, $link_id, $uid, $link_type); | |
dd502514 | 491 | } |
492 | // }}} | |
493 | // {{{ function add_user_pro() | |
494 | function add_user_pro($uid, $entrid, $pro) { | |
08cce2ff | 495 | XDB::execute( |
dd502514 | 496 | "INSERT INTO entreprises (`uid`, `entrid`, `entreprise`, `poste`, `secteur`, `ss_secteur`, `fonction`, |
b235d980 | 497 | `adr1`, `adr2`, `adr3`, `postcode`, `city`, `country`, `region`, `email`, `web`, `pub`, `adr_pub`, `email_pub`) |
dd502514 | 498 | SELECT u.user_id, {?}, {?}, {?}, s.id, ss.id, f.id, |
499 | {?}, {?}, {?}, {?}, {?}, gp.a2, gr.region, {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?} | |
500 | FROM auth_user_md5 AS u | |
501 | LEFT JOIN emploi_secteur AS s ON(s.label LIKE {?}) | |
502 | LEFT JOIN emploi_ss_secteur AS ss ON(s.id = ss.secteur AND ss.label LIKE {?}) | |
503 | LEFT JOIN fonctions_def AS f ON(f.fonction_fr LIKE {?} OR f.fonction_en LIKE {?}) | |
504 | LEFT JOIN geoloc_pays AS gp ON (gp.country LIKE {?} OR gp.pays LIKE {?}) | |
505 | LEFT JOIN geoloc_region AS gr ON (gr.a2 = gp.a2 AND gr.name LIKE {?}) | |
506 | WHERE u.user_id = {?} | |
507 | LIMIT 1", | |
508 | $entrid, $pro['entreprise'], $pro['poste'], | |
b235d980 | 509 | $pro['adr1'], $pro['adr2'], $pro['adr3'], $pro['postcode'], $pro['city'], $pro['email'], $pro['web'], $pro['pub'], $pro['adr_pub'], $pro['email_pub'], |
dd502514 | 510 | $pro['secteur'], $pro['sous_secteur'], $pro['fonction'], $pro['fonction'], |
511 | $pro['countrytxt'], $pro['countrytxt'], $pro['region'], | |
512 | $uid); | |
b235d980 GB |
513 | if (isset($pro['tels']) && is_array($pro['tels'])) { |
514 | $telid = 0; | |
515 | foreach ($pro['tels'] as $tel) { | |
516 | if ($pro['tel']) { | |
517 | add_user_tel($uid, 'pro', $entrid, $telid, $tel); | |
518 | $telid ++; | |
519 | } | |
520 | } | |
521 | } | |
dd502514 | 522 | } |
523 | // }}} | |
524 | // {{{ function update_user_pro() | |
525 | function update_user_pro($uid, $entrid, $pro) { | |
dd502514 | 526 | $join = ""; |
527 | $set = ""; | |
528 | $args_join = array(); | |
529 | $args_set = array(); | |
787bb3d7 | 530 | |
dd502514 | 531 | $join .= "LEFT JOIN emploi_secteur AS s ON(s.label LIKE {?}) |
532 | LEFT JOIN emploi_ss_secteur AS ss ON(s.id = ss.secteur AND ss.label LIKE {?}) | |
533 | LEFT JOIN fonctions_def AS f ON(f.fonction_fr LIKE {?} OR f.fonction_en LIKE {?})"; | |
534 | $args_join[] = $pro['secteur']; | |
535 | $args_join[] = $pro['sous_secteur']; | |
536 | $args_join[] = $pro['fonction']; | |
537 | $args_join[] = $pro['fonction']; | |
538 | $set .= ", e.`entreprise` = {?}, e.`secteur` = s.id, e.`ss_secteur` = ss.id, e.`fonction` = f.id, e.`poste`= {?}, e.`web` = {?}, e.`pub` = {?}"; | |
539 | $args_set[] = $pro['entreprise']; | |
540 | $args_set[] = $pro['poste']; | |
541 | $args_set[] = $pro['web']; | |
542 | $args_set[] = $pro['pub']; | |
787bb3d7 | 543 | |
dd502514 | 544 | if (isset($pro['adr1'])) { |
545 | $join .= "LEFT JOIN geoloc_pays AS gp ON (gp.country LIKE {?} OR gp.pays LIKE {?}) | |
546 | LEFT JOIN geoloc_region AS gr ON (gr.a2 = gp.a2 AND gr.name LIKE {?})"; | |
547 | $args_join[] = $pro['countrytxt']; | |
548 | $args_join[] = $pro['countrytxt']; | |
549 | $args_join[] = $pro['region']; | |
550 | $set .= ", e.`adr1` = {?}, e.`adr2` = {?}, e.`adr3` = {?}, e.`postcode` = {?}, e.`city` = {?}, e.`country` = gp.a2, e.`region` = gr.region, e.`adr_pub` = {?}"; | |
551 | $args_set[] = $pro['adr1']; | |
552 | $args_set[] = $pro['adr2']; | |
553 | $args_set[] = $pro['adr3']; | |
554 | $args_set[] = $pro['postcode']; | |
555 | $args_set[] = $pro['city']; | |
556 | $args_set[] = $pro['adr_pub']; | |
557 | } | |
787bb3d7 | 558 | |
dd502514 | 559 | if (isset($pro['email'])) { |
560 | $set .= ", e.`email` = {?}, e.`email_pub` = {?}"; | |
561 | $args_set[] = $pro['email']; | |
562 | $args_set[] = $pro['email_pub']; | |
787bb3d7 | 563 | } |
dd502514 | 564 | $query = "UPDATE entreprises AS e ".$join." SET ".substr($set,1)." WHERE e.uid = {?} AND e.entrid = {?}"; |
565 | $args_where = array($uid, $entrid); | |
566 | $args = array_merge(array($query), $args_join, $args_set, $args_where); | |
a3a049fc | 567 | call_user_func_array(array('XDB', 'execute'), $args); |
b235d980 GB |
568 | |
569 | ||
570 | if (isset($pro['tels']) && is_array($pro['tels'])) { | |
571 | $res = XDB::query("SELECT tel_id FROM profile_phones WHERE uid = {?} AND link_type = 'pro' AND link_id = {?} ORDER BY tel_id", $uid, $entrid); | |
572 | $telids = $res->fetchColumn(); | |
573 | foreach ($pro['tels'] as $tel) { | |
574 | if (isset($tel['telid']) && isset($tel['remove']) && $tel['remove']) { | |
575 | remove_user_tel($uid, 'pro', $entrid, $tel['telid']); | |
576 | if (isset($telids[$tel['telid']])) unset($telids[$tel['telid']]); | |
577 | } else if (isset($tel['telid'])) { | |
578 | update_user_tel($uid, 'pro', $entrid, $tel['telid'], $tel); | |
579 | } else { | |
580 | for ($telid = 0; isset($telids[$telid]) && ($telids[$telid] == $telid); $telid++); | |
581 | add_user_tel($uid, 'pro', $entrid, $telid, $tel); | |
582 | } | |
583 | } | |
584 | } | |
dd502514 | 585 | } |
586 | // }}} | |
587 | // {{{ function remove_user_pro() | |
588 | function remove_user_pro($uid, $entrid) { | |
08cce2ff | 589 | XDB::execute("DELETE FROM entreprises WHERE entrid = {?} AND uid = {?}", $entrid, $uid); |
b235d980 | 590 | XDB::execute("DELETE FROM profile_phones WHERE link_id = {?} AND uid = {?} AND link_type = 'pro'", $entrid, $uid); |
dd502514 | 591 | } |
592 | // }}} | |
b235d980 | 593 | // {{{ function set_user_details_addresses() |
dd502514 | 594 | function set_user_details_addresses($uid, $adrs) { |
23e39ac3 FB |
595 | $req = XDB::query('SELECT MAX(adrid) + 1 |
596 | FROM adresses | |
597 | WHERE uid = {?}', $uid); | |
598 | $adrid = $req->fetchOneCell(); | |
599 | if (is_null($adrid)) { | |
600 | $adrid = 0; | |
601 | } | |
dd502514 | 602 | foreach ($adrs as $adr) { |
b0470efa FB |
603 | if (!@$adr['remove']) { |
604 | add_user_address($uid, $adrid, $adr); | |
605 | ++$adrid; | |
606 | } | |
dd502514 | 607 | } |
608 | require_once 'geoloc.inc.php'; | |
609 | localize_addresses($uid); | |
610 | } | |
611 | // }}} | |
612 | // {{{ function set_user_details_pro() | |
613 | ||
614 | function set_user_details_pro($uid, $pros) | |
615 | { | |
23e39ac3 FB |
616 | $req = XDB::query('SELECT MAX(entrid) + 1 |
617 | FROM entreprises | |
618 | WHERE uid = {?}', $uid); | |
619 | $entrid = $req->fetchOneCell(); | |
620 | if (is_null($entrid)) { | |
621 | $entrid = 0; | |
622 | } | |
dd502514 | 623 | foreach ($pros as $pro) { |
b0470efa FB |
624 | if (!@$pro['remove']) { |
625 | add_user_pro($uid, $entrid, $pro); | |
626 | ++$entrid; | |
627 | } | |
dd502514 | 628 | } |
629 | } | |
0337d704 | 630 | |
631 | // }}} | |
dd502514 | 632 | // {{{ function set_user_details() |
633 | function set_user_details($uid, $details) { | |
dd502514 | 634 | if (isset($details['nom_usage'])) { |
08cce2ff | 635 | XDB::execute("UPDATE auth_user_md5 SET nom_usage = {?} WHERE user_id = {?}", strtoupper($details['nom_usage']), $uid); |
dd502514 | 636 | } |
dd502514 | 637 | if (isset($details['nationalite'])) { |
08cce2ff | 638 | XDB::execute( |
dd502514 | 639 | "UPDATE auth_user_md5 AS u |
640 | INNER JOIN geoloc_pays AS gp | |
641 | SET u.nationalite = gp.a2 | |
642 | WHERE (gp.a2 = {?} OR gp.nat = {?}) | |
643 | AND u.user_id = {?}", $details['nationalite'], $details['nationalite'], $uid); | |
644 | } | |
645 | if (isset($details['adr']) && is_array($details['adr'])) | |
646 | set_user_details_addresses($uid, $details['adr']); | |
647 | if (isset($details['adr_pro']) && is_array($details['adr_pro'])) | |
648 | set_user_details_pro($uid, $details['adr_pro']); | |
649 | if (isset($details['binets']) && is_array($details['binets'])) { | |
08cce2ff | 650 | XDB::execute("DELETE FROM binets_ins WHERE user_id = {?}", $uid); |
dd502514 | 651 | foreach ($details['binets'] as $binet) |
08cce2ff | 652 | XDB::execute( |
dd502514 | 653 | "INSERT INTO binets_ins (`user_id`, `binet_id`) |
654 | SELECT {?}, id FROM binets_def WHERE text = {?} LIMIT 1", | |
787bb3d7 | 655 | $uid, $binet); |
dd502514 | 656 | } |
657 | if (isset($details['gpxs']) && is_array($details['gpxs'])) { | |
08cce2ff | 658 | XDB::execute("DELETE FROM groupesx_ins WHERE user_id = {?}", $uid); |
dd502514 | 659 | foreach ($details['gpxs'] as $groupex) { |
a14159bf | 660 | if (preg_match('/<a href="[^"]*">([^<]+)</a>/u', $groupex, $a)) $groupex = $a[1]; |
08cce2ff | 661 | XDB::execute( |
dd502514 | 662 | "INSERT INTO groupesx_ins (`user_id`, `binet_id`) |
663 | SELECT {?}, id FROM groupesx_def WHERE text = {?} LIMIT 1", | |
664 | $uid, $groupex); | |
787bb3d7 | 665 | } |
dd502514 | 666 | } |
b235d980 GB |
667 | if (isset($details['tels']) && is_array($details['tels'])) { |
668 | $res = XDB::query("SELECT tel_id FROM profile_phones WHERE uid = {?} AND link_type = 'user' ORDER BY tel_id", $uid); | |
669 | $telids = $res->fetchColumn(); | |
670 | foreach ($details['tels'] as $tel) { | |
671 | if (isset($tel['telid']) && isset($tel['remove']) && $tel['remove']) { | |
672 | remove_user_tel($uid, 'user', 0, $tel['telid']); | |
673 | if (isset($telids[$tel['telid']])) unset($telids[$tel['telid']]); | |
674 | } else if (isset($tel['telid'])) { | |
675 | update_user_tel($uid, 'user', 0, $tel['telid'], $tel); | |
676 | } else { | |
677 | for ($telid = 0; isset($telids[$telid]) && ($telids[$telid] == $telid); $telid++); | |
678 | add_user_tel($uid, 'user', 0, $telid, $tel); | |
679 | } | |
680 | } | |
681 | } | |
682 | ||
f711b03f | 683 | // education |
dd502514 | 684 | // medals |
685 | } | |
686 | // }}} | |
0337d704 | 687 | // {{{ function _user_reindex |
688 | ||
6443c93d | 689 | function _user_reindex($uid, $keys) |
94f6c381 | 690 | { |
0337d704 | 691 | foreach ($keys as $i => $key) { |
6443c93d | 692 | if ($key['name'] == '') { |
0337d704 | 693 | continue; |
694 | } | |
6443c93d | 695 | $toks = preg_split('/[ \'\-]+/', $key['name']); |
0337d704 | 696 | $token = ""; |
697 | $first = 5; | |
698 | while ($toks) { | |
699 | $token = strtolower(replace_accent(array_pop($toks) . $token)); | |
6443c93d | 700 | $score = ($toks ? 0 : 10 + $first) * ($key['score'] / 10); |
c0c9f772 | 701 | XDB::execute("REPLACE INTO search_name (token, uid, soundex, score, flags) |
702 | VALUES ({?}, {?}, {?}, {?}, {?})", | |
6443c93d | 703 | $token, $uid, soundex_fr($token), $score, $key['public']); |
0337d704 | 704 | $first = 0; |
705 | } | |
706 | } | |
707 | } | |
708 | ||
709 | // }}} | |
710 | // {{{ function user_reindex | |
711 | ||
712 | function user_reindex($uid) { | |
6443c93d SJ |
713 | XDB::execute("DELETE FROM search_name |
714 | WHERE uid = {?}", | |
715 | $uid); | |
716 | $res = XDB::iterator("SELECT CONCAT(n.particle, n.name) AS name, e.score, | |
717 | FIND_IN_SET('public', e.flags) AS public | |
718 | FROM profile_name AS n | |
719 | INNER JOIN profile_name_enum AS e ON (n.typeid = e.id) | |
720 | WHERE n.pid = {?}", | |
721 | $uid); | |
722 | _user_reindex($uid, $res); | |
0337d704 | 723 | } |
724 | ||
725 | // }}} | |
433336f3 | 726 | // {{{ function set_new_usage() |
74c55fd6 | 727 | |
a11b5424 | 728 | function set_new_usage($uid, $usage, $alias=false) |
787bb3d7 | 729 | { |
74c55fd6 | 730 | XDB::execute("UPDATE auth_user_md5 set nom_usage={?} WHERE user_id={?}",$usage ,$uid); |
731 | XDB::execute("DELETE FROM aliases WHERE FIND_IN_SET('usage',flags) AND id={?}", $uid); | |
732 | if ($alias && $usage) { | |
733 | XDB::execute("UPDATE aliases SET flags=flags & 255-1 WHERE id={?}", $uid); | |
734 | XDB::execute("INSERT INTO aliases VALUES({?}, 'alias', 'usage,bestalias', {?}, null)", | |
735 | $alias, $uid); | |
736 | } | |
737 | $r = XDB::query("SELECT alias FROM aliases WHERE FIND_IN_SET('bestalias', flags) AND id = {?}", $uid); | |
a11b5424 | 738 | if ($r->numRows() == "") { |
74c55fd6 | 739 | XDB::execute("UPDATE aliases SET flags = 1 | flags WHERE id = {?} LIMIT 1", $uid); |
a11b5424 | 740 | $r = XDB::query("SELECT alias FROM aliases WHERE FIND_IN_SET('bestalias', flags) AND id = {?}", $uid); |
74c55fd6 | 741 | } |
74c55fd6 | 742 | user_reindex($uid); |
a11b5424 | 743 | return $r->fetchOneCell(); |
74c55fd6 | 744 | } |
745 | ||
433336f3 | 746 | // }}} |
747 | // {{{ function get_X_mat | |
748 | function get_X_mat($ourmat) | |
749 | { | |
787bb3d7 | 750 | if (!preg_match('/^[0-9]{8}$/', $ourmat)) { |
433336f3 | 751 | // le matricule de notre base doit comporter 8 chiffres |
752 | return 0; | |
787bb3d7 FB |
753 | } |
754 | ||
433336f3 | 755 | $year = intval(substr($ourmat, 0, 4)); |
756 | $rang = intval(substr($ourmat, 5, 3)); | |
757 | if ($year < 1996) { | |
787bb3d7 | 758 | return; |
433336f3 | 759 | } elseif ($year < 2000) { |
760 | $year = intval(substr(1900 - $year, 1, 3)); | |
761 | return sprintf('%02u0%03u', $year, $rang); | |
762 | } else { | |
763 | $year = intval(substr(1900 - $year, 1, 3)); | |
764 | return sprintf('%03u%03u', $year, $rang); | |
765 | } | |
787bb3d7 FB |
766 | } |
767 | ||
433336f3 | 768 | // }}} |
769 | ||
770 | ||
a7de4ef7 | 771 | // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: |
0337d704 | 772 | ?> |