/
users.php
185 lines (149 loc) · 5.38 KB
/
users.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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
<?php
/*
* users.php
*
* Copyright 2009 fae <fae@onet.eu>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
*/
require_once dirname(__FILE__) . '/common.php';
dgr_require('/includes/user.php');
dgr_startup();
try {
$user = new DGradeUser();
$style = dgr_get_style('.', $user->get_styleid());
} catch ( Exception $e ) {
/* user not logged in */
dgr_redirect('index.php');
}
if ( $user->get_level() != 0 )
die();
$users = dgr_get_users();
?>
<!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" xml:lang="en" lang="en">
<head>
<title>DGrade - <?php echo gettext('users'); ?></title>
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
<meta name="generator" content="Geany 0.18" />
<link type="text/css" rel="stylesheet" href="<?php echo $style; ?>" />
<script type="text/javascript" src="scripts/common.js"></script>
<script type="text/javascript" src="scripts/manage.js"></script>
<script type="text/javascript" src="scripts/validate.js"></script>
</head>
<body onload="set_page(false)">
<div id="main">
<!-- topmenu -->
<div id="topmenu">
<div class="left">
<span><?php echo gettext('Logged in as') . ': ' . $user->get_name() . ' ' . $user->get_surname(); ?></span>
<br />
<span><a href="index.php?logout=1"><?php echo gettext('Logout'); ?></a></span>
</div>
<div class="right">
<?php if ( $user->get_level() == 0 ) { ?>
<span class="menuitem"><a href="main.php"><?php echo gettext('Main page'); ?></a></span>
<span class="menuitem"><a href="classes.php"><?php echo gettext('Classes'); ?></a></span>
<span class="menuitem"><a href="subjects.php"><?php echo gettext('Subjects & semesters'); ?></a></span>
<span class="menuitem"><a href="class_subjects.php"><?php echo gettext('Class subjects'); ?></a></span>
<?php } ?>
<span class="menuitem"><a href="settings.php"><?php echo gettext('Settings'); ?></a></span>
</div>
</div>
<!-- menu -->
<div id="nav">
</div>
<br />
<div id="maincontainer">
<div id="choosebox">
<span id="chooseheader"><?php echo gettext('Users'); ?></span>
<span id="choosesel" style="display:none">1</span>
<span id="chooseid" style="display:none">0</span>
<div id="chooselist">
<table cellpadding="0" cellspacing="0" width="100%">
<tr id="choose0" onmouseover="make_pointer(this)" onclick="change_user_selection(0, 0)">
<td class="choosetd" style="text-align:center" colspan="3"><?php echo gettext('new user'); ?></td>
</tr>
<tr>
<td class="choosetd" colspan="3"> </td>
</tr>
<?php
$i = 0;
foreach ( $users as $u ) {
$tr = 'choose' . ++$i;
?>
<tr id="<?php echo $tr; ?>" onmouseover="make_pointer(this)" onclick="change_user_selection(<?php echo $i; ?>, <?php echo $u['uid'] ?>)">
<td style="width:15%" class="choosetd"><?php echo $i; ?></td>
<td class="choosetd"><?php echo $u['name']; ?></td>
<td class="choosetd"><?php echo $u['surname']; ?></td>
</tr>
<?php } ?>
</table>
</div>
</div>
<div id="workarea">
<span id="inputdisabled" style="display:none">1</span>
<table style="padding-top:64px" cellpadding="8" width="50%" class="centered">
<tr>
<td><?php echo gettext('Login'); ?>:</td>
<td><input type="text" id="login" disabled="disabled" maxlength="30" /></td>
</tr>
<tr>
<td><?php echo gettext('Password'); ?>:</td>
<td><input type="password" id="pass" disabled="disabled" /></td>
</tr>
<tr>
<td><?php echo gettext('Name'); ?>:</td>
<td><input type="text" id="user_name" disabled="disabled" maxlength="30" /></td>
</tr>
<tr>
<td><?php echo gettext('Surname'); ?>:</td>
<td><input type="text" id="user_surname" disabled="disabled" maxlength="30" /></td>
</tr>
<tr>
<td><?php echo gettext('E-mail'); ?>:</td>
<td><input type="text" id="email" disabled="disabled" maxlength="30" onblur="validate_email()" /></td>
<td>
<img id="emailvalid" class="hiddenimg" src="img/valid.png" alt="valid" />
<img id="emailbad" class="hiddenimg" src="img/bad.png" alt="bad" />
</td>
</tr>
<tr>
<td><?php echo gettext('Level'); ?>:</td>
<td>
<select id="levelsel" disabled="disabled">
<option value="0"><?php echo gettext('Administrator'); ?></option>
<option value="1"><?php echo gettext('Viewer'); ?></option>
<option value="2"><?php echo gettext('Teacher'); ?></option>
</select>
</td>
</tr>
<tr><td> </td></tr>
<tr>
<td style="text-align:center">
<input type="button" id="addbutton" value="<?php echo gettext('Save'); ?>" disabled="disabled" onclick="save_user()" />
</td>
<td style="text-align:center">
<input type="button" id="delbutton" value="<?php echo gettext('Delete'); ?>" disabled="disabled" onclick="delete_user()" />
</td>
</tr>
</table>
</div>
</div>
</div>
</body>
</html>