Proof of concept:
[platal.git] / htdocs / fiche.php
CommitLineData
0337d704 1<?php
2/***************************************************************************
50a40a33 3 * Copyright (C) 2003-2006 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
23require_once("xorg.inc.php");
8b10988d 24
25// manage the public fiche or ax fiche
26$view = 'private';
27if (!logged() || Env::get('view') == 'public') $view = 'public';
28if (logged() && Env::get('view') == 'ax') $view = 'ax';
29
30new_simple_page('fiche.tpl', ($view == 'public')?AUTH_PUBLIC:AUTH_COOKIE);
0337d704 31require_once('user.func.inc.php');
32
33if (!Env::has('user') && !Env::has('mat')) {
34 $page->kill("cette page n'existe pas");
35}
36
37if (Env::has('user')) {
38 $login = get_user_forlife(Env::get('user'));
39 if ($login === false) {
40 $page->kill("");
41 }
42}
43
44if (Env::has('mat')) {
45 $res = $globals->xdb->query(
46 "SELECT alias
47 FROM aliases AS a
48 INNER JOIN auth_user_md5 AS u ON (a.id=u.user_id AND a.type='a_vie')
49 WHERE matricule={?}", Env::getInt('mat'));
50 $login = $res->fetchOneCell();
51 if (empty($login)) {
52 $page->kill("cette page n'existe pas");
53 }
54}
55
56$new = Env::get('modif') == 'new';
8b10988d 57$user = get_user_details($login, Session::getInt('uid'), $view);
0337d704 58$title = $user['prenom'] . ' ' . empty($user['nom_usage']) ? $user['nom'] : $user['nom_usage'];
59$page->assign('xorg_title', $title);
60
61// photo
62
63$photo = 'getphoto.php?x='.$user['forlife'].($new ? '&amp;req=true' : '');
64
65if(!isset($user['y']) and !isset($user['x'])) {
66 list($user['x'], $user['y']) = getimagesize("images/none.png");
67}
68if(!isset($user['y']) or $user['y'] < 1) $user['y']=1;
69if(!isset($user['x']) or $user['x'] < 1) $user['x']=1;
70if($user['x'] > 240){
71 $user['y'] = (integer)($user['y']*240/$user['x']);
72 $user['x'] = 240;
73}
74if($user['y'] > 300){
75 $user['x'] = (integer)($user['x']*300/$user['y']);
76 $user['y'] = 300;
77}
78if($user['x'] < 160){
79 $user['y'] = (integer)($user['y']*160/$user['x']);
80 $user['x'] = 160;
81}
82
8b10988d 83$page->assign('logged', has_user_right('private', $view));
84if (!has_user_right($user['photo_pub'], $view)) {
85 $photo = "";
0337d704 86}
0337d704 87
8b10988d 88$page->assign_by_ref('x', $user);
0337d704 89$page->assign('photo_url', $photo);
90// alias virtual
91$res = $globals->xdb->query(
92 "SELECT alias
93 FROM virtual
94 INNER JOIN virtual_redirect USING(vid)
95 INNER JOIN auth_user_quick ON ( user_id = {?} AND emails_alias_pub = 'public' )
96 WHERE ( redirect={?} OR redirect={?} )
97 AND alias LIKE '%@{$globals->mail->alias_dom}'",
98 Session::getInt('uid'), $user['forlife'].'@'.$globals->mail->domain, $user['forlife'].'@'.$globals->mail->domain2);
99$page->assign('virtualalias', $res->fetchOneCell());
100
101$page->addJsLink('javascript/close_on_esc.js');
102$page->run();
103
104// vim:set et sws=4 sw=4 sts=4:
105?>