########################################################################################################################### ## MOD Title: Auto Edit ## MOD Version: 1.0.11 ## MOD Author: Logeen [www.kurshtml.edu.pl] ## MOD Description: Nie pozwala zalogowanym uzytkownikom, ktorzy nie maja rangi "Administrator" ani "Moderator", pisac kilku postow pod rzad w tym samym temacie. Kolejny post jest automatycznie dopisywany do poprzedniego z podaniem godziny/daty edycji oraz zmiana daty istniejacego postu na aktualna. ## Installation Level: easy ## Installation Time: 3-5 Minutes ## ## Files To Edit: 3 ## viewforum.php ## includes/functions_admin.php ## includes/functions_post.php ## ########################################################################################################################### # #-----[ OPEN ]-------------------------------- # viewforum.php # #-----[ FIND ]-------------------------------- # ORDER BY t.topic_last_post_id DESC "; # #-----[ REPLACE WITH ]-------------------------------- # ORDER BY p.post_time DESC "; # #-----[ FIND ]-------------------------------- # ORDER BY t.topic_type DESC, t.topic_last_post_id DESC # #-----[ REPLACE WITH ]-------------------------------- # ORDER BY t.topic_type DESC, p2.post_time DESC # #-----[ OPEN ]-------------------------------- # includes/functions_admin.php # #-----[ FIND ]-------------------------------- # case 'forum': $sql = "SELECT MAX(post_id) AS last_post, COUNT(post_id) AS total FROM " . POSTS_TABLE . " WHERE forum_id = $id"; if ( !($result = $db->sql_query($sql)) ) { message_die(GENERAL_ERROR, 'Could not get post ID', '', __LINE__, __FILE__, $sql); } if ( $row = $db->sql_fetchrow($result) ) { $last_post = ( $row['last_post'] ) ? $row['last_post'] : 0; $total_posts = ($row['total']) ? $row['total'] : 0; } # #-----[ REPLACE WITH ]-------------------------------- # case 'forum': $sql = "SELECT post_id AS last_post FROM " . POSTS_TABLE . " WHERE forum_id = $id ORDER BY post_time DESC LIMIT 1"; if ( !($result = $db->sql_query($sql)) ) { message_die(GENERAL_ERROR, 'Could not get post ID', '', __LINE__, __FILE__, $sql); } $sql = "SELECT COUNT(post_id) AS total FROM " . POSTS_TABLE . " WHERE forum_id = $id"; if ( !($result2 = $db->sql_query($sql)) ) { message_die(GENERAL_ERROR, 'Could not get post ID', '', __LINE__, __FILE__, $sql); } if ( ($row = $db->sql_fetchrow($result)) && ($row2 = $db->sql_fetchrow($result2)) ) { $last_post = ( $row['last_post'] ) ? $row['last_post'] : 0; $total_posts = ($row2['total']) ? $row2['total'] : 0; } # #-----[ OPEN ]-------------------------------- # includes/functions_post.php # #-----[ FIND ]-------------------------------- function submit_post( # #-----[ BEFORE, ADD ]-------------------------------- # $auto_edit = false; # #-----[ FIND ]-------------------------------- # include($phpbb_root_path . 'includes/functions_search.'.$phpEx); $current_time = time(); # #-----[ AFTER, ADD ]-------------------------------- # ////////// AUTO EDIT global $auto_edit; $auto_edit = false; if ($mode == 'reply') { $sql = "SELECT p.post_id, p.poster_id, p.post_time, pt.post_text, pt.bbcode_uid FROM " . POSTS_TABLE . " AS p, " . POSTS_TEXT_TABLE . " AS pt WHERE p.post_id = pt.post_id AND p.topic_id = " . intval($topic_id) . " ORDER BY p.post_time DESC LIMIT 1"; $result = $db->sql_query($sql); $auto_edit_array = $db->sql_fetchrow($result); if ($userdata['user_id'] == $auto_edit_array['poster_id'] && $userdata['user_id'] != ANONYMOUS && $userdata['user_level'] != ADMIN && $userdata['user_level'] != MOD) { $auto_edit_bbcode_uid = $bbcode_uid; $post_id = $auto_edit_array['post_id']; $bbcode_uid = $auto_edit_array['bbcode_uid']; if (!preg_match('/\[color=red(:[^\]]*)?\]\[size=9(:[^\]]*)?\]---------- [0-9]{2}:[0-9]{2} [0-9]{2}\.[0-9]{2}\.[0-9]{4} ----------\[\/size(:[^\]]*)?\]\[\/color(:[^\]]*)?\]/i', $auto_edit_array['post_text'])) $auto_edit_array['post_text'] = '[color=red' . ($bbcode_uid ? ':'.$bbcode_uid : '') . '][size=9' . ($bbcode_uid ? ':'.$bbcode_uid : '') . ']---------- ' . create_date('H:i d.m.Y', $auto_edit_array['post_time'], $board_config['board_timezone']) . ' ----------[/size' . ($bbcode_uid ? ':'.$bbcode_uid : '') . '][/color' . ($bbcode_uid ? ':'.$bbcode_uid : '') . ']' . "\r\n\r\n" . $auto_edit_array['post_text']; $post_message = addslashes($auto_edit_array['post_text']) . "\r\n\r\n" . '[color=red' . ($bbcode_uid ? ':'.$bbcode_uid : '') . '][size=9' . ($bbcode_uid ? ':'.$bbcode_uid : '') . ']---------- ' . create_date('H:i' . (date('Y.m.d', $auto_edit_array['post_time']) != date('Y.m.d', $current_time) ? ' d.m.Y' : ''), $current_time, $board_config['board_timezone']) . ' ----------[/size' . ($bbcode_uid ? ':'.$bbcode_uid : '') . '][/color' . ($bbcode_uid ? ':'.$bbcode_uid : '') . ']' . "\r\n\r\n" . str_replace(':'.$auto_edit_bbcode_uid, ':'.$bbcode_uid, $post_message); $mode = 'editpost'; $auto_edit = true; } } ////////// # #-----[ FIND ]-------------------------------- # "UPDATE " . POSTS_TABLE . " SET # #-----[ AFTER, ADD ]-------------------------------- # " . ($auto_edit ? " post_time = $current_time," : "") . " # #-----[ FIND ]-------------------------------- # function update_post_stats(&$mode, &$post_data, &$forum_id, &$topic_id, &$post_id, &$user_id) { global $db; # #-----[ REPLACE WITH ]-------------------------------- # function update_post_stats(&$mode, &$post_data, &$forum_id, &$topic_id, &$post_id, &$user_id) { global $db, $auto_edit; # #-----[ FIND ]-------------------------------- # $sql = "SELECT MAX(post_id) AS last_post_id FROM " . POSTS_TABLE . " WHERE forum_id = $forum_id"; # #-----[ REPLACE WITH ]-------------------------------- # $sql = "SELECT post_id AS last_post_id FROM " . POSTS_TABLE . " WHERE forum_id = $forum_id ORDER BY post_time DESC LIMIT 1"; # #-----[ FIND ]-------------------------------- # $forum_update_sql .= ", forum_last_post_id = $post_id" . (($mode == 'newtopic') ? ", forum_topics = forum_topics $sign" : ""); $topic_update_sql = "topic_last_post_id = $post_id" . (($mode == 'reply') ? ", topic_replies = topic_replies $sign" : ", topic_first_post_id = $post_id"); # #-----[ REPLACE WITH ]-------------------------------- # if ($auto_edit) $forum_update_sql = "forum_last_post_id = $post_id"; else { $forum_update_sql .= ", forum_last_post_id = $post_id" . (($mode == 'newtopic') ? ", forum_topics = forum_topics $sign" : ""); $topic_update_sql = "topic_last_post_id = $post_id" . (($mode == 'reply') ? ", topic_replies = topic_replies $sign" : ", topic_first_post_id = $post_id"); } # #-----[ FIND ]-------------------------------- # if ($mode != 'poll_delete') { $sql = "UPDATE " . USERS_TABLE . " SET user_posts = user_posts $sign WHERE user_id = $user_id"; # #-----[ REPLACE WITH ]-------------------------------- # if ($mode != 'poll_delete' && !$auto_edit) { $sql = "UPDATE " . USERS_TABLE . " SET user_posts = user_posts $sign WHERE user_id = $user_id"; # #-----[ SAVE/CLOSE ALL FILES ]------------------------------------------ # # EoM