diff options
Diffstat (limited to 'phpBB/includes/acp')
-rwxr-xr-x | phpBB/includes/acp/acp_inactive.php | 195 | ||||
-rw-r--r-- | phpBB/includes/acp/acp_main.php | 133 | ||||
-rw-r--r-- | phpBB/includes/acp/acp_prune.php | 2 | ||||
-rw-r--r-- | phpBB/includes/acp/acp_users.php | 4 | ||||
-rwxr-xr-x | phpBB/includes/acp/info/acp_inactive.php | 37 |
5 files changed, 244 insertions, 127 deletions
diff --git a/phpBB/includes/acp/acp_inactive.php b/phpBB/includes/acp/acp_inactive.php new file mode 100755 index 0000000000..ebadb8446d --- /dev/null +++ b/phpBB/includes/acp/acp_inactive.php @@ -0,0 +1,195 @@ +<?php +/** +* +* @package acp +* @version $Id$ +* @copyright (c) 2006 phpBB Group +* @license http://opensource.org/licenses/gpl-license.php GNU Public License +* +*/ + +/** +* @package acp +*/ +class acp_inactive +{ + var $u_action; + var $p_master; + + function acp_inactive(&$p_master) + { + $this->p_master = &$p_master; + } + + function main($id, $mode) + { + global $config, $db, $user, $auth, $template; + global $phpbb_root_path, $phpbb_admin_path, $phpEx, $table_prefix; + + $action = request_var('action', ''); + $mark = (isset($_REQUEST['mark'])) ? request_var('mark', array(0)) : array(); + $start = request_var('start', 0); + + // Sort keys + $sort_days = request_var('st', 0); + $sort_key = request_var('sk', 'i'); + $sort_dir = request_var('sd', 'd'); + + if (sizeof($mark)) + { + switch ($action) + { + case 'activate': + case 'delete': + $sql = 'SELECT username + FROM ' . USERS_TABLE . ' + WHERE ' . $db->sql_in_set('user_id', $mark); + $result = $db->sql_query($sql); + + $user_affected = array(); + while ($row = $db->sql_fetchrow($result)) + { + $user_affected[] = $row['username']; + } + $db->sql_freeresult($result); + + if ($action == 'activate') + { + include_once($phpbb_root_path . 'includes/functions_user.' . $phpEx); + + foreach ($mark as $user_id) + { + user_active_flip($user_id, USER_INACTIVE); + } + + set_config('num_users', $config['num_users'] + sizeof($mark), true); + + // Update latest username + update_last_username(); + } + else if ($action == 'delete') + { + if (!$auth->acl_get('a_userdel')) + { + trigger_error($user->lang['NO_ADMIN'], E_USER_WARNING); + } + + $sql = 'DELETE FROM ' . USER_GROUP_TABLE . ' WHERE ' . $db->sql_in_set('user_id', $mark); + $db->sql_query($sql); + $sql = 'DELETE FROM ' . USERS_TABLE . ' WHERE ' . $db->sql_in_set('user_id', $mark); + $db->sql_query($sql); + + add_log('admin', 'LOG_INACTIVE_' . strtoupper($action), implode(', ', $user_affected)); + } + + break; + + case 'remind': + if (empty($config['email_enable'])) + { + trigger_error($user->lang['EMAIL_DISABLED'], E_USER_WARNING); + } + + $sql = 'SELECT user_id, username, user_email, user_lang, user_jabber, user_notify_type, user_regdate, user_actkey + FROM ' . USERS_TABLE . ' + WHERE ' . $db->sql_in_set('user_id', $mark); + $result = $db->sql_query($sql); + + if ($row = $db->sql_fetchrow($result)) + { + // Send the messages + include_once($phpbb_root_path . 'includes/functions_messenger.'.$phpEx); + + $messenger = new messenger(); + + $board_url = generate_board_url() . "/ucp.$phpEx?mode=activate"; + $sig = str_replace('<br />', "\n", "-- \n" . $config['board_email_sig']); + + $usernames = array(); + do + { + $messenger->template('user_remind_inactive', $row['user_lang']); + + $messenger->replyto($config['board_email']); + $messenger->to($row['user_email'], $row['username']); + $messenger->im($row['user_jabber'], $row['username']); + + $messenger->assign_vars(array( + 'EMAIL_SIG' => $sig, + 'USERNAME' => html_entity_decode($row['username']), + 'SITENAME' => $config['sitename'], + 'REGISTER_DATE' => $user->format_date($row['user_regdate']), + + 'U_ACTIVATE' => "$board_url&mode=activate&u=" . $row['user_id'] . '&k=' . $row['user_actkey']) + ); + + $messenger->send($row['user_notify_type']); + + $usernames[] = $row['username']; + } + while ($row = $db->sql_fetchrow($result)); + + $messenger->save_queue(); + + add_log('admin', 'LOG_INACTIVE_REMIND', implode(', ', $usernames)); + unset($usernames); + } + $db->sql_freeresult($result); + + break; + } + } + + // Sorting + $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']); + $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']); + $sort_by_sql = array('i' => 'user_inactive_time', 'j' => 'user_regdate', 'l' => 'user_lastvisit', 'r' => 'user_inactive_reason', 'u' => 'username'); + + $s_limit_days = $s_sort_key = $s_sort_dir = $u_sort_param = ''; + 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); + + // Define where and sort sql for use in displaying logs + $sql_where = ($sort_days) ? (time() - ($sort_days * 86400)) : 0; + $sql_sort = $sort_by_sql[$sort_key] . ' ' . (($sort_dir == 'd') ? 'DESC' : 'ASC'); + + $inactive = array(); + $inactive_count = 0; + + view_inactive_users($inactive, $inactive_count, $config['topics_per_page'], $start, $sql_where, $sql_sort); + + foreach ($inactive as $row) + { + $template->assign_block_vars('inactive', array( + 'INACTIVE_DATE' => $user->format_date($row['user_inactive_time']), + 'JOINED' => $user->format_date($row['user_regdate']), + 'LAST_VISIT' => (!$row['user_lastvisit']) ? ' - ' : $user->format_date($row['user_lastvisit']), + 'REASON' => $row['inactive_reason'], + 'USER_ID' => $row['user_id'], + 'USERNAME' => $row['username'], + 'U_USER_ADMIN' => append_sid("{$phpbb_admin_path}index.$phpEx", "i=users&mode=overview&u={$row['user_id']}")) + ); + } + + $option_ary = array('activate' => 'ACTIVATE', 'delete' => 'DELETE'); + if ($config['email_enable']) + { + $option_ary += array('remind' => 'REMIND'); + } + + $template->assign_vars(array( + 'S_INACTIVE_USERS' => true, + 'S_INACTIVE_OPTIONS' => build_select($option_ary), + + 'S_LIMIT_DAYS' => $s_limit_days, + 'S_SORT_KEY' => $s_sort_key, + 'S_SORT_DIR' => $s_sort_dir, + 'S_ON_PAGE' => on_page($inactive_count, $config['topics_per_page'], $start), + 'PAGINATION' => generate_pagination($this->u_action . "&$u_sort_param", $inactive_count, $config['topics_per_page'], $start, true), + )); + + $this->tpl_name = 'acp_inactive'; + $this->page_title = 'ACP_INACTIVE_USERS'; + } +} + +?>
\ No newline at end of file diff --git a/phpBB/includes/acp/acp_main.php b/phpBB/includes/acp/acp_main.php index b0c12c7928..cefb80badc 100644 --- a/phpBB/includes/acp/acp_main.php +++ b/phpBB/includes/acp/acp_main.php @@ -50,123 +50,6 @@ class acp_main } $action = request_var('action', ''); - $mark = (isset($_REQUEST['mark'])) ? request_var('mark', array(0)) : array(); - - if (sizeof($mark)) - { - switch ($action) - { - case 'activate': - case 'delete': - - if (!$auth->acl_get('a_user')) - { - trigger_error($user->lang['NO_ADMIN'], E_USER_WARNING); - } - - $sql = 'SELECT username - FROM ' . USERS_TABLE . ' - WHERE ' . $db->sql_in_set('user_id', $mark); - $result = $db->sql_query($sql); - - $user_affected = array(); - while ($row = $db->sql_fetchrow($result)) - { - $user_affected[] = $row['username']; - } - $db->sql_freeresult($result); - - if ($action == 'activate') - { - include_once($phpbb_root_path . 'includes/functions_user.' . $phpEx); - - foreach ($mark as $user_id) - { - user_active_flip($user_id, USER_INACTIVE); - } - - set_config('num_users', $config['num_users'] + sizeof($mark), true); - - // Update latest username - update_last_username(); - } - else if ($action == 'delete') - { - if (!$auth->acl_get('a_userdel')) - { - trigger_error($user->lang['NO_ADMIN'], E_USER_WARNING); - } - - $sql = 'DELETE FROM ' . USER_GROUP_TABLE . ' WHERE ' . $db->sql_in_set('user_id', $mark); - $db->sql_query($sql); - $sql = 'DELETE FROM ' . USERS_TABLE . ' WHERE ' . $db->sql_in_set('user_id', $mark); - $db->sql_query($sql); - - add_log('admin', 'LOG_INDEX_' . strtoupper($action), implode(', ', $user_affected)); - } - - break; - - case 'remind': - if (!$auth->acl_get('a_user')) - { - trigger_error($user->lang['NO_ADMIN'], E_USER_WARNING); - } - - if (empty($config['email_enable'])) - { - trigger_error($user->lang['EMAIL_DISABLED'], E_USER_WARNING); - } - - $sql = 'SELECT user_id, username, user_email, user_lang, user_jabber, user_notify_type, user_regdate, user_actkey - FROM ' . USERS_TABLE . ' - WHERE ' . $db->sql_in_set('user_id', $mark); - $result = $db->sql_query($sql); - - if ($row = $db->sql_fetchrow($result)) - { - // Send the messages - include_once($phpbb_root_path . 'includes/functions_messenger.'.$phpEx); - - $messenger = new messenger(); - - $board_url = generate_board_url() . "/ucp.$phpEx?mode=activate"; - $sig = str_replace('<br />', "\n", "-- \n" . $config['board_email_sig']); - - $usernames = array(); - do - { - $messenger->template('user_remind_inactive', $row['user_lang']); - - $messenger->replyto($config['board_email']); - $messenger->to($row['user_email'], $row['username']); - $messenger->im($row['user_jabber'], $row['username']); - - $messenger->assign_vars(array( - 'EMAIL_SIG' => $sig, - 'USERNAME' => html_entity_decode($row['username']), - 'SITENAME' => $config['sitename'], - 'REGISTER_DATE' => $user->format_date($row['user_regdate']), - - 'U_ACTIVATE' => "$board_url&mode=activate&u=" . $row['user_id'] . '&k=' . $row['user_actkey']) - ); - - $messenger->send($row['user_notify_type']); - - $usernames[] = $row['username']; - } - while ($row = $db->sql_fetchrow($result)); - - $messenger->save_queue(); - - add_log('admin', 'LOG_INDEX_REMIND', implode(', ', $usernames)); - unset($usernames); - } - $db->sql_freeresult($result); - - break; - } - } switch ($action) { @@ -443,6 +326,7 @@ class acp_main 'U_ACTION' => append_sid("{$phpbb_admin_path}index.$phpEx"), 'U_ADMIN_LOG' => append_sid("{$phpbb_admin_path}index.$phpEx", 'i=logs&mode=admin'), + 'U_INACTIVE_USERS' => append_sid("{$phpbb_admin_path}index.$phpEx", 'i=inactive&mode=list'), 'S_ACTION_OPTIONS' => ($auth->acl_get('a_board')) ? $s_action_options : '', ) @@ -468,17 +352,18 @@ class acp_main if ($auth->acl_get('a_user')) { - $sql = 'SELECT user_id, username, user_regdate, user_lastvisit - FROM ' . USERS_TABLE . ' - WHERE user_type = ' . USER_INACTIVE . ' - ORDER BY user_regdate ASC'; - $result = $db->sql_query($sql); + $inactive = array(); + $inactive_count = 0; + + view_inactive_users($inactive, $inactive_count, 10); - while ($row = $db->sql_fetchrow($result)) + foreach ($inactive as $row) { $template->assign_block_vars('inactive', array( - 'DATE' => $user->format_date($row['user_regdate']), + 'INACTIVE_DATE' => $user->format_date($row['user_inactive_time']), + 'JOINED' => $user->format_date($row['user_regdate']), 'LAST_VISIT' => (!$row['user_lastvisit']) ? ' - ' : $user->format_date($row['user_lastvisit']), + 'REASON' => $row['inactive_reason'], 'USER_ID' => $row['user_id'], 'USERNAME' => $row['username'], 'U_USER_ADMIN' => append_sid("{$phpbb_admin_path}index.$phpEx", "i=users&mode=overview&u={$row['user_id']}")) diff --git a/phpBB/includes/acp/acp_prune.php b/phpBB/includes/acp/acp_prune.php index 0214a252d0..7c789e4773 100644 --- a/phpBB/includes/acp/acp_prune.php +++ b/phpBB/includes/acp/acp_prune.php @@ -269,7 +269,7 @@ class acp_prune { foreach ($user_ids as $user_id) { - user_active_flip($user_id, USER_NORMAL, false, false, true); + user_active_flip($user_id, USER_NORMAL, false, false, INACTIVE_MANUAL, true); } $l_log = 'LOG_PRUNE_USER_DEAC'; diff --git a/phpBB/includes/acp/acp_users.php b/phpBB/includes/acp/acp_users.php index cc5c1ffa78..87c9fc4edc 100644 --- a/phpBB/includes/acp/acp_users.php +++ b/phpBB/includes/acp/acp_users.php @@ -269,7 +269,7 @@ class acp_users if ($user_row['user_type'] != USER_INACTIVE) { - user_active_flip($user_id, $user_row['user_type'], $user_actkey, $user_row['username']); + user_active_flip($user_id, $user_row['user_type'], $user_actkey, $user_row['username'], INACTIVE_MANUAL); } $messenger = new messenger(false); @@ -311,7 +311,7 @@ class acp_users trigger_error($user->lang['CANNOT_DEACTIVATE_YOURSELF'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); } - user_active_flip($user_id, $user_row['user_type'], false, $user_row['username']); + user_active_flip($user_id, $user_row['user_type'], false, $user_row['username'], INACTIVE_MANUAL); $message = ($user_row['user_type'] == USER_INACTIVE) ? 'USER_ADMIN_ACTIVATED' : 'USER_ADMIN_DEACTIVED'; $log = ($user_row['user_type'] == USER_INACTIVE) ? 'LOG_USER_ACTIVE' : 'LOG_USER_INACTIVE'; diff --git a/phpBB/includes/acp/info/acp_inactive.php b/phpBB/includes/acp/info/acp_inactive.php new file mode 100755 index 0000000000..bee9d977d4 --- /dev/null +++ b/phpBB/includes/acp/info/acp_inactive.php @@ -0,0 +1,37 @@ +<?php +/** +* +* @package acp +* @version $Id$ +* @copyright (c) 2006 phpBB Group +* @license http://opensource.org/licenses/gpl-license.php GNU Public License +* +*/ + +/** +* @package module_install +*/ +class acp_inactive_info +{ + function module() + { + return array( + 'filename' => 'acp_inactive', + 'title' => 'ACP_INACTIVE_USERS', + 'version' => '1.0.0', + 'modes' => array( + 'list' => array('title' => 'ACP_INACTIVE_USERS', 'auth' => 'acl_a_user', 'cat' => array('ACP_CAT_USERS')), + ), + ); + } + + function install() + { + } + + function uninstall() + { + } +} + +?>
\ No newline at end of file |