interface.inc.php 31.9 KB
Newer Older
Ayolo's avatar
Ayolo committed
1
2
3
4
5
6
<?php

/** @file
 *
 *
 */
Ayolo's avatar
bleh    
Ayolo committed
7
/* Copyright 2005,2006,2008
Ayolo's avatar
Ayolo committed
8
 * - Julien Etelain < julien at pmad dot net >
Ayolo's avatar
bleh    
Ayolo committed
9
 * - Simon lopez < simon dot lopez at ayolo dot org >
Ayolo's avatar
Ayolo committed
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
 *
 * Ce fichier fait partie du site de l'Association des Étudiants de
 * l'UTBM, http://ae.utbm.fr.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; either version 2 of the
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 * 02111-1307, USA.
 */
Lopar's avatar
Lopar committed
29

Feu's avatar
Feu committed
30
$timing["all"] -= microtime(true);
Ayolo's avatar
Ayolo committed
31

32
setlocale(LC_ALL,"fr_FR.UTF8");
Ayolo's avatar
Ayolo committed
33

Feu's avatar
hein?    
Feu committed
34
if( !strncmp('/var/www/ae/www/taiste', $_SERVER['SCRIPT_FILENAME'], 22) )
Feu's avatar
Feu committed
35
36
37
38
  $GLOBALS["taiste"] = true;
else
  $GLOBALS["taiste"] = false;

Ayolo's avatar
Ayolo committed
39
40
41
42
43
44
45
46
47
48
49
50
require_once($topdir . "include/mysql.inc.php");
require_once($topdir . "include/mysqlae.inc.php");
require_once($topdir . "include/entities/std.inc.php");
require_once($topdir . "include/entities/utilisateur.inc.php");
require_once($topdir . "include/cts/standart.inc.php");

if ( !isset($wwwtopdir) )
  $wwwtopdir = $topdir;


/** Classe générant l'interface
 * @see site
Feu's avatar
Feu committed
51
 * @ingroup display
Ayolo's avatar
Ayolo committed
52
53
54
 */
class interfaceweb
{
Ayolo's avatar
bleh    
Ayolo committed
55
56
57
  var $db;
  var $dbrw;
  var $user;
Lopar's avatar
Lopar committed
58

Ayolo's avatar
bleh    
Ayolo committed
59
60
61
62
  var $contents;
  var $sides;
  var $sides_ref;
  var $boxes;
Ayolo's avatar
Ayolo committed
63

Ayolo's avatar
bleh    
Ayolo committed
64
65
  protected $buffer="";

Ayolo's avatar
bleh    
Ayolo committed
66
  var $section;
67
  var $title;
Ayolo's avatar
Ayolo committed
68

Ayolo's avatar
bleh    
Ayolo committed
69
70
71
  var $extracss;
  var $rss;
  var $extrajs;
Lopar's avatar
Lopar committed
72

Ayolo's avatar
bleh    
Ayolo committed
73
  var $compact;
Lopar's avatar
Lopar committed
74

Ayolo's avatar
bleh    
Ayolo committed
75
  var $params; // cache des paramètres
Lopar's avatar
Lopar committed
76

Feu's avatar
Feu committed
77
78
79
  var $meta_keywords;
  var $meta_description;
  var $alternate;
Lopar's avatar
Lopar committed
80

Ayolo's avatar
bleh    
Ayolo committed
81
82
83
84
85
  var $tab_array = array (array ("accueil", "index.php", "Accueil"),
        array ("presentation", "article.php?name=presentation", "Présentation",
           array (
              array ("article.php?name=presentation", "L'AE" ),
              array ("asso.php", "Associations et clubs" ),
86
              array ("article.php?name=presentation:services", "Services quotidiens" )
Ayolo's avatar
bleh    
Ayolo committed
87
             ) ),
88
        array ("services", "article.php?name=services", "Services" ),
Feu's avatar
Feu committed
89
90
        //array ("pg", "pgae.php", "Petit géni"),
        array ("eboutic", "e-boutic/", "E-boutic"),
Ayolo's avatar
bleh    
Ayolo committed
91
92
93
        array ("matmatronch", "matmatronch/", "Matmatronch"),
        array ("sas", "sas2/", "SAS"),
        array ("forum", "forum2/", "Forum"),
BenC's avatar
BenC committed
94
        array ("wiki", "wiki2/", "Wiki"),
Ayolo's avatar
bleh    
Ayolo committed
95
96
97
98
99
100
        array ("fichiers", "d.php", "Fichiers",
           array (
              array ("d.php", "Fichiers de l'AE" ),
              array ("asso.php", "Fichiers des associations et des clubs" )
             ) ),
        array ("liens","article.php?name=liens","Liens"));
Lopar's avatar
Lopar committed
101

Ayolo's avatar
bleh    
Ayolo committed
102
103
104
105
106
107
108
109
  /** Constructeur
   * @param $db instance de la base de donnée pour la lecture
   * @param $dbrw instance de la base de donéne pour l'écriture (+lecture)
   */
  function interfaceweb ( $db, $dbrw = false )
  {
    $this->db = $db;
    $this->dbrw = $dbrw;
Ayolo's avatar
bleh    
Ayolo committed
110

Ayolo's avatar
bleh    
Ayolo committed
111
    $this->sides["left"] = array();
Ayolo's avatar
bleh    
Ayolo committed
112
    $this->sides["right"] = array();
Lopar's avatar
Lopar committed
113

Ayolo's avatar
bleh    
Ayolo committed
114
115
116
117
118
    $this->user = new utilisateur( $db, $dbrw );
    $this->extracss = array();
    $this->extrajs = array();
    $this->rss = array();
    $this->contents=array();
Feu's avatar
Feu committed
119
    $this->alternate=array();
Ayolo's avatar
bleh    
Ayolo committed
120
  }
Ayolo's avatar
Ayolo committed
121

Ayolo's avatar
bleh    
Ayolo committed
122
123
124
125
126
127
128
129
  /** Défini les boites à afficher sur un coté
   * @param $side Coté (left ou right)
   * @param $boxes Array des nom des boites à afficher
   */
  function set_side_boxes ( $side, $boxes, $ref=null )
  {
    if ( $side != "left" && $side != "right" ) return;
    $this->sides[$side] = $boxes;
Lopar's avatar
Lopar committed
130

Ayolo's avatar
bleh    
Ayolo committed
131
132
133
134
135
136
137
138
    if ( $ref == null )
    {
      if ( isset($this->sides_ref[$side]) )
        unset($this->sides_ref[$side]);
    }
    else
      $this->sides_ref[$side] = $ref;
  }
Lopar's avatar
Lopar committed
139

Ayolo's avatar
bleh    
Ayolo committed
140
141
142
143
144
145
  /** Ajoute une boite affichable sur le coté
   * $name Nom de la boite
   * $contents Instance de stdcontents à afficher
   */
  function add_box ( $name, $contents )
  {
Ayolo's avatar
Ayolo committed
146
147
    if ( is_null($contents) )
      return;
Ayolo's avatar
bleh    
Ayolo committed
148
149
    $this->boxes[$name] = $contents;
  }
Ayolo's avatar
Ayolo committed
150

Ayolo's avatar
bleh    
Ayolo committed
151
152
153
154
155
156
157
158
  /** Ajoute une boite de contenu (dans le centre).
   * Si un titre est défini, alors il sera affiché.
   * @param $contents Instance de stdcontents à afficher.
   */
  function add_contents ( $contents )
  {
    $this->contents[] = $contents;
  }
Ayolo's avatar
Ayolo committed
159

Ayolo's avatar
bleh    
Ayolo committed
160
161
162
163
164
  /** Initlialise la page
   * @param $section Nom de la section
   * @param $title Titre de la page
   */
  function start_page ( $section, $title, $compact=false ) // <=> page
165
  {
Ayolo's avatar
bleh    
Ayolo committed
166
167
168
169
    $this->section = $section;
    $this->title = $title;
    $this->compact = $compact;
  }
Ayolo's avatar
Ayolo committed
170

Ayolo's avatar
bleh    
Ayolo committed
171
172
173
174
175
176
177
178
  /** Calcul de la survie des bars :P
   *
   */
  function get_comptoir()
  {
    return '';
  }

Ayolo's avatar
bleh    
Ayolo committed
179
180
  function add_css ( $url )
  {
181
    $this->extracss[] = $url;
Ayolo's avatar
bleh    
Ayolo committed
182
  }
Lopar's avatar
Lopar committed
183

Ayolo's avatar
bleh    
Ayolo committed
184
185
  function add_js ( $url )
  {
186
    $this->extrajs[] = $url;
Ayolo's avatar
bleh    
Ayolo committed
187
  }
Ayolo's avatar
Ayolo committed
188

Ayolo's avatar
bleh    
Ayolo committed
189
190
  function add_rss ( $title, $url )
  {
Feu's avatar
debug    
Feu committed
191
    $this->add_alternate ( "application/rss+xml", $title, $url );
Ayolo's avatar
bleh    
Ayolo committed
192
  }
Lopar's avatar
Lopar committed
193

Ayolo's avatar
bleh    
Ayolo committed
194
195
196
197
  /** Termine et affiche la page
   */
  function end_page () // <=> html_render
  {
Ayolo's avatar
bleh    
Ayolo committed
198
    global $wwwtopdir,$topdir,$timing ;
Feu's avatar
Feu committed
199
200
    $timing["render"] -= microtime(true);

Ayolo's avatar
bleh    
Ayolo committed
201
    header("Content-Type: text/html; charset=utf-8");
Lopar's avatar
Lopar committed
202

Ayolo's avatar
bleh    
Ayolo committed
203
204
    $this->buffer .= "<html xmlns=\"http://www.w3.org/1999/xhtml\" xmlns:v=\"urn:schemas-microsoft-com:vml\">\n";
    $this->buffer .= "<head>\n";
Lopar's avatar
Lopar committed
205

Ayolo's avatar
bleh    
Ayolo committed
206
    $this->buffer .= "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" />\n"; // (IE6 Legacy support)
Ayolo's avatar
bleh    
Ayolo committed
207
    if(!defined('NOTAE'))
Ayolo's avatar
bleh    
Ayolo committed
208
209
210
211
    {
      $this->buffer .= "<title>".htmlentities($this->title,ENT_COMPAT,"UTF-8")." - association des etudiants de l'utbm</title>\n";
      $this->buffer .= "<link rel=\"stylesheet\" type=\"text/css\" href=\"" . $wwwtopdir . "themes/default2/css/site2.css?".filemtime($wwwtopdir . "themes/default2/css/site2.css")."\" title=\"AE2-NEW2\" />\n";
    }
Ayolo's avatar
bleh    
Ayolo committed
212
    else
Ayolo's avatar
bleh    
Ayolo committed
213
214
215
216
217
218
219
    {
      $this->buffer .= "<title>".htmlentities($this->title,ENT_COMPAT,"UTF-8")."</title>\n";
      if(isset($this->css))
        $this->buffer .= "<link rel=\"stylesheet\" type=\"text/css\" href=\"" . $wwwtopdir . $this->css."?".filemtime($wwwtopdir . $this->css)."\" title=\"AE2-NEW2\" />\n";
      else
        $this->buffer .= "<link rel=\"stylesheet\" type=\"text/css\" href=\"" . $wwwtopdir . "themes/default2/css/site2.css?".filemtime($wwwtopdir . "themes/default2/css/site2.css")."\" title=\"AE2-NEW2\" />\n";
    }
Ayolo's avatar
Ayolo committed
220
221
    foreach ( $this->extracss as $url )
      if(file_exists(htmlentities($wwwtopdir . $url,ENT_COMPAT,"UTF-8")))
Ayolo's avatar
bleh    
Ayolo committed
222
        $this->buffer .= "<link rel=\"stylesheet\" type=\"text/css\" href=\"".
Ayolo's avatar
Ayolo committed
223
224
225
             htmlentities($wwwtopdir . $url,ENT_COMPAT,"UTF-8")."?".
             filemtime(htmlentities($wwwtopdir . $url,ENT_COMPAT,"UTF-8"))."\" />\n";

Feu's avatar
Feu committed
226
227
    foreach ( $this->alternate as $row )
    {
Ayolo's avatar
bleh    
Ayolo committed
228
      $this->buffer .= "<link rel=\"alternate\" ".
Feu's avatar
Feu committed
229
230
231
        "type=\"".htmlentities($row[0],ENT_COMPAT,"UTF-8")."\" ".
        "title=\"".htmlentities($row[1],ENT_COMPAT,"UTF-8")."\" ".
        "href=\"".htmlentities($row[2],ENT_COMPAT,"UTF-8")."\" />\n";
Feu's avatar
Feu committed
232
    }
Lopar's avatar
Lopar committed
233

Feu's avatar
Feu committed
234
    if ( !empty($this->meta_keywords) )
Ayolo's avatar
bleh    
Ayolo committed
235
      $this->buffer .= "<meta name=\"keywords\" content=\"".htmlentities($this->meta_keywords,ENT_COMPAT,"UTF-8")."\" />\n";
Lopar's avatar
Lopar committed
236

Feu's avatar
Feu committed
237
    if ( !empty($this->meta_description) )
Ayolo's avatar
bleh    
Ayolo committed
238
      $this->buffer .= "<meta name=\"description\" content=\"".htmlentities($this->meta_description,ENT_COMPAT,"UTF-8")."\" />\n";
Feu's avatar
Feu committed
239

Ayolo's avatar
bleh    
Ayolo committed
240
241
242
243
244
245
    $this->buffer .= "<link rel=\"SHORTCUT ICON\" href=\"" . $wwwtopdir . "favicon.ico\" />\n";
    $this->buffer .= "<script type=\"text/javascript\">var site_topdir='".$wwwtopdir."';</script>\n";
    $this->buffer .= "<script type=\"text/javascript\" src=\"" . $wwwtopdir . "js/site.js?".filemtime($wwwtopdir . "js/site.js")."\"></script>\n";
    $this->buffer .= "<script type=\"text/javascript\" src=\"" . $wwwtopdir . "js/ajax.js?".filemtime($wwwtopdir . "js/ajax.js")."\"></script>\n";
    $this->buffer .= "<script type=\"text/javascript\" src=\"" . $wwwtopdir . "js/dnds.js?".filemtime($wwwtopdir . "js/dnds.js")."\"></script>\n";
    $this->buffer .= "<script type=\"text/javascript\" src=\"" . $wwwtopdir . "js/box_slideshow.js?".filemtime($wwwtopdir . "js/box_slideshow.js")."\"></script>\n";
Lopar's avatar
Lopar committed
246

247
    foreach ( $this->extrajs as $url )
Ayolo's avatar
bleh    
Ayolo committed
248
      $this->buffer .= "<script type=\"text/javascript\" src=\"".htmlentities($wwwtopdir.$url,ENT_QUOTES,"UTF-8")."?".filemtime(htmlentities($wwwtopdir.$url,ENT_QUOTES,"UTF-8"))."\"></script>\n";
Lopar's avatar
Lopar committed
249

Ayolo's avatar
bleh    
Ayolo committed
250
    $this->buffer .= "</head>\n";
Lopar's avatar
Lopar committed
251

Ayolo's avatar
bleh    
Ayolo committed
252
    $this->buffer .= "<body>\n";
Ayolo's avatar
bleh    
Ayolo committed
253
    /* Generate the logo */
Ayolo's avatar
bleh    
Ayolo committed
254
    $this->buffer .= "<div id=\"site\">\n";
Ayolo's avatar
bleh    
Ayolo committed
255
    $this->buffer .= "<div id=\"dropmenudiv\" onMouseover=\"clearhidemenu()\" onMouseout=\"dynamichide(event)\"></div>\n";
Ayolo's avatar
bleh    
Ayolo committed
256
    if(!$this->user->is_valid())
Ayolo's avatar
bleh    
Ayolo committed
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
    {
      $this->buffer .= "<div id=\"overlay\" onclick=\"hideConnexionBox()\" style=\"display:none\"></div>\n";
      $this->buffer .= '<div id="passwordbox" style="display:none">';
      $this->buffer .= '<img id="close" src="'.$topdir.'images/actions/delete.png" onClick="hideConnexionBox()" alt="Fermer" ';
      $this->buffer .= 'title="Fermer" />';
      $frm = new form("connect",$topdir."connect.php",true,"POST","Connexion");
      $jsoch = "javascript:switchSelConnection(this);";
      $frm->add_select_field("domain",
           "Connexion",
           array("utbm"=>"UTBM / Assidu",
           "id"=>"ID",
           "autre"=>"E-mail",
           "alias"=>"Alias"),
           false,
           "",
           false,
           true,
           $jsoch);
      $frm->add_text_field("username","Utilisateur","prenom.nom","",20,true);
      $frm->add_password_field("password","Mot de passe","","",20);
      $frm->add_checkbox ( "personnal_computer", "Me connecter automatiquement la prochaine fois", false );
      $frm->add_submit("connectbtn","Se connecter");
      $this->buffer .= $frm->html_render();
      unset($frm);
      $this->buffer .= "</div>\n";
Ayolo's avatar
bleh    
Ayolo committed
282
    }
Ayolo's avatar
bleh    
Ayolo committed
283

Ayolo's avatar
bleh    
Ayolo committed
284
285
/* header */
    $this->buffer .= "<div id='header'>\n";
Ayolo's avatar
bleh    
Ayolo committed
286
    if(!defined('NOTAE'))
Ayolo's avatar
bleh    
Ayolo committed
287
288
    {
      $important=$this->get_param('box.Important');
Ayolo's avatar
bleh    
Ayolo committed
289
      if(!empty($important) && $important!="<p />")
Ayolo's avatar
bleh    
Ayolo committed
290
      {
BenC's avatar
test    
BenC committed
291
        $this->buffer .= "<div class=\"box\" id=\"important\">\n";
BenC's avatar
kwain    
BenC committed
292
        $this->buffer .= "<a class=\"logo\" href=\"http://ae.utbm.fr\"></a>";
BenC's avatar
test    
BenC committed
293
        $this->buffer .= "<div class=\"body\">\n";
Ayolo's avatar
bleh    
Ayolo committed
294
295
296
        $this->buffer .= $important. "\n";
        $this->buffer .= "</div></div>\n";
      }
Ayolo's avatar
bleh    
Ayolo committed
297
      else
Ayolo's avatar
bleh    
Ayolo committed
298
        $this->buffer .= "<div id=\"logo\"><a href=\"http://ae.utbm.fr\"><img src=\"" . $wwwtopdir ."images/ae_header.png\" alt=\"Logo AE\"/></a></div>\n";
Ayolo's avatar
bleh    
Ayolo committed
299
    }
Ayolo's avatar
bleh    
Ayolo committed
300
301
    if(isset($this->logo))
      $this->buffer .= "<div id=\"logo\"><img src=\"" . $wwwtopdir ."images/".$this->logo."\" alt=\"Logo\"/></div>\n";
Ayolo's avatar
bleh    
Ayolo committed
302
303
304
305

    $this->buffer .= "<div id='headermenu'>\n";
    if ( !$this->user->is_valid() )
    {
Ayolo's avatar
bleh    
Ayolo committed
306
307
      $this->buffer .= "<script type=\"text/javascript\">\n";
      $this->buffer .= "var menu_utilisateur=new Array();";
Ayolo's avatar
bleh    
Ayolo committed
308
      $this->buffer .= "menu_utilisateur[0]='<a class=\"firstdropdown\" href=\"".$topdir."index.php\" onClick=\"return showConnexionBox()\">Connexion</a>';";
Ayolo's avatar
bleh    
Ayolo committed
309
310
311
      $this->buffer .= "menu_utilisateur[1]='<a href=\"".$topdir."password.php\">Mot de passe perdu</a>';";
      $this->buffer .= "menu_utilisateur[2]='<a href=\"".$topdir."newaccount.php\">Créer un compte</a>';";
      $this->buffer .= "</script>";
Ayolo's avatar
bleh    
Ayolo committed
312
      $this->buffer .= "<div id='login' onMouseover=\"dropdownmenu(this, event, menu_utilisateur)\" onMouseout=\"delayhidemenu()\">\n";
Ayolo's avatar
bleh    
Ayolo committed
313
314
315
        $this->buffer .= "Identification\n";
    }
    elseif($this->user->type=="srv" )
Ayolo's avatar
bleh    
Ayolo committed
316
    {
Ayolo's avatar
bleh    
Ayolo committed
317
318
319
320
321
322
      $this->buffer .= "<script type=\"text/javascript\">\n";
      $this->buffer .= "var menu_utilisateur=new Array();";
      $i=0;
      $this->buffer .= "menu_utilisateur[$i]='<a href=\"".$topdir."disconnect.php\">Déconnexion</a>';";
      $this->buffer .= "</script>";
      $this->buffer .= "<div id='login' onMouseover=\"dropdownmenu(this, event, menu_utilisateur)\" onMouseout=\"delayhidemenu()\">\n";
Ayolo's avatar
Ayolo committed
323
      $this->buffer .= "<a href=\"".$topdir."boutique-utbm/suivi.php\">Suivi commandes</a>\n";
Ayolo's avatar
bleh    
Ayolo committed
324
325
326
    }
    else
    {
Ayolo's avatar
bleh    
Ayolo committed
327
      if(!defined('NOTAE') && $this->user->ae)
Ayolo's avatar
bleh    
Ayolo committed
328
329
330
331
332
333
      {
        $this->buffer.=$this->get_comptoir();
      }
      $this->buffer .= "<script type=\"text/javascript\">\n";
      $this->buffer .= "var menu_utilisateur=new Array();";
      $i=0;
Ayolo's avatar
bleh    
Ayolo committed
334
      if(!defined('NOTAE'))
Ayolo's avatar
bleh    
Ayolo committed
335
      {
Ayolo's avatar
bleh    
Ayolo committed
336
337
338
339
340
341
342
343
344
        if($this->user->ae)
        {
          $this->buffer .= "menu_utilisateur[$i]='<a class=\"firstdropdown\" href=\"".$topdir."user/compteae.php\">Compte AE : ".(sprintf("%.2f", $this->user->montant_compte/100))." Euros</a>';";
          $i++;
        }
        if($i==0)
          $this->buffer .= "menu_utilisateur[$i]='<a class=\"firstdropdown\" href=\"".$topdir."user.php?id_utilisateur=".$this->user->id."\">Informations personnelles</a>';";
        else
          $this->buffer .= "menu_utilisateur[$i]='<a href=\"".$topdir."user.php?id_utilisateur=".$this->user->id."\">Informations personnelles</a>';";
Ayolo's avatar
bleh    
Ayolo committed
345
        $i++;
Ayolo's avatar
bleh    
Ayolo committed
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
        if($this->user->utbm)
        {
          $this->buffer .= "menu_utilisateur[$i]='<a href=\"".$topdir."trombi/index.php\">Trombinoscope</a>';";
          $i++;
        }
        if( $this->user->is_in_group("jobetu_etu") )
        {
          $jobuser = new jobuser_etu($this->db);
          $jobuser->load_by_id($this->user->id);
          $jobuser->load_annonces();
          $this->buffer .= "menu_utilisateur[$i]='<a href=\"".
                           $topdir."jobetu/board_etu.php\">Mon compte JobEtu (".count($jobuser->annonces).")</a>';";
          unset($jobuser);
        }
        elseif( $this->user->is_in_group("jobetu_client") )
          $this->buffer .= "menu_utilisateur[$i]='<a href=\"".$topdir."jobetu/board_client.php\">AE JobEtu</a>';";
        else
          $this->buffer .= "menu_utilisateur[$i]='<a href=\"".$topdir."jobetu/index.php\">AE JobEtu</a>';";
        $i++;
        $this->buffer .= "menu_utilisateur[$i]='<a href=\"".$topdir."user/outils.php\">Mes outils</a>';";
Ayolo's avatar
bleh    
Ayolo committed
366
        $i++;
BenC's avatar
BenC committed
367
      }
Ayolo's avatar
bleh    
Ayolo committed
368
369
      $this->buffer .= "menu_utilisateur[$i]='<a href=\"".$topdir."disconnect.php\">Déconnexion</a>';";
      $this->buffer .= "</script>";
Ayolo's avatar
bleh    
Ayolo committed
370
      $this->buffer .= "<div id='login' onMouseover=\"dropdownmenu(this, event, menu_utilisateur)\" onMouseout=\"delayhidemenu()\">\n";
Ayolo's avatar
bleh    
Ayolo committed
371
      $this->buffer .= "<a href=\"".$topdir."user.php?id_utilisateur=".$this->user->id."\">".$this->user->prenom." ".$this->user->nom."</a>";
Ayolo's avatar
bleh    
Ayolo committed
372
373
374
    }
    $this->buffer .= "</div>\n";

Ayolo's avatar
bleh    
Ayolo committed
375
    if(!defined('NOTAE'))
Ayolo's avatar
bleh    
Ayolo committed
376
    {
Ayolo's avatar
bleh    
Ayolo committed
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
      $req = new requete($this->db,
          "SELECT `asso`.`id_asso`, " .
          "`asso`.`nom_asso` ".
          "FROM `asso_membre` " .
          "INNER JOIN `asso` ON `asso`.`id_asso`=`asso_membre`.`id_asso` " .
          "WHERE `asso_membre`.`role` > 1 AND `asso_membre`.`date_fin` IS NULL " .
          "AND `asso_membre`.`id_utilisateur`='".$this->user->id."' " .
          "AND `asso`.`id_asso` != '1' " .
          "ORDER BY asso.`nom_asso`");
      $req2 = new requete($this->db,
         "SELECT id_comptoir,nom_cpt " .
         "FROM cpt_comptoir " .
         "WHERE ( id_groupe IN (".$this->user->get_groups_csv().") OR `id_assocpt` IN (".$this->user->get_assos_csv(4).") ) AND nom_cpt != 'test' " .
         "ORDER BY nom_cpt");

      if (   $req->lines > 0
          || $req2->lines > 0
          || $this->user->is_in_group("root")
          || $this->user->is_in_group("moderateur_site")
          || $this->user->is_in_group("compta_admin")
          || $this->user->is_in_group("gestion_ae")
          || $this->user->is_in_group("gestion_syscarteae")
         )
Ayolo's avatar
bleh    
Ayolo committed
400
      {
Ayolo's avatar
bleh    
Ayolo committed
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
        $this->buffer .= "<script type=\"text/javascript\">\n";
        $this->buffer .= "var menu_assos=new Array();";
        $i=0;
        $class="class=\"firstdropdown\"";
        if( $this->user->is_in_group("root") )
        {
          $this->buffer .= "menu_assos[".$i."]='<a $class href=\"".$topdir."rootplace/index.php\">Équipe informatique</a>';";
          $i++;
          $class="";
        }
        if($this->user->is_in_group("moderateur_site"))
        {
          $this->buffer .= "menu_assos[".$i."]='<a $class href=\"".$topdir."ae/com.php\">Équipe com</a>';";
          $i++;
          $class="";
        }
        if( $this->user->is_in_group("compta_admin") )
        {
          $this->buffer .= "menu_assos[".$i."]='<a $class href=\"".$topdir."ae/compta.php\">Équipe trésorerie</a>';";
          $i++;
          $class="";
        }
        if( $this->user->is_in_group("gestion_ae") )
        {
          $this->buffer .= "menu_assos[".$i."]='<a $class href=\"".$topdir."ae/\">Équipe AE</a>';";
          $i++;
          $class="";
        }
        if( $this->user->is_in_group("gestion_syscarteae") )
        {
          $this->buffer .= "menu_assos[".$i."]='<a $class href=\"".$topdir."ae/syscarteae.php\">Carte AE</a>';";
          $i++;
          $class="";
        }
        while(list($id,$nom)=$req->get_row())
        {
          $this->buffer .= "menu_assos[".$i."]='<a $class href=\"".$topdir."asso/index.php?id_asso=$id\">".str_replace("'","\'",$nom)."</a>';";
          $i++;
          $class="";
        }
        if( $this->user->is_in_group("gestion_syscarteae") )
Ayolo's avatar
bleh    
Ayolo committed
442
        {
Ayolo's avatar
bleh    
Ayolo committed
443
          $this->buffer .= "menu_assos[".$i."]='<a $class href=\"".$topdir."comptoir/admin.php\">Admin : comptoirs</a>';";
Ayolo's avatar
bleh    
Ayolo committed
444
          $i++;
Ayolo's avatar
bleh    
Ayolo committed
445
          $class="";
Ayolo's avatar
bleh    
Ayolo committed
446
        }
Ayolo's avatar
bleh    
Ayolo committed
447
448
449
450
451
452
453
454
455
456
457
458
459
        else
        {
          while(list($id,$nom)=$req2->get_row())
          {
            $this->buffer .= "menu_assos[".$i."]='<a $class href=\"".$topdir."comptoir/admin.php?id_comptoir=$id\">Admin : ".str_replace("'","\'",$nom)."</a>';";
            $i++;
            $class="";
          }
        }
        $this->buffer .= "</script>";
        $this->buffer .= "<div id='assos' onMouseover=\"dropdownmenu(this, event, menu_assos, '150px')\" onMouseout='delayhidemenu()'>\n";
        $this->buffer .= "Gestion assos/clubs";
        $this->buffer .= "</div>\n";
Ayolo's avatar
bleh    
Ayolo committed
460
      }
Lopar's avatar
Lopar committed
461

Ayolo's avatar
bleh    
Ayolo committed
462
463
464
465
466
467
      $this->buffer .= "<div id=\"fsearchbox\">\n";
      $this->buffer .= "<form action=\"".$wwwtopdir."fsearch.php\" method=\"post\">";
      $this->buffer .= "<input type=\"text\" id=\"fsearchpattern\" name=\"pattern\" onblur=\"fsearch_stop_delayed();\" onkeyup=\"fsearch_keyup(event);\" value=\"\" />\n";
      $this->buffer .= "</form>";
      $this->buffer .= "<div class=\"fend\"></div></div>\n";
    }
Ayolo's avatar
bleh    
Ayolo committed
468
    $this->buffer .= "</div>\n";
Ayolo's avatar
bleh    
Ayolo committed
469
470
    if(!defined('NOTAE'))
      $this->buffer .= "<div id=\"fsearchres\"></div>\n";
Ayolo's avatar
bleh    
Ayolo committed
471
    $this->buffer .= "</div>\n";
Ayolo's avatar
bleh    
Ayolo committed
472
/* fin header */
Ayolo's avatar
Ayolo committed
473

Ayolo's avatar
bleh    
Ayolo committed
474
    $this->buffer .= "<div class=\"tabsv2\">\n";
Ayolo's avatar
bleh    
Ayolo committed
475
    $links=null;
Lopar's avatar
Lopar committed
476

Ayolo's avatar
bleh    
Ayolo committed
477
478
    foreach ($this->tab_array as $entry)
    {
Lopar's avatar
Lopar committed
479

Ayolo's avatar
bleh    
Ayolo committed
480
      $this->buffer .= "<span";
Ayolo's avatar
bleh    
Ayolo committed
481
482
      if ($this->section == $entry[0])
      {
Ayolo's avatar
bleh    
Ayolo committed
483
        $this->buffer .= " class=\"selected tab".$entry[0]."\"";
Ayolo's avatar
bleh    
Ayolo committed
484
485
486
        $links=$entry[3];
      }
      else
Ayolo's avatar
bleh    
Ayolo committed
487
        $this->buffer .= " class=\"tab".$entry[0]."\"";
gliss's avatar
gliss committed
488

Ayolo's avatar
bleh    
Ayolo committed
489
490
      $this->buffer .= "><a id=\"tab_".$entry[0]."\" href=\"" . $wwwtopdir . $entry[1] . "\"";
      $this->buffer .= " title=\"" . $entry[2] . "\">".$entry[2] . "</a></span>";
Ayolo's avatar
bleh    
Ayolo committed
491
    }
Lopar's avatar
Lopar committed
492

Ayolo's avatar
bleh    
Ayolo committed
493
    $this->buffer .= "</div>\n"; // /tabs
Lopar's avatar
Lopar committed
494

Ayolo's avatar
bleh    
Ayolo committed
495
496
    if ( $links )
    {
Ayolo's avatar
bleh    
Ayolo committed
497
      $this->buffer .= "<div class=\"sectionlinks\">";
Lopar's avatar
Lopar committed
498

Ayolo's avatar
bleh    
Ayolo committed
499
500
      foreach ( $links as $entry )
      {
501
        if ( !strncmp("http://",$entry[0],7) )
Ayolo's avatar
bleh    
Ayolo committed
502
          $this->buffer .= "<a href=\"".$entry[0]."\">".$entry[1]."</a>";
Ayolo's avatar
bleh    
Ayolo committed
503
        else
Ayolo's avatar
bleh    
Ayolo committed
504
          $this->buffer .= "<a href=\"".$wwwtopdir.$entry[0]."\">".$entry[1]."</a>";
Ayolo's avatar
bleh    
Ayolo committed
505
      }
Lopar's avatar
Lopar committed
506

Ayolo's avatar
bleh    
Ayolo committed
507
      $this->buffer .= "</div>\n";
Ayolo's avatar
bleh    
Ayolo committed
508
509
    }
    else
Ayolo's avatar
bleh    
Ayolo committed
510
      $this->buffer .= "<div class=\"emptysectionlinks\"></div>\n";
gliss's avatar
gliss committed
511

Ayolo's avatar
bleh    
Ayolo committed
512
    $this->buffer .= "<div class=\"contents\">\n";
Ayolo's avatar
bleh    
Ayolo committed
513
    $idpage = "";
Lopar's avatar
Lopar committed
514

Ayolo's avatar
bleh    
Ayolo committed
515
    $mode = $this->user->id > 0 ? "c" : "nc";
Lopar's avatar
Lopar committed
516

Ayolo's avatar
bleh    
Ayolo committed
517
518
    foreach ( $this->sides as $side => $names )
    {
519
      if ( count($names) )
Ayolo's avatar
bleh    
Ayolo committed
520
521
      {
        $idpage .= substr($side,0,1);
Lopar's avatar
Lopar committed
522

Ayolo's avatar
bleh    
Ayolo committed
523
524
525
526
527
528
529
530
531
        if ( isset($this->sides_ref[$side]) )
        {
          $ref = "dnds_".$this->sides_ref[$side];
          if ( isset($_SESSION["usersession"][$ref]) )
          {
            $n_names = array();
            $elts =   explode(",",$_SESSION["usersession"][$ref]);
            foreach ( $elts as $elt )
            {
532
              $name = substr($elt,5);
Ayolo's avatar
bleh    
Ayolo committed
533
534
535
536
537
538
539
540
541
              if ( in_array($name,$names) )
                $n_names[] = $name;
            }
            foreach ( $names as $name )
            {
              if ( !in_array($name,$n_names) )
                $n_names = array_merge( array($name), $n_names );
            }
            $names = $n_names;
542
          }
Ayolo's avatar
bleh    
Ayolo committed
543
544
545
        }
        else
          $ref = null;
Lopar's avatar
Lopar committed
546

Ayolo's avatar
test    
Ayolo committed
547
        $this->buffer .= "<div id=\"".$side."\" class=\"clearfix\">\n";
Ayolo's avatar
bleh    
Ayolo committed
548
549
        foreach ( $names as $name )
        {
Lopar's avatar
Lopar committed
550

Ayolo's avatar
bleh    
Ayolo committed
551
552
          if ( $cts = $this->boxes[$name] )
          {
Ayolo's avatar
test    
Ayolo committed
553
            $this->buffer .= "<div class=\"box\" id=\"sbox_".$name."\">\n";
Ayolo's avatar
bleh    
Ayolo committed
554
            if ( $cts->title && ($ref != null) )
Ayolo's avatar
test    
Ayolo committed
555
              $this->buffer .= "<h1><a onmousedown=\"dnds_startdrag(event,'sbox_".$name."','".$ref."');\" class=\"dragstartzone\">".$cts->title."</a></h1>\n";
Ayolo's avatar
bleh    
Ayolo committed
556
            elseif ( $cts->title )
Ayolo's avatar
test    
Ayolo committed
557
              $this->buffer .= "<h1>".$cts->title."</h1>\n";
Lopar's avatar
Lopar committed
558

Ayolo's avatar
test    
Ayolo committed
559
            $this->buffer .= "<div class=\"body\" id=\"sbox_body_".$name."\">\n";
Lopar's avatar
Lopar committed
560

Ayolo's avatar
test    
Ayolo committed
561
            $this->buffer .= $cts->html_render();
Lopar's avatar
Lopar committed
562

Ayolo's avatar
test    
Ayolo committed
563
564
            $this->buffer .= "</div>\n";
            $this->buffer .= "</div>\n";
Ayolo's avatar
bleh    
Ayolo committed
565
          }
Lopar's avatar
Lopar committed
566

Ayolo's avatar
bleh    
Ayolo committed
567
        }
Ayolo's avatar
test    
Ayolo committed
568
        $this->buffer .= "</div>\n";
Ayolo's avatar
bleh    
Ayolo committed
569
570
      }
    }
Lopar's avatar
Lopar committed
571

Ayolo's avatar
bleh    
Ayolo committed
572
    if ( $idpage == "" ) $idpage = "n";
Lopar's avatar
Lopar committed
573

Ayolo's avatar
bleh    
Ayolo committed
574
575
    $this->buffer .= "\n<!-- page -->\n";
    $this->buffer .= "<div class=\"page\" id=\"".$idpage."\">\n";
Lopar's avatar
Lopar committed
576

Ayolo's avatar
bleh    
Ayolo committed
577
578
579
580
    $i=0;
    foreach ( $this->contents as $cts )
    {
      $cssclass = "article";
Lopar's avatar
Lopar committed
581

Ayolo's avatar
bleh    
Ayolo committed
582
      if ( !is_null($cts->cssclass) )
583
        $cssclass = $cts->cssclass;
Lopar's avatar
Lopar committed
584

Ayolo's avatar
bleh    
Ayolo committed
585
      $i++;
Lopar's avatar
Lopar committed
586
587


Ayolo's avatar
bleh    
Ayolo committed
588
      $this->buffer .= "<div class=\"".$cssclass."\"";
Ayolo's avatar
bleh    
Ayolo committed
589
      if ( $cts->divid )
Ayolo's avatar
bleh    
Ayolo committed
590
        $this->buffer .= " id=\"".$cts->divid."\"";
Ayolo's avatar
bleh    
Ayolo committed
591
      else
Ayolo's avatar
bleh    
Ayolo committed
592
593
        $this->buffer .= " id=\"cts".$i."\"";
      $this->buffer .= ">\n";
Lopar's avatar
Lopar committed
594

Ayolo's avatar
bleh    
Ayolo committed
595
596
      if ( $cts->toolbox )
      {
Ayolo's avatar
bleh    
Ayolo committed
597
598
599
        $this->buffer .= "<div class=\"toolbox\">\n";
        $this->buffer .= $cts->toolbox->html_render()."\n";
        $this->buffer .= "</div>\n";
600
      }
Lopar's avatar
Lopar committed
601

Ayolo's avatar
bleh    
Ayolo committed
602
      if ( $cts->title )
Ayolo's avatar
bleh    
Ayolo committed
603
        $this->buffer .= "<h1>".$cts->title."</h1>\n";
Feu's avatar
humm...    
Feu committed
604

Ayolo's avatar
bleh    
Ayolo committed
605
      $this->buffer .= $cts->html_render();
Lopar's avatar
Lopar committed
606

Ayolo's avatar
bleh    
Ayolo committed
607
      $this->buffer .= "</div>\n";
Ayolo's avatar
bleh    
Ayolo committed
608
    }
Lopar's avatar
Lopar committed
609

Ayolo's avatar
bleh    
Ayolo committed
610
611
    $this->buffer .= "</div>\n"; // /page
    $this->buffer .= "<!-- end of page -->\n\n";
Ayolo's avatar
bleh    
Ayolo committed
612
    $this->buffer .= "</div>\n"; // /contents
Ayolo's avatar
bleh    
Ayolo committed
613
614
    $this->buffer .= "<div id=\"contentsend\">&nbsp;</div>\n";
    $this->buffer .= "<div id=\"endsite\">";
gliss's avatar
wip    
gliss committed
615
    $this->buffer .= "<div id=\"endsitelinks\">";
Ayolo's avatar
bleh    
Ayolo committed
616
617
618
    if(!defined('NOTAE'))
    {
      $this->buffer .= "<a href=\"". $wwwtopdir ."article.php?name=legals\">MENTIONS LÉGALES</a> ";
Ayolo's avatar
bleh    
Ayolo committed
619
      $this->buffer .= "<a href=\"". $wwwtopdir ."copyright_agent.php\">PROPRIÉTÉ INTELLECTUELLE</a>";
Ayolo's avatar
bleh    
Ayolo committed
620
621
622
623
624
      $this->buffer .= "<a href=\"". $wwwtopdir ."article.php?name=docs:index\">AIDE ET DOCUMENTATION</a> ";
      $this->buffer .= "<a href=\"". $wwwtopdir ."article.php?name=rd\">R&amp;D</a> ";
    }
    elseif(isset($this->footer))
      $this->buffer=$this->footer;
Ayolo's avatar
bleh    
Ayolo committed
625
626
627
    $this->buffer .= "</div>";// /endsitelinks
    $this->buffer .= "</div>";// /endsite
    $this->buffer .= "</div>\n"; // /site
Lopar's avatar
Lopar committed
628

BenC's avatar
BenC committed
629
630
    if ( $this->get_param("backup_server",true) )
    {
Ayolo's avatar
bleh    
Ayolo committed
631
632
633
      $this->buffer .= "<div id=\"topalert\">";
      $this->buffer .= "<img width=\"16\" height=\"16\" src=\"".$wwwtopdir."themes/default/images/exclamation.png\" />";
      $this->buffer .= "Le système fonctionne actuellement sur le serveur de secours, ".
BenC's avatar
BenC committed
634
           "veuillez limiter vos actions au strict minimum.";
Ayolo's avatar
bleh    
Ayolo committed
635
      $this->buffer .= "</div>";
BenC's avatar
BenC committed
636
    }
BenC's avatar
BenC committed
637
638
    elseif ( $this->get_param("warning_enabled",true) )
    {
Ayolo's avatar
bleh    
Ayolo committed
639
640
641
642
      $this->buffer .= "<div id=\"topalert\">";
      $this->buffer .= "<img width=\"16\" height=\"16\" src=\"".$wwwtopdir."themes/default/images/exclamation.png\" />";
      $this->buffer .= $this->get_param("warning_message");
      $this->buffer .= "</div>";
BenC's avatar
BenC committed
643
    }
Ayolo's avatar
bleh    
Ayolo committed
644
645
646
647
648
649
    $this->buffer .= "</body>\n";
    $this->buffer .= "</html>\n";
    echo $this->buffer;
    $timing["render"] += microtime(true);
    $timing["all"] += microtime(true);
    echo "<!-- ";
gliss's avatar
wip    
gliss committed
650
651
    if ( $GLOBALS["taiste"] ){
      print_r($timing);
Feu's avatar
Feu committed
652
      echo "\non est en taiste\n";
gliss's avatar
wip    
gliss committed
653
    }
Ayolo's avatar
bleh    
Ayolo committed
654
    echo " -->";
Ayolo's avatar
Ayolo committed
655
  }
Lopar's avatar
Lopar committed
656

Feu's avatar
Feu committed
657
658
659
660
661
662
  /**
   * Rendu de la page en mode popup (sans header, sans boites laterales)
   */
  function popup_end_page ()
  {
    global $wwwtopdir ;
Lopar's avatar
Lopar committed
663

Feu's avatar
Feu committed
664
    header("Content-Type: text/html; charset=utf-8");
Lopar's avatar
Lopar committed
665

Ayolo's avatar
bleh    
Ayolo committed
666
    //$this->buffer .= "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">";
Lopar's avatar
Lopar committed
667

Ayolo's avatar
bleh    
Ayolo committed
668
669
670
671
672
673
    $this->buffer .= "<html xmlns=\"http://www.w3.org/1999/xhtml\" xmlns:v=\"urn:schemas-microsoft-com:vml\">\n";
    $this->buffer .= "<head>\n";
    $this->buffer .= "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" />\n";
    $this->buffer .= "<title>".htmlentities($this->title,ENT_COMPAT,"UTF-8")." - association des etudiants de l'utbm</title>\n";
    $this->buffer .= "<link rel=\"stylesheet\" type=\"text/css\" href=\"" . $wwwtopdir . "themes/default/css/site.css?".filemtime($wwwtopdir . "themes/default/css/site.css")."\" title=\"AE2-NEW2\" />\n";
    $this->buffer .= "<link rel=\"stylesheet\" type=\"text/css\" href=\"" . $wwwtopdir . "css/popup.css?".filemtime($wwwtopdir ."css/popup.css")."\" />\n";
674
    foreach ( $this->extracss as $url )
Ayolo's avatar
bleh    
Ayolo committed
675
      $this->buffer .= "<link rel=\"stylesheet\" type=\"text/css\" href=\"" . htmlentities($wwwtopdir . $url,ENT_COMPAT,"UTF-8"). "\" />\n";
Lopar's avatar
Lopar committed
676

677
    foreach ( $this->rss as $title => $url )
Ayolo's avatar
bleh    
Ayolo committed
678
      $this->buffer .= "<link rel=\"alternate\" type=\"application/rss+xml\" title=\"".htmlentities($title,ENT_COMPAT,"UTF-8")."\" href=\"".htmlentities($url,ENT_COMPAT,"UTF-8")."\" />";
Lopar's avatar
Lopar committed
679

Ayolo's avatar
bleh    
Ayolo committed
680
681
682
683
684
    $this->buffer .= "<link rel=\"SHORTCUT ICON\" href=\"" . $wwwtopdir . "favicon.ico\" />\n";
    $this->buffer .= "<script type=\"text/javascript\">var site_topdir='".$wwwtopdir."';</script>\n";
    $this->buffer .= "<script type=\"text/javascript\" src=\"" . $wwwtopdir . "js/site.js\"></script>\n";
    $this->buffer .= "<script type=\"text/javascript\" src=\"" . $wwwtopdir . "js/ajax.js\"></script>\n";
    $this->buffer .= "<script type=\"text/javascript\" src=\"" . $wwwtopdir . "js/dnds.js\"></script>\n";
Lopar's avatar
Lopar committed
685

686
    foreach ( $this->extrajs as $url )
Ayolo's avatar
bleh    
Ayolo committed
687
      $this->buffer .= "<script type=\"text/javascript\" src=\"".htmlentities($wwwtopdir.$url,ENT_QUOTES,"UTF-8")."\"></script>\n";
Lopar's avatar
Lopar committed
688

Ayolo's avatar
bleh    
Ayolo committed
689
    $this->buffer .= "</head>\n";
Lopar's avatar
Lopar committed
690

Ayolo's avatar
bleh    
Ayolo committed
691
    $this->buffer .= "<body>\n";
Feu's avatar
Feu committed
692
    /* Generate the logo */
Lopar's avatar
Lopar committed
693

Ayolo's avatar
bleh    
Ayolo committed
694
    $this->buffer .= "<div id=\"popup\">";
Lopar's avatar
Lopar committed
695

Feu's avatar
Feu committed
696
697
698
699
    $i=0;
    foreach ( $this->contents as $cts )
    {
      $cssclass = "article";
Lopar's avatar
Lopar committed
700

Feu's avatar
Feu committed
701
      if ( !is_null($cts->cssclass) )
702
        $cssclass = $cts->cssclass;
Lopar's avatar
Lopar committed
703

Feu's avatar
Feu committed
704
      $i++;
Ayolo's avatar
bleh    
Ayolo committed
705
      $this->buffer .= "<div class=\"".$cssclass."\"";
Feu's avatar
Feu committed
706
      if ( $cts->divid )
Ayolo's avatar
bleh    
Ayolo committed
707
        $this->buffer .= " id=\"".$cts->divid."\"";
Feu's avatar
Feu committed
708
      else
Ayolo's avatar
bleh    
Ayolo committed
709
710
        $this->buffer .= " id=\"cts".$i."\"";
      $this->buffer .= ">\n";
Lopar's avatar
Lopar committed
711

Feu's avatar
Feu committed
712
713
      if ( $cts->toolbox )
      {
Ayolo's avatar
bleh    
Ayolo committed
714
715
716
        $this->buffer .= "<div class=\"toolbox\">\n";
        $this->buffer .= $cts->toolbox->html_render()."\n";
        $this->buffer .= "</div>\n";
717
      }
Lopar's avatar
Lopar committed
718

Feu's avatar
Feu committed
719
      if ( $cts->title )
Ayolo's avatar
bleh    
Ayolo committed
720
        $this->buffer .= "<h1>".$cts->title."</h1>\n";
Feu's avatar
Feu committed
721

Ayolo's avatar
bleh    
Ayolo committed
722
723
      $this->buffer .= $cts->html_render();
      $this->buffer .= "</div>\n";
Feu's avatar
Feu committed
724
    }
Lopar's avatar
Lopar committed
725

Ayolo's avatar
bleh    
Ayolo committed
726
727
728
    $this->buffer .= "</div>\n";
    $this->buffer .= "</body>\n";
    $this->buffer .= "</html>\n";
gliss's avatar
bleh    
gliss committed
729
    echo $this->buffer;
Feu's avatar
Feu committed
730
  }
Ayolo's avatar
Ayolo committed
731

Ayolo's avatar
bleh    
Ayolo committed
732
733
734
735
736
737
738
  /** Charge tous les paramètres du site.
   * ATTENTION: ceci est UNIQUEMENT concu pour stocker des paramètres.
   * @private
   */
  function load_params()
  {
    $this->params = array();
Lopar's avatar
Lopar committed
739

Ayolo's avatar
bleh    
Ayolo committed
740
741
    $req = new requete($this->db, "SELECT `nom_param`,`valeur_param` " .
        "FROM `site_parametres`");
Lopar's avatar
Lopar committed
742

Ayolo's avatar
bleh    
Ayolo committed
743
744
    while ( list($id,$name) = $req->get_row() )
      $this->params[$id] = $name;
Lopar's avatar
Lopar committed
745

BenC's avatar
BenC committed
746
    $this->params["backup_server"] = serialize($_SERVER["BACKUP_AE_SERVER"]);
Ayolo's avatar
bleh    
Ayolo committed
747
  }
Lopar's avatar
Lopar committed
748

Ayolo's avatar
bleh    
Ayolo committed
749
750
751
752
753
754
755
  /**
   * Obtient un paramètre du site.
   * @param $name Nom du paramètre
   * @param $value $default par défaut retrouné si il n'est pas définit
   */
  function get_param ( $name, $default=null )
  {
756
    if ( !$this->params )
Ayolo's avatar
bleh    
Ayolo committed
757
      $this->load_params();
Lopar's avatar
Lopar committed
758

759
    if ( !isset($this->params[$name]) )
Ayolo's avatar
bleh    
Ayolo committed
760
      return $default;
Lopar's avatar
Lopar committed
761

Ayolo's avatar
bleh    
Ayolo committed
762
763
    return unserialize($this->params[$name]);
  }
Ayolo's avatar
Ayolo committed
764

gliss's avatar
gliss committed
765

Ayolo's avatar
bleh    
Ayolo committed
766
767
768
769
770
771
772
  /**
   * Définit un paramètre du site.
   * @param $name Nom du paramètre
   * @param $value Valeur du paramètre.
   */
  function set_param ( $name, $value )
  {
773
    if ( !$this->params )
Ayolo's avatar
bleh    
Ayolo committed
774
      $this->load_params();
Lopar's avatar
Lopar committed
775

Ayolo's avatar
bleh    
Ayolo committed
776
    $value = serialize($value);
Lopar's avatar
Lopar committed
777

Ayolo's avatar
bleh    
Ayolo committed
778
779
780
    if ( !isset($this->params[$name]) )
    {
      $sql = new insert($this->dbrw,"site_parametres",
781
        array (
Ayolo's avatar
bleh    
Ayolo committed
782
783
784
          "nom_param" => $name,
          "valeur_param" => $value
        ));
Ayolo's avatar
alert    
Ayolo committed
785
      $this->params[$name]=$value;
Ayolo's avatar
bleh    
Ayolo committed
786
    }
787
    elseif ( $this->params[$name] !== $value )
Ayolo's avatar
bleh    
Ayolo committed
788
789
790
    {
      $sql = new update($this->dbrw,"site_parametres",
        array( "valeur_param" => $value),
Ayolo's avatar
bleh    
Ayolo committed
791
        array( "nom_param" => $name));      //$this->buffer .= " onmouseover=\"tabsection('".$entry[0]."', 'hoversectionlinks');\"";
Ayolo's avatar
alert    
Ayolo committed
792
      $this->params[$name]=$value;
Ayolo's avatar
bleh    
Ayolo committed
793
794
    }
  }
Ayolo's avatar
Ayolo committed
795

gliss's avatar
gliss committed
796

Ayolo's avatar
bleh    
Ayolo committed
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
  /**
   * Vérifie que l'utilisateur est vraiment sûre de procéder à une opération.
   * Certifié "boulet proof(tm)".
   * Remarque: ne fonctionne pas dans le cas de passage de tableaux en GET/POST
   * @param $section Section de la page de confirmation
   * @param $message Message à afficher
   * @param $uid identifiant unique de la question
   * @param $level niveau d'incidence (0:pas grave, 1:peu risqué, 2:trés risqué)
   */
  function is_sure ( $section,$message,$uid=null,$level=0 )
  {
    if ( isset($_POST["___i_am_really_sure"]) )
    {
      if ( $GLOBALS["svalid_call"] )
        return true;
      return false;
    }
    elseif ( isset($_POST["___finally_i_want_to_cancel"]) )
      return false;
Lopar's avatar
Lopar committed
816

Ayolo's avatar
bleh    
Ayolo committed
817
    if ( !$uid ) $uid=$section.md5($message);
Lopar's avatar
Lopar committed
818

jlaval's avatar
jlaval committed
819
    $this->start_page($section,"Êtes vous sûr ?");
Lopar's avatar
Lopar committed
820

Ayolo's avatar
bleh    
Ayolo committed
821
    $cts = new contents("Confirmation");
Lopar's avatar
Lopar committed
822

Ayolo's avatar
bleh    
Ayolo committed
823
824
    if ( $level == 2 )
      $cts->add_paragraph("ATTENTION","huge");
Lopar's avatar
Lopar committed
825

Ayolo's avatar
bleh    
Ayolo committed
826
    $cts->add_paragraph($message);
Lopar's avatar
Lopar committed
827

Ayolo's avatar
bleh    
Ayolo committed
828
    if ( $level == 2 )
slopez's avatar
slopez committed
829
      $cts->add_paragraph("Cette opération <b>pourrait avoir de lourdes conséquences</b> sur le <b>bon fonctionnement des services</b> si elle été appliquée sur un élément critique. <b>Contactez un administrateur en cas de doute</b>.");
Lopar's avatar
Lopar committed
830

gliss's avatar
gliss committed
831
    $cts->add_paragraph("Êtes vous sûr ?");
jlaval's avatar
Bluck    
jlaval committed
832
833
    if ($level == 3) {
      $phrase_magique = 'oui je suis sur de vouloir faire ça';
slopez's avatar
slopez committed
834
      $cts->add_paragraph('Tapez dans le champ correspondant et en toutes lettres la phrase "'.str_replace(' ',' &nbsp;',$phrase_magique).'"');
jlaval's avatar
Bluck    
jlaval committed
835
    }
Lopar's avatar
Lopar committed
836

Ayolo's avatar
bleh    
Ayolo committed
837
838
    $frm = new form("suretobesurefor".$uid,"?");
    $frm->allow_only_one_usage();
Lopar's avatar
Lopar committed
839

Ayolo's avatar
bleh    
Ayolo committed
840
    foreach ( $_POST as $key => $val )
Feu's avatar
fix    
Feu committed
841
      if ( $key != "magicform" )
Ayolo's avatar
bleh    
Ayolo committed
842
843
      {
        if($key=="__script__")
Ayolo's avatar
bleh    
Ayolo committed
844
          $frm->add_hidden($key,htmlspecialchars($val));
Ayolo's avatar
bleh    
Ayolo committed
845
846
847
        else
          $frm->add_hidden($key,$val);
      }
Ayolo's avatar
bleh    
Ayolo committed
848
    foreach ( $_GET as $key => $val )
Feu's avatar
fix    
Feu committed
849
850
      if ( $key != "magicform" )
        $frm->add_hidden($key,$val);
Lopar's avatar
Lopar committed
851

jlaval's avatar
jlaval committed
852
    if ($level == 3) {
slopez's avatar
slopez committed
853
854
      $_uid = gen_uid();
      $frm->add_text_field('____really_sure__'.$_uid, 'Tapez la phrase magique :', '', true, 50);
jlaval's avatar
jlaval committed
855
856
    }

857
858
    $frm->add_submit("___i_am_really_sure","OUI");
    $frm->add_submit("___finally_i_want_to_cancel","NON");
Lopar's avatar
Lopar committed
859

Ayolo's avatar
bleh    
Ayolo committed
860
    $cts->add($frm);
jlaval's avatar
jlaval committed
861
    if ($level == 3)
slopez's avatar
slopez committed
862
863
864
865
866
867
868
869
870
871
872
873
874
      $cts->puts('<script type="text/javascript">
var txt = document.getElementsByName("____really_sure__")[0];
var sub = document.getElementById("___i_am_really_sure");
sub.disabled = true;
txt.onkeypress = function (event){
  var txt = document.getElementsByName("____really_sure__'.$_uid.'")[0];
  var sub = document.getElementById("___i_am_really_sure");
  if (txt.value == "'.substr($phrase_magique, 0, strlen($phrase_magique) - 1).'")
    sub.disabled = false;
  else
    sub.disabled = true;
}
</script>');
Lopar's avatar
Lopar committed
875

Ayolo's avatar
bleh    
Ayolo committed
876
    $this->add_contents($cts);
Lopar's avatar
Lopar committed
877

Ayolo's avatar
bleh    
Ayolo committed
878
879
880
    $this->end_page();
    exit();
  }
Lopar's avatar
Lopar committed
881

Feu's avatar
Feu committed
882
883
884
885
886
  function set_meta_information( $keywords, $description )
  {
    $this->meta_keywords = $keywords;
    $this->meta_description = $description;
  }
Lopar's avatar
Lopar committed
887

Feu's avatar
Feu committed
888
889
890
891
  function add_alternate ( $type, $title, $href )
  {
    $this->alternate[]=array($type,$title,$href);
  }
Lopar's avatar
Lopar committed
892

Feu's avatar
Feu committed
893
894
895
896
897
898
  function add_alternate_geopoint ( &$geopoint )
  {
    global $wwwtopdir;
    $this->add_alternate("application/vnd.google-earth.kml+xml","KML",$wwwtopdir."loc.php?id_geopoint=".$geopoint->id."&action=kml");
  }

Lopar's avatar
Lopar committed
899

Ayolo's avatar
Ayolo committed
900
901
902
}

?>