Handle deletion of search matches and words upon deletion of topic + removal of confirmation on lock/unlock

git-svn-id: file:///svn/phpbb/trunk@1439 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
Paul S. Owen 2001-11-25 00:21:07 +00:00
parent 015c2739bd
commit 5c2c27f40d

View file

@ -182,18 +182,6 @@ if( !$is_auth['auth_mod'] )
// End Auth Check // End Auth Check
// //
//
// Load page header
//
$page_title = $lang['Mod_CP'];
include($phpbb_root_path . 'includes/page_header.'.$phpEx);
$template->assign_vars(array(
"FORUM_NAME" => $forum_name,
"U_VIEW_FORUM" => append_sid("viewforum.$phpEx?" . POST_FORUM_URL . "=$forum_id"))
);
// //
// Do major work ... // Do major work ...
// //
@ -264,7 +252,7 @@ switch($mode)
message_die(GENERAL_ERROR, "Could not delete topics", "", __LINE__, __FILE__, $sql); message_die(GENERAL_ERROR, "Could not delete topics", "", __LINE__, __FILE__, $sql);
} }
if( $post_id_sql != '' ) if( $post_id_sql != "" )
{ {
$sql = "DELETE $sql = "DELETE
FROM " . POSTS_TABLE . " FROM " . POSTS_TABLE . "
@ -281,9 +269,116 @@ switch($mode)
{ {
message_die(GENERAL_ERROR, "Could not delete posts text", "", __LINE__, __FILE__, $sql); message_die(GENERAL_ERROR, "Could not delete posts text", "", __LINE__, __FILE__, $sql);
} }
$sql = "DELETE
FROM " . SEARCH_MATCH_TABLE . "
WHERE post_id IN ($post_id_sql)";
if( !$result = $db->sql_query($sql) )
{
message_die(GENERAL_ERROR, "Could not delete posts text", "", __LINE__, __FILE__, $sql);
} }
if( $vote_id_sql != '' ) //
// Delete unmatched words
//
switch(SQL_LAYER)
{
case 'postgresql':
$sql = "DELETE FROM " . SEARCH_WORD_TABLE . "
WHERE word_id NOT IN (
SELECT word_id
FROM " . SEARCH_MATCH_TABLE . "
GROUP BY word_id)";
$result = $db->sql_query($sql);
if( !$result )
{
message_die(GENERAL_ERROR, "Couldn't delete old words from word table", __LINE__, __FILE__, $sql);
}
$unmatched_count = $db->sql_affectedrows();
break;
case 'oracle':
$sql = "DELETE FROM " . SEARCH_WORD_TABLE . "
WHERE word_id IN (
SELECT w.word_id
FROM " . SEARCH_WORD_TABLE . " w, " . SEARCH_MATCH_TABLE . " m
WHERE w.word_id = m.word_id(+)
AND m.word_id IS NULL)";
$result = $db->sql_query($sql);
if( !$result )
{
message_die(GENERAL_ERROR, "Couldn't delete old words from word table", __LINE__, __FILE__, $sql);
}
$unmatched_count = $db->sql_affectedrows();
break;
case 'mssql':
case 'msaccess':
$sql = "DELETE FROM " . SEARCH_WORD_TABLE . "
WHERE word_id IN (
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)";
$result = $db->sql_query($sql);
if( !$result )
{
message_die(GENERAL_ERROR, "Couldn't delete old words from word table", __LINE__, __FILE__, $sql);
}
$unmatched_count = $db->sql_affectedrows();
break;
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) )
{
if( $unmatched_count = $db->sql_numrows($result) )
{
$rowset = array();
while( $row = $db->sql_fetchrow($result) )
{
$rowset[] = $row['word_id'];
}
$word_id_sql = implode(", ", $rowset);
if( $word_id_sql )
{
$sql = "DELETE FROM " . SEARCH_WORD_TABLE . "
WHERE word_id IN ($word_id_sql)";
$result = $db->sql_query($sql);
if( !$result )
{
message_die(GENERAL_ERROR, "Couldn't delete word list entry", "", __LINE__, __FILE__, $sql);
}
}
else
{
return 0;
}
}
else
{
return 0;
}
}
break;
}
}
if( $vote_id_sql != "" )
{ {
$sql = "DELETE $sql = "DELETE
FROM " . VOTE_DESC_TABLE . " FROM " . VOTE_DESC_TABLE . "
@ -519,8 +614,6 @@ switch($mode)
break; break;
case 'lock': case 'lock':
if($confirm)
{
$topics = ( isset($HTTP_POST_VARS['topic_id_list']) ) ? $HTTP_POST_VARS['topic_id_list'] : array($topic_id); $topics = ( isset($HTTP_POST_VARS['topic_id_list']) ) ? $HTTP_POST_VARS['topic_id_list'] : array($topic_id);
$topic_id_sql = ""; $topic_id_sql = "";
@ -557,56 +650,10 @@ switch($mode)
); );
message_die(GENERAL_MESSAGE, $lang['Topics_Locked'] . "<br /><br />" . $message); message_die(GENERAL_MESSAGE, $lang['Topics_Locked'] . "<br /><br />" . $message);
}
else
{
if( empty($HTTP_POST_VARS['topic_id_list']) && empty($topic_id) )
{
message_die(GENERAL_MESSAGE, $lang['None_selected'], $lang['Error']);
}
$hidden_fields = '<input type="hidden" name="mode" value="' . $mode . '"><input type="hidden" name="' . POST_FORUM_URL . '" value="' . $forum_id . '">';
if( isset($HTTP_POST_VARS['topic_id_list']) )
{
$topics = $HTTP_POST_VARS['topic_id_list'];
for($i = 0; $i < count($topics); $i++)
{
$hidden_fields .= '<input type="hidden" name="topic_id_list[]" value="' . $topics[$i] . '">';
}
}
else
{
$hidden_fields .= '<input type="hidden" name="' . POST_TOPIC_URL . '" value="' . $topic_id . '">';
}
//
// Set template files
//
$template->set_filenames(array(
"confirm" => "confirm_body.tpl")
);
$template->assign_vars(array(
"MESSAGE_TITLE" => $lang['Confirm'],
"MESSAGE_TEXT" => $lang['Confirm_lock_topic'],
"L_YES" => $lang['Yes'],
"L_NO" => $lang['No'],
"S_CONFIRM_ACTION" => append_sid("modcp.$phpEx"),
"S_HIDDEN_FIELDS" => $hidden_fields)
);
$template->pparse("confirm");
include($phpbb_root_path . 'includes/page_tail.'.$phpEx);
}
break; break;
case 'unlock': case 'unlock':
if($confirm)
{
$topics = ( isset($HTTP_POST_VARS['topic_id_list']) ) ? $HTTP_POST_VARS['topic_id_list'] : array($topic_id); $topics = ( isset($HTTP_POST_VARS['topic_id_list']) ) ? $HTTP_POST_VARS['topic_id_list'] : array($topic_id);
$topic_id_sql = ""; $topic_id_sql = "";
@ -644,51 +691,6 @@ switch($mode)
message_die(GENERAL_MESSAGE, $lang['Topics_Unlocked'] . "<br /><br />" . $message); message_die(GENERAL_MESSAGE, $lang['Topics_Unlocked'] . "<br /><br />" . $message);
}
else
{
if( empty($HTTP_POST_VARS['topic_id_list']) && empty($topic_id) )
{
message_die(GENERAL_MESSAGE, $lang['None_selected'], $lang['Error']);
}
$hidden_fields = '<input type="hidden" name="mode" value="' . $mode . '"><input type="hidden" name="' . POST_FORUM_URL . '" value="' . $forum_id . '">';
if( isset($HTTP_POST_VARS['topic_id_list']) )
{
$topics = $HTTP_POST_VARS['topic_id_list'];
for($i = 0; $i < count($topics); $i++)
{
$hidden_fields .= '<input type="hidden" name="topic_id_list[]" value="' . $topics[$i] . '">';
}
}
else
{
$hidden_fields .= '<input type="hidden" name="' . POST_TOPIC_URL . '" value="' . $topic_id . '">';
}
//
// Set template files
//
$template->set_filenames(array(
"confirm" => "confirm_body.tpl")
);
$template->assign_vars(array(
"MESSAGE_TITLE" => $lang['Confirm'],
"MESSAGE_TEXT" => $lang['Confirm_unlock_topic'],
"L_YES" => $lang['Yes'],
"L_NO" => $lang['No'],
"S_CONFIRM_ACTION" => append_sid("modcp.$phpEx"),
"S_HIDDEN_FIELDS" => $hidden_fields)
);
$template->pparse("confirm");
include($phpbb_root_path . 'includes/page_tail.'.$phpEx);
}
break; break;
case 'split': case 'split':
@ -931,7 +933,7 @@ switch($mode)
"IP" => $ip_this_post, "IP" => $ip_this_post,
"U_LOOKUP_IP" => append_sid("modcp.$phpEx?mode=ip&" . POST_POST_URL . "=$post_id&amp;" . POST_TOPIC_URL . "=$topic_id&amp;rdns=" . $ip_this_post)) "U_LOOKUP_IP" => append_sid("modcp.$phpEx?mode=ip&amp;" . POST_POST_URL . "=$post_id&amp;" . POST_TOPIC_URL . "=$topic_id&amp;rdns=" . $ip_this_post))
); );
// //
@ -961,7 +963,7 @@ switch($mode)
"ROW_CLASS" => $row_class, "ROW_CLASS" => $row_class,
"IP" => $ip, "IP" => $ip,
"U_LOOKUP_IP" => append_sid("modcp.$phpEx?mode=ip&" . POST_POST_URL . "=$post_id&amp;" . POST_TOPIC_URL . "=$topic_id&amp;rdns=" . $ip)) "U_LOOKUP_IP" => append_sid("modcp.$phpEx?mode=ip&amp;" . POST_POST_URL . "=$post_id&amp;" . POST_TOPIC_URL . "=$topic_id&amp;rdns=" . $ip))
); );
} }
@ -987,11 +989,11 @@ switch($mode)
$row_class = ( !($i % 2) ) ? $theme['td_class1'] : $theme['td_class2']; $row_class = ( !($i % 2) ) ? $theme['td_class1'] : $theme['td_class2'];
$template->assign_block_vars("userrow", array( $template->assign_block_vars("userrow", array(
"USERNAME" => $username,
"ROW_COLOR" => "#" . $row_color, "ROW_COLOR" => "#" . $row_color,
"ROW_CLASS" => $row_class, "ROW_CLASS" => $row_class,
"USERNAME" => $username,
"U_PROFILE" => append_sid("profile.$phpEx?mode=viewprofile&" . POST_USERS_URL . "=$id"), "U_PROFILE" => append_sid("profile.$phpEx?mode=viewprofile&amp;" . POST_USERS_URL . "=$id"),
"U_SEARCHPOSTS" => append_sid("search.$phpEx?search_author=" . urlencode($username) . "&amp;showresults=topics")) "U_SEARCHPOSTS" => append_sid("search.$phpEx?search_author=" . urlencode($username) . "&amp;showresults=topics"))
); );
} }
@ -1001,9 +1003,21 @@ switch($mode)
break; break;
case 'auth': case 'auth':
//
// For future use ...
//
break; break;
default: default:
$page_title = $lang['Mod_CP'];
include($phpbb_root_path . 'includes/page_header.'.$phpEx);
$template->assign_vars(array(
"FORUM_NAME" => $forum_name,
"U_VIEW_FORUM" => append_sid("viewforum.$phpEx?" . POST_FORUM_URL . "=$forum_id"))
);
$template->assign_vars(array( $template->assign_vars(array(
"L_MOD_CP" => $lang['Mod_CP'], "L_MOD_CP" => $lang['Mod_CP'],
"L_MOD_CP_EXPLAIN" => $lang['Mod_CP_explain'], "L_MOD_CP_EXPLAIN" => $lang['Mod_CP_explain'],