Blame Identity/Webenv/phpBB/3.0.4/includes/acp/acp_inactive.php

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