function sportal_remove_article() { global $smcFunc, $sourcedir; checkSession('get'); if (!allowedTo(array('sp_remove_article', 'sp_manage_articles', 'sp_admin'))) { fatal_lang_error('error_sp_cannot_remove_article'); } require_once $sourcedir . '/Subs-PortalAdmin.php'; $message_id = !empty($_REQUEST['message']) ? (int) $_REQUEST['message'] : 0; $topic_id = !empty($_REQUEST['return']) ? $_REQUEST['return'] : ''; $smcFunc['db_query']('', ' DELETE FROM {db_prefix}sp_articles WHERE id_message = {int:message}', array('message' => $message_id)); fixCategoryArticles(); redirectexit('topic=' . $topic_id); }
function sportal_admin_category_delete() { global $smcFunc, $context, $txt; // Is an id set? If yes, then we need to get some category information. if (!empty($_REQUEST['category_id'])) { // Be sure you made it an integer. $_REQUEST['category_id'] = (int) $_REQUEST['category_id']; // Do you know which one to delete? if (empty($_REQUEST['category_id'])) { fatal_lang_error('error_sp_id_empty', false); } // Get the category info. You need in template. $context['category_info'] = getCategoryInfo($_REQUEST['category_id']); $context['category_info'] = $context['category_info'][0]; // Also get the category list. $context['list_categories'] = getCategoryInfo(); // If we have one, that is itself. Delete it. if (count($context['list_categories']) < 2) { $context['list_categories'] = array(); } } if (empty($_REQUEST['category_id']) && empty($_POST['category_id'])) { fatal_lang_error('error_sp_id_empty', false); } // No need to delete articles if category has no articles. But articles are executed if there isn't any other category. :P if (empty($_POST['delete_category']) && !empty($context['category_info']['articles'])) { // Call the right sub template. $context['sub_template'] = 'category_delete'; $context['page_title'] = $txt['sp-categoriesDelete']; } elseif (!empty($_POST['delete_category'])) { // Again. checkSession(); // Are we going to move something? if (!empty($_POST['category_move']) && !empty($_POST['category_move_to'])) { // We just need an integer. $_POST['category_move_to'] = (int) $_POST['category_move_to']; // These are the lucky ones, move them. $smcFunc['db_query']('', ' UPDATE {db_prefix}sp_articles SET id_category = {int:category_move_to} WHERE id_category = {int:category_id}', array('category_move_to' => $_POST['category_move_to'], 'category_id' => $_POST['category_id'])); // Fix the article counts. fixCategoryArticles(); } else { // Kill 'em all. (It's not the Metallica album. :P) $smcFunc['db_query']('', ' DELETE FROM {db_prefix}sp_articles WHERE id_category = {int:category_id}', array('category_id' => $_POST['category_id'])); } // Everybody will die one day... $smcFunc['db_query']('', ' DELETE FROM {db_prefix}sp_categories WHERE id_category = {int:category_id}', array('category_id' => $_POST['category_id'])); // Return to the list. redirectexit('action=admin;area=portalarticles;sa=categories'); } else { // Again. checkSession('get'); // Just delete the category. $smcFunc['db_query']('', ' DELETE FROM {db_prefix}sp_categories WHERE id_category = {int:category_id}', array('category_id' => $_REQUEST['category_id'])); // Fix the article counts. fixCategoryArticles(); // Return to the list. redirectexit('action=admin;area=portalarticles;sa=categories'); } }