site.inc.php 58.8 KB
Newer Older
Ayolo's avatar
Ayolo committed
1
2
3
4
5
6
<?php
/** @file
 *
 * @brief Fonctions générales du site.
 *
 */
Feu's avatar
Feu committed
7
/* Copyright 2004,2005,2006,2007
Ayolo's avatar
Ayolo committed
8
9
10
11
12
 * - Alexandre Belloni <alexandre POINT belloni CHEZ utbm POINT fr>
 * - Thomas Petazzoni <thomas POINT petazzoni CHEZ enix POINT org>
 * - Maxime Petazzoni <maxime POINT petazzoni CHEZ bulix POINT org>
 * - Pierre Mauduit <pierre POINT mauduit CHEZ utbm POINT fr>
 * - Julien Etelain <julien CHEZ pmad POINT net>
BenC's avatar
BenC committed
13
14
 * - Benjamin Collet <bcollet CHEZ oxynux POINT org>
 * - Sarah Amsellem <sarah POINT amsellem CHEZ gmail POINT com>
Ayolo's avatar
Ayolo committed
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
 *
 * Ce fichier fait partie du site de l'Association des 0tudiants 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.
 */
Feu's avatar
Feu committed
34
35
36
 
if ( !isset($GLOBALS['nosession']) )
  session_start();
Ayolo's avatar
Ayolo committed
37
38
39
40
41
42
43

require_once($topdir . "include/interface.inc.php");
require_once($topdir . "include/globals.inc.php");
require_once($topdir . "include/cts/calendar.inc.php");
require_once($topdir . "include/entities/sondage.inc.php");
require_once($topdir . "include/entities/campagne.inc.php");
require_once($topdir . "include/entities/cotisation.inc.php");
gliss's avatar
gliss committed
44
require_once($topdir . "jobetu/include/jobuser_etu.inc.php");
Ayolo's avatar
Ayolo committed
45
46
47
48

/** La classe principale du site */
class site extends interfaceweb
{
Ayolo's avatar
bleh  
Ayolo committed
49

Ayolo's avatar
Ayolo committed
50
  /** Constructeur de la classe */
Ayolo's avatar
bleh  
Ayolo committed
51
  function site ($siteae=true)
Ayolo's avatar
Ayolo committed
52
  {
Feu's avatar
Feu committed
53
    global $timing;
Feu's avatar
Feu committed
54
    $timing["includes"] = microtime(true)+$timing["all"];
Feu's avatar
Feu committed
55
56
    $timing["site::site"] -= microtime(true);
    
Ayolo's avatar
Ayolo committed
57
    $dbro = new mysqlae ();
Feu's avatar
debug  
Feu committed
58
    
Feu's avatar
debug  
Feu committed
59
    if (!$dbro->dbh)
Ayolo's avatar
Ayolo committed
60
61
62
      $this->fatal("no db");

    $dbrw = new mysqlae ("rw");
Feu's avatar
debug  
Feu committed
63
    if (!$dbrw->dbh)
64
      $this->fatal("no dbrw");
Ayolo's avatar
Ayolo committed
65

66
    $this->interfaceweb($dbro, $dbrw);
Ayolo's avatar
Ayolo committed
67
68
69
70

    if($_COOKIE['AE2_SESS_ID'])
      $this->load_session($_COOKIE['AE2_SESS_ID']);

71
72
    if ( $this->get_param("closed",false) && !$this->user->is_in_group("root") )
      $this->fatal("closed");
Ayolo's avatar
Ayolo committed
73
74

    $this->set_side_boxes("left",array("calendrier","alerts","connexion"),"default_left");
Feu's avatar
Feu committed
75
76
    
    $timing["site::site"] += microtime(true);
Ayolo's avatar
Ayolo committed
77
78
79
80

    /*
     * LEs css du site ae restent sur le site ae
     */
Ayolo's avatar
bleh  
Ayolo committed
81
    if ( $siteae )
Ayolo's avatar
Ayolo committed
82
83
84
    {
      $this->add_css("themes/fimu08/css/site.css");
    }
Feu's avatar
Feu committed
85
    
86
  }  
Feu's avatar
Feu committed
87

Feu's avatar
test  
Feu committed
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
  private function unset_session (  )
  {
    if ( isset($_COOKIE['AE2_SESS_ID']) )
    {
      $domain = ($_SERVER['HTTP_HOST'] != 'localhost' && $_SERVER['HTTP_HOST'] != '127.0.0.1') ? $_SERVER['HTTP_HOST'] : false;
      setcookie ("AE2_SESS_ID", "", time() - 3600, "/", $domain, 0);
      unset($_COOKIE['AE2_SESS_ID']);
    }
    
    if ( !isset($_SESSION["visite"]) )
      unset($_SESSION['visite']); 
        
    if ( isset($_SESSION['session_redirect']) )
      unset($_SESSION['session_redirect']);
  }


Feu's avatar
Feu committed
105
106
107
108
  /**
   * Charge une session en fonction de son identidiant.
   * @param $sid Identifiant de la session
   */
Feu's avatar
test  
Feu committed
109
  function load_session ( $sid )
Ayolo's avatar
Ayolo committed
110
  {
Feu's avatar
test  
Feu committed
111
112
113
114
115
116
117
118

    $req = new requete($this->db, 
      "SELECT `utilisateurs`.*, `expire_sess`, `derniere_visite`  ".
      "FROM `site_sessions` ".
      "INNER JOIN `utilisateurs` USING(`id_utilisateur`) ".
      "WHERE `id_session` = '".mysql_escape_string($sid)."'");

    if ($req->lines < 1 )
119
    {
Feu's avatar
test  
Feu committed
120
121
122
123
124
125
126
127
128
129
130
      $this->unset_session();
      return;
    }
    
    $row = $req->get_row();
    
    if ( $row["hash_utl"] != "valid")
    {
      new delete($this->dbrw,"site_sessions",array("id_session" => $sid));
      $this->unset_session();
      return;
131
    }
Feu's avatar
test  
Feu committed
132
    
Feu's avatar
Feu committed
133
    $expire = $row['expire_sess'];
Feu's avatar
test  
Feu committed
134

135
    // On n'est pas à une minute près
Feu's avatar
test  
Feu committed
136
137
    $d = date("Y-m-d H:i:")."00";

Feu's avatar
Feu committed
138
    if ( !is_null($expire) )
Ayolo's avatar
Ayolo committed
139
    {
Feu's avatar
test  
Feu committed
140
141
142
      $expire = strtotime($expire)-time();
      
      if ( $expire < 0 ) // Session expirée, fait le ménage
Ayolo's avatar
Ayolo committed
143
      {
Feu's avatar
test  
Feu committed
144
145
        new delete($this->dbrw,"site_sessions",array("id_session" => $sid));
        $this->unset_session();
Ayolo's avatar
Ayolo committed
146
147
        return;
      }
Feu's avatar
test  
Feu committed
148
149
150
151
152
153
154
155
156
157
158
159
160
      
      if ( $d != $row['derniere_visite'] )
        new update($this->dbrw, "site_sessions",
            array(
              "derniere_visite" => $d,
              "expire_sess" => date("Y-m-d H:i:s",time()+(16*60))),
              array("id_session" => $sid));       
    }
    else if ( $d != $row['derniere_visite'] )
    {
      new update($this->dbrw, "site_sessions",
          array("derniere_visite" => $d),
          array("id_session" => $sid)); 
161
    }
Ayolo's avatar
Ayolo committed
162
            
Feu's avatar
test  
Feu committed
163
    $this->user->_load($row);
Feu's avatar
test  
Feu committed
164
      
Feu's avatar
test  
Feu committed
165
    if ( !isset($_SESSION["visite"]) )
166
    {
Feu's avatar
test  
Feu committed
167
168
      $this->user->visite();
      $_SESSION["visite"]=time();
169
    }
Feu's avatar
test  
Feu committed
170
    
Feu's avatar
test  
Feu committed
171
172
    if ( !isset($_SESSION["usersession"]) ) // restore le usersession
      $_SESSION["usersession"] = $this->user->get_param("usersession",null);
Feu's avatar
test  
Feu committed
173
    
Ayolo's avatar
Ayolo committed
174
175
  }

Feu's avatar
Feu committed
176
177
178
179
180
181
  /**
   * Connecte l'utilisateur chargé dans le champ user ($this->user) pour 
   * 15 minutes, ou permanente, en créant une sessions et en envoyant un cookie.
   * @param $forever Precise si la session doit être permanente
   * @return l'identifiant de la session
   */
Ayolo's avatar
Ayolo committed
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
  function connect_user ($forever=true)
  {
    if ( $forever )
      $expire = null;
    else
      $expire = date("Y-m-d H:i:s",time()+(15*60)); // Session expire dans 15 minutes
  
    $sid = md5(rand(0,32000) . $_SERVER['REMOTE_ADDR'] . rand(0,32000));

    $req = new insert($this->dbrw, "site_sessions",
            array(
              "id_session"      => $sid,
              "id_utilisateur"    => $this->user->id,
              "date_debut_sess"  => date("Y-m-d H:i:s"),
              "derniere_visite"  => date("Y-m-d H:i:s"),
              "expire_sess" => $expire
              ));
    $domain = ($_SERVER['HTTP_HOST'] != 'localhost' && $_SERVER['HTTP_HOST'] != '127.0.0.1') ? $_SERVER['HTTP_HOST'] : false;
    setcookie ("AE2_SESS_ID", $sid, time() + 31536000, "/", $domain, 0);

    $this->user->visite();

Feu's avatar
wip  
Feu committed
204
205
    $this->add_box("connexion", $this->get_connection_contents());

Ayolo's avatar
Ayolo committed
206
207
208
    return $sid;
  }
  
Feu's avatar
Feu committed
209
210
211
212
213
214
215
216
  /**
   * Crée un identifiant unique pour connecter ultérieurement un utilisateur.
   * Utile pour envoyer un lien par e-mail avec authentification automatique.
   * Le "token" est en fait un identifiant de session, il expire au bout de 60 jours.
   * @param $id_utilisateur Id de l'utilisateur pour qui le "token" doit être généré
   * @return le "token" (identifiant de session)
   * @see load_token
   */
Feu's avatar
wip  
Feu committed
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
  function create_token_for_user ( $id_utilisateur )
  {
    $sid = "T".$id_utilisateur."$".md5(rand(0,32000) . "TOKEN" . $id_utilisateur . rand(0,32000));

    $req = new insert($this->dbrw, "site_sessions",
            array(
              "id_session"      => $sid,
              "id_utilisateur"    => $id_utilisateur,
              "date_debut_sess"  => date("Y-m-d H:i:s"),
              "derniere_visite"  => date("Y-m-d H:i:s"),
              "expire_sess" => date("Y-m-d H:i:s",time()+(24*60*60*60))
              ));

    return $sid;
  }
  
Feu's avatar
Feu committed
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
  /**
   * Ouvre une session pour l'utilisateur associé à un token donné.
   * La session est ouverte par le biai de connect_user(). Le token n'est plus
   * valable après l'appel à cette fonction.
   * @param $token le "token"
   * @return null en cas d'echec, ou l'identifiant de la session ouverte
   * @see connect_user
   * @see create_token_for_user
   */
  function load_token ( $token )
  {
    $this->user->id=null;
    $this->load_session($token);  
    if ( $this->user->is_valid() )
    {
      new delete($this->dbrw, "site_sessions", array("id_session"=>$token) );
      return $this->connect_user();
    }
    return null;
  }

  /**
   * Crée une session pour  l'utilisateur chargé dans le champ user ($this->user)  
   * pour 15 minutes, ou permanente.
   * @param $forever Precise si la session doit être permanente
   * @return l'identifiant de la session
   */
Ayolo's avatar
Ayolo committed
260
261
262
263
264
265
266
267
268
269
  function create_session ($forever=true)
  {
    if ( $forever )
      $expire = null;
    else
      $expire = date("Y-m-d H:i:s",time()+(15*60)); // Session expire dans 15 minutes
  
    $sid = md5(rand(0,32000) . $_SERVER['REMOTE_ADDR'] . rand(0,32000));

    $req = new insert($this->dbrw, "site_sessions",
270
271
272
273
274
275
                      array("id_session"      => $sid,
                            "id_utilisateur"  => $this->user->id,
                            "date_debut_sess" => date("Y-m-d H:i:s"),
                            "derniere_visite" => date("Y-m-d H:i:s"),
                            "expire_sess"     => $expire
                           ));
Ayolo's avatar
Ayolo committed
276
277
278
279

    return $sid;
  }

Feu's avatar
Feu committed
280
281
282
283
284
285
286
287
288
289
  /**
   * Demarre la page à rendre en spécifiant quelques informations clefs.
   * Aucune donnée ne sera envoyé au client avant l'appel de end_page.
   * Gènère la liste des boites en fonction de la section.
   * @param $section Nom de la section
   * @param $title Titre de la page
   * @param $compact Cache le logo et la boite informations (utile pour augmenter la taille de contenu visisble sans scroll)
   */
  function start_page ( $section, $title,$compact=false )
  {
Feu's avatar
Feu committed
290
    global $topdir,$timing;
Feu's avatar
Feu committed
291
292
293
294
    
    if ( isset($_REQUEST["fetch"]) )
      return;
      
Feu's avatar
Feu committed
295
    $timing["site::start_page"] -= microtime(true);
Feu's avatar
Feu committed
296
297
    parent::start_page($section,$title,$compact);
    
Feu's avatar
Feu committed
298
299
300
    $this->add_box("calendrier",new calendar($this->db));
    $this->add_box("connexion", $this->get_connection_contents());
    
Feu's avatar
Feu committed
301
302
    if ( $section == "accueil" )
    {
Feu's avatar
Feu committed
303
304
305
      //Nb: alerts est *trés* long à calculer, il ne sera donc que dans accueil
      $this->add_box("alerts",$this->get_alerts());
      
Feu's avatar
Feu committed
306
307
308
      $this->add_box("photo",$this->get_weekly_photo_contents());
      $this->add_box("anniv", $this->get_anniv_contents());
      $this->add_box("planning", $this->get_planning_contents());
309
      $this->add_box("services", $this->get_services_contents());
310
      $this->add_box("planning_permanences", $this->get_planning_permanences_contents());
Feu's avatar
Feu committed
311
      
Feu's avatar
Feu committed
312
      if ( $GLOBALS["taiste"] )
Feu's avatar
Feu committed
313
314
315
316
317
        $this->add_box("stream",$this->get_stream_box());
      
      if ($this->user->is_valid())
      {
        $this->add_box("forum",$this->get_forum_box());
Feu's avatar
Feu committed
318
        
Feu's avatar
Feu committed
319
        $this->add_box("comptoirs",$this->get_comptoirs_box());        
Sarah's avatar
Sarah committed
320
321
        if($site->user->sexe == '2')
        {
Ayolo's avatar
indent  
Ayolo committed
322
          $this->add_box("sondage",$this->get_sondage());
Sarah's avatar
Sarah committed
323
        }
Feu's avatar
Feu committed
324
        $this->set_side_boxes("right",
325
          array("planning","photo","anniv","stream", "services",
326
                "sondage","comptoirs","forum", "planning_permanences"),"accueil_c_right");
Feu's avatar
Feu committed
327
328
329
      } 
      else
        $this->set_side_boxes("right",
330
          array("planning","photo","anniv","services", "stream", "planning_permanences"),"accueil_nc_right");
Feu's avatar
Feu committed
331
332
333
334
      
    }
    elseif ( $section == "pg" )
    {
335
      $this->set_side_boxes("left",array("connexion"),"pg_left");
Feu's avatar
Feu committed
336
337
338
339
340
341
342
343
344
345
346
347
348
    }
    elseif ( $section == "matmatronch" )
    {
      require_once($topdir . "include/cts/newsflow.inc.php");
      
      $this->set_side_boxes("left",array("lastnews","connexion"),"mmt_left");
      $this->add_box("lastnews",new newslist ( "Denières nouvelles", $this->db ) );
    }
    elseif ( $section == "forum" )
    {
      $this->set_side_boxes("left",array());
      $this->set_side_boxes("right",array());
    }
Feu's avatar
Feu committed
349
350
    $timing["site::start_page"] += microtime(true);
    
Feu's avatar
Feu committed
351
352
353
354
355
356
  }

  /**
   * Gènère la boite "Attention".
   * @param renvoie un stdcontents, ou null (si vide)
   */
Ayolo's avatar
Ayolo committed
357
358
359
360
  function get_alerts()
  {
    global $topdir;

361
    if ( !$this->user->is_valid() ) return null;
Feu's avatar
Feu committed
362
    if ( $this->user->type=="srv" ) return null;
Ayolo's avatar
Ayolo committed
363
364
    $elements = array();

Ayolo's avatar
Ayolo committed
365
    if(date("m-d",$this->user->date_naissance) == date("m-d"))
Ayolo's avatar
Ayolo committed
366
      $elements[] = "<b>Joyeux anniversaire de la part de toute l'ae :)</b><br><small>Si ce n'est pas ton anniversaire nous t'invitons à mettre ton profil à jour : <a href='".$topdir."user.php?page=edit'><b>ici</b></a></small>";
Ayolo's avatar
Ayolo committed
367

Ayolo's avatar
Ayolo committed
368
369
370
    $carte = new carteae($this->db);
    $carte->load_by_utilisateur($this->user->id);

Feu's avatar
Feu committed
371
372
    $today = date("Y-m-d");

Ayolo's avatar
Ayolo committed
373
    $cpg = new campagne($this->db,$this->dbrw);
Feu's avatar
Feu committed
374
    $req = new requete($this->db, "SELECT `id_campagne` FROM `cpg_campagne` WHERE `date_fin_campagne`>='$today' ORDER BY date_debut_campagne DESC");
Ayolo's avatar
blop  
Ayolo committed
375
    while(list($id)=$req->get_row())
Ayolo's avatar
Ayolo committed
376
377
      if($cpg->load_by_id($id) && $this->user->is_in_group_id($cpg->group) && !$cpg->a_repondu($this->user->id))
        $elements[] = "<a href=\"".$topdir."campagne.php?id_campagne=".$cpg->id."\"><b>Campagne en cours : ".$cpg->nom."</b>.</a>";
Ayolo's avatar
Ayolo committed
378
379
380
381
382
383

    if ( $carte->is_valid() )
    {
      if ( $carte->etat_vie_carte == CETAT_ATTENTE &&
        !file_exists("/var/www/ae/www/ae2/var/img/matmatronch/" . $this->user->id .".identity.jpg") )
      {
BenC's avatar
BenC committed
384
        $elements[] = "<a href=\"".$topdir."user.php?page=edit&open=photo#setphotos\"><b>Vous devez ajouter une photo</b> pour que votre carte AE soit imprimée.</a>";
Ayolo's avatar
Ayolo committed
385
386
387
388
389
      }
      elseif ($carte->etat_vie_carte < CETAT_CIRCULATION )
      {
        $lieu = "Belfort";
        $this->user->load_all_extra();
Feu's avatar
fixes  
Feu committed
390
        if ( $this->user->departement == "tc" || 
Feu's avatar
Feu committed
391
          $this->user->departement == "mc" || 
Feu's avatar
fixes  
Feu committed
392
          $this->user->departement == "edim" )
Ayolo's avatar
Ayolo committed
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
          $lieu = "Sévenans";

        if ( $carte->etat_vie_carte == CETAT_AU_BUREAU_AE )
          $elements[] = "<b>Votre carte AE est prête</b>. Elle vous attends au bureau de l'AE de $lieu.";
        else
          $elements[] = "Votre carte AE est en cours de préparation, elle sera prochainement disponible au bureau de l'AE de $lieu.";
      }
    }

    if( $this->user->is_in_group("moderateur_site") )
    {
      $req = new requete($this->db,"SELECT COUNT(*) FROM `nvl_nouvelles`  WHERE `modere_nvl`='0' ");
      list($nbnews) = $req->get_row();

      $req = new requete($this->db,"SELECT COUNT(*) FROM `d_file`  WHERE `modere_file`='0' ");
      list($nbfichiers) = $req->get_row();
      $req = new requete($this->db,"SELECT COUNT(*) FROM `d_folder`  WHERE `modere_folder`='0' ");
      list($nbdossiers) = $req->get_row();
      $nbfichiers+=$nbdossiers;

413
414
415
416
417
418
      $req = new requete($this->db,"SELECT COUNT(*) FROM `planet_flux`  WHERE `modere`='0' ");
      list($nbflux) = $req->get_row();
      $req = new requete($this->db,"SELECT COUNT(*) FROM `planet_tags`  WHERE `modere`='0' ");
      list($nbtags) = $req->get_row();
      $nbflux+=$nbtags;

Ayolo's avatar
Ayolo committed
419
420
421
422
423
      if ( $nbnews > 0 )
        $elements[] = "<a href=\"".$topdir."ae/moderenews.php\"><b>$nbnews nouvelle(s)</b> à modérer</b></a>";

      if ( $nbfichiers > 0 )
        $elements[] = "<a href=\"".$topdir."ae/moderedrive.php\"><b>$nbfichiers fichier(s) et dossier(s)</b> à modérer</a>";
424
425
426

      if ( $nbflux > 0 )
        $elements[] = "<a href=\"".$topdir."planet/index.php?view=modere\"><b>$nbflux flux</b> à modérer</b></a>";
Ayolo's avatar
Ayolo committed
427
428
429
430
431
432
433
434
435
    }
    
    if ( $this->user->is_in_group("gestion_salles") )
    {
      $req = new requete($this->db,"SELECT COUNT(*) ".
        "FROM sl_reservation " .
        "INNER JOIN sl_salle ON sl_salle.id_salle=sl_reservation.id_salle " .
        "WHERE ((sl_reservation.date_accord_res IS NULL) OR " .
        "(sl_salle.convention_salle=1 AND sl_reservation.convention_salres=0)) " .
Feu's avatar
Feu committed
436
        "AND sl_reservation.date_debut_salres >= '$today'");
Ayolo's avatar
Ayolo committed
437
438
439
440
441
      list($count) = $req->get_row();

      if ( $count > 0 )
      $elements[] = "<a href=\"".$topdir."ae/modereres.php\"><b>$count reservation(s) de salles</b> à modérer</a>";
    }
442
    else if( $this->user->is_in_group("bdf-bureau") )
Sarah's avatar
Sarah committed
443
    {
Ayolo's avatar
Ayolo committed
444
      $req = new requete($this->db,"SELECT COUNT(*) ".
Sarah's avatar
Sarah committed
445
446
447
448
        "FROM sl_reservation " .
        "INNER JOIN sl_salle ON sl_salle.id_salle=sl_reservation.id_salle " .
        "WHERE ((sl_reservation.date_accord_res IS NULL) OR " .
        "(sl_salle.convention_salle=1 AND sl_reservation.convention_salres=0)) " .
Feu's avatar
Feu committed
449
        "AND sl_reservation.date_debut_salres >= '$today' " .
BenC's avatar
BenC committed
450
        "AND (sl_salle.id_salle='5' OR sl_salle.id_salle='28')");
Sarah's avatar
Sarah committed
451
452
453
      list($count) = $req->get_row();

      if ( $count > 0 )
BenC's avatar
BenC committed
454
      $elements[] = "<a href=\"".$topdir."ae/modereres.php\"><b>$count reservation(s) du foyer et de la Kfet</b></a>";
Sarah's avatar
Sarah committed
455
    }
Ayolo's avatar
Ayolo committed
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
    
    if ( $this->user->is_in_group("gestion_emprunts") )
    {
      $req = new requete($this->db,"SELECT COUNT(*) " .
        "FROM inv_emprunt WHERE etat_emprunt=0 ");
      list($count) = $req->get_row();

      if ( $count > 0 )
      $elements[] = "<a href=\"".$topdir."ae/modereemp.php\"><b>$count emprunts(s) de matériel</b> à modérer</a>";
    }

    $req = new requete($this->db, "SELECT COUNT(*) " .
      "FROM `cpt_vendu` " .
      "INNER JOIN `cpt_debitfacture` ON `cpt_debitfacture`.`id_facture` =`cpt_vendu`.`id_facture` " .
      "WHERE `id_utilisateur_client`='".$this->user->id."' AND a_retirer_vente='1'");

    list($nb) = $req->get_row();

    if ( $nb > 0 )
      $elements[] = "<a href=\"".$topdir."comptoir/encours.php\">Vous avez des commandes à venir retirer</a>";
      
    $sql = new requete($this->db,"SELECT `vt_election`.id_election, `vt_election`.nom_elec " .
        "FROM `vt_election` " .
        "LEFT JOIN vt_a_vote ON (`vt_a_vote`.`id_election`=`vt_election`.`id_election` AND vt_a_vote.id_utilisateur='".$this->user->id."')  " .
        "WHERE `date_debut`<= NOW() " .
        "AND `date_fin` >= NOW() " .
        "AND `id_groupe` IN (".$this->user->get_groups_csv().") " .
        "AND vt_a_vote.id_utilisateur IS NULL");

    if ( $sql->lines != 0 )
    {
      while ( list($id,$nom) = $sql->get_row() )
      {
        $elements[] = "<a href=\"".$topdir."elections.php?id_election=$id\"><b>Votez pour les élections : $nom</b></a>";
      }
    }

    if (  is_null($this->user->date_maj) )
Feu's avatar
test  
Feu committed
494
        $elements[] = "<b>Vous n'avez pas r&eacute;cemment mis &agrave; jour votre fiche Matmatronch</b> : <a href=\"".$topdir."majprofil.php\">La mettre &agrave; jour</a>";
Ayolo's avatar
Ayolo committed
495
    elseif ( (time() - $this->user->date_maj) > (6*30*24*60*60) )
Feu's avatar
test  
Feu committed
496
        $elements[] = "<b>Vous n'avez pas mis &agrave; jour votre fiche Matmatronch depuis ".round((time() - $this->user->date_maj)/(24*60*60))." jours !</b> : <a href=\"".$topdir."majprofil.php\">La mettre &agrave; jour</a>";
Ayolo's avatar
Ayolo committed
497

498
    if( $this->user->is_in_group("sas_admin") && (!$this->get_param("closed.sas",false) && is_dir("/var/www/ae/accounts/sas")) )
Ayolo's avatar
Ayolo committed
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
    {
      $req = new requete($this->db, "SELECT COUNT(*) FROM `sas_cat_photos` WHERE `modere_catph`='0' ");
      list($ncat) = $req->get_row();
      $req = new requete($this->db, "SELECT COUNT(*) FROM `sas_photos` WHERE `modere_ph`='0'");
      list($nphoto) = $req->get_row();
      if ( $ncat > 0 || $nphoto > 0 )
      {
        $msg = "";
        if ( $ncat > 0 )
          $msg .= $ncat." catégorie(s)";  
        if ( $ncat > 0 && $nphoto > 0 )
          $msg .= " et ";
        if ($nphoto > 0 )
          $msg .= $nphoto." photo(s)";
        $elements[] = "<a href=\"".$topdir."sas2/modere.php\">$msg &agrave; moderer dans le SAS</a>";
      }
    }
BenC's avatar
BenC committed
516

517
    if( !$this->get_param("closed.sas",false) && is_dir("/var/www/ae/accounts/sas"))
BenC's avatar
BenC committed
518
519
520
521
522
523
    {
      $req = new requete($this->db, "SELECT COUNT(*) FROM `sas_personnes_photos` WHERE `id_utilisateur`='".$this->user->id."' AND `vu_phutl`='0'");
      list($nphoto) = $req->get_row();
      if ( $nphoto > 0 )
        $elements[] = "<a href=\"".$topdir."user/photos.php?see=new\"><b>".$nphoto." nouvelle(s) photo(s)</b> dans le SAS</a>";
    }
BenC's avatar
wip  
BenC committed
524
    
Ayolo's avatar
Ayolo committed
525
526
527
528
529
530
531
532
    $cotiz = new cotisation($this->db);
    $cotiz->load_lastest_by_user ( $this->user->id );

    if ( ($cotiz->is_valid()) && ($cotiz->date_fin_cotis < time()) && (time()-$cotiz->date_fin_cotis < (30*24*60*60)) )
    {
      $elements[] = "<a href=\"".$topdir."e-boutic/?cat=23\"><b>Votre cotisation &agrave; l'AE est expir&eacute;e !</b> Renouvelez l&agrave; en ligne avec E-boutic.</a>";
    }

533
    if ( !$this->user->droit_image && !$this->get_param("closed.sas",false) && is_dir("/var/www/ae/accounts/sas") )
534
535
536
537
538
539
540
541
542
543
544
    {
      $sql = new requete($this->db,
        "SELECT COUNT(*) " .
        "FROM sas_personnes_photos " .
        "INNER JOIN sas_photos ON (sas_photos.id_photo=sas_personnes_photos.id_photo) " .
        "WHERE sas_personnes_photos.id_utilisateur=".$this->user->id." " .
        "AND sas_personnes_photos.accord_phutl='0' " .
        "AND (droits_acces_ph & 0x100)");
      list($count) = $sql->get_row();

      if ( $count > 0 )
545
        $elements[] ="<a href=\"".$topdir."sas2/droitimage.php?page=process\"><b>$count photo(s)</b> nécessitent votre accord</a>";
546
547
548
      
    }

pedrov's avatar
pedrov committed
549
550
551
552
    /* alertes covoiturage */
    $nbsteps = $this->user->covoiturage_steps_moderation(); 
    
    if ($nbsteps == 1)
Ayolo's avatar
fix  
Ayolo committed
553
554
555
    {
      $elements[] = "<a href=\"".$topdir."covoiturage/\">$nbsteps étape de covoiturage à modérer<b></a>";
    }
pedrov's avatar
pedrov committed
556
557
558
    else if ($nbsteps > 1)
      $elements[] = "<a href=\"".$topdir."covoiturage/\">$nbsteps étapes de covoiturage à modérer<b></a>";

559
    $assoces = $this->user->get_assos(ROLEASSO_PRESIDENT);
560
561
    
    if (count($assoces) > 0)
Ayolo's avatar
fix  
Ayolo committed
562
563
564
    {
      require_once($topdir. "include/entities/asso.inc.php");
       
Ayolo's avatar
Ayolo committed
565
566
567
568
569
570
571
572
573
574
575
576
577
578
      foreach ($assoces as $key => $assoce)
      {
        $asso = new asso($this->db);
        $asso->load_by_id($key);
        $pm = $asso->get_pending_unmod_mail();
        if ($pm == 1)
        {
          $elements[] = "<a href=\"http://ml.aeinfo.net/cgi-bin/mailman/admindb/".$asso->nom_unix.".membres\"><b>$pm e-mail en attente de modération sur la liste de diffusion de ". $asso->nom_unix . "</b></a>";
        }
        else if ($pm > 1)
        {
          $elements[] = "<a href=\"http://ml.aeinfo.net/cgi-bin/mailman/admindb/".$asso->nom_unix.".membres\"><b>$pm e-mails en attente de modération sur la liste de diffusion de ". $asso->nom_unix . "</b></a>";
        }
      }
Ayolo's avatar
fix  
Ayolo committed
579
    }
pedrov's avatar
pedrov committed
580

Ayolo's avatar
Ayolo committed
581
    if ( count($elements) == 0 ) return null;
Feu's avatar
Feu committed
582
583
    
    $cts = new contents("Attention");
Ayolo's avatar
Ayolo committed
584
585
586
587
588
589
590
591
592
593

    if ( count($elements) == 1 )
      $cts->add_paragraph("Nous attirons votre attention sur l'&eacute;l&eacute;ment suivant:");
    else
      $cts->add_paragraph("Nous attirons votre attention sur les &eacute;l&eacute;ments suivants:");

    $cts->add(new itemlist(false,false,$elements));
    return $cts;
  }

Feu's avatar
Feu committed
594
595
596
597
  /**
   * Gènère la boite sondage.
   * @param renvoie un stdcontents, ou null (si vide)
   */
Ayolo's avatar
Ayolo committed
598
599
600
601
602
603
604
  function get_sondage()
  {
    $sdn = new sondage($this->db,$this->dbrw);

    $sdn->load_lastest();
    if ( !$sdn->is_valid() )
      return NULL;
Feu's avatar
Feu committed
605
606
607
      
    if ( $this->user->type=="srv" ) return null;
    
Ayolo's avatar
Ayolo committed
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
    require_once($topdir."include/cts/react.inc.php");

    $react = new reactonforum ( $this->db, $this->user, $sdn->question, array("id_sondage"=>$sdn->id), null, false );

    if ( $sdn->a_repondu($this->user->id) )
    {
      $cts = new contents("Sondage");

      $cts->add_paragraph("<b>".$sdn->question."</b>");

      $cts->puts("<p>");

      $res = $sdn->get_results();

      foreach ( $res as $re )
      {
        $cumul+=$re[1];
        $pc = $re[1]*100/$sdn->total;

        $cts->puts($re[0]."<br/>");

        $wpx = floor($pc);
        if ( $wpx != 0 )
          $cts->puts("<div class=\"activebar\" style=\"width: ".$wpx."px\"></div>");
        if ( $wpx != 100 )
          $cts->puts("<div class=\"inactivebar\" style=\"width: ".(100-$wpx)."px\"></div>");

        $cts->puts("<div class=\"percentbar\">".round($pc,1)."%</div>");
        $cts->puts("<div class=\"clearboth\"></div>\n");

      }

      if ( $cumul < $sdn->total )
      {
        $pc = ( $sdn->total-$cumul)*100/$sdn->total;
        $cts->puts("<br/>Blanc ou nul : ".round($pc,1)."%");
      }

      $cts->puts("</p>");

      $cts->add_paragraph("(".$sdn->total." réponses)","nbvotes");
      
      $cts->add($react);
      
      $cts->add_paragraph("<a href=\"sondage.php\">Archives</a>","nbvotes");
      
      return $cts;
    }

    $cts = new contents("Sondage");
    $cts->add_paragraph("<b>".$sdn->question."</b>");

    
    $frm = new form("sondage","sondage.php");
    $frm->add_hidden("id_sondage",$sdn->id);

664
665
    $reps = $sdn->get_reponses();
    foreach( $reps as $num => $rep )
Ayolo's avatar
Ayolo committed
666
667
668
669
670
671
672
673
674
675
676
677
678
679
      $resp_[$num] = "$rep<br/>";

    $frm->add_radiobox_field ( "numrep", "", $resp_ );

    $frm->add_submit("answord","Repondre");
    $cts->add($frm);
    
    $cts->add($react);

    $cts->add_paragraph("<a href=\"sondage.php\">Archives</a>","nbvotes");
    
    return $cts;
  }

Feu's avatar
Feu committed
680
681
682
683
  /**
   * Gènère la boite de "Connexion" / "L'AE et Moi".
   * @param renvoie un stdcontents, ou null (si vide)
   */
Ayolo's avatar
Ayolo committed
684
685
686
  function get_connection_contents ()
  {
    global $topdir;
www-data's avatar
global  
www-data committed
687
    global $wwwtopdir;
Ayolo's avatar
Ayolo committed
688
689
690

    if ( !$this->user->is_valid() )
    {
Feu's avatar
Feu committed
691
      $cts = new contents("Connexion");
Ayolo's avatar
Ayolo committed
692
      $frm = new form("connect",$topdir."connect.php",true,"POST","Connexion");
pedrov's avatar
pedrov committed
693
694
      $jsoch = "javascript:switchSelConnection(this);";
      $frm->add_select_field("domain",
Ayolo's avatar
Ayolo committed
695
696
697
698
699
700
701
702
703
704
           "Connexion",
           array("utbm"=>"UTBM / Assidu", 
           "id"=>"ID", 
           "autre"=>"E-mail", 
           "alias"=>"Alias"),
           false, 
           "", 
           false,
           true,
           $jsoch);
Ayolo's avatar
Ayolo committed
705
706
707
      $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 );
Feu's avatar
Feu committed
708
709
710
      $frm->add_submit("connectbtn","Se connecter");
      $cts->add($frm);
      
711
      $cts->add_paragraph("<a href=\"".$wwwtopdir."article.php?name=docs:connexion\">Aide</a> - <a href=\"".$wwwtopdir."password.php\">Mot de passe perdu</a>");
Feu's avatar
Feu committed
712
      
Feu's avatar
Feu committed
713
      return $cts;
Ayolo's avatar
Ayolo committed
714
715
    }

Feu's avatar
Feu committed
716
717
    $today=date("Y-m-d");

Ayolo's avatar
Ayolo committed
718
    $cts = new contents("L'AE et Moi");
719
    $cts->add_paragraph($this->get_param('box.Welcome')." <b>".$this->user->prenom." ".$this->user->nom."</b>");
Ayolo's avatar
Ayolo committed
720

Feu's avatar
Feu committed
721
722
723
724
725
726
727
    if ( $this->user->type=="srv" )
    {
      if ( $this->user->montant_compte < 0 )
        $cts->add_paragraph("<br><a href=\"".$topdir."user/compteae.php\">Factures en attente de paiement : ".(sprintf("%.2f", $this->user->montant_compte/-100))." Euros</a>");      
    }
    else
      $cts->add_paragraph("<br><a href=\"".$topdir."user/compteae.php\">Compte AE : ".(sprintf("%.2f", $this->user->montant_compte/100))." Euros</a>");
Ayolo's avatar
Ayolo committed
728
729

    $sublist = new itemlist("Mon Compte","boxlist");
730
    $sublist->add("<a href=\"".$topdir."user.php?id_utilisateur=".$this->user->id."\">Informations personnelles</a>");
Feu's avatar
Feu committed
731
732
733
734
    
    if ( $this->user->type=="srv" ) 
      $sublist->add("<a href=\"".$topdir."user/compteae.php\">Factures</a>");
    else
gliss's avatar
gliss committed
735
    {
Feu's avatar
Feu committed
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
      $sublist->add("<a href=\"".$topdir."uvs/edt.php\">Mes emplois du temps</a>");
      if($this->user->utbm)
        $sublist->add("<a href=\"".$topdir."trombi/index.php\">Trombinoscope</a>");
      $sublist->add("<a href=\"".$topdir."user.php?view=assos\">Associations et clubs</a>");
      if( $this->user->is_in_group("jobetu_etu") )
      {
        $jobuser = new jobuser_etu($this->db);
        $jobuser->load_by_id($this->user->id);
        $jobuser->load_annonces();
        $sublist->add("<a href=\"".$topdir."jobetu/board_etu.php\">Mon compte JobEtu (".count($jobuser->annonces).")</a>");
      }
      else if( $this->user->is_in_group("jobetu_client") )
        $sublist->add("<a href=\"".$topdir."jobetu/board_client.php\">AE JobEtu</a>");
      else
        $sublist->add("<a href=\"".$topdir."jobetu/index.php\">AE JobEtu</a>");
      $sublist->add("<a href=\"".$topdir."user.php?view=parrain\">Parrains et fillots</a>");
      $sublist->add("<a href=\"".$topdir."user/compteae.php\">Compte AE</a>");
gliss's avatar
gliss committed
753
    }
Ayolo's avatar
reorga  
Ayolo committed
754
755
756
757
    $cts->add($sublist,true, true, "accountbox", "boxlist", true, true);

    $sublist = new itemlist("Infos et r&eacute;servations","boxlist");
    
Ayolo's avatar
Ayolo committed
758
759
760
761
762
    $req = new requete($this->db,"SELECT  " .
      "COUNT(*) " .
      "FROM sl_reservation " .
      "INNER JOIN sl_salle ON sl_salle.id_salle=sl_reservation.id_salle " .
      "WHERE sl_reservation.id_utilisateur='".$this->user->id."' AND " .
Feu's avatar
Feu committed
763
      "sl_reservation.date_debut_salres >= '$today' AND " .
Ayolo's avatar
Ayolo committed
764
765
766
767
768
769
770
771
      "((sl_reservation.date_accord_res IS NULL) OR " .
      "(sl_salle.convention_salle=1 AND sl_reservation.convention_salres=0)) " );
    list($nb) = $req->get_row();

    if ( $nb )
      $sublist->add("<a href=\"".$topdir."user/reservations.php\"><b>Mes reservations de salles : $nb en attente</b></a>");
    else
      $sublist->add("<a href=\"".$topdir."user/reservations.php\">Mes reservations de salles</a>");
Ayolo's avatar
reorga  
Ayolo committed
772

Ayolo's avatar
Ayolo committed
773
    $req = new requete($this->db,"SELECT COUNT(*) " .
Ayolo's avatar
reorga  
Ayolo committed
774
775
      "FROM inv_emprunt " .
      "WHERE id_utilisateur='".$this->user->id."' AND etat_emprunt<=1");
Ayolo's avatar
Ayolo committed
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
    list($nb) = $req->get_row();

    if ( $nb )
      $sublist->add("<a href=\"".$topdir."user/emprunts.php\"><b>Mes emprunts de matériel : $nb en attente</b></a>");
    else
      $sublist->add("<a href=\"".$topdir."user/emprunts.php\">Mes emprunts de matériel</a>");

    $sublist->add("<a href=\"".$topdir."news.php\">Proposer une nouvelle</a>");
    $sublist->add("<a href=\"".$topdir."salle.php?page=reservation\">Reserver une salle</a>");
    $sublist->add("<a href=\"".$topdir."emprunt.php\">Reserver du matériel</a>");

    $cts->add($sublist,true, true, "infobox", "boxlist", true, true);

    if( $this->user->is_in_group("moderateur_site") )
    {
      $sublist = new itemlist("Equipe com'","boxlist");
792
      $sublist->add("<a href=\"".$topdir."ae/com.php\">Tâches usuelles</a>");
Ayolo's avatar
Ayolo committed
793
794
795
      $cts->add($sublist,true, true, "siteadminbox", "boxlist", true, false);
    }

Feu's avatar
Feu committed
796
797
798
799
800
801
802
803
    if( $this->user->is_in_group("compta_admin") )
    {
      $sublist = new itemlist("Comptabilité de l'AE","boxlist");
      $sublist->add("<a href=\"".$topdir."entreprise.php\">Carnet d'adresses</a>");
      $sublist->add("<a href=\"".$topdir."compta/\">Comptabilitée</a>");
      $sublist->add("<a href=\"".$topdir."comptoir/admin.php\">Comptoirs AE</a>");   
      $cts->add($sublist,true, true, "comptaadminbox", "boxlist", true, false);
    }
Ayolo's avatar
Ayolo committed
804
805
806

    if( $this->user->is_in_group("gestion_ae") )
    {
807
808
      $sublist = new itemlist("AE : Administration","boxlist");
      $sublist->add("<a href=\"".$topdir."ae/\">Tâches usuelles</a>");
Ayolo's avatar
Ayolo committed
809
      $sublist->add("<a href=\"".$topdir."ae/cartesae.php\">Cartes AE</a>");
Ayolo's avatar
Ayolo committed
810
811
      $sublist->add("<a href=\"".$topdir."asso.php\">Associations et clubs</a>");
      $cts->add($sublist,true, true, "aeadminbox", "boxlist", true, false);
Feu's avatar
Feu committed
812
          
Ayolo's avatar
Ayolo committed
813
814
815
      $sublist = new itemlist("Salles, inventaire","boxlist");
      $sublist->add("<a href=\"".$topdir."sitebat.php\">Batiments, salles</a>");
      $sublist->add("<a href=\"".$topdir."objtype.php\">Type d'objets (inventaire)</a>");
Feu's avatar
Feu committed
816
817
      $sublist->add("<a href=\"".$topdir."ae/modereres.php\">Reservation salles</a>");
      $sublist->add("<a href=\"".$topdir."ae/modereemp.php\">Emprunts de matériel</a>");
Ayolo's avatar
Ayolo committed
818
819
      $cts->add($sublist,true, true, "sainvadminbox", "boxlist", true, false);
    }
Feu's avatar
Feu committed
820
821
822
823
    
    if( $this->user->is_in_group("gestion_syscarteae") )
    {
      $sublist = new itemlist("Système Carte AE","boxlist");
Feu's avatar
fix  
Feu committed
824
825
826
      $sublist->add("<a href=\"".$topdir."ae/syscarteae.php?view=factures\">Appels à facture</a>");
      $sublist->add("<a href=\"".$topdir."ae/syscarteae.php?view=comptes\">Comptes</a>");
      $sublist->add("<a href=\"".$topdir."ae/syscarteae.php?view=retrait\">Produits non retirés</a>");
Feu's avatar
Feu committed
827
      $sublist->add("<a href=\"".$topdir."ae/syscarteae.php?view=remb\">Rembourser</a>");
Feu's avatar
Feu committed
828
829
830
      $cts->add($sublist,true, true, "syscarteaebox", "boxlist", true, false);
    }
    
Ayolo's avatar
Ayolo committed
831
832
    if( $this->user->is_in_group("root") )
    {
Feu's avatar
Feu committed
833
      $sublist = new itemlist("Equipe info","boxlist");
Ayolo's avatar
Ayolo committed
834
      $sublist->add("<a href=\"".$topdir."rootplace/index.php\">Rootplace</a>");
Feu's avatar
Feu committed
835
      $cts->add($sublist,true, true, "rootadminbox", "boxlist", true, false);
Ayolo's avatar
Ayolo committed
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
    }


    $req = new requete($this->db,
        "SELECT `asso`.`id_asso`, " .
        "`asso`.`nom_asso`, ".
        "`asso_membre`.`role` " .
        "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`");

    if ( $req->lines > 0 )
    {
      while ( list($id,$nom,$role) = $req->get_row() )
      {
        $sublist = new itemlist("$nom","boxlist");
        $sublist->add("<a href=\"".$topdir."asso/index.php?id_asso=$id\">Outils</a>");
        $sublist->add("<a href=\"".$topdir."asso/inventaire.php?id_asso=$id\">Inventaire</a>");
        $sublist->add("<a href=\"".$topdir."asso/reservations.php?id_asso=$id\">Reservations</a>");
        $sublist->add("<a href=\"".$topdir."asso/membres.php?id_asso=$id\">Membres</a>");
        $sublist->add("<a href=\"".$topdir."asso/mailing.php?id_asso=$id\">Mailing</a>");
        $sublist->add("<a href=\"".$topdir."asso/ventes.php?id_asso=$id\">Ventes</a>");
        $sublist->add("<a href=\"".$topdir."d.php?id_asso=$id\">Fichiers</a>");
pedrov's avatar
FAX \!  
pedrov committed
862

Ayolo's avatar
Ayolo committed
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
        if ( $role >= ROLEASSO_TRESORIER )
        {
          $reqa = new requete ($this->db,
            "SELECT id_classeur,nom_classeur " .
            "FROM `cpta_classeur` " .
            "INNER JOIN `cpta_cpasso` ON `cpta_cpasso`.`id_cptasso`=`cpta_classeur`.`id_cptasso` " .
            "INNER JOIN cpta_cpbancaire ON cpta_cpbancaire.id_cptbc=cpta_cpasso.id_cptbc " .
            "WHERE cpta_cpasso.id_asso='".$id."' AND `cpta_classeur`.`ferme`='0'" .
            "ORDER BY `cpta_classeur`.`date_debut_classeur` DESC");    
            
          if ( $reqa->lines == 1 )
          {
            list($id,$nom) = $reqa->get_row();
            $sublist->add("<a href=\"".$topdir."compta/classeur.php?id_classeur=$id\">Compta $nom</a>");
          }
        }
pedrov's avatar
FAX \!  
pedrov committed
879
880
881



Ayolo's avatar
Ayolo committed
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
        $cts->add($sublist,true, true, "asso".$id."box", "boxlist", true, true);
      }
    }

    $req = new requete($this->db,"SELECT id_comptoir,nom_cpt " .
        "FROM cpt_comptoir " .
        "WHERE `type_cpt`='2' " .
        "AND id_groupe_vendeur IN (".$this->user->get_groups_csv().") " .
        "ORDER BY nom_cpt");

    if ( $req->lines > 0 )
    {

      $sublist = new itemlist("Actions bureaux AE","boxlist");

       while ( list($id,$nom) = $req->get_row() )
        $sublist->add("<a href=\"".$topdir."comptoir/bureau.php?id_comptoir=$id\">$nom</a>");

      $cts->add($sublist,true, true, "cptbureau", "boxlist", true, true);

    }


Feu's avatar
Feu committed
905
    if ( $this->user->is_in_group("root") && $this->user->is_in_group("gestion_syscarteae") )
Ayolo's avatar
Ayolo committed
906
907
908
      $req = new requete($this->db,"SELECT cpt_comptoir.id_comptoir,cpt_comptoir.nom_cpt " .
        "FROM cpt_comptoir " .
        "ORDER BY cpt_comptoir.nom_cpt");
Feu's avatar
Feu committed
909
    elseif ( $this->user->is_in_group("gestion_syscarteae") )
Ayolo's avatar
Ayolo committed
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
      $req = new requete($this->db,"SELECT cpt_comptoir.id_comptoir,cpt_comptoir.nom_cpt " .
        "FROM cpt_comptoir WHERE cpt_comptoir.nom_cpt != 'test' " .
        "ORDER BY cpt_comptoir.nom_cpt");
    else
      $req = 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 )
    {
      $sublist = new itemlist("Admin comptoirs","boxlist");

       while ( list($id,$nom) = $req->get_row() )
        $sublist->add("<a href=\"".$topdir."comptoir/admin.php?id_comptoir=$id\">$nom</a>");

      $cts->add($sublist,true, true, "cptadmin", "boxlist", true, false);
    }

    if ( $this->user->is_asso_role ( 27, 1 ) )
    {
      $sublist = new itemlist("Staff Mat'Matronch","boxlist");
       $sublist->add("<a href=\"".$topdir."mmt/wiki/\">Wiki Mat'Matronch</a>");
      $sublist->add("<a href=\"".$topdir."matmatronch/upload_photo_user.php\">Upload des Photos</a>");
      $sublist->add("<a href=\"".$topdir."matmatronch/inscriptions.php\">Ajout utilisateur</a>");
      $cts->add($sublist,true, true, "matmatronchbox", "boxlist", true, false);
    }
Feu's avatar
Feu committed
937

Ayolo's avatar
Ayolo committed
938
939
940
941
942
943
944
945
946
947
948
949
950

    /* Bouton de Deconnexion */
    $frm = new form("disconnect",$topdir."disconnect.php",false,"POST","Deconnexion");
    $frm->add_submit("disconnect","Se déconnecter");
    $cts->add($frm);

    return $cts;
  }

  /** Génre la boite qui affiche les anniversaires */
  function get_anniv_contents ()
  {
    global $topdir;
Feu's avatar
Feu committed
951
    
Feu's avatar
Feu committed
952
953
    require_once($topdir."include/cts/cached.inc.php");
    
Feu's avatar
Feu committed
954
955
956
957
958
    $cache = new cachedcontents("anniv");
    
    if ( $cache->is_cached_since(strtotime(date("Y-m-d")." 00:00:00")) )
      return $cache->get_cache();
      
Ayolo's avatar
Ayolo committed
959
960
    $cts = new contents("Anniversaire");

Feu's avatar
Feu committed
961
962
    $annee = date("Y");

Feu's avatar
Feu committed
963
964
965
966
    $req = new requete ($this->db, "SELECT `utilisateurs`.`id_utilisateur`,`utilisateurs`.`nom_utl`,".
    "`utilisateurs`.`prenom_utl`,`utl_etu_utbm`.`surnom_utbm`,`utilisateurs`.`date_naissance_utl` ".
    "FROM `utilisateurs` ".
    "INNER JOIN `utl_etu_utbm` ON `utilisateurs`.`id_utilisateur` = `utl_etu_utbm`.`id_utilisateur` ".
Feu's avatar
Feu committed
967
    "WHERE `utilisateurs`.`date_naissance_utl` LIKE '%-" . date("m-d") . "' ".
Feu's avatar
Feu committed
968
969
    "AND (`utilisateurs`.`ancien_etudiant_utl` = '0' OR `utilisateurs`.`ae_utl` = '1') ".
    "ORDER BY `utilisateurs`.`date_naissance_utl` DESC");                                
Ayolo's avatar
Ayolo committed
970
971
972

    if ($req->lines > 0)
    {
Feu's avatar
Feu committed
973
      $cts->add_paragraph($this->get_param('box.Anniversaire'));
Ayolo's avatar
Ayolo committed
974
975
976
977
978
979

      $old_age = 0;
      $count   = 0;

      while ($res = $req->get_row())
      {
Feu's avatar
Feu committed
980
981

        $age=$annee-substr($res['date_naissance_utl'],0,4);
Ayolo's avatar
Ayolo committed
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
        if (!$count || ($old_age != $age))
        {
          if ( $count )
            $cts->puts("</ul>\n");
          
          $cts->puts("<h2 class=\"epure\">" . $age . " ans</h2>\n");
          $cts->puts("<ul>\n");
          $old_age = $age;
        }

        if (empty($res['surnom_utbm']))
          $nom = $res['prenom_utl'] . " " . $res['nom_utl'];
        else
          $nom = $res['surnom_utbm'];

        $ref = "anniv". $res['id_utilisateur'];
        
        $count++;
        $cts->puts ("<li><a id=\"$ref\" onmouseover=\"show_tooltip('$ref','$topdir','utilisateur','".$res['id_utilisateur']."');\" onmouseout=\"hide_tooltip('$ref');\" href=\"". $topdir ."user.php?id_utilisateur=". $res['id_utilisateur'] .
         "\">" . $nom . "</a></li>\n");
      }
      $cts->puts("</ul>\n");
    }
    else
    {
Feu's avatar
Feu committed
1007
      $cts->add_paragraph("L'AE est triste de vous annoncer qu'il n'y a pas d'anniversaire aujourd'hui.\n");
Ayolo's avatar
Ayolo committed
1008
    }
Feu's avatar
Feu committed
1009
1010
    
    return $cache->set_contents($cts);
Ayolo's avatar
Ayolo committed
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
  }

  /** Fonction qui génére le contents du dernier planning de l'AE */
  function get_planning_contents ()
  {
    global $topdir;
    if ( !file_exists($topdir."var/img/com/planning.jpg"))
      return null;
      
    $planning_valid = filemtime($topdir."var/img/com/planning.jpg") + (7 * 24 * 60 * 60);
    if ( time() <= $planning_valid )
    {
      $cts = new contents("Planning");
      $cts->puts("<center><a href=\"".$topdir."article.php?name=planning\"><img src=\"".$topdir."var/img/com/planning-small.jpg?".$planning_valid."\" alt=\"Planning\" /></a></center>");
      return $cts;
    }
  }
Feu's avatar
Feu committed
1028
  
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
  /**
   * Renvoie un contents avec la liste des services pour accès direct
   */
  function get_services_contents()
  {
    global $topdir;
    $cts = new contents("Services");
    $lst = new itemlist(false,false, 
                        array(
                          "<a href=\"/e-boutic/\">E-Boutic</a>",
                          "<a href=\"/uvs/\">Pédagogie</a>",
                          "<a href=\"/jobetu/\">AE JobEtu</a>",
                          "<a href=\"/laverie/\">Laverie</a>",
                          "<a href=\"/emprunt.php\">Prêt de matériel</a>",
                          "<a href=\"/covoiturage/\">Covoiturage</a>"
                        ));
    $cts->add($lst);
    return $cts;
  }
  
Feu's avatar
Feu committed
1049
1050
1051
1052
  /**
   * Gènère la boite contenant la photo de la semaine.
   * @param renvoie un stdcontents
   */
Ayolo's avatar
Ayolo committed
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
  function get_weekly_photo_contents ()
  {
    global $topdir;
    if ( !file_exists($topdir."var/img/com/weekly_photo.jpg"))
      return null;
    $weekly_photo_valid = filemtime($topdir."var/img/com/weekly_photo.jpg") + (7 * 24 * 60 * 60);
    if ( time() <= $weekly_photo_valid )
    {
    $cts = new contents("Photo de la semaine");
    $cts->puts("<center><a href=\"".$topdir."article.php?name=weekly_photo\"><img src=\"".$topdir."var/img/com/weekly_photo-small.jpg?".$weekly_photo_valid."\" style=\"margin-bottom:0.5em;\" alt=\"Photo de la semaine\" /></a><br/>");
1063
    $cts->puts($this->get_param('box.Weekly_photo'));
Ayolo's avatar
Ayolo committed
1064
1065
1066
1067
1068
    $cts->puts("</center>");
    return $cts;
    }
  }

Feu's avatar
Feu committed
1069
1070
1071
  /**
   * Gènère la boite d'information sur les comptoirs.
   * @param renvoie un stdcontents
Ayolo's avatar
Ayolo committed
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
   */
  function get_comptoirs_box ()
  {
    global $topdir;
    // 1- On ferme les sessions expirés
    $req = new requete ($this->dbrw,
           "UPDATE `cpt_tracking` SET `closed_time`='".date("Y-m-d H:i:s")."'
            WHERE `activity_time` <= '".date("Y-m-d H:i:s",time()-intval(ini_get("session.gc_maxlifetime")))."'
            AND `closed_time` IS NULL");
  
    // 2- On récupère les infos sur les bars ouverts
    $req = new requete ($this->dbrw,
           "SELECT MAX(activity_time),id_comptoir
            FROM `cpt_tracking`
            WHERE `activity_time` > '".date("Y-m-d H:i:s",time()-intval(ini_get("session.gc_maxlifetime")))."'
            AND `closed_time` IS NULL
            GROUP BY id_comptoir");
            
    while ( list($act,$id) = $req->get_row() )
      $activity[$id]=strtotime($act);
  
    // 3- On récupère les infos sur tous les bars 
    $req = new requete ($this->dbrw,
           "SELECT id_comptoir, nom_cpt
            FROM cpt_comptoir 
            WHERE type_cpt='0' AND id_comptoir != '4' AND id_comptoir != '8'
            ORDER BY nom_cpt");
            
    $list = new itemlist("Comptoirs <i>(beta)</i>");


    while ( list($id,$nom) = $req->get_row() )
    {
      $led = "green";
      $descled = "ouvert";
  
      if ( !isset($activity[$id]) )
      {
        $led = "red";
        $descled = "fermé (ou pas d'activité depuis plus de ".(intval(ini_get("session.gc_maxlifetime"))/60)." minutes)";
      }
      elseif ( time()-$activity[$id] > 600 )
      {
        $led = "yellow";
        $descled = "ouvert (mais pas d'activité depuis plus de 10 minutes)";

      }
        $list->add("<a href=\"comptoir/activity.php?id_comptoir=$id\"><img src=\"".$topdir."images/leds/".$led."led.png\" class=\"icon\" alt=\"".htmlentities($descled,ENT_NOQUOTES,"UTF-8")."\" title=\"".htmlentities($descled,ENT_NOQUOTES,"UTF-8")."\" /> $nom</a>");
    
    }
  
    return $list;
  
  }
  
Feu's avatar
Feu committed
1127
1128
1129
1130
  /**
   * Gènère la boite d'information sur le forum
   * @param renvoie un stdcontents
   */
Feu's avatar
test  
Feu committed
1131
1132
  function get_forum_box ()
  {  
pedrov's avatar
bogus ?  
pedrov committed
1133
    global $wwwtopdir, $topdir;
Feu's avatar
test  
Feu committed
1134
    require_once($topdir . "include/entities/forum.inc.php");
Feu's avatar
fixes  
Feu committed
1135
    $forum = new forum($this->db);
Feu's avatar
test  
Feu committed
1136
1137
    $forum->load_by_id(1);

Feu's avatar
test  
Feu committed
1138
1139
    $cts = new contents("Forum");
  
Feu's avatar
Feu committed
1140
1141
    $query = "SELECT frm_sujet.titre_sujet, ".
        "frm_sujet.id_sujet, " .
Feu's avatar
test  
Feu committed
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
        "frm_message.date_message, " .
        "frm_message.id_message, " .
        "dernier_auteur.alias_utl AS `nom_utilisateur_dernier_auteur`, " .
        "dernier_auteur.id_utilisateur AS `id_utilisateur_dernier`, " .
        "premier_auteur.alias_utl AS `nom_utilisateur_premier_auteur`, " .
        "premier_auteur.id_utilisateur AS `id_utilisateur_premier`, " .
        "1 AS `nonlu`, " .
        "titre_forum AS `soustitre_sujet` " .
        "FROM frm_sujet " .
        "INNER JOIN frm_forum USING(id_forum) ".
        "LEFT JOIN frm_message ON ( frm_message.id_message = frm_sujet.id_message_dernier ) " .
        "LEFT JOIN utilisateurs AS `dernier_auteur` ON ( dernier_auteur.id_utilisateur=frm_message.id_utilisateur ) " .
        "LEFT JOIN utilisateurs AS `premier_auteur` ON ( premier_auteur.id_utilisateur=frm_sujet.id_utilisateur ) ".
        "LEFT JOIN frm_sujet_utilisateur ".
          "ON ( frm_sujet_utilisateur.id_sujet=frm_sujet.id_sujet ".
Feu's avatar
fixes  
Feu committed
1157
          "AND frm_sujet_utilisateur.id_utilisateur='".$this->user->id."' ) ".
Feu's avatar
test  
Feu committed
1158
1159
        "WHERE ";
              
Feu's avatar
fixes  
Feu committed
1160
    if( is_null($this->user->tout_lu_avant))
Feu's avatar
test  
Feu committed
1161
1162
1163
1164
1165
      $query .= "(frm_sujet_utilisateur.id_message_dernier_lu<frm_sujet.id_message_dernier ".
                "OR frm_sujet_utilisateur.id_message_dernier_lu IS NULL) ";    
    else
      $query .= "((frm_sujet_utilisateur.id_message_dernier_lu<frm_sujet.id_message_dernier ".
                "OR frm_sujet_utilisateur.id_message_dernier_lu IS NULL) ".
Feu's avatar
fixes  
Feu committed
1166
                "AND frm_message.date_message > '".date("Y-m-d H:i:s",$this->user->tout_lu_avant)."') ";  
Feu's avatar
test  
Feu committed
1167
  
Feu's avatar
fixes  
Feu committed
1168
    if ( !$forum->is_admin( $this->user ) )
Feu's avatar
test  
Feu committed
1169
    {
Feu's avatar
fixes  
Feu committed
1170
      $grps = $this->user->get_groups_csv();
Feu's avatar
test  
Feu committed
1171
1172
1173
      $query .= "AND ((droits_acces_forum & 0x1) OR " .
        "((droits_acces_forum & 0x10) AND id_groupe IN ($grps)) OR " .
        "(id_groupe_admin IN ($grps)) OR " .
Feu's avatar
fixes  
Feu committed
1174
        "((droits_acces_forum & 0x100) AND frm_forum.id_utilisateur='".$this->user->id."')) ";
Feu's avatar
test  
Feu committed
1175
1176
    }
  
Feu's avatar
wip  
Feu committed
1177
1178
    $query_fav = $query."AND frm_sujet_utilisateur.etoile_sujet='1' ";
    $query_fav .= "ORDER BY frm_message.date_message DESC ";
Feu's avatar
wip  
Feu committed
1179
    $query_fav .= "LIMIT 4 ";
Feu's avatar
wip  
Feu committed
1180
    
Feu's avatar
wip  
Feu committed
1181
    $query .= "AND ( frm_sujet_utilisateur.etoile_sujet IS NULL OR frm_sujet_utilisateur.etoile_sujet!='1' ) ";
Feu's avatar
test  
Feu committed
1182
    $query .= "ORDER BY frm_message.date_message DESC ";
Feu's avatar
wip  
Feu committed
1183
    $query .= "LIMIT 4 ";
Feu's avatar
test  
Feu committed
1184
  
Feu's avatar
wip  
Feu committed
1185
    $req = new requete($this->db,$query_fav);
Feu's avatar
wip  
Feu committed
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
  
    if ( $req->lines > 0 )
    {
      $cts->add_title(2,"<a href=\"".$wwwtopdir."forum2/search.php?page=unread\">Favoris non lus</a>");
      $list = new itemlist();
      while ( $row = $req->get_row() )
      {
        $list->add("<a href=\"".$wwwtopdir."forum2/?id_sujet=".$row['id_sujet']."&amp;spage=firstunread#firstunread\"\">".
        htmlentities($row['titre_sujet'], ENT_NOQUOTES, "UTF-8").
        "</a>");
      }
      $cts->add($list);
Feu's avatar
wip  
Feu committed
1198
      if ( $req->lines == 4 )
Feu's avatar
wip  
Feu committed
1199
1200
1201
1202
1203
        $cts->add_paragraph("<a href=\"".$wwwtopdir."forum2/search.php?page=unread\">suite...</a>");
    }
    else
      $cts->add_paragraph("pas de favoris non lus");
  
Feu's avatar
fixes  
Feu committed
1204
    $req = new requete($this->db,$query);
Feu's avatar
test  
Feu committed
1205
1206
1207
    
    if ( $req->lines > 0 )
    {
Feu's avatar
wip  
Feu committed
1208
      $cts->add_title(2,"<a href=\"".$wwwtopdir."forum2/search.php?page=unread\">Derniers messages non lus</a>");
Feu's avatar
test  
Feu committed
1209
1210
1211
1212
1213
1214
1215
      $list = new itemlist();
      while ( $row = $req->get_row() )
      {
        $list->add("<a href=\"".$wwwtopdir."forum2/?id_sujet=".$row['id_sujet']."&amp;spage=firstunread#firstunread\"\">".
        htmlentities($row['titre_sujet'], ENT_NOQUOTES, "UTF-8").
        "</a>");
      }
Feu's avatar
wip  
Feu committed
1216
      $cts->add($list);
Feu's avatar
wip  
Feu committed
1217
      if ( $req->lines == 4 )
Feu's avatar
wip  
Feu committed
1218
        $cts->add_paragraph("<a href=\"".$wwwtopdir."forum2/search.php?page=unread\">suite...</a>");
Feu's avatar
test  
Feu committed
1219
1220
    }
    else
Feu's avatar
wip  
Feu committed
1221
      $cts->add_paragraph("pas d'autres messages non lus");
Feu's avatar
wip  
Feu committed
1222
    
Feu's avatar
test  
Feu committed
1223
    return $cts;
Feu's avatar
test  
Feu committed
1224
  }
1225
1226
1227
1228
1229
 
  /**
   * Génère la boite des permanences à venir
   * @param renvoie un stdcontents
   */
1230
  function get_planning_permanences_contents()
1231
  {
BenC's avatar
BenC committed
1232
    $cts = new contents("Prochaines permanences");
1233
1234
1235

    $cts->add_paragraph("<a href=\"".$wwwtopdir."planning\">Les plannings de permanences</a>");

1236
1237
    $req = new requete($this->db,"SET lc_time_names='fr_FR'");

BenC's avatar
BenC committed
1238
    //TODO : Faire en sorte qu'il affiche tout seul les différents plannings et plus avoir à hardcoder l'id_planning
1239
    $sublist = new itemlist("Bureau AE - Belfort");
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
    
    $req = new requete($this->db,"SELECT DAYNAME(start_gap) AS day, HOUR(start_gap) AS hour " .
                                 "FROM pl_gap " .
                                 "INNER JOIN pl_gap_user USING(id_gap) " .
                                 "WHERE id_planning='164' " .
                                   "AND (" .
                                     "DAYOFWEEK(pl_gap.start_gap)>DAYOFWEEK(CURDATE()) " .
                                     "OR (" .
                                       "DAYOFWEEK(start_gap)=DAYOFWEEK(CURDATE()) " .
                                       "AND HOUR(start_gap)>=HOUR(CURTIME()) " .
                                     ") " .
                                   ") " .
                                   "AND ((WEEKOFYEAR(CURDATE())-WEEKOFYEAR(start_gap))%2)=0 " .
1253
                                 "GROUP BY id_gap " .
BenC's avatar
BenC committed
1254
1255
                                 "ORDER BY DAYOFWEEK(start_gap), HOUR(start_gap) " .
                                 "LIMIT 3");
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265

    if($req->lines < 1)
    {
      $sublist->add("Aucune permanence à venir pour cette semaine");
    }
    else
    {
      while(list($day,$hour) = $req->get_row() )
        $sublist->add(ucfirst($day) . " à " . $hour . "h");
    }
1266

BenC's avatar
BenC committed
1267
    $cts->add($sublist, true, true, "bureau_ae_belfort", "boxlist", true, true);
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
    
        $sublist = new itemlist("Bureau AE - Sevenans");
    
    $req = new requete($this->db,"SELECT DAYNAME(start_gap) AS day, HOUR(start_gap) AS hour " .
                                 "FROM pl_gap " .
                                 "INNER JOIN pl_gap_user USING(id_gap) " .
                                 "WHERE id_planning='166' " .
                                   "AND (" .
                                     "DAYOFWEEK(pl_gap.start_gap)>DAYOFWEEK(CURDATE()) " .
                                     "OR (" .
                                       "DAYOFWEEK(start_gap)=DAYOFWEEK(CURDATE()) " .
                                       "AND HOUR(start_gap)>=HOUR(CURTIME()) " .
                                     ") " .
                                   ") " .
                                   "AND ((WEEKOFYEAR(CURDATE())-WEEKOFYEAR(start_gap))%2)=0 " .
1283
                                 "GROUP BY id_gap " .
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
                                 "ORDER BY DAYOFWEEK(start_gap), HOUR(start_gap) " .
                                 "LIMIT 3");

    if($req->lines < 1)
    {
      $sublist->add("Aucune permanence à venir pour cette semaine");
    }
    else
    {
      while(list($day,$hour) = $req->get_row() )
        $sublist->add(ucfirst($day) . " à " . $hour . "h");
    }

    $cts->add($sublist, true, true, "bureau_ae_sevenans", "boxlist", true, true);
1298
1299
1300
1301

    return $cts;
  }

Feu's avatar
Feu committed
1302
1303
1304
1305
  /**
   * Gènère la boite d'information Superflux
   * @param renvoie un stdcontents
   */
Feu's avatar
testons  
Feu committed
1306
1307
1308
1309
1310
1311
  function get_stream_box()
  {
    $cts = new contents("Superflux");
    
    $cts->add_paragraph("La webradio de l'AE");
    
Feu's avatar
Feu committed
1312
    if ( $GLOBALS["taiste"] )
Feu's avatar
Feu committed
1313
1314
1315
1316
1317
1318
      $infofile = $topdir."var/cache/stream";
    else
      $infofile = $topdir."var/cache/stream-prod";
  
    if ( file_exists($infofile) )
      $GLOBALS["streaminfo"] = unserialize(file_get_contents($infofile));