Skip to content

Commit

Permalink
Implements #875 Add "Rebuild Settings" to cache tools.
Browse files Browse the repository at this point in the history
  • Loading branch information
Omar Gonzalez committed Jul 5, 2014
1 parent 9304d2f commit 26cbfa1
Showing 1 changed file with 50 additions and 3 deletions.
53 changes: 50 additions & 3 deletions admin/modules/tools/cache.php
Expand Up @@ -28,8 +28,25 @@
admin_redirect("index.php?module=tools-cache");
}

$query = $db->simple_select("datacache", "*", "title = '".$db->escape_string($mybb->input['title'])."'");
$cacheitem = $db->fetch_array($query);
// Rebuilds forum settings
if($mybb->input['title'] == 'settings')
{
$cachedsettings = (array)$mybb->settings;
if(isset($cachedsettings['internal']))
{
unset($cachedsettings['internal']);
}

$cacheitem = array(
'title' => 'settings',
'cache' => serialize($cachedsettings)
);
}
else
{
$query = $db->simple_select("datacache", "*", "title = '".$db->escape_string($mybb->input['title'])."'");
$cacheitem = $db->fetch_array($query);
}

if(!$cacheitem)
{
Expand All @@ -50,7 +67,6 @@
$page->add_breadcrumb_item($lang->view);
$page->output_header($lang->cache_manager);


$table = new Table;

$table->construct_cell("<pre>\n{$cachecontents}\n</pre>");
Expand All @@ -71,6 +87,20 @@

$plugins->run_hooks("admin_tools_cache_rebuild");

// Rebuilds forum settings
if($mybb->input['title'] == 'settings')
{
rebuild_settings();

$plugins->run_hooks("admin_tools_cache_rebuild_commit");

// Log admin action
log_admin_action($mybb->input['title']);

flash_message($lang->success_cache_reloaded, 'success');
admin_redirect("index.php?module=tools-cache");
}

if(method_exists($cache, "update_{$mybb->input['title']}"))
{
$func = "update_{$mybb->input['title']}";
Expand Down Expand Up @@ -165,6 +195,9 @@
}
}

// Rebuilds forum settings
rebuild_settings();

$plugins->run_hooks("admin_tools_cache_rebuild_all_commit");

// Log admin action
Expand Down Expand Up @@ -222,6 +255,20 @@

$table->construct_row();
}

// Rebuilds forum settings
$cachedsettings = (array)$mybb->settings;
if(isset($cachedsettings['internal']))
{
unset($cachedsettings['internal']);
}

$table->construct_cell("<strong><a href=\"index.php?module=tools-cache&amp;action=view&amp;title=settings\">settings</a></strong>");
$table->construct_cell(get_friendly_size(strlen(serialize($cachedsettings))), array("class" => "align_center"));
$table->construct_cell("<a href=\"index.php?module=tools-cache&amp;action=reload&amp;title=settings&amp;my_post_key={$mybb->post_code}\">".$lang->reload_cache."</a>", array("class" => "align_center"));

$table->construct_row();

$table->output("<div style=\"float: right;\"><small><a href=\"index.php?module=tools-cache&amp;action=rebuild_all&amp;my_post_key={$mybb->post_code}\">".$lang->rebuild_reload_all."</a></small></div>".$lang->cache_manager);

$page->output_footer();
Expand Down

0 comments on commit 26cbfa1

Please sign in to comment.