diff options
author | cash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2010-11-29 02:53:32 +0000 |
---|---|---|
committer | cash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2010-11-29 02:53:32 +0000 |
commit | aefce16b306505c6cfed8d87e975b2c9680559b4 (patch) | |
tree | d79433a597577196a3d6c7dba08beabc9cea3eb2 /mod/logrotate/start.php | |
parent | 13a495664c79037557e6c5ea7c3e442be0523139 (diff) | |
download | elgg-aefce16b306505c6cfed8d87e975b2c9680559b4.tar.gz elgg-aefce16b306505c6cfed8d87e975b2c9680559b4.tar.bz2 |
cleaned up some of the other smaller plugins
git-svn-id: http://code.elgg.org/elgg/trunk@7468 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'mod/logrotate/start.php')
-rw-r--r-- | mod/logrotate/start.php | 101 |
1 files changed, 49 insertions, 52 deletions
diff --git a/mod/logrotate/start.php b/mod/logrotate/start.php index 485f53f49..28c1694eb 100644 --- a/mod/logrotate/start.php +++ b/mod/logrotate/start.php @@ -1,56 +1,53 @@ <?php - /** - * Elgg log rotator. - * - * @package ElggLogRotate - */ - - /** - * Initialise the plugin. - * - */ - function logrotate_init() - { - $period = get_plugin_setting('period','logrotate'); - switch ($period) - { - case 'weekly': - case 'monthly' : - case 'yearly' : +/** + * Elgg log rotator. + * + * @package ElggLogRotate + */ + +elgg_register_event_handler('init', 'system', 'logrotate_init'); + +function logrotate_init() { + $period = get_plugin_setting('period', 'logrotate'); + switch ($period) { + case 'weekly': + case 'monthly' : + case 'yearly' : break; - default: $period = 'monthly'; - } - - // Register cron hook - elgg_register_plugin_hook_handler('cron', $period, 'logrotate_cron'); + default: + $period = 'monthly'; } - - /** - * Trigger the log rotation. - * - */ - function logrotate_cron($hook, $entity_type, $returnvalue, $params) - { - $resulttext = elgg_echo("logrotate:logrotated"); - - $day = 86400; - - $offset = 0; - $period = get_plugin_setting('period','logrotate'); - switch ($period) - { - case 'weekly': $offset = $day * 7; break; - case 'yearly' : $offset = $day * 365; break; - case 'monthly' : // assume 28 days even if a month is longer. Won't cause data loss. - default: $offset = $day * 28;; - } - - if (!archive_log($offset)) - $resulttext = elgg_echo("logrotate:lognotrotated"); - - return $returnvalue . $resulttext; + + // Register cron hook + elgg_register_plugin_hook_handler('cron', $period, 'logrotate_cron'); +} + +/** + * Trigger the log rotation. + */ +function logrotate_cron($hook, $entity_type, $returnvalue, $params) { + $resulttext = elgg_echo("logrotate:logrotated"); + + $day = 86400; + + $offset = 0; + $period = get_plugin_setting('period', 'logrotate'); + switch ($period) { + case 'weekly': + $offset = $day * 7; + break; + case 'yearly': + $offset = $day * 365; + break; + case 'monthly': + default: + // assume 28 days even if a month is longer. Won't cause data loss. + $offset = $day * 28; } - - // Initialise plugin - elgg_register_event_handler('init','system','logrotate_init'); -?>
\ No newline at end of file + + if (!archive_log($offset)) { + $resulttext = elgg_echo("logrotate:lognotrotated"); + } + + return $returnvalue . $resulttext; +} |