root / branches / phpBB-3_0_0 / phpBB / includes / acp / acp_inactive.php
History | View | Annotate | Download (10.2 kB)
| 1 | 6394 | grahamje | <?php
|
|---|---|---|---|
| 2 | 8147 | acydburn | /**
|
| 3 | 6394 | grahamje | * |
| 4 | 6394 | grahamje | * @package acp |
| 5 | 6394 | grahamje | * @version $Id$ |
| 6 | 8147 | acydburn | * @copyright (c) 2006 phpBB Group |
| 7 | 8147 | acydburn | * @license http://opensource.org/licenses/gpl-license.php GNU Public License |
| 8 | 6394 | grahamje | * |
| 9 | 6394 | grahamje | */ |
| 10 | 6394 | grahamje | |
| 11 | 6394 | grahamje | /**
|
| 12 | 8147 | acydburn | * @ignore |
| 13 | 8147 | acydburn | */ |
| 14 | 8147 | acydburn | if (!defined('IN_PHPBB')) |
| 15 | 8147 | acydburn | {
|
| 16 | 8147 | acydburn | exit;
|
| 17 | 8147 | acydburn | } |
| 18 | 8147 | acydburn | |
| 19 | 8147 | acydburn | /**
|
| 20 | 6394 | grahamje | * @package acp |
| 21 | 6394 | grahamje | */ |
| 22 | 6394 | grahamje | class acp_inactive |
| 23 | 6394 | grahamje | {
|
| 24 | 6394 | grahamje | var $u_action; |
| 25 | 6394 | grahamje | var $p_master; |
| 26 | 6394 | grahamje | |
| 27 | 6394 | grahamje | function acp_inactive(&$p_master) |
| 28 | 6394 | grahamje | {
|
| 29 | 6394 | grahamje | $this->p_master = &$p_master; |
| 30 | 6394 | grahamje | } |
| 31 | 6394 | grahamje | |
| 32 | 6394 | grahamje | function main($id, $mode) |
| 33 | 6394 | grahamje | {
|
| 34 | 6394 | grahamje | global $config, $db, $user, $auth, $template; |
| 35 | 6394 | grahamje | global $phpbb_root_path, $phpbb_admin_path, $phpEx, $table_prefix; |
| 36 | 6394 | grahamje | |
| 37 | 6803 | acydburn | include($phpbb_root_path . 'includes/functions_user.' . $phpEx); |
| 38 | 6803 | acydburn | |
| 39 | 6428 | acydburn | $user->add_lang('memberlist'); |
| 40 | 6428 | acydburn | |
| 41 | 6394 | grahamje | $action = request_var('action', ''); |
| 42 | 6394 | grahamje | $mark = (isset($_REQUEST['mark'])) ? request_var('mark', array(0)) : array(); |
| 43 | 6394 | grahamje | $start = request_var('start', 0); |
| 44 | 8120 | kellanved | $submit = isset($_POST['submit']); |
| 45 | 6394 | grahamje | |
| 46 | 6394 | grahamje | // Sort keys
|
| 47 | 6394 | grahamje | $sort_days = request_var('st', 0); |
| 48 | 6394 | grahamje | $sort_key = request_var('sk', 'i'); |
| 49 | 6394 | grahamje | $sort_dir = request_var('sd', 'd'); |
| 50 | 6394 | grahamje | |
| 51 | 8120 | kellanved | $form_key = 'acp_inactive'; |
| 52 | 8120 | kellanved | add_form_key($form_key);
|
| 53 | 8120 | kellanved | |
| 54 | 9845 | acydburn | // We build the sort key and per page settings here, because they may be needed later
|
| 55 | 9845 | acydburn | |
| 56 | 9845 | acydburn | // Number of entries to display
|
| 57 | 9845 | acydburn | $per_page = request_var('users_per_page', (int) $config['topics_per_page']); |
| 58 | 9845 | acydburn | |
| 59 | 9845 | acydburn | // Sorting
|
| 60 | 9845 | acydburn | $limit_days = array(0 => $user->lang['ALL_ENTRIES'], 1 => $user->lang['1_DAY'], 7 => $user->lang['7_DAYS'], 14 => $user->lang['2_WEEKS'], 30 => $user->lang['1_MONTH'], 90 => $user->lang['3_MONTHS'], 180 => $user->lang['6_MONTHS'], 365 => $user->lang['1_YEAR']); |
| 61 | 9845 | acydburn | $sort_by_text = array('i' => $user->lang['SORT_INACTIVE'], 'j' => $user->lang['SORT_REG_DATE'], 'l' => $user->lang['SORT_LAST_VISIT'], 'd' => $user->lang['SORT_LAST_REMINDER'], 'r' => $user->lang['SORT_REASON'], 'u' => $user->lang['SORT_USERNAME'], 'p' => $user->lang['SORT_POSTS'], 'e' => $user->lang['SORT_REMINDER']); |
| 62 | 9845 | acydburn | $sort_by_sql = array('i' => 'user_inactive_time', 'j' => 'user_regdate', 'l' => 'user_lastvisit', 'd' => 'user_reminded_time', 'r' => 'user_inactive_reason', 'u' => 'username_clean', 'p' => 'user_posts', 'e' => 'user_reminded'); |
| 63 | 9845 | acydburn | |
| 64 | 9845 | acydburn | $s_limit_days = $s_sort_key = $s_sort_dir = $u_sort_param = ''; |
| 65 | 9845 | acydburn | gen_sort_selects($limit_days, $sort_by_text, $sort_days, $sort_key, $sort_dir, $s_limit_days, $s_sort_key, $s_sort_dir, $u_sort_param); |
| 66 | 9845 | acydburn | |
| 67 | 8120 | kellanved | if ($submit && sizeof($mark)) |
| 68 | 6394 | grahamje | {
|
| 69 | 8149 | kellanved | if ($action !== 'delete' && !check_form_key($form_key)) |
| 70 | 8120 | kellanved | {
|
| 71 | 8120 | kellanved | trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action), E_USER_WARNING); |
| 72 | 8120 | kellanved | } |
| 73 | 8120 | kellanved | |
| 74 | 6394 | grahamje | switch ($action) |
| 75 | 6394 | grahamje | {
|
| 76 | 6394 | grahamje | case 'activate': |
| 77 | 6394 | grahamje | case 'delete': |
| 78 | 6803 | acydburn | |
| 79 | 8147 | acydburn | $sql = 'SELECT user_id, username |
| 80 | 6394 | grahamje | FROM ' . USERS_TABLE . ' |
| 81 | 6394 | grahamje | WHERE ' . $db->sql_in_set('user_id', $mark); |
| 82 | 6394 | grahamje | $result = $db->sql_query($sql); |
| 83 | 9845 | acydburn | |
| 84 | 6394 | grahamje | $user_affected = array(); |
| 85 | 6394 | grahamje | while ($row = $db->sql_fetchrow($result)) |
| 86 | 6394 | grahamje | {
|
| 87 | 6803 | acydburn | $user_affected[$row['user_id']] = $row['username']; |
| 88 | 6394 | grahamje | } |
| 89 | 6394 | grahamje | $db->sql_freeresult($result); |
| 90 | 6394 | grahamje | |
| 91 | 6394 | grahamje | if ($action == 'activate') |
| 92 | 6394 | grahamje | {
|
| 93 | 10310 | toonarmy | // Get those 'being activated'...
|
| 94 | 10310 | toonarmy | $sql = 'SELECT user_id, username' . (($config['require_activation'] == USER_ACTIVATION_ADMIN) ? ', user_email, user_lang' : '') . ' |
| 95 | 10310 | toonarmy | FROM ' . USERS_TABLE . ' |
| 96 | 10310 | toonarmy | WHERE ' . $db->sql_in_set('user_id', $mark) . ' |
| 97 | 10310 | toonarmy | AND user_type = ' . USER_INACTIVE; |
| 98 | 10310 | toonarmy | $result = $db->sql_query($sql); |
| 99 | 10310 | toonarmy | |
| 100 | 10310 | toonarmy | $inactive_users = array(); |
| 101 | 10310 | toonarmy | while ($row = $db->sql_fetchrow($result)) |
| 102 | 7909 | acydburn | {
|
| 103 | 10310 | toonarmy | $inactive_users[] = $row; |
| 104 | 7909 | acydburn | } |
| 105 | 10310 | toonarmy | $db->sql_freeresult($result); |
| 106 | 7909 | acydburn | |
| 107 | 6436 | acydburn | user_active_flip('activate', $mark); |
| 108 | 7909 | acydburn | |
| 109 | 7909 | acydburn | if ($config['require_activation'] == USER_ACTIVATION_ADMIN && !empty($inactive_users)) |
| 110 | 7909 | acydburn | {
|
| 111 | 7909 | acydburn | include_once($phpbb_root_path . 'includes/functions_messenger.' . $phpEx); |
| 112 | 7909 | acydburn | |
| 113 | 10124 | acydburn | $messenger = new messenger(false); |
| 114 | 7909 | acydburn | |
| 115 | 7909 | acydburn | foreach ($inactive_users as $row) |
| 116 | 7909 | acydburn | {
|
| 117 | 7909 | acydburn | $messenger->template('admin_welcome_activated', $row['user_lang']); |
| 118 | 7909 | acydburn | |
| 119 | 7909 | acydburn | $messenger->to($row['user_email'], $row['username']); |
| 120 | 7909 | acydburn | |
| 121 | 11568 | git-gate | $messenger->anti_abuse_headers($config, $user); |
| 122 | 7909 | acydburn | |
| 123 | 7909 | acydburn | $messenger->assign_vars(array( |
| 124 | 7909 | acydburn | 'USERNAME' => htmlspecialchars_decode($row['username'])) |
| 125 | 7909 | acydburn | ); |
| 126 | 7909 | acydburn | |
| 127 | 7909 | acydburn | $messenger->send(NOTIFY_EMAIL); |
| 128 | 7909 | acydburn | } |
| 129 | 7909 | acydburn | |
| 130 | 7909 | acydburn | $messenger->save_queue();
|
| 131 | 7909 | acydburn | } |
| 132 | 9845 | acydburn | |
| 133 | 10310 | toonarmy | if (!empty($inactive_users)) |
| 134 | 10310 | toonarmy | {
|
| 135 | 10310 | toonarmy | foreach ($inactive_users as $row) |
| 136 | 10310 | toonarmy | {
|
| 137 | 10310 | toonarmy | add_log('admin', 'LOG_USER_ACTIVE', $row['username']); |
| 138 | 10310 | toonarmy | add_log('user', $row['user_id'], 'LOG_USER_ACTIVE_USER'); |
| 139 | 10310 | toonarmy | } |
| 140 | 10310 | toonarmy | } |
| 141 | 10310 | toonarmy | |
| 142 | 9845 | acydburn | // For activate we really need to redirect, else a refresh can result in users being deactivated again
|
| 143 | 9845 | acydburn | $u_action = $this->u_action . "&$u_sort_param&start=$start"; |
| 144 | 9845 | acydburn | $u_action .= ($per_page != $config['topics_per_page']) ? "&users_per_page=$per_page" : ''; |
| 145 | 9845 | acydburn | |
| 146 | 9845 | acydburn | redirect($u_action);
|
| 147 | 6394 | grahamje | } |
| 148 | 6394 | grahamje | else if ($action == 'delete') |
| 149 | 6394 | grahamje | {
|
| 150 | 8149 | kellanved | if (confirm_box(true)) |
| 151 | 6394 | grahamje | {
|
| 152 | 8149 | kellanved | if (!$auth->acl_get('a_userdel')) |
| 153 | 8149 | kellanved | {
|
| 154 | 8149 | kellanved | trigger_error($user->lang['NO_AUTH_OPERATION'] . adm_back_link($this->u_action), E_USER_WARNING); |
| 155 | 8149 | kellanved | } |
| 156 | 8149 | kellanved | |
| 157 | 8149 | kellanved | foreach ($mark as $user_id) |
| 158 | 8149 | kellanved | {
|
| 159 | 8149 | kellanved | user_delete('retain', $user_id, $user_affected[$user_id]); |
| 160 | 8149 | kellanved | } |
| 161 | 8263 | acydburn | |
| 162 | 8263 | acydburn | add_log('admin', 'LOG_INACTIVE_' . strtoupper($action), implode(', ', $user_affected)); |
| 163 | 6394 | grahamje | } |
| 164 | 8149 | kellanved | else
|
| 165 | 6803 | acydburn | {
|
| 166 | 8149 | kellanved | $s_hidden_fields = array( |
| 167 | 8149 | kellanved | 'mode' => $mode, |
| 168 | 8149 | kellanved | 'action' => $action, |
| 169 | 8149 | kellanved | 'mark' => $mark, |
| 170 | 8149 | kellanved | 'submit' => 1, |
| 171 | 8240 | acydburn | 'start' => $start, |
| 172 | 8149 | kellanved | ); |
| 173 | 8149 | kellanved | confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields($s_hidden_fields)); |
| 174 | 6803 | acydburn | } |
| 175 | 6394 | grahamje | } |
| 176 | 6394 | grahamje | |
| 177 | 6394 | grahamje | break;
|
| 178 | 6394 | grahamje | |
| 179 | 6394 | grahamje | case 'remind': |
| 180 | 6394 | grahamje | if (empty($config['email_enable'])) |
| 181 | 6394 | grahamje | {
|
| 182 | 6428 | acydburn | trigger_error($user->lang['EMAIL_DISABLED'] . adm_back_link($this->u_action), E_USER_WARNING); |
| 183 | 6394 | grahamje | } |
| 184 | 6394 | grahamje | |
| 185 | 8147 | acydburn | $sql = 'SELECT user_id, username, user_email, user_lang, user_jabber, user_notify_type, user_regdate, user_actkey |
| 186 | 8147 | acydburn | FROM ' . USERS_TABLE . ' |
| 187 | 9327 | toonarmy | WHERE ' . $db->sql_in_set('user_id', $mark) . ' |
| 188 | 9327 | toonarmy | AND user_inactive_reason';
|
| 189 | 9327 | toonarmy | |
| 190 | 9327 | toonarmy | $sql .= ($config['require_activation'] == USER_ACTIVATION_ADMIN) ? ' = ' . INACTIVE_REMIND : ' <> ' . INACTIVE_MANUAL; |
| 191 | 9327 | toonarmy | |
| 192 | 6394 | grahamje | $result = $db->sql_query($sql); |
| 193 | 6394 | grahamje | |
| 194 | 6394 | grahamje | if ($row = $db->sql_fetchrow($result)) |
| 195 | 6394 | grahamje | {
|
| 196 | 6394 | grahamje | // Send the messages
|
| 197 | 8241 | acydburn | include_once($phpbb_root_path . 'includes/functions_messenger.' . $phpEx); |
| 198 | 6394 | grahamje | |
| 199 | 6394 | grahamje | $messenger = new messenger(); |
| 200 | 9845 | acydburn | $usernames = $user_ids = array(); |
| 201 | 6730 | acydburn | |
| 202 | 6394 | grahamje | do
|
| 203 | 6394 | grahamje | {
|
| 204 | 6394 | grahamje | $messenger->template('user_remind_inactive', $row['user_lang']); |
| 205 | 6394 | grahamje | |
| 206 | 6394 | grahamje | $messenger->to($row['user_email'], $row['username']); |
| 207 | 6394 | grahamje | $messenger->im($row['user_jabber'], $row['username']); |
| 208 | 6394 | grahamje | |
| 209 | 11568 | git-gate | $messenger->anti_abuse_headers($config, $user); |
| 210 | 9327 | toonarmy | |
| 211 | 6394 | grahamje | $messenger->assign_vars(array( |
| 212 | 6548 | acydburn | 'USERNAME' => htmlspecialchars_decode($row['username']), |
| 213 | 9327 | toonarmy | 'REGISTER_DATE' => $user->format_date($row['user_regdate'], false, true), |
| 214 | 6730 | acydburn | 'U_ACTIVATE' => generate_board_url() . "/ucp.$phpEx?mode=activate&u=" . $row['user_id'] . '&k=' . $row['user_actkey']) |
| 215 | 6394 | grahamje | ); |
| 216 | 6394 | grahamje | |
| 217 | 6394 | grahamje | $messenger->send($row['user_notify_type']); |
| 218 | 6394 | grahamje | |
| 219 | 6394 | grahamje | $usernames[] = $row['username']; |
| 220 | 9845 | acydburn | $user_ids[] = (int) $row['user_id']; |
| 221 | 6394 | grahamje | } |
| 222 | 6394 | grahamje | while ($row = $db->sql_fetchrow($result)); |
| 223 | 6394 | grahamje | |
| 224 | 6394 | grahamje | $messenger->save_queue();
|
| 225 | 6394 | grahamje | |
| 226 | 9845 | acydburn | // Add the remind state to the database
|
| 227 | 9845 | acydburn | $sql = 'UPDATE ' . USERS_TABLE . ' |
| 228 | 9845 | acydburn | SET user_reminded = user_reminded + 1, |
| 229 | 9845 | acydburn | user_reminded_time = ' . time() . ' |
| 230 | 9845 | acydburn | WHERE ' . $db->sql_in_set('user_id', $user_ids); |
| 231 | 9845 | acydburn | $db->sql_query($sql); |
| 232 | 9845 | acydburn | |
| 233 | 6394 | grahamje | add_log('admin', 'LOG_INACTIVE_REMIND', implode(', ', $usernames)); |
| 234 | 6394 | grahamje | unset($usernames); |
| 235 | 6394 | grahamje | } |
| 236 | 6394 | grahamje | $db->sql_freeresult($result); |
| 237 | 9845 | acydburn | |
| 238 | 9845 | acydburn | // For remind we really need to redirect, else a refresh can result in more than one reminder
|
| 239 | 9845 | acydburn | $u_action = $this->u_action . "&$u_sort_param&start=$start"; |
| 240 | 9845 | acydburn | $u_action .= ($per_page != $config['topics_per_page']) ? "&users_per_page=$per_page" : ''; |
| 241 | 9845 | acydburn | |
| 242 | 9845 | acydburn | redirect($u_action);
|
| 243 | 9845 | acydburn | |
| 244 | 6394 | grahamje | break;
|
| 245 | 6394 | grahamje | } |
| 246 | 6394 | grahamje | } |
| 247 | 6394 | grahamje | |
| 248 | 6394 | grahamje | // Define where and sort sql for use in displaying logs
|
| 249 | 6394 | grahamje | $sql_where = ($sort_days) ? (time() - ($sort_days * 86400)) : 0; |
| 250 | 6394 | grahamje | $sql_sort = $sort_by_sql[$sort_key] . ' ' . (($sort_dir == 'd') ? 'DESC' : 'ASC'); |
| 251 | 6394 | grahamje | |
| 252 | 6394 | grahamje | $inactive = array(); |
| 253 | 6394 | grahamje | $inactive_count = 0; |
| 254 | 6394 | grahamje | |
| 255 | 9845 | acydburn | $start = view_inactive_users($inactive, $inactive_count, $per_page, $start, $sql_where, $sql_sort); |
| 256 | 6394 | grahamje | |
| 257 | 6394 | grahamje | foreach ($inactive as $row) |
| 258 | 6394 | grahamje | {
|
| 259 | 6394 | grahamje | $template->assign_block_vars('inactive', array( |
| 260 | 6394 | grahamje | 'INACTIVE_DATE' => $user->format_date($row['user_inactive_time']), |
| 261 | 9845 | acydburn | 'REMINDED_DATE' => $user->format_date($row['user_reminded_time']), |
| 262 | 6394 | grahamje | 'JOINED' => $user->format_date($row['user_regdate']), |
| 263 | 6394 | grahamje | 'LAST_VISIT' => (!$row['user_lastvisit']) ? ' - ' : $user->format_date($row['user_lastvisit']), |
| 264 | 9845 | acydburn | |
| 265 | 6394 | grahamje | 'REASON' => $row['inactive_reason'], |
| 266 | 6394 | grahamje | 'USER_ID' => $row['user_id'], |
| 267 | 9845 | acydburn | 'POSTS' => ($row['user_posts']) ? $row['user_posts'] : 0, |
| 268 | 9845 | acydburn | 'REMINDED' => $row['user_reminded'], |
| 269 | 9845 | acydburn | |
| 270 | 9845 | acydburn | 'REMINDED_EXPLAIN' => $user->lang('USER_LAST_REMINDED', (int) $row['user_reminded'], $user->format_date($row['user_reminded_time'])), |
| 271 | 9845 | acydburn | |
| 272 | 9845 | acydburn | 'USERNAME_FULL' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour'], false, append_sid("{$phpbb_admin_path}index.$phpEx", 'i=users&mode=overview')), |
| 273 | 9845 | acydburn | 'USERNAME' => get_username_string('username', $row['user_id'], $row['username'], $row['user_colour']), |
| 274 | 9845 | acydburn | 'USER_COLOR' => get_username_string('colour', $row['user_id'], $row['username'], $row['user_colour']), |
| 275 | 9845 | acydburn | |
| 276 | 9845 | acydburn | 'U_USER_ADMIN' => append_sid("{$phpbb_admin_path}index.$phpEx", "i=users&mode=overview&u={$row['user_id']}"), |
| 277 | 9845 | acydburn | 'U_SEARCH_USER' => ($auth->acl_get('u_search')) ? append_sid("{$phpbb_root_path}search.$phpEx", "author_id={$row['user_id']}&sr=posts") : '', |
| 278 | 9845 | acydburn | )); |
| 279 | 6394 | grahamje | } |
| 280 | 6394 | grahamje | |
| 281 | 6394 | grahamje | $option_ary = array('activate' => 'ACTIVATE', 'delete' => 'DELETE'); |
| 282 | 6394 | grahamje | if ($config['email_enable']) |
| 283 | 6394 | grahamje | {
|
| 284 | 6394 | grahamje | $option_ary += array('remind' => 'REMIND'); |
| 285 | 6394 | grahamje | } |
| 286 | 6394 | grahamje | |
| 287 | 6394 | grahamje | $template->assign_vars(array( |
| 288 | 6394 | grahamje | 'S_INACTIVE_USERS' => true, |
| 289 | 6394 | grahamje | 'S_INACTIVE_OPTIONS' => build_select($option_ary), |
| 290 | 6394 | grahamje | |
| 291 | 6394 | grahamje | 'S_LIMIT_DAYS' => $s_limit_days, |
| 292 | 6394 | grahamje | 'S_SORT_KEY' => $s_sort_key, |
| 293 | 6394 | grahamje | 'S_SORT_DIR' => $s_sort_dir, |
| 294 | 9845 | acydburn | 'S_ON_PAGE' => on_page($inactive_count, $per_page, $start), |
| 295 | 9845 | acydburn | 'PAGINATION' => generate_pagination($this->u_action . "&$u_sort_param&users_per_page=$per_page", $inactive_count, $per_page, $start, true), |
| 296 | 9845 | acydburn | 'USERS_PER_PAGE' => $per_page, |
| 297 | 9845 | acydburn | |
| 298 | 11301 | git-gate | 'U_ACTION' => $this->u_action . "&$u_sort_param&users_per_page=$per_page&start=$start", |
| 299 | 6394 | grahamje | )); |
| 300 | 6394 | grahamje | |
| 301 | 6394 | grahamje | $this->tpl_name = 'acp_inactive'; |
| 302 | 6394 | grahamje | $this->page_title = 'ACP_INACTIVE_USERS'; |
| 303 | 6394 | grahamje | } |
| 304 | 6394 | grahamje | } |
| 305 | 6394 | grahamje | |
| 306 | 6394 | grahamje | ?> |

