############################################################## ## MOD Title: Last Post by User in Memberlist ## MOD Author: alexi02 < N/A > (Alejandro Iannuzzi) http://www.uzzisoft.com ## MOD Description: In the memberlist it shows the last time each user posted ## MOD Version: 0.1.0 ## ## Installation Level: Easy ## Installation Time: 5 Minutes ## Files To Edit: memberlist.php ## language/lang_english/lang_main.php ## templates/subSilver/memberlist_body.tpl ## Included Files: N/A ## ## License: http://opensource.org/licenses/gpl-license.php GNU General Public License v2 ############################################################## ## For security purposes, please check: http://www.phpbb.com/mods/ ## for the latest version of this MOD. Although MODs are checked ## before being allowed in the MODs Database there is no guarantee ## that there are no security problems within the MOD. No support ## will be given for MODs not found within the MODs Database which ## can be found at http://www.phpbb.com/mods/ ############################################################## ## Author Notes: ## ## A quick way to see the user's last post time in the memberlist. ## ############################################################## ## MOD History: ## ## 2007-02-04 - Version 0.1.0 ## - Initial Release (for phpBB 2.0.22) ## ############################################################## ## Before Adding This MOD To Your Forum, You Should Back Up All Files Related To This MOD ############################################################## # #-----[ SQL ]------------------------------------------ # Change phpbb_users to your tables # ALTER TABLE `phpbb_users` ADD `last_post` INT( 11 ) NOT NULL DEFAULT '0'; # #-----[ OPEN ]------------------------------------------ # memberlist.php # #-----[ FIND ]------------------------------------------ # $mode_types_text = array($lang['Sort_Joined'], $lang['Sort_Username'], $lang['Sort_Location'], $lang['Sort_Posts'], $lang['Sort_Email'], $lang['Sort_Website'], $lang['Sort_Top_Ten']); # #-----[ IN-LINE FIND ]------------------------------------------ # $lang['Sort_Posts'], # #-----[ IN-LINE AFTER, ADD ]------------------------------------------ # $lang['Last_post'], # #-----[ FIND ]------------------------------------------ # $mode_types = array('joined', 'username', 'location', 'posts', 'email', 'website', 'topten'); # #-----[ IN-LINE FIND ]------------------------------------------ # 'posts', # #-----[ IN-LINE AFTER, ADD ]------------------------------------------ # 'lastpost', # #-----[ FIND ]------------------------------------------ # 'L_POSTS' => $lang['Posts'], # #-----[ AFTER, ADD ]------------------------------------------ # 'L_LASTPOST' => $lang['Last_post'], # #-----[ FIND ]------------------------------------------ # case 'email': # #-----[ BEFORE, ADD ]------------------------------------------ # case 'lastpost': $order_by = "last_post $sort_order LIMIT $start, " . $board_config['topics_per_page']; break; # #-----[ FIND ]------------------------------------------ # default: $order_by = "user_regdate $sort_order LIMIT $start, " . $board_config['topics_per_page']; break; } # #-----[ AFTER, ADD ]------------------------------------------ # // // Start Last Post by User in Memberlist Mod // // Sync last posts with users in users table // Inefficient I know $sql = "SELECT user_id FROM " . USERS_TABLE; if( !($result = $db->sql_query($sql)) ) { message_die(GENERAL_ERROR, 'Could not query users', '', __LINE__, __FILE__, $sql); } if ( $row = $db->sql_fetchrow($result) ) { $i = 0; do { $user_id = $row['user_id']; // Posts SQL $sql = "SELECT post_time FROM " . POSTS_TABLE . " WHERE poster_id = " . $user_id . " ORDER BY post_time DESC LIMIT 0, 1"; if ( !($result_lastpost = $db->sql_query($sql)) ) { message_die(GENERAL_ERROR, "Could not obtain post information", '', __LINE__, __FILE__, $sql); } $post_row = $db->sql_fetchrow($result_lastpost); $db->sql_freeresult($result_lastpost); // If the user has posts to their id if ($post_row) { // Update Users Last Post in users table $update_sql = "UPDATE " . USERS_TABLE . " SET last_post = " . $post_row['post_time'] . " WHERE user_id = " . $user_id; if ( !($result_update = $db->sql_query($update_sql)) ) { message_die(GENERAL_ERROR, 'Could not update users table', '', __LINE__, __FILE__, $update_sql); } } $i++; } while ( $row = $db->sql_fetchrow($result) ); $db->sql_freeresult($result); } // // End Last Post by User in Memberlist Mod // # #-----[ FIND ]------------------------------------------ # $sql = "SELECT username, user_id, user_viewemail, user_posts, user_regdate, user_from, user_website, user_email, user_icq, user_aim, user_yim, user_msnm, user_avatar, user_avatar_type, user_allowavatar FROM " . USERS_TABLE . " WHERE user_id <> " . ANONYMOUS . " ORDER BY $order_by"; # #-----[ IN-LINE FIND ]------------------------------------------ # user_allowavatar # #-----[ IN-LINE AFTER, ADD ]------------------------------------------ # , last_post # #-----[ FIND ]------------------------------------------ # $search = '' . sprintf($lang['Search_user_posts'], $username) . ''; # #-----[ AFTER, ADD ]------------------------------------------ # // // Start Last Post by User in Memberlist Mod // if ( !empty($row['last_post']) ) { $last_post_date = create_date($board_config['default_dateformat'], $row['last_post'], $board_config['board_timezone']); } else { $last_post_date = ''; } // // End Last Post by User in Memberlist Mod // # #-----[ FIND ]------------------------------------------ # 'POSTS' => $posts, # #-----[ AFTER, ADD ]------------------------------------------ # 'LASTPOST' => $last_post_date, # #-----[ OPEN ]------------------------------------------ # language/lang_english/lang_main.php # #-----[ FIND ]------------------------------------------ # ?> # #-----[ BEFORE, ADD ]------------------------------------------ # $lang['Last_post'] = 'Last Post'; // Last Post by User in Memberlist Mod # #-----[ OPEN ]------------------------------------------ # templates/subSilver/memberlist_body.tpl # #-----[ FIND ]------------------------------------------ # {L_POSTS} # #-----[ AFTER, ADD ]------------------------------------------ # {L_LASTPOST} # #-----[ FIND ]------------------------------------------ # {memberrow.POSTS} # #-----[ AFTER, ADD ]------------------------------------------ # {memberrow.LASTPOST} # #-----[ FIND ]------------------------------------- #   # #-----[ INCREMENT ]------------------------------------- # %:1 # #-----[ SAVE/CLOSE ALL FILES ]------------------------------------------ # # EoM