-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
154 lines (128 loc) · 4.48 KB
/
index.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
<?php
// TODO : Move this to a more appropriate place. This was done and commented
// out in Session::__construct().
session_start();
require "includes/globals.php";
include "functions/functions.php";
$valid_modules = array("user", "leave", "employees");
$session =& Session::instance();
$application =& Application::instance();
$application->init();
$user =& MySQLTableUser::instance();
$notifications =& Notification::instance();
$module = Request::get("module", "get", "employees", "string");
if(!in_array($module, $valid_modules))
{
exit("Invalid module.");
}
if(!is_alpha($module))
{
exit("Illegal module name.");
}
//If the user is not logged in and this is not the user module (which renders
// the login page) redirect them to the login page.
if($module !== "user" && !isset($user->data))
{
// $url = generate_url(array("module", "view", "action")) . "&module=user";
$url = "index.php?module=user&view=login";
$response =& Response::instance();
$response->redirect($url);
}
$action = Request::get("action", "get");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<link type="text/css" rel="stylesheet" href="css/reset.css" />
<link type="text/css" rel="stylesheet" href="css/defaults.css" />
<link type="text/css" rel="stylesheet" href="css/dw.css" />
<link type="text/css" rel="stylesheet" href="css/nav.css" />
<link type="text/css" rel="stylesheet" href="css/form.css" />
<link type="text/css" rel="stylesheet" href="css/template.css" />
<link type="text/css" rel="stylesheet" href="css/interface.css" />
<link type="text/css" rel="stylesheet" href="css/julian_robichaux_date_picker.css" />
<?php if(!is_null($module)) { ?>
<link type="text/css" rel="stylesheet" href="css/<?php echo $module ?>.css" />
<?php } ?>
<script type="text/javascript" src="js/common.js"></script>
<script type="text/javascript" src="js/julian_robichaux_date_picker.js"></script>
<script type="text/javascript" src="js/date_pickers.js"></script>
<script type="text/javascript" src="js/default.js"></script>
<title>Sabila Leave Manager</title>
</head>
<body class="bg_texture <?php echo $module ?>">
<div id="wrapper">
<div id="header">
<img src="myomege_logo.jpg" alt="MyOmega" />
</div>
<div id="user" class="blue_bar_repeat text3">
<?php if(isset($user->data)) { ?>
<?php
// $loginFormSent = (bool)Request::get("loginFormSent", "post", false);
$loginEntry = new FormRequest("loginform", "post");
if(!is_null($loginEntry->get("form_sent")))
{
// if(!Application::login($loginEntry->get("user_name"), $loginEntry->get("user_password")))
// {
// $notifications->addNotification("Incorrect login details.", Notification::NOTIF_ERROR);
// }
}
else
{
// Application::session();
}
$data = array();
$row = array("employees", "employees", "Employees");
array_push($data, $row);
// $row = array("serverbrowser", "ServerBrowser");
// array_push($data, $row);
$nav = new HTMLList();
$nav->setData($data);
$attribs = new Attributes();
$attribs->set("id", "mainNav");
$nav->setAttributes($attribs);
$nav->setFormat('<a href="'.generate_url(array("module", "display", "view", "action", "id"), array("module" => '%1$s', "view" => '%2$s')) . '">%3$s</a>');
// $nav->setFields(array("Module", "Text"));
// $nav->setGroupBy("Text");
if(isset($user->data))
{
?>
<p id="user_info">
Logged in as: <span class="username"><?php echo $user->get("username") ?></span>
<a href="<?php echo generate_url(array("action", "module", "view"), array("module" => "user", "action" => "logout")) ?>">logout</a>
</p>
<?php
}
?>
<?php } else { ?>
<p id="user_info"> </p>
<?php } ?>
</div>
<div id="main" class="box">
<?php
//Determine the paths of the module files.
$module_path = "modules/" . $module . ".php";
$moduleFunctionsPath = "functions/" . $module . ".php";
//If the files exist load them.
if(is_file($moduleFunctionsPath))
{
include $moduleFunctionsPath;
}
if(is_file($module_path))
{
include $module_path;
$module = 'Module' . ucwords($module);
$module::execute();
}
?>
</div>
<div style="clear: both;"><!-- x --></div>
<div id="footer"></div>
</div>
<?php
echo $notifications;
$notifications->clear();
?>
</body>
</html>