Changelog
[platal.git] / modules / profile.php
... / ...
CommitLineData
1<?php
2/***************************************************************************
3 * Copyright (C) 2003-2006 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
22class ProfileModule extends PLModule
23{
24 function handlers()
25 {
26 return array(
27 'photo' => $this->make_hook('photo', AUTH_PUBLIC),
28 'photo/change' => $this->make_hook('photo_change', AUTH_MDP),
29
30 'fiche.php' => $this->make_hook('fiche', AUTH_PUBLIC),
31 'profile' => $this->make_hook('profile', AUTH_PUBLIC),
32 'profile/edit' => $this->make_hook('p_edit', AUTH_MDP),
33 'profile/orange' => $this->make_hook('p_orange', AUTH_MDP),
34 'profile/usage' => $this->make_hook('p_usage', AUTH_MDP),
35
36 'referent' => $this->make_hook('referent', AUTH_COOKIE),
37 'referent/search' => $this->make_hook('ref_search', AUTH_COOKIE),
38
39 'trombi' => $this->make_hook('trombi', AUTH_COOKIE),
40
41 'vcard' => $this->make_hook('vcard', AUTH_COOKIE),
42 );
43 }
44
45 /* XXX COMPAT */
46 function handler_fiche(&$page)
47 {
48 return $this->handler_profile($page, Env::v('user'));
49 }
50
51
52 function _trombi_getlist($offset, $limit)
53 {
54 $where = ( $this->promo > 0 ? "WHERE promo='{$this->promo}'" : "" );
55
56 $res = XDB::query(
57 "SELECT COUNT(*)
58 FROM auth_user_md5 AS u
59 RIGHT JOIN photo AS p ON u.user_id=p.uid
60 $where");
61 $pnb = $res->fetchOneCell();
62
63 $res = XDB::query(
64 "SELECT promo, user_id, a.alias AS forlife,
65 IF (nom_usage='', nom, nom_usage) AS nom, prenom
66 FROM photo AS p
67 INNER JOIN auth_user_md5 AS u ON u.user_id=p.uid
68 INNER JOIN aliases AS a ON ( u.user_id=a.id AND a.type='a_vie' )
69 $where
70 ORDER BY promo, nom, prenom LIMIT {?}, {?}", $offset*$limit, $limit);
71
72 return array($pnb, $res->fetchAllAssoc());
73 }
74
75 function handler_photo(&$page, $x = null, $req = null)
76 {
77 if (is_null($x)) {
78 return PL_NOT_FOUND;
79 }
80
81 $res = XDB::query("SELECT id, pub FROM aliases
82 LEFT JOIN photo ON(id = uid)
83 WHERE alias = {?}", $x);
84 list($uid, $photo_pub) = $res->fetchOneRow();
85
86 if ($req && S::logged()) {
87 include 'validations.inc.php';
88 $myphoto = PhotoReq::get_request($uid);
89 Header('Content-type: image/'.$myphoto->mimetype);
90 echo $myphoto->data;
91 } else {
92 $res = XDB::query(
93 "SELECT attachmime, attach
94 FROM photo
95 WHERE uid={?}", $uid);
96
97 if ((list($type, $data) = $res->fetchOneRow())
98 && ($photo_pub == 'public' || S::logged())) {
99 Header("Content-type: image/$type");
100 echo $data;
101 } else {
102 Header('Content-type: image/png');
103 echo file_get_contents(dirname(__FILE__).'/../htdocs/images/none.png');
104 }
105 }
106 exit;
107 }
108
109 function handler_photo_change(&$page)
110 {
111 $page->changeTpl('trombino.tpl');
112
113 require_once('validations.inc.php');
114
115 $trombi_x = '/home/web/trombino/photos'.S::v('promo')
116 .'/'.S::v('forlife').'.jpg';
117
118 if (Env::has('upload')) {
119 $file = isset($_FILES['userfile']['tmp_name'])
120 ? $_FILES['userfile']['tmp_name']
121 : Env::v('photo');
122 if ($data = file_get_contents($file)) {
123 if ($myphoto = new PhotoReq(S::v('uid'), $data)) {
124 $myphoto->submit();
125 }
126 } else {
127 $page->trig('Fichier inexistant ou vide');
128 }
129 } elseif (Env::has('trombi')) {
130 $myphoto = new PhotoReq(S::v('uid'),
131 file_get_contents($trombi_x));
132 if ($myphoto) {
133 $myphoto->commit();
134 $myphoto->clean();
135 }
136 } elseif (Env::v('suppr')) {
137 XDB::execute('DELETE FROM photo WHERE uid = {?}',
138 S::v('uid'));
139 XDB::execute('DELETE FROM requests
140 WHERE user_id = {?} AND type="photo"',
141 S::v('uid'));
142 } elseif (Env::v('cancel')) {
143 $sql = XDB::query('DELETE FROM requests
144 WHERE user_id={?} AND type="photo"',
145 S::v('uid'));
146 }
147
148 $sql = XDB::query('SELECT COUNT(*) FROM requests
149 WHERE user_id={?} AND type="photo"',
150 S::v('uid'));
151 $page->assign('submited', $sql->fetchOneCell());
152 $page->assign('has_trombi_x', file_exists($trombi_x));
153 }
154
155 function handler_profile(&$page, $x = null)
156 {
157 if (is_null($x)) {
158 return PL_NOT_FOUND;
159 }
160
161 global $globals;
162 require_once 'user.func.inc.php';
163
164 $page->changeTpl('fiche.tpl', SIMPLE);
165
166 $view = 'private';
167 if (!S::logged() || Env::v('view') == 'public') $view = 'public';
168 if (S::logged() && Env::v('view') == 'ax') $view = 'ax';
169
170 if (is_numeric($x)) {
171 $res = XDB::query(
172 "SELECT alias
173 FROM aliases AS a
174 INNER JOIN auth_user_md5 AS u ON (a.id=u.user_id AND a.type='a_vie')
175 WHERE matricule={?}", $x);
176 $login = $res->fetchOneCell();
177 } else {
178 $login = get_user_forlife($x);
179 }
180
181 if (empty($login)) {
182 return PL_NOT_FOUND;
183 }
184
185 $new = Env::v('modif') == 'new';
186 $user = get_user_details($login, S::v('uid'), $view);
187 $title = $user['prenom'] . ' ' . empty($user['nom_usage']) ? $user['nom'] : $user['nom_usage'];
188 $page->assign('xorg_title', $title);
189
190 // photo
191
192 $photo = 'photo/'.$user['forlife'].($new ? '/req' : '');
193
194 if (!isset($user['y']) and !isset($user['x'])) {
195 list($user['x'], $user['y']) = getimagesize("images/none.png");
196 }
197 if (!isset($user['y']) or $user['y'] < 1) $user['y']=1;
198 if (!isset($user['x']) or $user['x'] < 1) $user['x']=1;
199 if ($user['x'] > 240) {
200 $user['y'] = (integer)($user['y']*240/$user['x']);
201 $user['x'] = 240;
202 }
203 if ($user['y'] > 300) {
204 $user['x'] = (integer)($user['x']*300/$user['y']);
205 $user['y'] = 300;
206 }
207 if ($user['x'] < 160) {
208 $user['y'] = (integer)($user['y']*160/$user['x']);
209 $user['x'] = 160;
210 }
211
212 $page->assign('logged', has_user_right('private', $view));
213 if (!has_user_right($user['photo_pub'], $view)) {
214 $photo = "";
215 }
216
217 $page->assign_by_ref('x', $user);
218 $page->assign('photo_url', $photo);
219 // alias virtual
220 $res = XDB::query(
221 "SELECT alias
222 FROM virtual
223 INNER JOIN virtual_redirect USING(vid)
224 INNER JOIN auth_user_quick ON ( user_id = {?} AND emails_alias_pub = 'public' )
225 WHERE ( redirect={?} OR redirect={?} )
226 AND alias LIKE '%@{$globals->mail->alias_dom}'",
227 S::v('uid'),
228 $user['forlife'].'@'.$globals->mail->domain,
229 $user['forlife'].'@'.$globals->mail->domain2);
230 $page->assign('virtualalias', $res->fetchOneCell());
231
232 $page->addJsLink('javascript/close_on_esc.js');
233 }
234
235 function handler_p_edit(&$page, $opened_tab = 'general')
236 {
237 global $globals;
238
239 $page->changeTpl('profil.tpl');
240
241 $page->addCssLink('css/profil.css');
242 $page->assign('xorg_title', 'Polytechnique.org - Mon Profil');
243
244 require_once 'tabs.inc.php';
245 require_once 'profil.func.inc.php';
246 require_once 'synchro_ax.inc.php';
247
248 if (Post::has('register_from_ax_question')) {
249 XDB::query('UPDATE auth_user_quick
250 SET profile_from_ax = 1
251 WHERE user_id = {?}',
252 S::v('uid'));
253 }
254
255 if (is_ax_key_missing()) {
256 $page->assign('no_private_key', true);
257 }
258
259 if (Env::v('synchro_ax') == 'confirm' && !is_ax_key_missing()) {
260 ax_synchronize(S::v('bestalias'), S::v('uid'));
261 $page->trig('Ton profil a été synchronisé avec celui du site polytechniciens.com');
262 }
263
264 // pour tous les tabs, la date de naissance pour verifier
265 // quelle est bien rentree et la date.
266 $res = XDB::query(
267 "SELECT naissance, DATE_FORMAT(date, '%d.%m.%Y')
268 FROM auth_user_md5
269 WHERE user_id={?}", S::v('uid'));
270 list($naissance, $date_modif_profil) = $res->fetchOneRow();
271
272 // lorsqu'on n'a pas la date de naissance en base de données
273 if (!$naissance) {
274 // la date de naissance n'existait pas et vient d'être soumise dans la variable
275 if (Env::has('birth')) {
276 //en cas d'erreur :
277 if (!ereg('[0-3][0-9][0-1][0-9][1][9]([0-9]{2})', Env::v('birth'))) {
278 $page->assign('etat_naissance', 'query');
279 $page->trig('Date de naissance incorrecte ou incohérente.');
280 return;
281 }
282
283 //sinon
284 $birth = sprintf("%s-%s-%s", substr(Env::v('birth'), 4, 4),
285 substr(Env::v('birth'), 2, 2),
286 substr(Env::v('birth'), 0, 2));
287 XDB::execute("UPDATE auth_user_md5
288 SET naissance={?}
289 WHERE user_id={?}", $birth,
290 S::v('uid'));
291 $page->assign('etat_naissance', 'ok');
292 return;
293 }
294
295 $page->assign('etat_naissance', 'query');
296 return; // on affiche le formulaire pour naissance
297 }
298
299 //doit-on faire un update ?
300 if (Env::has('modifier') || Env::has('suivant')) {
301 require_once "profil/get_{$opened_tab}.inc.php";
302 require_once "profil/verif_{$opened_tab}.inc.php";
303
304 if($page->nb_errs()) {
305 require_once "profil/assign_{$opened_tab}.inc.php";
306 $page->assign('onglet', $opened_tab);
307 $page->assign('onglet_tpl', "profil/$opened_tab.tpl");
308 return;
309 }
310
311 $date=date("Y-m-j");//nouvelle date de mise a jour
312
313 //On sauvegarde l'uid pour l'AX
314 /* on sauvegarde les changements dans user_changes :
315 * on a juste besoin d'insérer le user_id de la personne dans la table
316 */
317 XDB::execute('REPLACE INTO user_changes SET user_id={?}',
318 S::v('uid'));
319
320 if (!S::has('suid')) {
321 require_once 'notifs.inc.php';
322 register_watch_op(S::v('uid'), WATCH_FICHE);
323 }
324
325 // mise a jour des champs relatifs au tab ouvert
326 require_once "profil/update_{$opened_tab}.inc.php";
327
328 $log =& S::v('log');
329 $log->log('profil', $opened_tab);
330 $page->assign('etat_update', 'ok');
331 }
332
333 if (Env::has('suivant')) {
334 pl_redirect('profile/edit/' . get_next_tab($opened_tab));
335 }
336
337 require_once "profil/get_{$opened_tab}.inc.php";
338 require_once "profil/verif_{$opened_tab}.inc.php";
339 require_once "profil/assign_{$opened_tab}.inc.php";
340
341 $page->assign('onglet', $opened_tab);
342 $page->assign('onglet_tpl', "profil/$opened_tab.tpl");
343
344 return;
345 }
346
347 function handler_p_orange(&$page)
348 {
349 $page->changeTpl('orange.tpl');
350
351 require_once 'validations.inc.php';
352 require_once 'xorg.misc.inc.php';
353
354 $res = XDB::query(
355 "SELECT u.promo, u.promo_sortie
356 FROM auth_user_md5 AS u
357 WHERE user_id={?}", S::v('uid'));
358
359 list($promo, $promo_sortie_old) = $res->fetchOneRow();
360 $page->assign('promo_sortie_old', $promo_sortie_old);
361 $page->assign('promo', $promo);
362
363 if (!Env::has('promo_sortie')) {
364 return;
365 }
366
367 $promo_sortie = Env::i('promo_sortie');
368
369 if ($promo_sortie < 1000 || $promo_sortie > 9999) {
370 $page->trig('L\'année de sortie doit être un nombre de quatre chiffres');
371 }
372 elseif ($promo_sortie < $promo + 3) {
373 $page->trig('Trop tôt');
374 }
375 elseif ($promo_sortie == $promo_sortie_old) {
376 $page->trig('Tu appartiens déjà à la promotion correspondante à cette année de sortie.');
377 }
378 elseif ($promo_sortie == $promo + 3) {
379 XDB::execute(
380 "UPDATE auth_user_md5 set promo_sortie={?}
381 WHERE user_id={?}", $promo_sortie, S::v('uid'));
382 $page->trig('Ton statut "orange" a été supprimé.');
383 $page->assign('promo_sortie_old', $promo_sortie);
384 }
385 else {
386 $page->assign('promo_sortie', $promo_sortie);
387
388 if (Env::has('submit')) {
389 $myorange = new OrangeReq(S::v('uid'),
390 $promo_sortie);
391 $myorange->submit();
392 $page->assign('myorange', $myorange);
393 }
394 }
395 }
396
397 function handler_referent(&$page, $x = null)
398 {
399 require_once 'user.func.inc.php';
400
401 if (is_null($x)) {
402 return PL_NOT_FOUND;
403 }
404
405 $page->changeTpl('fiche_referent.tpl', SIMPLE);
406
407 $res = XDB::query(
408 "SELECT prenom, nom, user_id, promo, cv, a.alias AS bestalias
409 FROM auth_user_md5 AS u
410 INNER JOIN aliases AS a ON (u.user_id=a.id
411 AND FIND_IN_SET('bestalias', a.flags))
412 INNER JOIN aliases AS a1 ON (u.user_id=a1.id
413 AND a1.alias = {?}
414 AND a1.type!='homonyme')", $x);
415
416 if ($res->numRows() != 1) {
417 return PL_NOT_FOUND;
418 }
419
420 list($prenom, $nom, $user_id, $promo, $cv, $bestalias) = $res->fetchOneRow();
421
422 $page->assign('prenom', $prenom);
423 $page->assign('nom', $nom);
424 $page->assign('promo', $promo);
425 $page->assign('cv', $cv);
426 $page->assign('bestalias', $bestalias);
427 $page->assign('adr_pro', get_user_details_pro($user_id));
428
429 ///// recuperations infos referent
430
431 //expertise
432 $res = XDB::query("SELECT expertise FROM mentor WHERE uid = {?}", $user_id);
433 $page->assign('expertise', $res->fetchOneCell());
434
435 //secteurs
436 $secteurs = $ss_secteurs = Array();
437 $res = XDB::iterRow(
438 "SELECT s.label, ss.label
439 FROM mentor_secteurs AS m
440 LEFT JOIN emploi_secteur AS s ON(m.secteur = s.id)
441 LEFT JOIN emploi_ss_secteur AS ss ON(m.secteur = ss.secteur AND m.ss_secteur = ss.id)
442 WHERE uid = {?}", $user_id);
443 while (list($sec, $ssec) = $res->next()) {
444 $secteurs[] = $sec;
445 $ss_secteurs[] = $ssec;
446 }
447 $page->assign_by_ref('secteurs', $secteurs);
448 $page->assign_by_ref('ss_secteurs', $ss_secteurs);
449
450 //pays
451 $res = XDB::query(
452 "SELECT gp.pays
453 FROM mentor_pays AS m
454 LEFT JOIN geoloc_pays AS gp ON(m.pid = gp.a2)
455 WHERE uid = {?}", $user_id);
456 $page->assign('pays', $res->fetchColumn());
457
458 $page->addJsLink('javascript/close_on_esc.js');
459 }
460
461 function handler_ref_search(&$page)
462 {
463 $page->changeTpl('referent.tpl');
464
465 $page->assign('xorg_title', 'Polytechnique.org - Conseil Pro');
466
467 $secteur_sel = Post::v('secteur');
468 $ss_secteur_sel = Post::v('ss_secteur');
469 $pays_sel = Post::v('pays', '00');
470 $expertise_champ = Post::v('expertise');
471
472 $page->assign('pays_sel', $pays_sel);
473 $page->assign('expertise_champ', $expertise_champ);
474 $page->assign('secteur_sel', $secteur_sel);
475 $page->assign('ss_secteur_sel', $ss_secteur_sel);
476
477 //recuperation des noms de secteurs
478 $res = XDB::iterRow("SELECT id, label FROM emploi_secteur");
479 $secteurs[''] = '';
480 while (list($tmp_id, $tmp_label) = $res->next()) {
481 $secteurs[$tmp_id] = $tmp_label;
482 }
483 $page->assign_by_ref('secteurs', $secteurs);
484
485 //on recupere les sous-secteurs si necessaire
486 $ss_secteurs[''] = '';
487 if (!empty($secteur_sel)) {
488 $res = XDB::iterRow("SELECT id, label FROM emploi_ss_secteur
489 WHERE secteur = {?}", $secteur_sel);
490 while (list($tmp_id, $tmp_label) = $res->next()) {
491 $ss_secteurs[$tmp_id] = $tmp_label;
492 }
493 }
494 $page->assign_by_ref('ss_secteurs', $ss_secteurs);
495
496 //recuperation des noms de pays
497 $res = XDB::iterRow("SELECT a2, pays FROM geoloc_pays
498 WHERE pays <> '' ORDER BY pays");
499 $pays['00'] = '';
500 while (list($tmp_id, $tmp_label) = $res->next()) {
501 $pays[$tmp_id] = $tmp_label;
502 }
503 $page->assign_by_ref('pays', $pays);
504
505 // nb de mentors
506 $res = XDB::query("SELECT count(*) FROM mentor");
507 $page->assign('mentors_number', $res->fetchOneCell());
508
509 if (!Env::has('Chercher')) {
510 return;
511 }
512
513 // On vient d'un formulaire
514 $where = array();
515
516 if ($pays_sel != '00') {
517 $where[] = "mp.pid = '".addslashes($pays_sel)."'";
518 }
519 if ($secteur_sel) {
520 $where[] = "ms.secteur = '".addslashes($secteur_sel)."'";
521 if ($ss_secteur_sel) {
522 $where[] = "ms.ss_secteur = '".addslashes($ss_secteur_sel)."'";
523 }
524 }
525 if ($expertise_champ) {
526 $where[] = "MATCH(m.expertise) AGAINST('".addslashes($expertise_champ)."')";
527 }
528
529 if ($where) {
530 $where = join(' AND ', $where);
531
532 $sql = "SELECT m.uid, a.prenom, a.nom, a.promo,
533 l.alias AS bestalias, m.expertise, mp.pid,
534 ms.secteur, ms.ss_secteur
535 FROM mentor AS m
536 LEFT JOIN auth_user_md5 AS a ON(m.uid = a.user_id)
537 INNER JOIN aliases AS l ON (a.user_id=l.id AND
538 FIND_IN_SET('bestalias', l.flags))
539 LEFT JOIN mentor_pays AS mp ON(m.uid = mp.uid)
540 LEFT JOIN mentor_secteurs AS ms ON(m.uid = ms.uid)
541 WHERE $where
542 GROUP BY uid
543 ORDER BY RAND({?})";
544 $res = XDB::iterator($sql, S::v('uid'));
545
546 if ($res->total() == 0) {
547 $page->assign('recherche_trop_large', true);
548 return;
549 }
550
551 $nb_max_res_total = 100;
552 $nb_max_res_ppage = 10;
553
554 $curpage = Env::i('curpage', 1);
555 $personnes = array();
556 $i = 0;
557
558 while (($pers = $res->next()) && count($personnes) < $nb_max_res_total) {
559 $the_page = intval($i / $nb_max_res_ppage) + 1;
560 if ($the_page == $curpage) {
561 $personnes[] = $pers;
562 }
563 $i ++;
564 }
565
566 $page->assign('personnes', $personnes);
567 $page->assign('curpage', $curpage);
568 $page->assign('nb_pages_total',
569 intval($res->total() / $nb_max_res_ppage) + 1);
570 }
571 }
572
573 function handler_p_usage(&$page)
574 {
575 $page->changeTpl('nomusage.tpl');
576
577 require_once 'validations.inc.php';
578 require_once 'xorg.misc.inc.php';
579 require_once 'diogenes/diogenes.flagset.inc.php';
580
581 $res = XDB::query(
582 "SELECT u.nom, u.nom_usage, u.flags, e.alias
583 FROM auth_user_md5 AS u
584 LEFT JOIN aliases AS e ON(u.user_id = e.id
585 AND FIND_IN_SET('usage', e.flags))
586 WHERE user_id={?}", S::v('uid'));
587
588 list($nom, $usage_old, $flags, $alias_old) = $res->fetchOneRow();
589 $flags = new flagset($flags);
590 $page->assign('usage_old', $usage_old);
591 $page->assign('alias_old', $alias_old);
592
593 $nom_usage = replace_accent(trim(Env::v('nom_usage')));
594 $nom_usage = strtoupper($nom_usage);
595 $page->assign('usage_req', $nom_usage);
596
597 if (Env::has('submit') && ($nom_usage != $usage_old)) {
598 // on vient de recevoir une requete, differente de l'ancien nom d'usage
599 if ($nom_usage == $nom) {
600 $page->assign('same', true);
601 } else { // le nom de mariage est distinct du nom à l'X
602 // on calcule l'alias pour l'afficher
603 $reason = Env::v('reason');
604 if ($reason == 'other') {
605 $reason = Env::v('other_reason');
606 }
607 $myusage = new UsageReq(S::v('uid'), $nom_usage, $reason);
608 $myusage->submit();
609 $page->assign('myusage', $myusage);
610 }
611 }
612 }
613
614 function handler_trombi(&$page, $promo = null)
615 {
616 require_once 'trombi.inc.php';
617
618 $page->changeTpl('trombipromo.tpl');
619 $page->assign('xorg_title', 'Polytechnique.org - Trombi Promo');
620
621 if (is_null($promo)) {
622 return;
623 }
624
625 $this->promo = $promo = intval($promo);
626
627 if ($promo >= 1900 && $promo < intval(date('Y'))
628 || ($promo == -1 && S::has_perms()))
629 {
630 $trombi = new Trombi(array($this, '_trombi_getlist'));
631 $trombi->hidePromo();
632 $trombi->setAdmin();
633 $page->assign_by_ref('trombi', $trombi);
634 } else {
635 $page->trig('Promotion incorrecte (saisir au format YYYY). Recommence.');
636 }
637 }
638
639 function format_adr($params, &$smarty)
640 {
641 // $adr1, $adr2, $adr3, $postcode, $city, $region, $country
642 extract($params['adr']);
643 $adr = $adr1;
644 $adr = trim("$adr\n$adr2");
645 $adr = trim("$adr\n$adr3");
646 return quoted_printable_encode(";;$adr;$city;$region;$postcode;$country");
647 }
648
649 function handler_vcard(&$page, $x = null)
650 {
651 if (is_null($x)) {
652 return PL_NOT_FOUND;
653 }
654
655 global $globals;
656
657 if (substr($x, -4) == '.vcf') {
658 $x = substr($x, 0, strlen($x) - 4);
659 }
660
661 $page->changeTpl('vcard.tpl', NO_SKIN);
662 require_once 'xorg.misc.inc.php';
663 require_once 'user.func.inc.php';
664
665 $page->register_modifier('qp_enc', 'quoted_printable_encode');
666 $page->register_function('format_adr', array($this, 'format_adr'));
667
668 $login = get_user_forlife($x);
669 $user = get_user_details($login);
670
671 // alias virtual
672 $res = XDB::query(
673 "SELECT alias
674 FROM virtual
675 INNER JOIN virtual_redirect USING(vid)
676 INNER JOIN auth_user_quick ON ( user_id = {?} AND emails_alias_pub = 'public' )
677 WHERE ( redirect={?} OR redirect={?} )
678 AND alias LIKE '%@{$globals->mail->alias_dom}'",
679 S::v('uid'),
680 $user['forlife'].'@'.$globals->mail->domain,
681 $user['forlife'].'@'.$globals->mail->domain2);
682
683 $user['virtualalias'] = $res->fetchOneCell();
684
685 $page->assign_by_ref('vcard', $user);
686
687 header("Pragma: ");
688 header("Cache-Control: ");
689 header("Content-type: text/x-vcard\n");
690 header("Content-Transfer-Encoding: Quoted-Printable\n");
691 }
692}
693
694?>