forked from BlackMac/timetrack
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTTActions.class.php
50 lines (40 loc) · 1019 Bytes
/
TTActions.class.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<?php
require_once ("TimeTrackSQL.class.php");
class TTActions {
private $ttrack;
function __construct() {
session_start();
$this->ttrack= new TimeTrack();
}
function loginAction() {
if (isset($_SESSION['username'])) {
return array('view'=>'login_success');
}
if (!isset($_POST['username'])) {
return array('view'=>'login_form');
} else {
if ($this->ttrack->login($_POST['username'], $_POST['password'])) {
$_SESSION['username']=$_POST['username'];
//$_SESSION['user']=
redirect('list');
}
return array('view'=>'login_form');
}
}
function logoutAction() {
unset($_SESSION['username']);
redirect('login');
}
function registerAction() {
return 'register';
}
function importAction() {
if (!isset($_SESSION['username'])) redirect('login');
return null;
}
function listAction() {
if (!isset($_SESSION['username'])) redirect('login');
$events=$this->ttrack->getEvents();
return array('view'=>'login_success', 'events'=>$events);;
}
}