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

/** @file
 *
 *
 */
7
/* Copyright 2005 - 2010
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 >
10
 * - Benjamin Collet < bcollet at oxynux dot org>
Ayolo's avatar
Ayolo committed
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
 *
 * 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
30

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

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

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

Ayolo's avatar
Ayolo committed
40 41 42 43 44 45 46 47 48 49 50 51
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
52
 * @ingroup display
Ayolo's avatar
Ayolo committed
53 54 55
 */
class interfaceweb
{
Ayolo's avatar
bleh  
Ayolo committed
56 57 58
  var $db;
  var $dbrw;
  var $user;
Lopar's avatar
Lopar committed
59

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

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

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

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

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

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

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

mbriand's avatar
mbriand committed
82 83 84 85 86 87
  var $tab_array = array (
        array ("accueil", "index.php", "Accueil",
          array(
            array("index.php", "Les nouvelles"),
            array("events.php", "Aujourd'hui"),
            array("weekmail.php", "Le weekmail"),
mbriand's avatar
mbriand committed
88
              ) ),
mbriand's avatar
mbriand committed
89
        array ("presentation", "article.php?name=presentation", "L'AE",
Ayolo's avatar
bleh  
Ayolo committed
90
           array (
mbriand's avatar
mbriand committed
91 92 93 94
              array("article.php?name=presentation","Présentation"),
              array("article.php?name=presentation:services","Services quotidiens"),
              array("article.php?name=presentation:carteae","La carte AE"),
              array("article.php?name=presentation:siteae","Le site AE"),
mbriand's avatar
mbriand committed
95 96
              array("article.php?name=presentation:activites","Activités et clubs"),
              array("activites.php?view=trombino","Responsables des clubs"),
Ayolo's avatar
bleh  
Ayolo committed
97 98
             ) ),
        array ("matmatronch", "matmatronch/", "Matmatronch"),
99
        array ("wiki", "wiki2/", "Wiki"),
Ayolo's avatar
bleh  
Ayolo committed
100
        array ("sas", "sas2/", "SAS"),
mbriand's avatar
mbriand committed
101 102
        array ("forum", "forum2/", "Forum",
          array(
mbriand's avatar
mbriand committed
103 104 105
            array("forum2/index.php", "Sommaire"),
            array("forum2/search.php?page=unread", "Messages non lus"),
            array("forum2/search.php", "Recherche"),
BenC's avatar
BenC committed
106
            array("forum2/search.php?page=starred", "Favoris"),
mbriand's avatar
mbriand committed
107
            array("forum2/admin/", "Administration"),
mbriand's avatar
mbriand committed
108
          )  ),
109 110 111 112
        array ("services", "article.php?name=services", "Services" ),
        //array ("pg", "pgae.php", "Petit géni"),
        //e-boutic -> services
        //array ("e-boutic", "e-boutic/", "E-boutic"),
Ayolo's avatar
bleh  
Ayolo committed
113 114 115 116 117
        array ("fichiers", "d.php", "Fichiers",
           array (
              array ("d.php", "Fichiers de l'AE" ),
              array ("asso.php", "Fichiers des associations et des clubs" )
             ) ),
mbriand's avatar
mbriand committed
118 119
        array ("liens","article.php?name=liens","Partenaires"),
        array ("aide","article.php?name=docs:index","Aide"));
Lopar's avatar
Lopar committed
120

Ayolo's avatar
bleh  
Ayolo committed
121 122 123 124 125 126 127 128
  /** 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
129

Ayolo's avatar
bleh  
Ayolo committed
130
    $this->sides["left"] = array();
Ayolo's avatar
bleh  
Ayolo committed
131
    $this->sides["right"] = array();
Lopar's avatar
Lopar committed
132

Ayolo's avatar
bleh  
Ayolo committed
133 134 135 136 137
    $this->user = new utilisateur( $db, $dbrw );
    $this->extracss = array();
    $this->extrajs = array();
    $this->rss = array();
    $this->contents=array();
Feu's avatar
Feu committed
138
    $this->alternate=array();
Ayolo's avatar
bleh  
Ayolo committed
139
  }
Ayolo's avatar
Ayolo committed
140

Ayolo's avatar
bleh  
Ayolo committed
141 142 143 144 145 146 147 148
  /** 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
149

Ayolo's avatar
bleh  
Ayolo committed
150 151 152 153 154 155 156 157
    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
158

Ayolo's avatar
bleh  
Ayolo committed
159 160 161 162 163 164
  /** 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
165 166
    if ( is_null($contents) )
      return;
Ayolo's avatar
bleh  
Ayolo committed
167 168
    $this->boxes[$name] = $contents;
  }
Ayolo's avatar
Ayolo committed
169

Ayolo's avatar
bleh  
Ayolo committed
170 171 172 173 174 175 176 177
  /** 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
178

Ayolo's avatar
bleh  
Ayolo committed
179 180 181 182 183
  /** Initlialise la page
   * @param $section Nom de la section
   * @param $title Titre de la page
   */
  function start_page ( $section, $title, $compact=false ) // <=> page
184
  {
Ayolo's avatar
bleh  
Ayolo committed
185 186 187 188
    $this->section = $section;
    $this->title = $title;
    $this->compact = $compact;
  }
Ayolo's avatar
Ayolo committed
189

Ayolo's avatar
bleh  
Ayolo committed
190 191 192 193 194 195 196 197
  /** Calcul de la survie des bars :P
   *
   */
  function get_comptoir()
  {
    return '';
  }

Ayolo's avatar
bleh  
Ayolo committed
198 199
  function add_css ( $url )
  {
200
    $this->extracss[] = $url;
Ayolo's avatar
bleh  
Ayolo committed
201
  }
Lopar's avatar
Lopar committed
202

Ayolo's avatar
bleh  
Ayolo committed
203 204
  function add_js ( $url )
  {
205
    $this->extrajs[] = $url;
Ayolo's avatar
bleh  
Ayolo committed
206
  }
Ayolo's avatar
Ayolo committed
207

Ayolo's avatar
bleh  
Ayolo committed
208 209
  function add_rss ( $title, $url )
  {
Feu's avatar
debug  
Feu committed
210
    $this->add_alternate ( "application/rss+xml", $title, $url );
Ayolo's avatar
bleh  
Ayolo committed
211
  }
Lopar's avatar
Lopar committed
212

Ayolo's avatar
bleh  
Ayolo committed
213 214 215 216
  /** Termine et affiche la page
   */
  function end_page () // <=> html_render
  {
Ayolo's avatar
bleh  
Ayolo committed
217
    global $wwwtopdir,$topdir,$timing ;
Feu's avatar
Feu committed
218 219
    $timing["render"] -= microtime(true);

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

Ayolo's avatar
bleh  
Ayolo committed
222 223
    $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
224

Ayolo's avatar
bleh  
Ayolo committed
225
    $this->buffer .= "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" />\n"; // (IE6 Legacy support)
Ayolo's avatar
bleh  
Ayolo committed
226
    if(!defined('NOTAE'))
Ayolo's avatar
bleh  
Ayolo committed
227 228
    {
      $this->buffer .= "<title>".htmlentities($this->title,ENT_COMPAT,"UTF-8")." - association des etudiants de l'utbm</title>\n";
mbriand's avatar
prout  
mbriand committed
229
      $this->buffer .= "<link rel=\"stylesheet\" type=\"text/css\" href=\"" . $wwwtopdir . "themes/default3/css/site3.css?".filemtime($wwwtopdir . "themes/default3/css/site3.css")."\" title=\"AE2-NEW3\" />\n";
Ayolo's avatar
bleh  
Ayolo committed
230
    }
Ayolo's avatar
bleh  
Ayolo committed
231
    else
Ayolo's avatar
bleh  
Ayolo committed
232 233 234 235 236
    {
      $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
mbriand's avatar
prout  
mbriand committed
237
        $this->buffer .= "<link rel=\"stylesheet\" type=\"text/css\" href=\"" . $wwwtopdir . "themes/default3/css/site3.css?".filemtime($wwwtopdir . "themes/default3/css/site3.css")."\" title=\"AE2-NEW3\" />\n";
Ayolo's avatar
bleh  
Ayolo committed
238
    }
Ayolo's avatar
Ayolo committed
239 240
    foreach ( $this->extracss as $url )
      if(file_exists(htmlentities($wwwtopdir . $url,ENT_COMPAT,"UTF-8")))
Ayolo's avatar
bleh  
Ayolo committed
241
        $this->buffer .= "<link rel=\"stylesheet\" type=\"text/css\" href=\"".
Ayolo's avatar
Ayolo committed
242 243 244
             htmlentities($wwwtopdir . $url,ENT_COMPAT,"UTF-8")."?".
             filemtime(htmlentities($wwwtopdir . $url,ENT_COMPAT,"UTF-8"))."\" />\n";

Feu's avatar
Feu committed
245 246
    foreach ( $this->alternate as $row )
    {
Ayolo's avatar
bleh  
Ayolo committed
247
      $this->buffer .= "<link rel=\"alternate\" ".
Feu's avatar
Feu committed
248 249 250
        "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
251
    }
Lopar's avatar
Lopar committed
252

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

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

mbriand's avatar
mbriand committed
259
    $this->buffer .= "<link rel=\"SHORTCUT ICON\" href=\"" . $wwwtopdir . "favicon.ico?".filemtime($wwwtopdir."favicon.ico")."\" />\n";
Ayolo's avatar
bleh  
Ayolo committed
260 261 262 263 264
    $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
265

266
    foreach ( $this->extrajs as $url )
Ayolo's avatar
bleh  
Ayolo committed
267
      $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
268

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

Ayolo's avatar
bleh  
Ayolo committed
271
    $this->buffer .= "<body>\n";
Ayolo's avatar
bleh  
Ayolo committed
272
    /* Generate the logo */
Ayolo's avatar
bleh  
Ayolo committed
273
    $this->buffer .= "<div id=\"site\">\n";
274
    $this->buffer .= "<div id=\"dropmenudiv\" onmouseover=\"clearhidemenu()\" onmouseout=\"dynamichide(event)\"></div>\n";
Ayolo's avatar
bleh  
Ayolo committed
275
    if(!$this->user->is_valid())
Ayolo's avatar
bleh  
Ayolo committed
276 277 278
    {
      $this->buffer .= "<div id=\"overlay\" onclick=\"hideConnexionBox()\" style=\"display:none\"></div>\n";
      $this->buffer .= '<div id="passwordbox" style="display:none">';
279
      $this->buffer .= '<img id="close" src="'.$topdir.'images/actions/delete.png" onclick="hideConnexionBox()" alt="Fermer" ';
Ayolo's avatar
bleh  
Ayolo committed
280 281 282 283 284 285 286 287 288 289 290 291 292 293
      $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);
Antoine Tenart's avatar
bleh  
Antoine Tenart committed
294
      $frm->add_text_field("username","Utilisateur","prenom.nom","",20,true,true,null,false,35);
Ayolo's avatar
bleh  
Ayolo committed
295 296 297 298 299 300
      $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
301
    }
Ayolo's avatar
bleh  
Ayolo committed
302

Ayolo's avatar
bleh  
Ayolo committed
303 304
/* header */
    $this->buffer .= "<div id='header'>\n";
Ayolo's avatar
bleh  
Ayolo committed
305
    if(!defined('NOTAE'))
Ayolo's avatar
bleh  
Ayolo committed
306 307
    {
      $important=$this->get_param('box.Important');
Ayolo's avatar
bleh  
Ayolo committed
308
      if(!empty($important) && $important!="<p />")
Ayolo's avatar
bleh  
Ayolo committed
309
      {
BenC's avatar
test  
BenC committed
310
        $this->buffer .= "<div class=\"box\" id=\"important\">\n";
BenC's avatar
kwain  
BenC committed
311
        $this->buffer .= "<a class=\"logo\" href=\"http://ae.utbm.fr\"></a>";
BenC's avatar
test  
BenC committed
312
        $this->buffer .= "<div class=\"body\">\n";
Ayolo's avatar
bleh  
Ayolo committed
313 314 315
        $this->buffer .= $important. "\n";
        $this->buffer .= "</div></div>\n";
      }
mbriand's avatar
mbriand committed
316

mbriand's avatar
mbriand committed
317
      //if (isset($_SERVER['HTTPS']))
mbriand's avatar
mbriand committed
318
        $url = "https://ae.utbm.fr";
mbriand's avatar
mbriand committed
319 320
      //else
      //  $url = "http://ae.utbm.fr";
mbriand's avatar
mbriand committed
321 322 323 324
      if($GLOBALS["taiste"])
        $url .= "/taiste/";

      $this->buffer .= "<div id=\"logo\"><a href=\"".$url."\"><img src=\"" . $wwwtopdir ."images/ae_header.png\" alt=\"Logo AE\"/></a></div>\n";
Ayolo's avatar
bleh  
Ayolo committed
325
    }
Ayolo's avatar
bleh  
Ayolo committed
326 327
    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
328 329 330 331

    $this->buffer .= "<div id='headermenu'>\n";
    if ( !$this->user->is_valid() )
    {
Ayolo's avatar
bleh  
Ayolo committed
332 333
      $this->buffer .= "<script type=\"text/javascript\">\n";
      $this->buffer .= "var menu_utilisateur=new Array();";
334
      $this->buffer .= "menu_utilisateur[0]='<a class=\"firstdropdown\" href=\"".$topdir."connect.php\" onclick=\"return showConnexionBox()\">Connexion</a>';";
Ayolo's avatar
bleh  
Ayolo committed
335 336 337
      $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>";
338
      $this->buffer .= "<div id='login' onmouseover=\"dropdownmenu(this, event, menu_utilisateur)\" onmouseout=\"delayhidemenu()\">\n";
slopez's avatar
fix  
slopez committed
339
        $this->buffer .= "<a href='".$topdir."connect.php'>Identification</a>\n";
Ayolo's avatar
bleh  
Ayolo committed
340 341
    }
    elseif($this->user->type=="srv" )
Ayolo's avatar
bleh  
Ayolo committed
342
    {
Ayolo's avatar
bleh  
Ayolo committed
343 344 345 346 347
      $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>";
348
      $this->buffer .= "<div id='login' onmouseover=\"dropdownmenu(this, event, menu_utilisateur)\" onmouseout=\"delayhidemenu()\">\n";
Ayolo's avatar
Ayolo committed
349
      $this->buffer .= "<a href=\"".$topdir."boutique-utbm/suivi.php\">Suivi commandes</a>\n";
Ayolo's avatar
bleh  
Ayolo committed
350 351 352
    }
    else
    {
Ayolo's avatar
bleh  
Ayolo committed
353
      if(!defined('NOTAE') && $this->user->ae)
Ayolo's avatar
bleh  
Ayolo committed
354 355 356 357 358 359
      {
        $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
360
      if(!defined('NOTAE'))
Ayolo's avatar
bleh  
Ayolo committed
361
      {
362
        $this->buffer .= "menu_utilisateur[$i]='<a class=\"firstdropdown\" href=\"".$topdir."user.php?id_utilisateur=".$this->user->id."\">Mes informations</a>';";
363
        $i++;
Ayolo's avatar
bleh  
Ayolo committed
364 365
        if($this->user->ae)
        {
366
          $this->buffer .= "menu_utilisateur[$i]='<a href=\"".$topdir."user/compteae.php\">Compte AE : ".(sprintf("%.2f", $this->user->montant_compte/100))." €</a>';";
Ayolo's avatar
bleh  
Ayolo committed
367 368
          $i++;
        }
mbriand's avatar
mbriand committed
369 370
        $i++;
        $this->buffer .= "menu_utilisateur[$i]='<a href=\"".$topdir."user/outils.php\">Mes outils</a>';";
Ayolo's avatar
bleh  
Ayolo committed
371
        $i++;
Ayolo's avatar
bleh  
Ayolo committed
372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390
        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++;
BenC's avatar
BenC committed
391
      }
Ayolo's avatar
bleh  
Ayolo committed
392 393
      $this->buffer .= "menu_utilisateur[$i]='<a href=\"".$topdir."disconnect.php\">Déconnexion</a>';";
      $this->buffer .= "</script>";
394
      $this->buffer .= "<div id='login' onmouseover=\"dropdownmenu(this, event, menu_utilisateur)\" onmouseout=\"delayhidemenu()\">\n";
Ayolo's avatar
bleh  
Ayolo committed
395
      $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
396 397 398
    }
    $this->buffer .= "</div>\n";

Ayolo's avatar
bleh  
Ayolo committed
399
    if(!defined('NOTAE'))
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
      $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 " .
mbriand's avatar
mbriand committed
413
         "WHERE id_groupe IN (".$this->user->get_groups_csv().") AND nom_cpt != 'test' " .
mbriand's avatar
bleh  
mbriand committed
414
         "AND archive != '1' " .
Ayolo's avatar
bleh  
Ayolo committed
415 416 417 418 419 420 421 422 423 424
         "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
425
      {
Ayolo's avatar
bleh  
Ayolo committed
426 427 428 429
        $this->buffer .= "<script type=\"text/javascript\">\n";
        $this->buffer .= "var menu_assos=new Array();";
        $i=0;
        $class="class=\"firstdropdown\"";
430 431

        /* Droits spécifiques */
Ayolo's avatar
bleh  
Ayolo committed
432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461
        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="";
        }
462 463

        /* Gestion assos */
Ayolo's avatar
bleh  
Ayolo committed
464 465 466 467 468 469
        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="";
        }
470 471

        /* Admins comptoirs */
472
        if( $req2->lines > 4 )
Ayolo's avatar
bleh  
Ayolo committed
473
        {
Ayolo's avatar
bleh  
Ayolo committed
474
          $this->buffer .= "menu_assos[".$i."]='<a $class href=\"".$topdir."comptoir/admin.php\">Admin : comptoirs</a>';";
Ayolo's avatar
bleh  
Ayolo committed
475
          $i++;
Ayolo's avatar
bleh  
Ayolo committed
476
          $class="";
Ayolo's avatar
bleh  
Ayolo committed
477
        }
Ayolo's avatar
bleh  
Ayolo committed
478 479 480 481 482 483 484 485 486
        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="";
          }
        }
487

Ayolo's avatar
bleh  
Ayolo committed
488
        $this->buffer .= "</script>";
489
        $this->buffer .= "<div id='assos' onmouseover=\"dropdownmenu(this, event, menu_assos, '150px')\" onmouseout='delayhidemenu()'>\n";
Ayolo's avatar
bleh  
Ayolo committed
490 491
        $this->buffer .= "Gestion assos/clubs";
        $this->buffer .= "</div>\n";
Ayolo's avatar
bleh  
Ayolo committed
492
      }
Lopar's avatar
Lopar committed
493

Ayolo's avatar
bleh  
Ayolo committed
494 495 496 497 498 499
      $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
500
    $this->buffer .= "</div>\n";
Ayolo's avatar
bleh  
Ayolo committed
501 502
    if(!defined('NOTAE'))
      $this->buffer .= "<div id=\"fsearchres\"></div>\n";
Ayolo's avatar
bleh  
Ayolo committed
503
    $this->buffer .= "</div>\n";
Ayolo's avatar
bleh  
Ayolo committed
504
/* fin header */
Ayolo's avatar
Ayolo committed
505

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

Ayolo's avatar
bleh  
Ayolo committed
509 510
    foreach ($this->tab_array as $entry)
    {
Lopar's avatar
Lopar committed
511

Ayolo's avatar
bleh  
Ayolo committed
512
      $this->buffer .= "<span";
Ayolo's avatar
bleh  
Ayolo committed
513 514
      if ($this->section == $entry[0])
      {
Ayolo's avatar
bleh  
Ayolo committed
515
        $this->buffer .= " class=\"selected tab".$entry[0]."\"";
Ayolo's avatar
bleh  
Ayolo committed
516 517 518
        $links=$entry[3];
      }
      else
Ayolo's avatar
bleh  
Ayolo committed
519
        $this->buffer .= " class=\"tab".$entry[0]."\"";
gliss's avatar
gliss committed
520

Ayolo's avatar
bleh  
Ayolo committed
521 522
      $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
523
    }
Lopar's avatar
Lopar committed
524

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

Ayolo's avatar
bleh  
Ayolo committed
527 528
    if ( $links )
    {
Ayolo's avatar
bleh  
Ayolo committed
529
      $this->buffer .= "<div class=\"sectionlinks\">";
Lopar's avatar
Lopar committed
530

Ayolo's avatar
bleh  
Ayolo committed
531 532
      foreach ( $links as $entry )
      {
mbriand's avatar
mbriand committed
533 534 535
        if (($entry[0] == "forum2/admin/") && (!$this->user->is_in_group('root') && !$this->user->is_in_group('moderateur_forum')))
          continue;

536
        if ( !strncmp("http://",$entry[0],7) )
Ayolo's avatar
bleh  
Ayolo committed
537
          $this->buffer .= "<a href=\"".$entry[0]."\">".$entry[1]."</a>";
538
        elseif(!empty($entry[0]))
Ayolo's avatar
bleh  
Ayolo committed
539
          $this->buffer .= "<a href=\"".$wwwtopdir.$entry[0]."\">".$entry[1]."</a>";
540
        else
541
          $this->buffer .= "<span>".$entry[1]."</span>";
Ayolo's avatar
bleh  
Ayolo committed
542
      }
Lopar's avatar
Lopar committed
543

Ayolo's avatar
bleh  
Ayolo committed
544
      $this->buffer .= "</div>\n";
Ayolo's avatar
bleh  
Ayolo committed
545 546
    }
    else
Ayolo's avatar
bleh  
Ayolo committed
547
      $this->buffer .= "<div class=\"emptysectionlinks\"></div>\n";
gliss's avatar
gliss committed
548

Ayolo's avatar
bleh  
Ayolo committed
549
    $this->buffer .= "<div class=\"contents\">\n";
Ayolo's avatar
bleh  
Ayolo committed
550
    $idpage = "";
Lopar's avatar
Lopar committed
551

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

Ayolo's avatar
bleh  
Ayolo committed
554 555
    foreach ( $this->sides as $side => $names )
    {
556
      if ( count($names) )
Ayolo's avatar
bleh  
Ayolo committed
557 558
      {
        $idpage .= substr($side,0,1);
Lopar's avatar
Lopar committed
559

Ayolo's avatar
bleh  
Ayolo committed
560 561 562 563 564 565 566 567 568
        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 )
            {
569
              $name = substr($elt,5);
Ayolo's avatar
bleh  
Ayolo committed
570 571 572 573 574 575 576 577 578
              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;
579
          }
Ayolo's avatar
bleh  
Ayolo committed
580 581 582
        }
        else
          $ref = null;
Lopar's avatar
Lopar committed
583

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

Ayolo's avatar
bleh  
Ayolo committed
588 589
          if ( $cts = $this->boxes[$name] )
          {
Ayolo's avatar
test  
Ayolo committed
590
            $this->buffer .= "<div class=\"box\" id=\"sbox_".$name."\">\n";
Ayolo's avatar
bleh  
Ayolo committed
591
            if ( $cts->title && ($ref != null) )
Ayolo's avatar
test  
Ayolo committed
592
              $this->buffer .= "<h1><a onmousedown=\"dnds_startdrag(event,'sbox_".$name."','".$ref."');\" class=\"dragstartzone\">".$cts->title."</a></h1>\n";
Ayolo's avatar
bleh  
Ayolo committed
593
            elseif ( $cts->title )
Ayolo's avatar
test  
Ayolo committed
594
              $this->buffer .= "<h1>".$cts->title."</h1>\n";
Lopar's avatar
Lopar committed
595

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

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

Ayolo's avatar
test  
Ayolo committed
600 601
            $this->buffer .= "</div>\n";
            $this->buffer .= "</div>\n";
Ayolo's avatar
bleh  
Ayolo committed
602
          }
Lopar's avatar
Lopar committed
603

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

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

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

Ayolo's avatar
bleh  
Ayolo committed
614 615 616 617
    $i=0;
    foreach ( $this->contents as $cts )
    {
      $cssclass = "article";
Lopar's avatar
Lopar committed
618

Ayolo's avatar
bleh  
Ayolo committed
619
      if ( !is_null($cts->cssclass) )
620
        $cssclass = $cts->cssclass;
Lopar's avatar
Lopar committed
621

Ayolo's avatar
bleh  
Ayolo committed
622
      $i++;
Lopar's avatar
Lopar committed
623 624


Ayolo's avatar
bleh  
Ayolo committed
625
      $this->buffer .= "<div class=\"".$cssclass."\"";
Ayolo's avatar
bleh  
Ayolo committed
626
      if ( $cts->divid )
Ayolo's avatar
bleh  
Ayolo committed
627
        $this->buffer .= " id=\"".$cts->divid."\"";
Ayolo's avatar
bleh  
Ayolo committed
628
      else
Ayolo's avatar
bleh  
Ayolo committed
629 630
        $this->buffer .= " id=\"cts".$i."\"";
      $this->buffer .= ">\n";
Lopar's avatar
Lopar committed
631

Ayolo's avatar
bleh  
Ayolo committed
632 633
      if ( $cts->toolbox )
      {
Ayolo's avatar
bleh  
Ayolo committed
634 635 636
        $this->buffer .= "<div class=\"toolbox\">\n";
        $this->buffer .= $cts->toolbox->html_render()."\n";
        $this->buffer .= "</div>\n";
637
      }
Lopar's avatar
Lopar committed
638

Ayolo's avatar
bleh  
Ayolo committed
639
      if ( $cts->title )
mbriand's avatar
mbriand committed
640
        $this->buffer .= "<h1>".$cts->title."</h1>\n";
Feu's avatar
Feu committed
641

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

Ayolo's avatar
bleh  
Ayolo committed
644
      $this->buffer .= "</div>\n";
Ayolo's avatar
bleh  
Ayolo committed
645
    }
Lopar's avatar
Lopar committed
646

Ayolo's avatar
bleh  
Ayolo committed
647 648
    $this->buffer .= "</div>\n"; // /page
    $this->buffer .= "<!-- end of page -->\n\n";
Ayolo's avatar
bleh  
Ayolo committed
649
    $this->buffer .= "</div>\n"; // /contents
Ayolo's avatar
bleh  
Ayolo committed
650 651
    $this->buffer .= "<div id=\"contentsend\">&nbsp;</div>\n";
    $this->buffer .= "<div id=\"endsite\">";
gliss's avatar
wip  
gliss committed
652
    $this->buffer .= "<div id=\"endsitelinks\">";
Ayolo's avatar
bleh  
Ayolo committed
653 654 655
    if(!defined('NOTAE'))
    {
      $this->buffer .= "<a href=\"". $wwwtopdir ."article.php?name=legals\">MENTIONS LÉGALES</a> ";
Ayolo's avatar
bleh  
Ayolo committed
656
      $this->buffer .= "<a href=\"". $wwwtopdir ."copyright_agent.php\">PROPRIÉTÉ INTELLECTUELLE</a>";
Ayolo's avatar
bleh  
Ayolo committed
657 658 659 660 661
      $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
662 663 664
    $this->buffer .= "</div>";// /endsitelinks
    $this->buffer .= "</div>";// /endsite
    $this->buffer .= "</div>\n"; // /site
Lopar's avatar
Lopar committed
665

BenC's avatar
BenC committed
666 667
    if ( $this->get_param("backup_server",true) )
    {
Ayolo's avatar
bleh  
Ayolo committed
668 669 670
      $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
671
           "veuillez limiter vos actions au strict minimum.";
Ayolo's avatar
bleh  
Ayolo committed
672
      $this->buffer .= "</div>";
BenC's avatar
BenC committed
673
    }
BenC's avatar
BenC committed
674 675
    elseif ( $this->get_param("warning_enabled",true) )
    {
Ayolo's avatar
bleh  
Ayolo committed
676 677 678 679
      $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
680
    }
Ayolo's avatar
bleh  
Ayolo committed
681 682 683 684 685 686
    $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
687 688
    if ( $GLOBALS["taiste"] ){
      print_r($timing);
Feu's avatar
Feu committed
689
      echo "\non est en taiste\n";
gliss's avatar
wip  
gliss committed
690
    }
Ayolo's avatar
bleh  
Ayolo committed
691
    echo " -->";
Ayolo's avatar
Ayolo committed
692
  }
Lopar's avatar
Lopar committed
693

Feu's avatar
Feu committed
694 695 696 697 698 699
  /**
   * Rendu de la page en mode popup (sans header, sans boites laterales)
   */
  function popup_end_page ()
  {
    global $wwwtopdir ;
Lopar's avatar
Lopar committed
700

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

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

Ayolo's avatar
bleh  
Ayolo committed
705 706 707 708 709 710
    $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";
711
    foreach ( $this->extracss as $url )
Ayolo's avatar
bleh  
Ayolo committed
712
      $this->buffer .= "<link rel=\"stylesheet\" type=\"text/css\" href=\"" . htmlentities($wwwtopdir . $url,ENT_COMPAT,"UTF-8"). "\" />\n";
Lopar's avatar
Lopar committed
713

714
    foreach ( $this->rss as $title => $url )
Ayolo's avatar
bleh  
Ayolo committed
715
      $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
716

Ayolo's avatar
bleh  
Ayolo committed
717 718 719 720 721
    $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
722

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

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

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

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

Feu's avatar
Feu committed
733 734 735 736
    $i=0;
    foreach ( $this->contents as $cts )
    {
      $cssclass = "article";
Lopar's avatar
Lopar committed
737

Feu's avatar
Feu committed
738
      if ( !is_null($cts->cssclass) )
739
        $cssclass = $cts->cssclass;
Lopar's avatar
Lopar committed
740

Feu's avatar
Feu committed
741
      $i++;
Ayolo's avatar
bleh  
Ayolo committed
742
      $this->buffer .= "<div class=\"".$cssclass."\"";
Feu's avatar
Feu committed
743
      if ( $cts->divid )
Ayolo's avatar
bleh  
Ayolo committed
744
        $this->buffer .= " id=\"".$cts->divid."\"";
Feu's avatar
Feu committed
745
      else
Ayolo's avatar
bleh  
Ayolo committed
746 747
        $this->buffer .= " id=\"cts".$i."\"";
      $this->buffer .= ">\n";
Lopar's avatar
Lopar committed
748

Feu's avatar
Feu committed
749 750
      if ( $cts->toolbox )
      {
Ayolo's avatar
bleh  
Ayolo committed
751 752 753
        $this->buffer .= "<div class=\"toolbox\">\n";
        $this->buffer .= $cts->toolbox->html_render()."\n";
        $this->buffer .= "</div>\n";
754
      }
Lopar's avatar
Lopar committed
755

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

Ayolo's avatar
bleh  
Ayolo committed
759 760
      $this->buffer .= $cts->html_render();
      $this->buffer .= "</div>\n";
Feu's avatar
Feu committed
761
    }
Lopar's avatar
Lopar committed
762

Ayolo's avatar
bleh  
Ayolo committed
763 764 765
    $this->buffer .= "</div>\n";
    $this->buffer .= "</body>\n";
    $this->buffer .= "</html>\n";
gliss's avatar
bleh  
gliss committed
766
    echo $this->buffer;
Feu's avatar
Feu committed
767
  }
Ayolo's avatar
Ayolo committed
768

Ayolo's avatar
bleh  
Ayolo committed
769 770 771 772 773 774 775
  /** 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
776

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

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

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

Ayolo's avatar
bleh  
Ayolo committed
786 787 788 789 790 791 792
  /**
   * 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 )
  {
793
    if ( !$this->params )
Ayolo's avatar
bleh  
Ayolo committed
794
      $this->load_params();
Lopar's avatar
Lopar committed
795

796
    if ( !isset($this->params[$name]) )
Ayolo's avatar
bleh  
Ayolo committed
797
      return $default;
Lopar's avatar
Lopar committed
798

Ayolo's avatar
bleh  
Ayolo committed
799 800
    return unserialize($this->params[$name]);
  }
Ayolo's avatar
Ayolo committed
801

gliss's avatar
gliss committed
802

Ayolo's avatar
bleh  
Ayolo committed
803 804 805 806 807 808 809
  /**
   * Définit un paramètre du site.
   * @param $name Nom du paramètre
   * @param $value Valeur du paramètre.
   */
  function set_param ( $name, $value )
  {
810
    if ( !$this->params )
Ayolo's avatar
bleh  
Ayolo committed
811
      $this->load_params();
Lopar's avatar
Lopar committed
812

Ayolo's avatar
bleh  
Ayolo committed
813
    $value = serialize($value);
Lopar's avatar
Lopar committed
814

Ayolo's avatar
bleh  
Ayolo committed
815 816 817
    if ( !isset($this->params[$name]) )
    {
      $sql = new insert($this->dbrw,"site_parametres",
818
        array (
Ayolo's avatar
bleh  
Ayolo committed
819 820 821
          "nom_param" => $name,
          "valeur_param" => $value
        ));
Ayolo's avatar
alert  
Ayolo committed
822
      $this->params[$name]=$value;
Ayolo's avatar
bleh  
Ayolo committed
823
    }
824
    elseif ( $this->params[$name] !== $value )
Ayolo's avatar
bleh  
Ayolo committed
825 826 827
    {
      $sql = new update($this->dbrw,"site_parametres",
        array( "valeur_param" => $value),
Ayolo's avatar
bleh  
Ayolo committed
828
        array( "nom_param" => $name));      //$this->buffer .= " onmouseover=\"tabsection('".$entry[0]."', 'hoversectionlinks');\"";
Ayolo's avatar
alert  
Ayolo committed
829
      $this->params[$name]=$value;
Ayolo's avatar
bleh  
Ayolo committed
830 831
    }
  }
Ayolo's avatar
Ayolo committed
832

gliss's avatar
gliss committed
833

Ayolo's avatar
bleh  
Ayolo committed
834 835 836 837 838 839 840
  /**
   * 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
mbriand's avatar
mbriand committed
841
   * @param $level niveau d'incidence (0:pas grave, 1:peu risqué, 2:trés risqué, 3:risque la colère des administrateurs)
Ayolo's avatar
bleh  
Ayolo committed
842 843 844 845 846 847 848 849 850 851 852
   */
  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
853

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

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

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

Ayolo's avatar
bleh  
Ayolo committed
860 861
    if ( $level == 2 )
      $cts->add_paragraph("ATTENTION","huge");
Lopar's avatar
Lopar committed
862

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

Ayolo's avatar
bleh  
Ayolo committed
865
    if ( $level == 2 )
slopez's avatar
slopez committed
866
      $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
867

gliss's avatar
gliss committed
868
    $cts->add_paragraph("Êtes vous sûr ?");
jlaval's avatar
Bluck  
jlaval committed
869 870
    if ($level == 3) {
      $phrase_magique = 'oui je suis sur de vouloir faire ça';
jlaval's avatar
jlaval committed
871
      $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
872
    }
Lopar's avatar
Lopar committed
873

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

Ayolo's avatar
bleh  
Ayolo committed
877
    foreach ( $_POST as $key => $val )
Feu's avatar
fix  
Feu committed
878
      if ( $key != "magicform" )
Ayolo's avatar
bleh  
Ayolo committed
879 880
      {
        if($key=="__script__")
Ayolo's avatar
bleh  
Ayolo committed
881
          $frm->add_hidden($key,htmlspecialchars($val));
mbriand's avatar
bleh  
mbriand committed
882 883 884
        else if (is_array($val))
        {
          foreach ( $val as $k => $v )
mbriand's avatar
bleh  
mbriand committed
885
            $frm->add_hidden($key.'['.$k.']',$v);
mbriand's avatar
bleh  
mbriand committed
886
        }
Ayolo's avatar
bleh  
Ayolo committed
887 888 889
        else
          $frm->add_hidden($key,$val);
      }
Ayolo's avatar
bleh  
Ayolo committed
890
    foreach ( $_GET as $key => $val )
Feu's avatar
fix  
Feu committed
891
      if ( $key != "magicform" )
mbriand's avatar
bleh  
mbriand committed
892 893 894 895
      {
        if (is_array($val))
        {
          foreach ( $val as $k => $v )
mbriand's avatar
bleh  
mbriand committed
896
            $frm->add_hidden($key.'['.$k.']',$v);
mbriand's avatar
bleh  
mbriand committed
897 898 899 900
        }
        else
          $frm->add_hidden($key,$val);
      }
Lopar's avatar
Lopar committed
901

jlaval's avatar
jlaval committed
902
    if ($level == 3) {
slopez's avatar
slopez committed
903 904
      $_uid = gen_uid();
      $frm->add_text_field('____really_sure__'.$_uid, 'Tapez la phrase magique :', '', true, 50);
jlaval's avatar
jlaval committed
905 906
    }

907 908
    $frm->add_submit("___i_am_really_sure","OUI");
    $frm->add_submit("___finally_i_want_to_cancel","NON");
Lopar's avatar
Lopar committed
909

Ayolo's avatar
bleh  
Ayolo committed
910
    $cts->add($frm);
jlaval's avatar
jlaval committed
911
    if ($level == 3)
slopez's avatar
slopez committed
912
      $cts->puts('<script type="text/javascript">
jlaval's avatar
jlaval committed
913
var txt = document.getElementsByName("____really_sure__'.$_uid.'")[0];
slopez's avatar
slopez committed
914 915
var sub = document.getElementById("___i_am_really_sure");
sub.disabled = true;
slopez's avatar
fix?  
slopez committed
916 917 918 919 920 921 922 923 924 925
txt.onkeyup = function (event){
  if ( event != null )
  {
    var sub = document.getElementById("___i_am_really_sure");
    var txt = document.getElementsByName("____really_sure__'.$_uid.'")[0];
    if (txt.value == "'.$phrase_magique.'")
      sub.disabled = false;
    else
      sub.disabled = true;
  }
slopez's avatar
slopez committed
926 927
}
</script>');
Lopar's avatar
Lopar committed
928

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

Ayolo's avatar
bleh  
Ayolo committed
931 932 933
    $this->end_page();
    exit();
  }
Lopar's avatar
Lopar committed
934

Feu's avatar
Feu committed
935 936 937 938 939
  function set_meta_information( $keywords, $description )
  {
    $this->meta_keywords = $keywords;
    $this->meta_description = $description;
  }
Lopar's avatar
Lopar committed
940

Feu's avatar
Feu committed
941 942 943 944
  function add_alternate ( $type, $title, $href )
  {
    $this->alternate[]=array($type,$title,$href);
  }
Lopar's avatar
Lopar committed
945

Feu's avatar
Feu committed
946 947 948 949 950 951
  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
952

Ayolo's avatar
Ayolo committed
953 954 955
}

?>