index.php 1.52 KB
Newer Older
stc's avatar
stc committed
1 2 3
<?php
session_start();

4
include 'lib/cas_connect.php';
stc's avatar
stc committed
5

6
include 'lib/db.php';
7
include 'lib/views.php';
8
include 'lib/admin.php';
9

stc's avatar
stc committed
10
$db = new DB();
11
//if ($_SESSION['localcopy']) {
12
  $db->copyUser($_SESSION['utclogin'], $_SESSION['surname'], $_SESSION['firstname'], $_SESSION['mail']);
13
  $_SESSION['localcopy']=false;
14
//}
15 16 17
$admin = new Admin($db);
$view = new Views($admin, $_SESSION['utclogin'], $_SESSION['surname'], $_SESSION['firstname']);

Stephane Crozat's avatar
Stephane Crozat committed
18
$view->printHtmlBegin($admin);
19
$view->printUser($db->isResp($_SESSION['utclogin']), $db->isAdmin($_SESSION['utclogin']));
20 21 22

if (isset($_GET['mode'])) {
  if ($_GET['mode']=='resp') {
23 24
    if (isset($_GET['action']) && isset($_GET['api']) && isset($_GET['login'])) {
      if ($_GET['action']=='validate') {
25
        $db->validate($_SESSION['utclogin'], $_GET['api'], $_GET['login']);
26 27
      }
    }
28
    $view->respValidation($db->apiListResp($admin, $_SESSION['utclogin']));
29 30 31 32 33
  }
  if ($_GET['mode']=='admin') {
    $view->adminFunction($_SESSION['utclogin']);
  }
}
34 35 36 37 38
else {
  /** Subscription and unsubscription management **/
  if (isset($_GET['api']) && $admin->isActive()) {
    if (isset($_GET['action'])) {
      if ($_GET['action']=='sub') {
39
        $db->subToApi($admin, $_SESSION['utclogin'], $_GET['api']);
40 41 42 43
      }
      elseif ($_GET['action']=='unsub') {
        $db->unsubToApi($_SESSION['utclogin'], $_GET['api']);
      }
stc's avatar
stc committed
44 45
    }
  }
46 47
  $view->printInstructions($db->config());
  $view->printSubList($db->subList($_SESSION['utclogin']));
48
  $view->printApiList($db->apiList($admin, $_SESSION['utclogin']));
stc's avatar
stc committed
49 50
}
?>