migrate getlogo
[platal.git] / modules / xnetgrp.php
CommitLineData
ae7bb180 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 XnetGrpModule extends PLModule
23{
24 function handlers()
25 {
26 return array(
dd798f38 27 'grp' => $this->make_hook('index', AUTH_PUBLIC),
28 'grp/asso.php' => $this->make_hook('index', AUTH_PUBLIC),
29 'grp/logo' => $this->make_hook('logo', AUTH_PUBLIC),
ae7bb180 30 );
31 }
32
33 function handler_index(&$page)
34 {
35 global $globals;
36
37 if (!$globals->asso('id')) {
38 return PL_NOT_FOUND;
39 }
40
41 $page->changeTpl('xnet/groupe/asso.tpl');
42 $page->useMenu();
43 $page->setType($globals->asso('cat'));
44 $page->assign('is_member', is_member());
45 $page->assign('logged', logged());
46
47 $page->assign('asso', $globals->asso());
48 }
dd798f38 49
50 function handler_logo(&$page)
51 {
52 global $globals;
53
54 $res = $globals->xdb->query("SELECT logo, logo_mime
55 FROM groupex.asso WHERE id = {?}",
56 $globals->asso('id'));
57 list($logo, $logo_mime) = $res->fetchOneRow();
58
59 if (!empty($logo)) {
60 header("Content-type: $mime");
61 header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
62 header('Last-Modified:' . gmdate('D, d M Y H:i:s') . ' GMT');
63 header('Cache-Control: no-cache, must-revalidate');
64 header('Pragma: no-cache');
65 echo $logo;
66 } else {
67 header('Content-type: image/jpeg');
68 header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
69 header('Last-Modified:' . gmdate('D, d M Y H:i:s') . ' GMT');
70 header('Cache-Control: no-cache, must-revalidate');
71 header('Pragma: no-cache');
72 readfile(dirname(__FILE__).'/../htdocs.net/images/dflt_carre.jpg');
73 }
74
75 exit;
76 }
ae7bb180 77}
78
79?>