|
|
4c79b5 |
|
|
|
4c79b5 |
/**
|
|
|
4c79b5 |
*
|
|
|
4c79b5 |
* @package acp
|
|
|
4c79b5 |
* @version $Id: acp_inactive.php 8598 2008-06-04 15:37:06Z naderman $
|
|
|
4c79b5 |
* @copyright (c) 2006 phpBB Group
|
|
|
4c79b5 |
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
|
|
|
4c79b5 |
*
|
|
|
4c79b5 |
*/
|
|
|
4c79b5 |
|
|
|
4c79b5 |
/**
|
|
|
4c79b5 |
* @ignore
|
|
|
4c79b5 |
*/
|
|
|
4c79b5 |
if (!defined('IN_PHPBB'))
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
exit;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
/**
|
|
|
4c79b5 |
* @package acp
|
|
|
4c79b5 |
*/
|
|
|
4c79b5 |
class acp_inactive
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
var $u_action;
|
|
|
4c79b5 |
var $p_master;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
function acp_inactive(&$p_master)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$this->p_master = &$p_master;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
function main($id, $mode)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
global $config, $db, $user, $auth, $template;
|
|
|
4c79b5 |
global $phpbb_root_path, $phpbb_admin_path, $phpEx, $table_prefix;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
include($phpbb_root_path . 'includes/functions_user.' . $phpEx);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$user->add_lang('memberlist');
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$action = request_var('action', '');
|
|
|
4c79b5 |
$mark = (isset($_REQUEST['mark'])) ? request_var('mark', array(0)) : array();
|
|
|
4c79b5 |
$start = request_var('start', 0);
|
|
|
4c79b5 |
$submit = isset($_POST['submit']);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
// Sort keys
|
|
|
4c79b5 |
$sort_days = request_var('st', 0);
|
|
|
4c79b5 |
$sort_key = request_var('sk', 'i');
|
|
|
4c79b5 |
$sort_dir = request_var('sd', 'd');
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$form_key = 'acp_inactive';
|
|
|
4c79b5 |
add_form_key($form_key);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
if ($submit && sizeof($mark))
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
if ($action !== 'delete' && !check_form_key($form_key))
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action), E_USER_WARNING);
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
switch ($action)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
case 'activate':
|
|
|
4c79b5 |
case 'delete':
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$sql = 'SELECT user_id, username
|
|
|
4c79b5 |
FROM ' . USERS_TABLE . '
|
|
|
4c79b5 |
WHERE ' . $db->sql_in_set('user_id', $mark);
|
|
|
4c79b5 |
$result = $db->sql_query($sql);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$user_affected = array();
|
|
|
4c79b5 |
while ($row = $db->sql_fetchrow($result))
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$user_affected[$row['user_id']] = $row['username'];
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
$db->sql_freeresult($result);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
if ($action == 'activate')
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
if ($config['require_activation'] == USER_ACTIVATION_ADMIN)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
// Get those 'being activated'...
|
|
|
4c79b5 |
$sql = 'SELECT user_id, username, user_email, user_lang
|
|
|
4c79b5 |
FROM ' . USERS_TABLE . '
|
|
|
4c79b5 |
WHERE ' . $db->sql_in_set('user_id', $mark) . '
|
|
|
4c79b5 |
AND user_type = ' . USER_INACTIVE;
|
|
|
4c79b5 |
$result = $db->sql_query($sql);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$inactive_users = array();
|
|
|
4c79b5 |
while ($row = $db->sql_fetchrow($result))
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$inactive_users[] = $row;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
$db->sql_freeresult($result);
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
user_active_flip('activate', $mark);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
if ($config['require_activation'] == USER_ACTIVATION_ADMIN && !empty($inactive_users))
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
include_once($phpbb_root_path . 'includes/functions_messenger.' . $phpEx);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$messenger = new messenger();
|
|
|
4c79b5 |
|
|
|
4c79b5 |
foreach ($inactive_users as $row)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$messenger->template('admin_welcome_activated', $row['user_lang']);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$messenger->to($row['user_email'], $row['username']);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$messenger->headers('X-AntiAbuse: Board servername - ' . $config['server_name']);
|
|
|
4c79b5 |
$messenger->headers('X-AntiAbuse: User_id - ' . $user->data['user_id']);
|
|
|
4c79b5 |
$messenger->headers('X-AntiAbuse: Username - ' . $user->data['username']);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$messenger->assign_vars(array(
|
|
|
4c79b5 |
'USERNAME' => htmlspecialchars_decode($row['username']))
|
|
|
4c79b5 |
);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$messenger->send(NOTIFY_EMAIL);
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$messenger->save_queue();
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
else if ($action == 'delete')
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
if (confirm_box(true))
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
if (!$auth->acl_get('a_userdel'))
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
trigger_error($user->lang['NO_AUTH_OPERATION'] . adm_back_link($this->u_action), E_USER_WARNING);
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
foreach ($mark as $user_id)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
user_delete('retain', $user_id, $user_affected[$user_id]);
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
add_log('admin', 'LOG_INACTIVE_' . strtoupper($action), implode(', ', $user_affected));
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
else
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$s_hidden_fields = array(
|
|
|
4c79b5 |
'mode' => $mode,
|
|
|
4c79b5 |
'action' => $action,
|
|
|
4c79b5 |
'mark' => $mark,
|
|
|
4c79b5 |
'submit' => 1,
|
|
|
4c79b5 |
'start' => $start,
|
|
|
4c79b5 |
);
|
|
|
4c79b5 |
confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields($s_hidden_fields));
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
break;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
case 'remind':
|
|
|
4c79b5 |
if (empty($config['email_enable']))
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
trigger_error($user->lang['EMAIL_DISABLED'] . adm_back_link($this->u_action), E_USER_WARNING);
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$sql = 'SELECT user_id, username, user_email, user_lang, user_jabber, user_notify_type, user_regdate, user_actkey
|
|
|
4c79b5 |
FROM ' . USERS_TABLE . '
|
|
|
4c79b5 |
WHERE ' . $db->sql_in_set('user_id', $mark);
|
|
|
4c79b5 |
$result = $db->sql_query($sql);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
if ($row = $db->sql_fetchrow($result))
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
// Send the messages
|
|
|
4c79b5 |
include_once($phpbb_root_path . 'includes/functions_messenger.' . $phpEx);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$messenger = new messenger();
|
|
|
4c79b5 |
$usernames = array();
|
|
|
4c79b5 |
|
|
|
4c79b5 |
do
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$messenger->template('user_remind_inactive', $row['user_lang']);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$messenger->to($row['user_email'], $row['username']);
|
|
|
4c79b5 |
$messenger->im($row['user_jabber'], $row['username']);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$messenger->assign_vars(array(
|
|
|
4c79b5 |
'USERNAME' => htmlspecialchars_decode($row['username']),
|
|
|
4c79b5 |
'REGISTER_DATE' => $user->format_date($row['user_regdate']),
|
|
|
4c79b5 |
'U_ACTIVATE' => generate_board_url() . "/ucp.$phpEx?mode=activate&u=" . $row['user_id'] . '&k=' . $row['user_actkey'])
|
|
|
4c79b5 |
);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$messenger->send($row['user_notify_type']);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$usernames[] = $row['username'];
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
while ($row = $db->sql_fetchrow($result));
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$messenger->save_queue();
|
|
|
4c79b5 |
|
|
|
4c79b5 |
add_log('admin', 'LOG_INACTIVE_REMIND', implode(', ', $usernames));
|
|
|
4c79b5 |
unset($usernames);
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
$db->sql_freeresult($result);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
break;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
// Sorting
|
|
|
4c79b5 |
$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']);
|
|
|
4c79b5 |
$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']);
|
|
|
4c79b5 |
$sort_by_sql = array('i' => 'user_inactive_time', 'j' => 'user_regdate', 'l' => 'user_lastvisit', 'r' => 'user_inactive_reason', 'u' => 'username_clean');
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$s_limit_days = $s_sort_key = $s_sort_dir = $u_sort_param = '';
|
|
|
4c79b5 |
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);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
// Define where and sort sql for use in displaying logs
|
|
|
4c79b5 |
$sql_where = ($sort_days) ? (time() - ($sort_days * 86400)) : 0;
|
|
|
4c79b5 |
$sql_sort = $sort_by_sql[$sort_key] . ' ' . (($sort_dir == 'd') ? 'DESC' : 'ASC');
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$inactive = array();
|
|
|
4c79b5 |
$inactive_count = 0;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$start = view_inactive_users($inactive, $inactive_count, $config['topics_per_page'], $start, $sql_where, $sql_sort);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
foreach ($inactive as $row)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$template->assign_block_vars('inactive', array(
|
|
|
4c79b5 |
'INACTIVE_DATE' => $user->format_date($row['user_inactive_time']),
|
|
|
4c79b5 |
'JOINED' => $user->format_date($row['user_regdate']),
|
|
|
4c79b5 |
'LAST_VISIT' => (!$row['user_lastvisit']) ? ' - ' : $user->format_date($row['user_lastvisit']),
|
|
|
4c79b5 |
'REASON' => $row['inactive_reason'],
|
|
|
4c79b5 |
'USER_ID' => $row['user_id'],
|
|
|
4c79b5 |
'USERNAME' => $row['username'],
|
|
|
4c79b5 |
'U_USER_ADMIN' => append_sid("{$phpbb_admin_path}index.$phpEx", "i=users&mode=overview&u={$row['user_id']}"))
|
|
|
4c79b5 |
);
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$option_ary = array('activate' => 'ACTIVATE', 'delete' => 'DELETE');
|
|
|
4c79b5 |
if ($config['email_enable'])
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$option_ary += array('remind' => 'REMIND');
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$template->assign_vars(array(
|
|
|
4c79b5 |
'S_INACTIVE_USERS' => true,
|
|
|
4c79b5 |
'S_INACTIVE_OPTIONS' => build_select($option_ary),
|
|
|
4c79b5 |
|
|
|
4c79b5 |
'S_LIMIT_DAYS' => $s_limit_days,
|
|
|
4c79b5 |
'S_SORT_KEY' => $s_sort_key,
|
|
|
4c79b5 |
'S_SORT_DIR' => $s_sort_dir,
|
|
|
4c79b5 |
'S_ON_PAGE' => on_page($inactive_count, $config['topics_per_page'], $start),
|
|
|
4c79b5 |
'PAGINATION' => generate_pagination($this->u_action . "&$u_sort_param", $inactive_count, $config['topics_per_page'], $start, true),
|
|
|
4c79b5 |
|
|
|
4c79b5 |
'U_ACTION' => $this->u_action . '&start=' . $start,
|
|
|
4c79b5 |
));
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$this->tpl_name = 'acp_inactive';
|
|
|
4c79b5 |
$this->page_title = 'ACP_INACTIVE_USERS';
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
?>
|