From bfcabd3df2a4377d879cb5cc22d9cb4cafeec8f5 Mon Sep 17 00:00:00 2001 From: James Atkinson Date: Tue, 10 Jul 2001 23:21:00 +0000 Subject: [PATCH] Confirm in moderator control panel works on Deletes git-svn-id: file:///svn/phpbb/trunk@619 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/language/lang_english.php | 5 + phpBB/modcp.php | 216 ++++++++++++++++++++------------ 2 files changed, 142 insertions(+), 79 deletions(-) diff --git a/phpBB/language/lang_english.php b/phpBB/language/lang_english.php index 994ad3ab74..9f00606b32 100755 --- a/phpBB/language/lang_english.php +++ b/phpBB/language/lang_english.php @@ -218,6 +218,7 @@ $lang['Post_Annoucement'] = "Announcement"; $lang['Post_Sticky'] = "Sticky"; $lang['Options'] = "Options"; +$lang['Confirm'] = "Confirm"; $lang['Confirm_delete'] = "Are you sure you want to delete this post?"; $lang['Submit_post'] = "Submit Post"; $lang['Preview'] = "Preview"; @@ -491,6 +492,10 @@ $lang['Topics_Removed'] = "The selected topics have been successfully removed fr $lang['Topics_Locked'] = "The selected topics have been locked"; $lang['Topics_Unlocked'] = "The selected topics have been unlocked"; $lang['Return_to_modcp'] = "to return to the moderator control panel"; +$lang['Confirm_delete_topic'] = "Are you sure you want to remove this topic(s)?"; +$lang['Confirm_lock_topic'] = "Are you sure you want to lock this topic(s)?"; +$lang['Confirm_unlock_topic'] = "Are you sure you want to unlock this topic(s)?"; +$lang['Confirm_move_topic'] = "Are you sure you want to move this topic(s)?"; // // Old format ... _DON'T_add_any_ new entries here!! diff --git a/phpBB/modcp.php b/phpBB/modcp.php index 8d94828556..879a9d620a 100644 --- a/phpBB/modcp.php +++ b/phpBB/modcp.php @@ -98,14 +98,29 @@ if(!$is_mod) message_die(CRITICAL_MESSAGE, $lang['Not_Moderator'], $lang['Not_Authorised'], __LINE__, __FILE__); } + +// +// Check if user did or did not confirm +// If they did not, forward them to the last page they were on +// +$confirm = ($HTTP_POST_VARS['confirm']) ? 1 : 0; +if($HTTP_POST_VARS['not_confirm']) +{ + header("Location: index.$phpEx"); +} + include('includes/page_header.'.$phpEx); +// Set template files +$template->set_filenames(array("body" => "modcp_body.tpl", "confirm" => "confirm.tpl")); + $mode = ($HTTP_POST_VARS['mode']) ? $HTTP_POST_VARS['mode'] : $HTTP_GET_VARS['mode']; $delete = ($HTTP_POST_VARS['delete']) ? 1 : 0; $move = ($HTTP_POST_VARS['move']) ? 1 : 0; $lock = ($HTTP_POST_VARS['lock']) ? 1 : 0; $unlock = ($HTTP_POST_VARS['unlock']) ? 1 : 0; + if(!$mode) { if($delete) @@ -129,98 +144,126 @@ if(!$mode) switch($mode) { case 'delete': - if($HTTP_POST_VARS['preform_op']) + if($confirm) { - $topics = $HTTP_POST_VARS['preform_op']; - } - else - { - $topics = array($HTTP_GET_VARS[POST_TOPIC_URL]); - } - - $sql = "SELECT post_id FROM ".POSTS_TABLE." WHERE "; - $delete_topics = "DELETE FROM ".TOPICS_TABLE." WHERE "; - for($x = 0; $x < count($topics); $x++) - { - if($x > 0) + if($HTTP_POST_VARS['preform_op']) { - $sql .= " OR "; - $delete_topics .= " OR "; + $topics = $HTTP_POST_VARS['preform_op']; } - $sql .= "topic_id = ".$topics[$x]; - $delete_topics .= "topic_id = ".$topics[$x]; - } - $topics_removed = $x; - - if(!$result = $db->sql_query($sql)) - { - message_die(GENERAL_ERROR, "Could not get posts lists for deletion!", "Error", __LINE__, __FILE__, $sql); - } - $num_posts = $db->sql_numrows($result); - $rowset = $db->sql_fetchrowset($result); - $delete_posts = "DELETE FROM ".POSTS_TABLE." WHERE "; - $delete_text = "DELETE FROM ".POSTS_TEXT_TABLE." WHERE "; - for($x = 0; $x < $num_posts; $x++) - { - if($x > 0) + else { - $delete_posts .= " OR "; - $delete_text .= " OR "; + $topics = array($HTTP_GET_VARS[POST_TOPIC_URL]); } - $delete_posts .= "post_id = ".$rowset[$x]['post_id']; - $delete_text .= "post_id = ".$rowset[$x]['post_id']; - } - $posts_removed = $x; - - if(!$result = $db->sql_query($delete_text, BEGIN_TRANSACTION)) - { - message_die(GENERAL_ERROR, "Could not delete posts text!", "Error", __LINE__, __FILE__, $delete_text); - } - - if(!$result = $db->sql_query($delete_posts)) - { - message_die(GENERAL_ERROR, "Could not delete posts!", "Error", __LINE__, __FILE__, $delete_posts); - } - if(!$result = $db->sql_query($delete_topics)) - { - message_die(GENERAL_ERROR, "Could not delete topics!", "Error", __LINE__, __FILE__, $delete_topics); - } - - if(SQL_LAYER != "mysql") - { - $update_index = "UPDATE ".FORUMS_TABLE." - SET forum_topics = forum_topics - $topics_removed, - forum_posts = forum_posts - $posts_removed, - forum_last_post_id = (select max(post_id) FROM ".POSTS_TABLE." - WHERE forum_id = $forum_id) WHERE forum_id = $forum_id"; - - if(!$result = $db->sql_query($update_index, END_TRANSACTION)) + $sql = "SELECT post_id FROM ".POSTS_TABLE." WHERE "; + $delete_topics = "DELETE FROM ".TOPICS_TABLE." WHERE "; + for($x = 0; $x < count($topics); $x++) { - message_die(GENERAL_ERROR, "Could not update index!", "Error", __LINE__, __FILE__, $delete_topics); + if($x > 0) + { + $sql .= " OR "; + $delete_topics .= " OR "; + } + $sql .= "topic_id = ".$topics[$x]; + $delete_topics .= "topic_id = ".$topics[$x]; } - } - else - { - $sql = "select max(post_id) AS last_post FROM ".POSTS_TABLE." WHERE forum_id = $forum_id"; + $topics_removed = $x; + if(!$result = $db->sql_query($sql)) { - message_die(GENERAL_ERROR, "Could not get last post id", "Error", __LINE__, __FILE__, $sql); + message_die(GENERAL_ERROR, "Could not get posts lists for deletion!", "Error", __LINE__, __FILE__, $sql); } - $last_post = $db->sql_fetchrowset($result); - $update_index = "UPDATE ".FORUMS_TABLE." - SET forum_topics = forum_topics - $topics_removed, - forum_posts = forum_posts - $posts_removed, - forum_last_post_id = ".$last_post[0]['last_post']." WHERE forum_id = $forum_id"; - if(!$result = $db->sql_query($update_index, END_TRANSACTION)) + $num_posts = $db->sql_numrows($result); + $rowset = $db->sql_fetchrowset($result); + $delete_posts = "DELETE FROM ".POSTS_TABLE." WHERE "; + $delete_text = "DELETE FROM ".POSTS_TEXT_TABLE." WHERE "; + for($x = 0; $x < $num_posts; $x++) { - message_die(GENERAL_ERROR, "Could not update index!", "Error", __LINE__, __FILE__, $update_index); + if($x > 0) + { + $delete_posts .= " OR "; + $delete_text .= " OR "; + } + $delete_posts .= "post_id = ".$rowset[$x]['post_id']; + $delete_text .= "post_id = ".$rowset[$x]['post_id']; } - } - - $msg = $lang['Topics_Removed'] . "
" . "". $lang['Click'] . " " . $lang['Here'] ." " . $lang['Return_to_modcp']; - message_die(GENERAL_MESSAGE, $msg); + $posts_removed = $x; + if(!$result = $db->sql_query($delete_text, BEGIN_TRANSACTION)) + { + message_die(GENERAL_ERROR, "Could not delete posts text!", "Error", __LINE__, __FILE__, $delete_text); + } + + if(!$result = $db->sql_query($delete_posts)) + { + message_die(GENERAL_ERROR, "Could not delete posts!", "Error", __LINE__, __FILE__, $delete_posts); + } + + if(!$result = $db->sql_query($delete_topics)) + { + message_die(GENERAL_ERROR, "Could not delete topics!", "Error", __LINE__, __FILE__, $delete_topics); + } + + if(SQL_LAYER != "mysql") + { + $update_index = "UPDATE ".FORUMS_TABLE." + SET forum_topics = forum_topics - $topics_removed, + forum_posts = forum_posts - $posts_removed, + forum_last_post_id = (select max(post_id) FROM ".POSTS_TABLE." + WHERE forum_id = $forum_id) WHERE forum_id = $forum_id"; + + if(!$result = $db->sql_query($update_index, END_TRANSACTION)) + { + message_die(GENERAL_ERROR, "Could not update index!", "Error", __LINE__, __FILE__, $delete_topics); + } + } + else + { + $sql = "select max(post_id) AS last_post FROM ".POSTS_TABLE." WHERE forum_id = $forum_id"; + if(!$result = $db->sql_query($sql)) + { + message_die(GENERAL_ERROR, "Could not get last post id", "Error", __LINE__, __FILE__, $sql); + } + $last_post = $db->sql_fetchrowset($result); + $update_index = "UPDATE ".FORUMS_TABLE." + SET forum_topics = forum_topics - $topics_removed, + forum_posts = forum_posts - $posts_removed, + forum_last_post_id = ".$last_post[0]['last_post']." WHERE forum_id = $forum_id"; + if(!$result = $db->sql_query($update_index, END_TRANSACTION)) + { + message_die(GENERAL_ERROR, "Could not update index!", "Error", __LINE__, __FILE__, $update_index); + } + } + + $msg = $lang['Topics_Removed'] . "
" . "". $lang['Click'] . " " . $lang['Here'] ." " . $lang['Return_to_modcp']; + message_die(GENERAL_MESSAGE, $msg); + } + else + { + $hidden_fields = ''; + if($HTTP_POST_VARS['preform_op']) + { + $topics = $HTTP_POST_VARS['preform_op']; + for($x = 0; $x < count($topics); $x++) + { + $hidden_fields .= ''; + } + } + else + { + $hidden_fields .= ''; + } + + $template->assign_vars(array("MESSAGE_TITLE" => $lang['Confirm'], + "MESSAGE_TEXT" => $lang['Confirm_delete_topic'], + "L_YES" => $lang['Yes'], + "L_NO" => $lang['No'], + "S_CONFIRM_ACTION" => append_sid("modcp.$phpEx"), + "HIDDEN_FIELDS" => $hidden_fields)); + $template->pparse("confirm"); + include('includes/page_tail.'.$phpEx); + exit(); + } break; case 'move': echo 'Move'; @@ -287,10 +330,25 @@ switch($mode) message_die(GENERAL_MESSAGE, $msg); } break; + + case 'split': + if($HTTP_POST_VARS['split_posts']) + { + + + } + else + { + + + + } + + + break; default: - $template->set_filenames(array("body" => "modcp_body.tpl")); $template->assign_vars(array("L_MOD_EXPLAIN" => $lang['ModCp_Explain'], "L_SELECT" => $lang['Select'], "L_DELETE" => $lang['Delete'],