5
* @version $Id: acp_inactive.php,v 1.19 2007/12/05 13:55:14 acydburn Exp $
6
* @copyright (c) 2006 phpBB Group
7
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
14
if (!defined('IN_PHPBB'))
27
function acp_inactive(&$p_master)
29
$this->p_master = &$p_master;
32
function main($id, $mode)
34
global $config, $db, $user, $auth, $template;
35
global $phpbb_root_path, $phpbb_admin_path, $phpEx, $table_prefix;
37
include($phpbb_root_path . 'includes/functions_user.' . $phpEx);
39
$user->add_lang('memberlist');
41
$action = request_var('action', '');
42
$mark = (isset($_REQUEST['mark'])) ? request_var('mark', array(0)) : array();
43
$start = request_var('start', 0);
44
$submit = isset($_POST['submit']);
47
$sort_days = request_var('st', 0);
48
$sort_key = request_var('sk', 'i');
49
$sort_dir = request_var('sd', 'd');
51
$form_key = 'acp_inactive';
52
add_form_key($form_key);
54
if ($submit && sizeof($mark))
56
if ($action !== 'delete' && !check_form_key($form_key))
58
trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action), E_USER_WARNING);
66
$sql = 'SELECT user_id, username
67
FROM ' . USERS_TABLE . '
68
WHERE ' . $db->sql_in_set('user_id', $mark);
69
$result = $db->sql_query($sql);
71
$user_affected = array();
72
while ($row = $db->sql_fetchrow($result))
74
$user_affected[$row['user_id']] = $row['username'];
76
$db->sql_freeresult($result);
78
if ($action == 'activate')
80
if ($config['require_activation'] == USER_ACTIVATION_ADMIN)
82
// Get those 'being activated'...
83
$sql = 'SELECT user_id, username, user_email, user_lang
84
FROM ' . USERS_TABLE . '
85
WHERE ' . $db->sql_in_set('user_id', $mark) . '
86
AND user_type = ' . USER_INACTIVE;
87
$result = $db->sql_query($sql);
89
$inactive_users = array();
90
while ($row = $db->sql_fetchrow($result))
92
$inactive_users[] = $row;
94
$db->sql_freeresult($result);
97
user_active_flip('activate', $mark);
99
if ($config['require_activation'] == USER_ACTIVATION_ADMIN && !empty($inactive_users))
101
include_once($phpbb_root_path . 'includes/functions_messenger.' . $phpEx);
103
$messenger = new messenger();
105
foreach ($inactive_users as $row)
107
$messenger->template('admin_welcome_activated', $row['user_lang']);
109
$messenger->to($row['user_email'], $row['username']);
111
$messenger->headers('X-AntiAbuse: Board servername - ' . $config['server_name']);
112
$messenger->headers('X-AntiAbuse: User_id - ' . $user->data['user_id']);
113
$messenger->headers('X-AntiAbuse: Username - ' . $user->data['username']);
115
$messenger->assign_vars(array(
116
'USERNAME' => htmlspecialchars_decode($row['username']))
119
$messenger->send(NOTIFY_EMAIL);
122
$messenger->save_queue();
125
else if ($action == 'delete')
127
if (confirm_box(true))
129
if (!$auth->acl_get('a_userdel'))
131
trigger_error($user->lang['NO_AUTH_OPERATION'] . adm_back_link($this->u_action), E_USER_WARNING);
134
foreach ($mark as $user_id)
136
user_delete('retain', $user_id, $user_affected[$user_id]);
139
add_log('admin', 'LOG_INACTIVE_' . strtoupper($action), implode(', ', $user_affected));
143
$s_hidden_fields = array(
150
confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields($s_hidden_fields));
157
if (empty($config['email_enable']))
159
trigger_error($user->lang['EMAIL_DISABLED'] . adm_back_link($this->u_action), E_USER_WARNING);
162
$sql = 'SELECT user_id, username, user_email, user_lang, user_jabber, user_notify_type, user_regdate, user_actkey
163
FROM ' . USERS_TABLE . '
164
WHERE ' . $db->sql_in_set('user_id', $mark);
165
$result = $db->sql_query($sql);
167
if ($row = $db->sql_fetchrow($result))
170
include_once($phpbb_root_path . 'includes/functions_messenger.' . $phpEx);
172
$messenger = new messenger();
173
$usernames = array();
177
$messenger->template('user_remind_inactive', $row['user_lang']);
179
$messenger->to($row['user_email'], $row['username']);
180
$messenger->im($row['user_jabber'], $row['username']);
182
$messenger->assign_vars(array(
183
'USERNAME' => htmlspecialchars_decode($row['username']),
184
'REGISTER_DATE' => $user->format_date($row['user_regdate']),
185
'U_ACTIVATE' => generate_board_url() . "/ucp.$phpEx?mode=activate&u=" . $row['user_id'] . '&k=' . $row['user_actkey'])
188
$messenger->send($row['user_notify_type']);
190
$usernames[] = $row['username'];
192
while ($row = $db->sql_fetchrow($result));
194
$messenger->save_queue();
196
add_log('admin', 'LOG_INACTIVE_REMIND', implode(', ', $usernames));
199
$db->sql_freeresult($result);
206
$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']);
207
$sort_by_text = array('i' => $user->lang['SORT_INACTIVE'], 'j' => $user->lang['SORT_REG_DATE'], 'l' => $user->lang['SORT_LAST_VISIT'], 'r' => $user->lang['SORT_REASON'], 'u' => $user->lang['SORT_USERNAME']);
208
$sort_by_sql = array('i' => 'user_inactive_time', 'j' => 'user_regdate', 'l' => 'user_lastvisit', 'r' => 'user_inactive_reason', 'u' => 'username_clean');
210
$s_limit_days = $s_sort_key = $s_sort_dir = $u_sort_param = '';
211
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);
213
// Define where and sort sql for use in displaying logs
214
$sql_where = ($sort_days) ? (time() - ($sort_days * 86400)) : 0;
215
$sql_sort = $sort_by_sql[$sort_key] . ' ' . (($sort_dir == 'd') ? 'DESC' : 'ASC');
220
$start = view_inactive_users($inactive, $inactive_count, $config['topics_per_page'], $start, $sql_where, $sql_sort);
222
foreach ($inactive as $row)
224
$template->assign_block_vars('inactive', array(
225
'INACTIVE_DATE' => $user->format_date($row['user_inactive_time']),
226
'JOINED' => $user->format_date($row['user_regdate']),
227
'LAST_VISIT' => (!$row['user_lastvisit']) ? ' - ' : $user->format_date($row['user_lastvisit']),
228
'REASON' => $row['inactive_reason'],
229
'USER_ID' => $row['user_id'],
230
'USERNAME' => $row['username'],
231
'U_USER_ADMIN' => append_sid("{$phpbb_admin_path}index.$phpEx", "i=users&mode=overview&u={$row['user_id']}"))
235
$option_ary = array('activate' => 'ACTIVATE', 'delete' => 'DELETE');
236
if ($config['email_enable'])
238
$option_ary += array('remind' => 'REMIND');
241
$template->assign_vars(array(
242
'S_INACTIVE_USERS' => true,
243
'S_INACTIVE_OPTIONS' => build_select($option_ary),
245
'S_LIMIT_DAYS' => $s_limit_days,
246
'S_SORT_KEY' => $s_sort_key,
247
'S_SORT_DIR' => $s_sort_dir,
248
'S_ON_PAGE' => on_page($inactive_count, $config['topics_per_page'], $start),
249
'PAGINATION' => generate_pagination($this->u_action . "&$u_sort_param", $inactive_count, $config['topics_per_page'], $start, true),
251
'U_ACTION' => $this->u_action . '&start=' . $start,
254
$this->tpl_name = 'acp_inactive';
255
$this->page_title = 'ACP_INACTIVE_USERS';
b'\\ No newline at end of file'