[Phpbbkb-checkins] SF.net SVN: phpbbkb: [64] main/trunk
Status: Alpha
Brought to you by:
markthedaemon
From: <so...@us...> - 2007-03-06 22:13:27
|
Revision: 64 http://svn.sourceforge.net/phpbbkb/?rev=64&view=rev Author: softphp Date: 2007-03-06 14:13:22 -0800 (Tue, 06 Mar 2007) Log Message: ----------- - Fixed bug #20, #21, #22.. Let's go alpha! Modified Paths: -------------- main/trunk/admin/admin_kb.php main/trunk/includes/functions_kb.php main/trunk/kb.php main/trunk/language/lang_english/lang_kb.php Modified: main/trunk/admin/admin_kb.php =================================================================== --- main/trunk/admin/admin_kb.php 2007-02-24 20:51:19 UTC (rev 63) +++ main/trunk/admin/admin_kb.php 2007-03-06 22:13:22 UTC (rev 64) @@ -198,14 +198,10 @@ $cancel = isset($HTTP_POST_VARS['cancel']) ? true : false; if($cancel) { - // Redirect back to cat page - $meta = '<meta http-equiv="refresh" content="0;url=' . append_sid('admin_kb.' . $phpEx . '?mode=cats') . '>"'; + // Redirect back to cat page + $message = $lang['kbadm_delcat_success'] . '<br /><br />' . sprintf($lang['kbadm_Click_return_catadmin'], '<a href="' . append_sid("admin_kb." . $phpEx . "?mode=cats") . '">', '</a>') . '<br /><br />' . sprintf($lang['Click_return_admin_index'], '<a href="' . append_sid("index.$phpEx?pane=right") . '">', '</a>'); - $template->assign_vars(array( - 'META' => $meta) - ); - - message_die(GENERAL_MESSAGE, ''); + message_die(GENERAL_MESSAGE, $message); } elseif(!$confirm) { @@ -246,6 +242,54 @@ message_die(GENERAL_ERROR, "Couldn't delete category from categories table.", "", __LINE__, __FILE__, $sql); } + // Obtain articles that has been deleted. + $sql = "SELECT article_id FROM " . KB_ARTICLECATS_TABLE . " WHERE cat_id = '" . $cat_id . "'"; + if(!$result = $db->sql_query($sql)) + { + message_die(GENERAL_ERROR, "Couldn't obtain articles that needs deletion.", "", __LINE__, __FILE__, $sql); + } + + while($row = $db->sql_fetchrow($result)) + { + $sql = "DELETE FROM " . KB_ARTICLES_TABLE . " WHERE article_id = '" . $row['article_id'] . "'"; + if(!$db->sql_query($sql)) + { + message_die(GENERAL_ERROR, "Couldn't delete articles from article table.", "", __LINE__, __FILE__, $sql); + } + } + + // Now get subcats and loop through them deleting all of them and their articles. + $sql = "SELECT cat_id FROM " . KB_CATEGORIES_TABLE . " WHERE cat_main = '" . $cat_id . "'"; + if(!$result = $db->sql_query($sql)) + { + message_die(GENERAL_ERROR, "Couldn't obtain subcategories.", "", __LINE__, __FILE__, $sql); + } + + while($row = $db->sql_fetchrow($result)) + { + // Get all articles and delete them, then delete articlecats entries + $sql = "SELECT article_id FROM " . KB_ARTICLECATS_TABLE . " WHERE cat_id = '" . $row['cat_id'] . "'"; + if(!$result2 = $db->sql_query($sql)) + { + message_die(GENERAL_ERROR, "Couldn't obtain articles that needs deletion.", "", __LINE__, __FILE__, $sql); + } + + while($row2 = $db->sql_fetchrow($result2)) + { + $sql = "DELETE FROM " . KB_ARTICLES_TABLE . " WHERE article_id = '" . $row2['article_id'] . "'"; + if(!$db->sql_query($sql)) + { + message_die(GENERAL_ERROR, "Couldn't delete articles from article table.", "", __LINE__, __FILE__, $sql); + } + } + + $sql = "DELETE FROM " . KB_ARTICLECATS_TABLE . " WHERE cat_id = '" . $row['cat_id'] . "'"; + if(!$db->sql_query($sql)) + { + message_die(GENERAL_ERROR, "Couldn't delete subcategory from articlecats table.", "", __LINE__, __FILE__, $sql); + } + } + $sql = "DELETE FROM " . KB_ARTICLECATS_TABLE . " WHERE cat_id = '" . $cat_id . "'"; if(!$db->sql_query($sql)) { @@ -259,6 +303,9 @@ message_die(GENERAL_ERROR, "Couldn't delete subcategories from articlecats table.", "", __LINE__, __FILE__, $sql); } + // Delete subcats articles.. oh no + + $message = $lang['kbadm_delcat_success'] . '<br /><br />' . sprintf($lang['kbadm_Click_return_catadmin'], '<a href="' . append_sid("admin_kb." . $phpEx . "?mode=cats") . '">', '</a>') . '<br /><br />' . sprintf($lang['Click_return_admin_index'], '<a href="' . append_sid("index.$phpEx?pane=right") . '">', '</a>'); // Delete all articles in this category or set cat_id to another one or? I'm not sure how we should handle this? Modified: main/trunk/includes/functions_kb.php =================================================================== --- main/trunk/includes/functions_kb.php 2007-02-24 20:51:19 UTC (rev 63) +++ main/trunk/includes/functions_kb.php 2007-03-06 22:13:22 UTC (rev 64) @@ -810,7 +810,7 @@ if($cancel) { - $meta = '<meta http-equiv="refresh" content="0;url=' . append_sid('kb.' . $phpEx) . '>"'; + $meta = '<meta http-equiv="refresh" content="0;url=' . append_sid('kb.' . $phpEx) . '">'; $template->assign_vars(array( 'META' => $meta) Modified: main/trunk/kb.php =================================================================== --- main/trunk/kb.php 2007-02-24 20:51:19 UTC (rev 63) +++ main/trunk/kb.php 2007-03-06 22:13:22 UTC (rev 64) @@ -494,10 +494,7 @@ // include($phpbb_root_path . 'includes/page_header.' . $phpEx); - if($action != "delete_article") - { - $template->pparse('body'); - } + $template->pparse('body'); include($phpbb_root_path . 'includes/page_tail.'.$phpEx); } Modified: main/trunk/language/lang_english/lang_kb.php =================================================================== --- main/trunk/language/lang_english/lang_kb.php 2007-02-24 20:51:19 UTC (rev 63) +++ main/trunk/language/lang_english/lang_kb.php 2007-03-06 22:13:22 UTC (rev 64) @@ -75,7 +75,7 @@ $lang['kbadm_cat_parent'] = "Parent Category"; $lang['kbadm_empty_cat_title'] = "The Category Title submitted was empty."; $lang['kbadm_empty_cat_desc'] = "The Category Description submitted was empty."; -$lang['kbadm_confirm_deletecat'] = "Are you sure you want to delete this category?"; +$lang['kbadm_confirm_deletecat'] = "Are you sure you want to delete this category? <b>Please notice that all subcategories aswell as all categories in this category (or subcategories) will be deleted, even though they are assigned other categories aswell!</b>"; $lang['kbadm_Click_return_catadmin'] = "Click %shere%s to return to category administration."; $lang['kbadm_header_addcat'] = "Add Category"; $lang['kbadm_explain_addcat'] = "From here you can add a new category."; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |