|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
//------------------------------------------------------------------------------ |
|
4
|
|
|
// |
|
5
|
|
|
// eTraxis - Records tracking web-based system |
|
6
|
|
|
// Copyright (C) 2005-2011 Artem Rodygin |
|
7
|
|
|
// |
|
8
|
|
|
// This program is free software: you can redistribute it and/or modify |
|
9
|
|
|
// it under the terms of the GNU General Public License as published by |
|
10
|
|
|
// the Free Software Foundation, either version 3 of the License, or |
|
11
|
|
|
// (at your option) any later version. |
|
12
|
|
|
// |
|
13
|
|
|
// This program is distributed in the hope that it will be useful, |
|
14
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
15
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
16
|
|
|
// GNU General Public License for more details. |
|
17
|
|
|
// |
|
18
|
|
|
// You should have received a copy of the GNU General Public License |
|
19
|
|
|
// along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
20
|
|
|
// |
|
21
|
|
|
//------------------------------------------------------------------------------ |
|
22
|
|
|
|
|
23
|
|
|
/** |
|
24
|
|
|
* @package eTraxis |
|
25
|
|
|
* @ignore |
|
26
|
|
|
*/ |
|
27
|
|
|
|
|
28
|
|
|
/**#@+ |
|
29
|
|
|
* Dependency. |
|
30
|
|
|
*/ |
|
31
|
|
|
require_once('../engine/engine.php'); |
|
32
|
|
|
require_once('../dbo/accounts.php'); |
|
33
|
|
|
/**#@-*/ |
|
34
|
|
|
|
|
35
|
|
|
init_page(LOAD_TAB); |
|
36
|
|
|
|
|
37
|
|
|
if (get_user_level() != USER_LEVEL_ADMIN) |
|
38
|
|
|
{ |
|
39
|
|
|
debug_write_log(DEBUG_NOTICE, 'User must have admin rights to be allowed.'); |
|
40
|
|
|
exit; |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
// check that requested account exists |
|
44
|
|
|
|
|
45
|
|
|
$id = ustr2int(try_request('id')); |
|
46
|
|
|
$account = account_find($id); |
|
47
|
|
|
|
|
48
|
|
|
if (!$account) |
|
|
|
|
|
|
49
|
|
|
{ |
|
50
|
|
|
debug_write_log(DEBUG_NOTICE, 'Account cannot be found.'); |
|
51
|
|
|
exit; |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
if ($account['is_ldapuser']) |
|
55
|
|
|
{ |
|
56
|
|
|
debug_write_log(DEBUG_NOTICE, 'Active Directory account cannot be viewed.'); |
|
57
|
|
|
exit; |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
// local JS functions |
|
61
|
|
|
|
|
62
|
|
|
$resTitle = ustrprocess(get_js_resource(RES_ACCOUNT_X_ID), ustr2js(account_get_username($account['username'], FALSE))); |
|
63
|
|
|
$resOK = get_js_resource(RES_OK_ID); |
|
64
|
|
|
$resCancel = get_js_resource(RES_CANCEL_ID); |
|
65
|
|
|
|
|
66
|
|
|
$xml = <<<JQUERY |
|
67
|
|
|
<script> |
|
68
|
|
|
|
|
69
|
|
|
function accountModify () |
|
70
|
|
|
{ |
|
71
|
|
|
jqModal("{$resTitle}", "modify.php?id={$id}", "{$resOK}", "{$resCancel}", "$('#modifyform').submit()"); |
|
72
|
|
|
} |
|
73
|
|
|
|
|
74
|
|
|
function accountToggle () |
|
75
|
|
|
{ |
|
76
|
|
|
$.post("disable.php?id={$id}", function () { |
|
77
|
|
|
reloadTab(); |
|
78
|
|
|
}); |
|
79
|
|
|
} |
|
80
|
|
|
|
|
81
|
|
|
function accountUnlock () |
|
82
|
|
|
{ |
|
83
|
|
|
$.post("unlock.php?id={$id}", function () { |
|
84
|
|
|
reloadTab(); |
|
85
|
|
|
}); |
|
86
|
|
|
} |
|
87
|
|
|
|
|
88
|
|
|
</script> |
|
89
|
|
|
JQUERY; |
|
90
|
|
|
|
|
91
|
|
|
// generate buttons |
|
92
|
|
|
|
|
93
|
|
|
$xml .= '<button url="index.php">' . get_html_resource(RES_BACK_ID) . '</button>' |
|
94
|
|
|
. '<buttonset>' |
|
95
|
|
|
. '<button action="accountModify()">' . get_html_resource(RES_MODIFY_ID) . '</button>'; |
|
96
|
|
|
|
|
97
|
|
|
$xml .= (is_account_removable($id) |
|
98
|
|
|
? '<button url="delete.php?id=' . $id . '" prompt="' . get_js_resource(RES_CONFIRM_DELETE_ACCOUNT_ID) . '">' |
|
99
|
|
|
: '<button disabled="false">') |
|
100
|
|
|
. get_html_resource(RES_DELETE_ID) |
|
101
|
|
|
. '</button>'; |
|
102
|
|
|
|
|
103
|
|
|
$xml .= '<button action="accountToggle()">' |
|
104
|
|
|
. get_html_resource($account['is_disabled'] ? RES_ENABLE_ID : RES_DISABLE_ID) |
|
105
|
|
|
. '</button>'; |
|
106
|
|
|
|
|
107
|
|
|
if (is_account_locked($account['locks_count'], $account['lock_time'])) |
|
108
|
|
|
{ |
|
109
|
|
|
$xml .= '<button action="accountUnlock()">' |
|
110
|
|
|
. get_html_resource(RES_UNLOCK_ID) |
|
111
|
|
|
. '</button>'; |
|
112
|
|
|
} |
|
113
|
|
|
|
|
114
|
|
|
$xml .= '</buttonset>'; |
|
115
|
|
|
|
|
116
|
|
|
// generate account information |
|
117
|
|
|
|
|
118
|
|
|
$xml .= '<group title="' . get_html_resource(RES_ACCOUNT_INFO_ID) . '">' |
|
119
|
|
|
. '<text label="' . get_html_resource(RES_USERNAME_ID) . '">' . ustr2html(account_get_username($account['username'], FALSE)) . '</text>' |
|
120
|
|
|
. '<text label="' . get_html_resource(RES_FULLNAME_ID) . '">' . ustr2html($account['fullname']) . '</text>' |
|
121
|
|
|
. '<text label="' . get_html_resource(RES_EMAIL_ID) . '">' . ustr2html($account['email']) . '</text>' |
|
122
|
|
|
. '<text label="' . get_html_resource(RES_DESCRIPTION_ID) . '">' . ustr2html($account['description']) . '</text>' |
|
123
|
|
|
. '<text label="' . get_html_resource(RES_PERMISSIONS_ID) . '">' . get_html_resource($account['is_admin'] ? RES_ADMINISTRATOR_ID : RES_USER_ID) . '</text>' |
|
124
|
|
|
. '<text label="' . get_html_resource(RES_STATUS_ID) . '">' . get_html_resource(is_account_locked($account['locks_count'], $account['lock_time']) ? RES_LOCKED_ID : ($account['is_disabled'] ? RES_DISABLED_ID : RES_ACTIVE_ID)) . '</text>' |
|
125
|
|
|
. '</group>'; |
|
126
|
|
|
|
|
127
|
|
|
echo(xml2html($xml)); |
|
128
|
|
|
|
|
129
|
|
|
?> |
|
|
|
|
|
|
130
|
|
|
|
This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.
Consider making the comparison explicit by using
empty(..)or! empty(...)instead.