diff -r e3d7322305bf -r 5e1f1e916419 punbb/admin/categories.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/punbb/admin/categories.php Sat Apr 05 23:56:45 2008 -0400 @@ -0,0 +1,414 @@ + $_ ) +{ + $$key =& $GLOBALS[$key]; +} + +($hook = get_hook('acg_start')) ? eval($hook) : null; + +if ($session->user_level < USER_LEVEL_ADMIN) + message($lang_common['No permission']); + +// Load the admin.php language file +require PUN_ROOT.'lang/'.$pun_user['language'].'/admin.php'; +$GLOBALS['lang_admin'] = $lang_admin; + + +// Add a new category +if (isset($_POST['add_cat'])) +{ + $new_cat_name = trim($_POST['new_cat_name']); + if ($new_cat_name == '') + message($lang_admin['Must name category']); + + ($hook = get_hook('acg_add_cat_form_submitted')) ? eval($hook) : null; + + $query = array( + 'INSERT' => 'cat_name', + 'INTO' => 'categories', + 'VALUES' => '\''.$pun_db->escape($new_cat_name).'\'' + ); + + ($hook = get_hook('acg_qr_add_category')) ? eval($hook) : null; + $pun_db->query_build($query) or error(__FILE__, __LINE__); + + pun_redirect(pun_link($pun_url['admin_categories']), $lang_admin['Category added'].' '.$lang_admin['Redirect']); +} + + +// Delete a category +else if (isset($_POST['del_cat']) || isset($_POST['del_cat_comply'])) +{ + $cat_to_delete = intval($_POST['cat_to_delete']); + if ($cat_to_delete < 1) + message($lang_common['Bad request']); + + // User pressed the cancel button + if (isset($_POST['del_cat_cancel'])) + pun_redirect(pun_link($pun_url['admin_categories']), $lang_admin['Cancel redirect']); + + ($hook = get_hook('acg_del_cat_form_submitted')) ? eval($hook) : null; + + if (isset($_POST['del_cat_comply'])) // Delete a category with all forums and posts + { + @set_time_limit(0); + + $query = array( + 'SELECT' => 'f.id', + 'FROM' => 'forums AS f', + 'WHERE' => 'cat_id='.$cat_to_delete + ); + + ($hook = get_hook('acg_qr_get_forums_to_delete')) ? eval($hook) : null; + $result = $pun_db->query_build($query) or error(__FILE__, __LINE__); + $num_forums = $pun_db->num_rows($result); + + for ($i = 0; $i < $num_forums; ++$i) + { + $cur_forum = $pun_db->result($result, $i); + + // Prune all posts and topics + prune($cur_forum, 1, -1); + + // Delete the forum + $query = array( + 'DELETE' => 'forums', + 'WHERE' => 'id='.$cur_forum + ); + + ($hook = get_hook('acg_qr_delete_forum')) ? eval($hook) : null; + $pun_db->query_build($query) or error(__FILE__, __LINE__); + } + + delete_orphans(); + + // Delete the category + $query = array( + 'DELETE' => 'categories', + 'WHERE' => 'id='.$cat_to_delete + ); + + ($hook = get_hook('acg_qr_delete_category')) ? eval($hook) : null; + $pun_db->query_build($query) or error(__FILE__, __LINE__); + + // Regenerate the quickjump cache + require_once PUN_ROOT.'include/cache.php'; + generate_quickjump_cache(); + + pun_redirect(pun_link($pun_url['admin_categories']), $lang_admin['Category deleted'].' '.$lang_admin['Redirect']); + } + else // If the user hasn't comfirmed the delete + { + $query = array( + 'SELECT' => 'c.cat_name', + 'FROM' => 'categories AS c', + 'WHERE' => 'c.id='.$cat_to_delete + ); + + ($hook = get_hook('acg_qr_get_category_name')) ? eval($hook) : null; + $result = $pun_db->query_build($query) or error(__FILE__, __LINE__); + $cat_name = $pun_db->result($result); + + + // Setup breadcrumbs + $pun_page['crumbs'] = array( + array($pun_config['o_board_title'], pun_link($pun_url['index'])), + array($lang_admin['Forum administration'], pun_link($pun_url['admin_index'])), + array($lang_admin['Categories'], pun_link($pun_url['admin_categories'])), + $lang_admin['Delete category'] + ); + + ($hook = get_hook('acg_del_cat_pre_header_load')) ? eval($hook) : null; + + define('PUN_PAGE_SECTION', 'start'); + define('PUN_PAGE', 'admin-categories'); + require PUN_ROOT.'header.php'; + +?> +
'.strtolower($lang_admin['Forums']).'') ?>
+