/
users.php
103 lines (90 loc) · 3.1 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
<?php
$paths = array(
'.', 'backbone', 'components', 'content', 'model', 'render', 'scripts', 'styles', 'images'
);
$includePath = implode( PATH_SEPARATOR, $paths );
set_include_path( get_include_path() . PATH_SEPARATOR . $includePath );
require_once('Page.php');
require_once('Template.php');
require_once('User.php');
$user = User::getByID($_SESSION['userid']);
secure(2); // only allow admins or staff (roleid <= 2)
$page = new Page("Users :: Afterthought", 'users');
$tmpl = new Template();
$page->run();
$tmpl->self = $page->self;
$tmpl->code = isset( $_GET['code'] ) ? $_GET['code'] : -1;
$tmpl->users = User::toArray(User::getAll());
switch( $tmpl->code ){
case 0:
// filler error
$tmpl->alert['type'] = "error";
$tmpl->alert['message'] = "I'm sorry Dave, I can't let you do that.";
break;
case 3:
// Employee was deleted successfully
$tmpl->alert['type'] = "okay";
$tmpl->alert['message'] = "The employee was deleted successfully.";
break;
case 4:
// Employee was deleted successfully, cascade delete failed
$tmpl->alert['type'] = "error";
$tmpl->alert['message'] = "The employee was deleted, but associated data could not be removed. Please contact an administrator.<br />" . $tmpl->errorcode;
break;
case 5:
// Employee was disabled successfully
$tmpl->alert['type'] = "okay";
$tmpl->alert['message'] = "The employee login was disabled successfully.";
break;
case 6:
// Employee was enabled successfully
$tmpl->alert['type'] = "okay";
$tmpl->alert['message'] = "The employee login was enabled successfully.";
break;
case 7:
// Employee disable failed
$tmpl->alert['type'] = "error";
$tmpl->alert['message'] = "The employee login could not be disabled.";
break;
case 8:
// Employee enable failed
$tmpl->alert['type'] = "error";
$tmpl->alert['message'] = "The employee login could not be enabled.";
break;
case 9:
// Force password change succeeded
$tmpl->alert['type'] = "okay";
$tmpl->alert['message'] = "The employee will be prompted to change their password at next login.";
break;
case 10:
// accept current password succeeded
$tmpl->alert['type'] = "okay";
$tmpl->alert['message'] = "The employee will not be prompted to change their password.";
break;
case 11:
// Force password change failed
$tmpl->alert['type'] = "error";
$tmpl->alert['message'] = "Attempting to prompt for the employee to change their password at next login failed.";
break;
case 12:
// accept current password failed
$tmpl->alert['type'] = "error";
$tmpl->alert['message'] = "Attempting to remove the prompt for the employee to change their password at next login failed.";
break;
default:
break;
}
$html = $tmpl->build('users.html');
$css = $tmpl->build('users.css');
$js = $tmpl->build('users.js');
$appContent = array(
'html' => $html,
'css' => array( 'code' => $css,
'link' => 'users'
),
'js' => array( 'code' => $js,
'link' => 'users'
)
);
echo $page->build($appContent);
?>