################################################################# ## Mod Title: Enhanced Admin User Lookup ## Mod Version: 1.0.0 ## Author: Matthijs < phpbb@matthijs.net > - http://www.matthijs.net/ ## Description: This will replace the lookup of users in the ## admin panel with a more enhanced and user- ## friendly version. ## ## Installation Level: Easy ## Installation Time: 5 Minutes ## Files To Edit: templates/subSilver/admin/user_select_body.tpl, ## admin/admin_users.php, ## language/lang_english/lang_admin.php ## Included Files: templates/subSilver/admin/user_lookup_body.tpl ################################################################# ## Security Disclaimer: This MOD Cannot Be Posted To Or Added At Any Non-Official phpBB Sites ################################################################# ## ## Author Note: ## ## FEATURES in current version: ## - Wildcard username search ## - Wildcard email search ## - More than XX posts search ## - Joined after DATE search ## ## Results of the search are displayed with ## direct links to Edit User. ## If the search yields only one result, ## you're taken to Edit User immediately. ## ################################################################# ## Before Adding This MOD To Your Forum, You Should Back Up All Files Related To This MOD ################################################################# # #-----[ OPEN templates/subSilver/admin/user_select_body.tpl ]------- # # #-----[ REPLACE ALL CONTENTS WITH ]--------- #

{L_USER_TITLE}

{L_USER_EXPLAIN}

{L_USER_LOOKUP_EXPLAIN}

{L_LOOK_UP}
{L_USERNAME}
{L_EMAIL_ADDRESS}
{L_POSTS}
{L_JOINED}
{L_JOINED_EXPLAIN}
{S_HIDDEN_FIELDS}
# #-----[ CREATE templates/subSilver/admin/user_lookup_body.tpl ]---------- #

{L_USER_TITLE}

{L_USER_EXPLAIN}

 {L_USERNAME}   {L_EMAIL_ADDRESS}   {L_POSTS}   {L_JOINED}   {L_ACTIVE} 
{user_row.USERNAME} {user_row.EMAIL} {user_row.POSTS} {user_row.JOINED} {user_row.ACTIVE}
 

# #-----[ OPEN admin/admin_users.php ]-------------------- # # #-----[ FIND ]------------------------------------------ # if( !empty($setmodules) ) { $filename = basename(__FILE__); $module['Users']['Manage'] = $filename; return; } # #-----[ AFTER, ADD ]------------------------------------ # if ( isset($HTTP_POST_VARS['mode']) ) { if ( $HTTP_POST_VARS['mode'] == 'lookup' ) { $no_page_header = true; } } # #-----[ FIND ]------------------------------ # else { // // Default user selection box // # #-----[ BEFORE, ADD ]------------------------------ # else if ( $mode == 'lookup' ) { // // Lookup user // $username = ( !empty($HTTP_POST_VARS['username']) ) ? str_replace('%', '%%', trim(strip_tags( $HTTP_POST_VARS['username'] ) )) : ''; $email = ( !empty($HTTP_POST_VARS['email']) ) ? trim(strip_tags(htmlspecialchars( $HTTP_POST_VARS['email'] ) )) : ''; $posts = ( !empty($HTTP_POST_VARS['posts']) ) ? intval(trim(strip_tags( $HTTP_POST_VARS['posts'] ) )) : ''; $joined = ( !empty($HTTP_POST_VARS['joined']) ) ? trim(strtotime( $HTTP_POST_VARS['joined'] ) ) : 0; $sql_where = ( !empty($username) ) ? 'u.username LIKE "%' . str_replace("\'", "''", $username) . '%"' : ''; $sql_where .= ( !empty($email) ) ? ( ( !empty($sql_where) ) ? ' AND u.user_email LIKE "%' . $email . '%"' : 'u.user_email LIKE "%' . $email . '%"' ) : ''; $sql_where .= ( !empty($posts) ) ? ( ( !empty($sql_where) ) ? ' AND u.user_posts >= ' . $posts : 'u.user_posts >= ' . $posts ) : ''; $sql_where .= ( $joined ) ? ( ( !empty($sql_where) ) ? ' AND u.user_regdate >= ' . $joined : 'u.user_regdate >= ' . $joined ) : ''; if ( !empty($sql_where) ) { $sql = "SELECT u.user_id, u.username, u.user_email, u.user_posts, u.user_active, u.user_regdate FROM " . USERS_TABLE . " u WHERE $sql_where ORDER BY u.username ASC"; if ( !( $result = $db->sql_query($sql) ) ) { message_die(GENERAL_ERROR, 'Unable to query users', '', __LINE__, __FILE__, $sql); } else if ( !$db->sql_numrows($result) ) { $message = $lang['No_user_id_specified']; $message .= '

' . sprintf($lang['Click_return_useradmin'], '', '') . '

' . sprintf($lang['Click_return_admin_index'], '', ''); message_die(GENERAL_MESSAGE, $message); } else if ( $db->sql_numrows($result) == 1 ) { // Redirect to this user $row = $db->sql_fetchrow($result); $template->assign_vars(array( "META" => '') ); $message .= $lang['One_user_found']; $message .= '

' . sprintf($lang['Click_goto_user'], '', ''); message_die(GENERAL_MESSAGE, $message); } else { // Show select screen include('page_header_admin.'.$phpEx); $template->set_filenames(array( 'body' => 'admin/user_lookup_body.tpl') ); $template->assign_vars(array( 'L_USER_TITLE' => $lang['User_admin'], 'L_USER_EXPLAIN' => $lang['User_admin_explain'], 'L_ACTIVE' => $lang['User_status'], 'L_EMAIL_ADDRESS' => $lang['Email_address']) ); $i = 0; while ( $row = $db->sql_fetchrow($result) ) { $row_color = ( !($i % 2) ) ? $theme['td_color1'] : $theme['td_color2']; $row_class = ( !($i % 2) ) ? $theme['td_class1'] : $theme['td_class2']; $template->assign_block_vars('user_row', array( 'ROW_COLOR' => '#' . $row_color, 'ROW_CLASS' => $row_class, 'USERNAME' => $row['username'], 'EMAIL' => $row['user_email'], 'POSTS' => $row['user_posts'], 'ACTIVE' => ( $row['user_active'] ) ? $lang['Yes'] : $lang['No'], 'JOINED' => create_date($lang['DATE_FORMAT'], $row['user_regdate'], $board_config['board_timezone']), 'U_USERNAME' => append_sid("admin_users.$phpEx?mode=edit&" . POST_USERS_URL . "=" . $row['user_id'])) ); $i++; } $template->pparse('body'); } } else { $message = $lang['No_user_id_specified']; $message .= '

' . sprintf($lang['Click_return_useradmin'], '', '') . '

' . sprintf($lang['Click_return_admin_index'], '', ''); message_die(GENERAL_MESSAGE, $message); } } # #-----[ FIND ]------------------------------ # 'L_FIND_USERNAME' => $lang['Find_username'], # #-----[ AFTER, ADD ]------------------------ # 'L_USER_LOOKUP_EXPLAIN' => $lang['User_lookup_explain'], 'L_EMAIL_ADDRESS' => $lang['Email_address'], 'L_JOINED_EXPLAIN' => $lang['User_joined_explain'], # #-----[ OPEN language/lang_english/lang_admin.php ]------- # # #-----[ FIND ]------------------------------ # $lang['User_special_explain'] = "These fields are not able to be modified by the users. Here you can set their status and other options that are not given to users."; # #-----[ AFTER, ADD ]------------------------ # // Added for enhanced user management $lang['User_lookup_explain'] = "You can lookup users by specifying one or more of the criteria below. No wildcards are needed, they will be added automatically."; $lang['One_user_found'] = "Only one user was found, you're being taken to that user"; $lang['Click_goto_user'] = "Click %sHere%s to edit this users profile"; $lang['User_joined_explain'] = "The syntax used is identical to the PHP strtotime() function"; # #-----[ SAVE/CLOSE ALL FILES ]------------------------------------------ # # EoM