Commit 93819d7f authored by Stephane Crozat's avatar Stephane Crozat

Modification de l'index pour gérer le cas resp et le cas admin

parent 0a3dc27c
<?php
session_start();
if (!isset($_SESSION['login'])) {
/* If session is already open for current PHP file, user is already logged in, do nothing
If session is not open on current PHP file, check if it is open on CAS server
If it is open on CAS server retrieve session informations
If it is not on open on CAS server, ask for login to CAS server
*/
include $_SERVER['DOCUMENT_ROOT'].'/apisub/lib/cas.php';
$info = CAS::authenticate();
if ($info != -1) {
$_SESSION['ticket'] = $_GET['ticket'];
$_SESSION['utclogin'] = $info['cas:user'];
$_SESSION['mail'] = $info['cas:attributes']['cas:mail'];
$_SESSION['surname'] = strtoupper($info['cas:attributes']['cas:sn']);
$_SESSION['firstname'] = $info['cas:attributes']['cas:givenName'];
}
else
CAS::login();
}
echo $_SESSION['ticket']." ".$_SESSION['utclogin']
?>
......@@ -38,7 +38,15 @@ $view = new Views($admin, $_SESSION['utclogin'], $_SESSION['surname'], $_SESSION
$view->printHtmlBegin();
$view->printUser($db->isResp($_SESSION['utclogin']), $db->isAdmin($_SESSION['utclogin']));
$view->printInstructions($db->config());
if (isset($_GET['mode'])) {
if ($_GET['mode']=='resp') {
$view->respValidation($_SESSION['utclogin']);
}
if ($_GET['mode']=='admin') {
$view->adminFunction($_SESSION['utclogin']);
}
}
/** Subscription and unsubscription management **/
if (isset($_GET['api']) && $admin->isActive()) {
......@@ -52,6 +60,7 @@ if (isset($_GET['api']) && $admin->isActive()) {
}
}
$view->printInstructions($db->config());
$view->printSubList($db->subList($_SESSION['utclogin']));
$view->printApiList($db->apiList('E', 2019), $_SESSION['utclogin']);
......
......@@ -39,10 +39,10 @@ class Views {
public function printUser($isResp, $isAdmin) {
echo "<p><i>$this->firstname $this->surname</i> (<b>$this->utclogin</b>)</p>";
if ($isResp) {
echo '<a href="resp.php">[Gérer ses Api]</a> ';
echo '<a href="index.php?mode=resp">[Gérer ses Api]</a> ';
}
if ($isAdmin) {
echo '<a href="admin.php">[Super-pouvoirs]</a>';
echo '<a href="index.php?mode=admin">[Super-pouvoirs]</a>';
}
}
......@@ -100,4 +100,11 @@ class Views {
}
}
public function respValidation ($utclogin) {
echo "<p>Je dois vérifier que $utclogin est un responsable d'Api</p>";
}
public function adminFunction ($utclogin) {
echo "<p>Je dois vérifier que $utclogin a vraiment des super-pouvoirs ?</p>";
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment