forked from pellcorp/opendb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
user_listing.php
170 lines (136 loc) · 7.27 KB
/
user_listing.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
<?php
/*
Open Media Collectors Database
Copyright (C) 2001,2013 by Jason Pell
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
// This must be first - includes config.php
require_once("./include/begin.inc.php");
include_once("./lib/database.php");
include_once("./lib/auth.php");
include_once("./lib/logging.php");
include_once("./lib/email.php");
include_once("./lib/user.php");
include_once("./lib/datetime.php");
include_once("./lib/borrowed_item.php");
include_once("./lib/listutils.php");
include_once("./lib/HTML_Listing.class.php");
if (is_site_enabled()) {
if (is_opendb_valid_session()) {
if (is_user_granted_permission(PERM_ADMIN_USER_LISTING)) {
if (strlen($HTTP_VARS['override_page_title']) > 0)
$page_title = $HTTP_VARS['override_page_title'];
else if ($HTTP_VARS['restrict_active_ind'] == 'X')
$page_title = get_opendb_lang_var('activate_users');
else
$page_title = get_opendb_lang_var('user_list');
echo (_theme_header($page_title));
echo ("<h2>" . $page_title . "</h2>");
$listingObject = new HTML_Listing($PHP_SELF, $HTTP_VARS, $HTTP_VARS['mode']);
$listingObject->setNoRowsMessage(get_opendb_lang_var('no_users_found'));
if ($HTTP_VARS['restrict_active_ind'] == 'X')
$restrict_users_mode = INCLUDE_ACTIVATE_USER;
else if ($HTTP_VARS['show_deactivated_users'] == 'Y')
$restrict_users_mode = INCLUDE_DEACTIVATED_USER;
else
$restrict_users_mode = EXCLUDE_DEACTIVATED_USER;
$listingObject->startListing();
if (is_numeric($listingObject->getItemsPerPage())) {
$listingObject->setTotalItems(fetch_user_cnt(NULL, INCLUDE_ROLE_PERMISSIONS, INCLUDE_CURRENT_USER, $restrict_users_mode));
if ($listingObject->getTotalItemCount() > 0) {
$result = fetch_user_rs(NULL, //$user_role_permissions
INCLUDE_ROLE_PERMISSIONS, INCLUDE_CURRENT_USER, $restrict_users_mode, $listingObject->getCurrentOrderBy(), $listingObject->getCurrentSortOrder(), $listingObject->getStartIndex(), $listingObject->getItemsPerPage());
}
} else {
$result = fetch_user_rs(NULL, //$user_role_permissions
INCLUDE_ROLE_PERMISSIONS, INCLUDE_CURRENT_USER, $restrict_users_mode, $listingObject->getCurrentOrderBy(), $listingObject->getCurrentSortOrder()); //$include_deactivated_users
}
$listingObject->addHeaderColumn(NULL, 'user_id_rs', FALSE, 'checkbox');
$listingObject->addHeaderColumn(get_opendb_lang_var('user'), 'user_id');
$listingObject->addHeaderColumn(get_opendb_lang_var('action'));
$listingObject->addHeaderColumn(get_opendb_lang_var('user_role'), 'role');
if ($HTTP_VARS['restrict_active_ind'] != 'X') {
$listingObject->addHeaderColumn(get_opendb_lang_var('last_visit'), 'lastvisit');
}
if ($result) {
$v_listing_url_vars = $HTTP_VARS;
$v_listing_url_vars['mode'] = NULL;
unset($v_listing_url_vars['show_deactivated_users_cbox']);
register_opendb_session_var('user_listing_url_vars', $v_listing_url_vars);
while ($user_r = db_fetch_assoc($result)) {
$user_is_active = is_user_active($user_r['user_id']);
$listingObject->startRow();
// todo - consider disabling for guest users!
if ($HTTP_VARS['restrict_active_ind'] != 'X' ? $user_is_active : TRUE) {
$listingObject->addCheckboxColumn($user_r['user_id'], FALSE);
} else {
$listingObject->addColumn();
}
$user_name = get_opendb_lang_var('user_name', array('fullname' => $user_r['fullname'], 'user_id' => $user_r['user_id']));
$listingObject->addColumn('<a href="user_profile.php?uid=' . $user_r['user_id'] . '" title="' . get_opendb_lang_var('user_profile') . '">' . $user_name . '</a>');
$action_links_rs = NULL;
$action_links_rs[] = array('url' => 'user_admin.php?op=edit&user_id=' . $user_r['user_id'], 'img' => 'edit_user.gif', 'text' => get_opendb_lang_var('edit'));
if ($user_r['user_id'] != get_opendb_session_var('user_id')) {
if ($user_r['active_ind'] == 'X') {
$action_links_rs[] = array('url' => 'user_admin.php?op=delete&user_id=' . $user_r['user_id'], 'img' => 'delete_user.gif', 'text' => get_opendb_lang_var('delete_user'));
} else if ($user_is_active) {
$action_links_rs[] = array('url' => 'user_admin.php?op=deactivate&user_id=' . $user_r['user_id'], 'img' => 'deactivate_user.gif', 'text' => get_opendb_lang_var('deactivate_user'));
}
if (!$user_is_active) {
$action_links_rs[] = array('url' => 'user_admin.php?op=activate&user_id=' . $user_r['user_id'], 'img' => 'activate_user.gif', 'text' => get_opendb_lang_var('activate_user'));
}
}
$action_links_rs[] = array('url' => 'user_admin.php?op=change_password&user_id=' . $user_r['user_id'], 'img' => 'change_password.gif', 'text' => get_opendb_lang_var('change_password'));
$listingObject->addActionColumn($action_links_rs);
$listingObject->addColumn($user_r['role_description']);
if ($HTTP_VARS['restrict_active_ind'] != 'X') {
if ($user_r['active_ind'] == 'Y') {
$listingObject->addColumn((strlen($user_r['lastvisit']) > 0 ? get_localised_timestamp(get_opendb_config_var('user_admin', 'datetime_mask'), $user_r['lastvisit']) : get_opendb_lang_var('never_logged_in')));
} else {
$listingObject->addColumn(get_opendb_lang_var('deactivated'));
}
}
$listingObject->endRow();
}
db_free_result($result);
} //if($result)
$listingObject->endListing();
if ($listingObject->isCheckboxColumns() > 0) {
if ($HTTP_VARS['restrict_active_ind'] == 'X') {
$checkbox_action_rs[] = array('action' => 'user_admin.php', 'op' => 'activate_users', 'link' => get_opendb_lang_var('activate_users'));
} else if (is_valid_opendb_mailer()) {
$checkbox_action_rs[] = array('action' => 'email.php', 'op' => 'send_to_uids', 'link' => get_opendb_lang_var('email_users'));
}
echo (format_checkbox_action_links('user_id_rs', get_opendb_lang_var('no_users_checked'), $checkbox_action_rs));
}
echo (format_help_block($listingObject->getHelpEntries()));
echo ("<ul class=\"listingControls\">");
if ($HTTP_VARS['restrict_active_ind'] != 'X') {
echo ("<li>" . getToggleControl($PHP_SELF, $HTTP_VARS, get_opendb_lang_var('show_deactivated_users'), 'show_deactivated_users', ifempty($HTTP_VARS['show_deactivated_users'], 'N')) . "</li>");
}
echo ("<li>" . getItemsPerPageControl($PHP_SELF, $HTTP_VARS) . "</li>");
echo ("</ul>");
echo (_theme_footer());
} else {
opendb_not_authorised_page(PERM_ADMIN_USER_LISTING, $HTTP_VARS);
}
} else {
// invalid login, so login instead.
redirect_login($PHP_SELF, $HTTP_VARS);
}
} else { //if(is_site_enabled())
opendb_site_disabled();
}
// Cleanup after begin.inc.php
require_once("./include/end.inc.php");
?>