admin_redirect("index.php?module=style-themes"); } $plugins->run_hooks("admin_style_themes_force"); // User clicked no if ($mybb->input['no']) { admin_redirect("index.php?module=style-themes"); } if ($mybb->request_method == "post") { $updated_users = array("style" => $theme['tid']); $plugins->run_hooks("admin_style_themes_force_commit"); $db->update_query("users", $updated_users); // Log admin action log_admin_action($theme['tid'], htmlspecialchars_uni($theme['name'])); flash_message($lang->success_theme_forced, 'success'); admin_redirect("index.php?module=style-themes"); } else { $page->output_confirm_action("index.php?module=style-themes&action=force&tid={$theme['tid']}", $lang->confirm_theme_forced); } } if (!$mybb->input['action']) { $page->output_header($lang->themes); $plugins->run_hooks("admin_style_themes_start"); $page->output_nav_tabs($sub_tabs, 'themes'); $table = new Table(); $table->construct_header($lang->theme); $table->construct_header($lang->num_users, array("class" => "align_center", "width" => 100)); $table->construct_header($lang->controls, array("class" => "align_center", "width" => 150)); build_theme_list(); $table->output($lang->themes); $page->output_footer(); }
function build_theme_list($parent = 0, $depth = 0) { global $mybb, $db, $table, $lang, $page; // Global $table is bad, but it will have to do for now static $theme_cache; $padding = $depth * 20; // Padding if (!is_array($theme_cache)) { $themes = cache_themes(); $query = $db->query("\n\t\t\tSELECT style, COUNT(uid) AS users\n\t\t\tFROM " . TABLE_PREFIX . "users\n\t\t\tGROUP BY style\n\t\t"); while ($user_themes = $db->fetch_array($query)) { if ($user_themes['style'] == 0) { $user_themes['style'] = $themes['default']; } if ($themes[$user_themes['style']]['users'] > 0) { $themes[$user_themes['style']]['users'] += intval($user_themes['users']); } else { $themes[$user_themes['style']]['users'] = intval($user_themes['users']); } } // Restrucure the theme array to something we can "loop-de-loop" with foreach ($themes as $key => $theme) { if ($key == "default") { continue; } $theme_cache[$theme['pid']][$theme['tid']] = $theme; } $theme_cache['num_themes'] = count($themes); unset($themes); } if (!is_array($theme_cache[$parent])) { return; } foreach ($theme_cache[$parent] as $theme) { $popup = new PopupMenu("theme_{$theme['tid']}", $lang->options); if ($theme['tid'] > 1) { $popup->add_item($lang->edit_theme, "index.php?module=style-themes&action=edit&tid={$theme['tid']}"); $theme['name'] = "<a href=\"index.php?module=style-themes&action=edit&tid={$theme['tid']}\">" . htmlspecialchars_uni($theme['name']) . "</a>"; // We must have at least the master and 1 other active theme if ($theme_cache['num_themes'] > 2) { $popup->add_item($lang->delete_theme, "index.php?module=style-themes&action=delete&tid={$theme['tid']}&my_post_key={$mybb->post_code}", "return AdminCP.deleteConfirmation(this, '{$lang->confirm_theme_deletion}')"); } if ($theme['def'] != 1) { $popup->add_item($lang->set_as_default, "index.php?module=style-themes&action=set_default&tid={$theme['tid']}&my_post_key={$mybb->post_code}"); $set_default = "<a href=\"index.php?module=style-themes&action=set_default&tid={$theme['tid']}&my_post_key={$mybb->post_code}\"><img src=\"styles/{$page->style}/images/icons/make_default.gif\" alt=\"{$lang->set_as_default}\" style=\"vertical-align: middle;\" title=\"{$lang->set_as_default}\" /></a>"; } else { $set_default = "<img src=\"styles/{$page->style}/images/icons/default.gif\" alt=\"{$lang->default_theme}\" style=\"vertical-align: middle;\" title=\"{$lang->default_theme}\" />"; } $popup->add_item($lang->force_on_users, "index.php?module=style-themes&action=force&tid={$theme['tid']}&my_post_key={$mybb->post_code}", "return AdminCP.deleteConfirmation(this, '{$lang->confirm_theme_forced}')"); } $popup->add_item($lang->export_theme, "index.php?module=style-themes&action=export&tid={$theme['tid']}"); $table->construct_cell("<div class=\"float_right\">{$set_default}</div><div style=\"margin-left: {$padding}px;\"><strong>{$theme['name']}</strong></div>"); $table->construct_cell(my_number_format($theme['users']), array("class" => "align_center")); $table->construct_cell($popup->fetch(), array("class" => "align_center")); $table->construct_row(); // Fetch & build any child themes build_theme_list($theme['tid'], ++$depth); } }