} if ($inherited_stylesheets == true) { flash_message($lang->error_inheriting_stylesheets, 'error'); admin_redirect("index.php?module=style-themes"); } $query = $db->simple_select("themestylesheets", "cachefile", "tid='{$theme['tid']}'"); while ($cachefile = $db->fetch_array($query)) { @unlink(MYBB_ROOT . "cache/themes/theme{$theme['tid']}/{$cachefile['cachefile']}"); } @unlink(MYBB_ROOT . "cache/themes/theme{$theme['tid']}/index.html"); $db->delete_query("themestylesheets", "tid='{$theme['tid']}'"); // Update the CSS file list for this theme update_theme_stylesheet_list($theme['tid'], $theme, true); $db->update_query("users", array('style' => 0), "style='{$theme['tid']}'"); @rmdir(MYBB_ROOT . "cache/themes/theme{$theme['tid']}/"); $children = make_child_theme_list($theme['tid']); $child_tid = $children[0]; $db->update_query("themes", array('pid' => $theme['pid']), "tid='{$child_tid}'"); $db->delete_query("themes", "tid='{$theme['tid']}'", 1); $plugins->run_hooks("admin_style_themes_delete_commit"); // Log admin action log_admin_action($theme['tid'], htmlspecialchars_uni($theme['name'])); flash_message($lang->success_theme_deleted, 'success'); admin_redirect("index.php?module=style-themes"); } else { $page->output_confirm_action("index.php?module=style-themes&action=delete&tid={$theme['tid']}", $lang->confirm_theme_deletion); } } if ($mybb->input['action'] == "edit") { $query = $db->simple_select("themes", "*", "tid='" . $mybb->get_input('tid', MyBB::INPUT_INT) . "'"); $theme = $db->fetch_array($query);
function make_child_theme_list($tid) { static $themes_by_child; $themes = array(); if (!is_array($themes_by_child)) { $theme_cache = cache_themes(); foreach ($theme_cache as $key => $theme) { if ($key == "default") { continue; } $themes_by_child[$theme['pid']][$theme['tid']] = $theme; } } if (!is_array($themes_by_child[$tid])) { return; } $themes = array(); foreach ($themes_by_child[$tid] as $theme) { $themes[] = $theme['tid']; $children = make_child_theme_list($theme['tid']); if (is_array($children)) { $themes = array_merge($themes, $children); } } return $themes; }