control.inc
1.41 KB
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
51
52
53
54
55
56
57
58
<?php
/**
* $Id$
*
* Contains the controller helper functions
*
* Copyright (c) 1999-2002 The Owl Project Team
* Licensed under the GNU GPL. For full terms see the file COPYING.
* @version $Revision$
* @author jam dms team
* @package dmslib
*/
/**
* Redirects to the specified URL
*
* @param $url the URL to forward to
*/
function redirect($url) {
// everything is relative to the root url
$url = $default->owl_root_url . $url;
header("Location: $url");
}
/**
* Generates a link via the control page, with the passed action
*
* @param $action
* the controller action to generate a link for
* @return the generated href
*/
//TODO: maybe this should just be the url?
function generateLink($action) {
return "<a href=\"control.php?action=$action\">";
}
/**
* Validates the session.
*
* @param $sessionID
* the session ID to validate
* @return
* true if the session is valid, else false.
*/
function checkSession() {
$sessionStatus = Session::verify();
// TODO: error handling in here with appropriate actions
// error messages are in $sessionStatus["errorMessage"]
switch ($sessionStatus["status"]) {
case 1 : // session verified, update lastused time
return true;
break;
case 2 : // session timed out
case 3 : // session already in use
return false;
}
}