Main Page   File List   File Members   Related Pages  

dbcleanup.php

Go to the documentation of this file.
00001 <?php
00002 // $Header: /cvsroot/modphpcms/modphpcms/modules/dbcleanup.php,v 1.2 2004/05/04 22:33:17 fred87 Exp $
00003 
00004 function dbcleanup_install()
00005 //{{{
00006 {
00007         $info['name'] = 'dbcleanup';
00008         $info['title'] = 'Database cleanup';
00009         $info['description'] = 'Runs an optimize query after every page load';
00010         $info['has_admin'] = 1;
00011         $info['enabled'] = 1;
00012         set_module_info($info);
00013         
00014         $hooks = get_entry('hooks', 'page_sent');
00015         ListAdd('dbcleanup', $hooks);
00016         set_entry('hooks', 'page_sent', $hooks);
00017 
00018         $toclean = get_entry('config', 'cleaning_tables');
00019         ListAdd('config', $toclean);
00020         ListAdd('css_desc', $toclean);
00021         ListAdd('css_values', $toclean);
00022         ListAdd('hooks', $toclean);
00023         ListAdd('modules', $toclean);
00024         ListAdd('pages', $toclean);
00025         set_entry('config', 'cleaning_tables', $toclean);
00026 
00027         module_installed();
00028 }
00029 //}}}
00030 function dbcleanup_uninstall($preserve_data)
00031 //{{{
00032 {
00033         delete_module('dbcleanup');
00034 
00035         $hooks = get_entry('hooks', 'page_sent');
00036         ListDel('dbcleanup', $hooks);
00037         set_entry('hooks', 'page_sent', $hooks);
00038 
00039         if (!$preserve_data)
00040                 delete_entry('config', 'cleaning_tables');
00041 }
00042 //}}}
00043 function dbcleanup_page_sent()  // the actual module code - called by a hook
00044 //{{{
00045 {
00046         $info = get_module_info('dbcleanup');
00047         if (!$info['enabled'])
00048                 return;
00049 
00050         $toclean = get_entry('config', 'cleaning_tables');
00051         $tables = explode(';', $toclean);
00052         foreach ($tables as $table)
00053                 optimize_table($table);
00054 }
00055 //}}}
00056 ?>

Generated on Wed Jun 9 03:38:16 2004 for modphpcms by doxygen1.2.18