<?php
#=
/****************************************************************************
Copyright 2002-2005, Daniel Deycard, Jacques Messines, Alain Pomirol
(CATICE Académie de Bordeaux)

This file is part of Gibii.

Gibii 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.

Gibii 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 Gibii; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

****************************************************************************/
include ("../include/vars_adm.php");
include("../include/util.inc.php");

$statuts=array('Prof','Admin','Gest');
$dests=array('../prof/prof_ut.php','../admin/admin_ut.php','../gestion/gest_ut.php');

// On décode la chaîne passée en paramètre
$param = unserialize(base64_decode($_GET['c']));
// $param['s'] contient /prof/prof_haut.php ou /admin/admin_haut.php ou /gestion/gest_haut.php
// suivant la provenance.
//$statut = explode('/',$param['s']);
//$s = ucfirst($statut[1]);
$source=$param['s'];
$dest=$param['d'];
//print $s;exit();
// $param['d'] contient la clé de tableau correspondant à la destination
if ($dest != 0 && $dest != 1 && $dest != 2) exit();

opensession($statuts[$source]);            //marche même pour un prof non admin
if (!in_array($sess_statut,$statuts)) exit(); //pas de cadeau !

if (isset($sess_statut_prof) && ($sess_statut_prof & 6)) {     //6 = 4 | 2
    // c'est un prof 'admin-adjoint' (& 2)
    // ou un prof 'gestionnaire-adjoint' (& 4)
    // il a le droit d'aller partout ou presque...
    $sess_statut=$statuts[$dest];
    $d = $dests[$dest];
    session_puts('sess_statut');
    header("Location: $d");
    }
?>