|
From: Paul S. O. <ps...@us...> - 2002-03-17 14:07:47
|
Update of /cvsroot/phpbb/phpBB2/includes
In directory usw-pr-cvs1:/tmp/cvs-serv28805/includes
Modified Files:
functions_post.php functions_search.php
Log Message:
Various updates
Index: functions_post.php
===================================================================
RCS file: /cvsroot/phpbb/phpBB2/includes/functions_post.php,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** functions_post.php 10 Mar 2002 00:27:24 -0000 1.1
--- functions_post.php 17 Mar 2002 14:07:43 -0000 1.2
***************
*** 253,256 ****
--- 253,260 ----
}
}
+ else if ( $mode == 'editpost' )
+ {
+ $result = remove_search_post($post_id);
+ }
if ( $mode == 'newtopic' || ( $mode == 'editpost' && $post_data['first_post'] ) )
***************
*** 287,300 ****
}
- if ( $mode == 'editpost' )
- {
- $sql = "DELETE FROM " . SEARCH_MATCH_TABLE . "
- WHERE post_id = $post_id";
- if ( !($db->sql_query($sql)) )
- {
- message_die(GENERAL_ERROR, 'Error in deleting post', '', __LINE__, __FILE__, $sql);
- }
- }
-
add_search_words($post_id, stripslashes($post_message), stripslashes($post_subject));
--- 291,294 ----
***************
*** 368,376 ****
}
- if ( $mode == 'editpost' )
- {
- remove_unmatched_words();
- }
-
$meta = '<meta http-equiv="refresh" content="3;url=' . append_sid("viewtopic.$phpEx?" . POST_POST_URL . "=" . $post_id) . '#' . $post_id . '">';
$message = $lang['Stored'] . '<br /><br />' . sprintf($lang['Click_view_message'], '<a href="' . append_sid("viewtopic.$phpEx?" . POST_POST_URL . "=" . $post_id) . '#' . $post_id . '">', '</a>') . '<br /><br />' . sprintf($lang['Click_return_forum'], '<a href="' . append_sid("viewforum.$phpEx?" . POST_FORUM_URL . "=$forum_id") . '">', '</a>');
--- 362,365 ----
***************
*** 382,386 ****
// Update post stats and details
//
! function update_post_stats($mode, &$post_data, &$forum_id, &$topic_id, &$post_id)
{
global $db, $userdata;
--- 371,375 ----
// Update post stats and details
//
! function update_post_stats(&$mode, &$post_data, &$forum_id, &$topic_id, &$post_id)
{
global $db, $userdata;
***************
*** 448,452 ****
else if ( $mode != 'poll_delete' )
{
! $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" );
}
--- 437,441 ----
else if ( $mode != 'poll_delete' )
{
! $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" );
}
Index: functions_search.php
===================================================================
RCS file: /cvsroot/phpbb/phpBB2/includes/functions_search.php,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** functions_search.php 10 Mar 2002 00:27:24 -0000 1.1
--- functions_search.php 17 Mar 2002 14:07:43 -0000 1.2
***************
*** 348,381 ****
}
! function remove_unmatched_words()
{
global $db;
! switch(SQL_LAYER)
{
case 'mysql':
case 'mysql4':
! $sql = "SELECT w.word_id
! FROM " . SEARCH_WORD_TABLE . " w
! LEFT JOIN " . SEARCH_MATCH_TABLE . " m ON m.word_id = w.word_id
! WHERE m.word_id IS NULL";
! if( $result = $db->sql_query($sql) )
{
! $word_id_sql = "";
while( $row = $db->sql_fetchrow($result) )
{
! $word_id_sql .= ( $word_id_sql != "" ) ? ", " . $row['word_id'] : $row['word_id'];
}
! if( $word_id_sql != "" )
{
! $sql = "DELETE FROM " . SEARCH_WORD_TABLE . "
! WHERE word_id IN ($word_id_sql)";
! if( !($result = $db->sql_query($sql, END_TRANSACTION)) )
{
! message_die(GENERAL_ERROR, "Couldn't delete word list entry", "", __LINE__, __FILE__, $sql);
}
! return $db->sql_affectedrows();
}
}
--- 348,396 ----
}
! function remove_search_post($post_id)
{
global $db;
! $words_removed = false;
!
! switch( SQL_LAYER )
{
case 'mysql':
case 'mysql4':
! $sql = "SELECT word_id
! FROM " . SEARCH_MATCH_TABLE . "
! WHERE post_id = $post_id";
! if ( $result = $db->sql_query($sql) )
{
! $word_id_sql = '';
while( $row = $db->sql_fetchrow($result) )
{
! $word_id_sql .= ( $word_id_sql != '' ) ? ', ' . $row['word_id'] : $row['word_id'];
}
! $sql = "SELECT word_id
! FROM " . SEARCH_MATCH_TABLE . "
! WHERE word_id IN ($word_id_sql)
! GROUP BY word_id
! HAVING COUNT(word_id) = 1";
! if ( $result = $db->sql_query($sql) )
{
! $word_id_sql = '';
! while( $row = $db->sql_fetchrow($result) )
{
! $word_id_sql .= ( $word_id_sql != '' ) ? ', ' . $row['word_id'] : $row['word_id'];
}
! if ( $word_id_sql != '' )
! {
! $sql = "DELETE FROM " . SEARCH_WORD_TABLE . "
! WHERE word_id IN ($word_id_sql)";
! if ( !($result = $db->sql_query($sql, END_TRANSACTION)) )
! {
! message_die(GENERAL_ERROR, 'Could not delete word list entry', '', __LINE__, __FILE__, $sql);
! }
!
! $words_removed = $db->sql_affectedrows();
! }
}
}
***************
*** 384,402 ****
default:
$sql = "DELETE FROM " . SEARCH_WORD_TABLE . "
! WHERE word_id NOT IN (
! SELECT word_id
! FROM " . SEARCH_MATCH_TABLE . "
! GROUP BY word_id)";
! if( !($result = $db->sql_query($sql, END_TRANSACTION)) )
{
! message_die(GENERAL_ERROR, "Couldn't delete old words from word table", __LINE__, __FILE__, $sql);
}
! return $db->sql_affectedrows();
break;
}
! return 0;
}
--- 399,431 ----
default:
$sql = "DELETE FROM " . SEARCH_WORD_TABLE . "
! WHERE word_id IN (
! SELECT word_id
! FROM " . SEARCH_MATCH_TABLE . "
! WHERE word_id IN (
! SELECT word_id
! FROM " . SEARCH_MATCH_TABLE . "
! WHERE post_id = $post_id
! )
! GROUP BY word_id
! HAVING COUNT(word_id) = 1
! )";
! if ( !($result = $db->sql_query($sql, END_TRANSACTION)) )
{
! message_die(GENERAL_ERROR, 'Could not delete old words from word table', '', __LINE__, __FILE__, $sql);
}
! $words_removed = $db->sql_affectedrows();
break;
}
! $sql = "DELETE FROM " . SEARCH_MATCH_TABLE . "
! WHERE post_id = $post_id";
! if ( !($db->sql_query($sql)) )
! {
! message_die(GENERAL_ERROR, 'Error in deleting post', '', __LINE__, __FILE__, $sql);
! }
!
! return $words_removed;
}
|