aboutsummaryrefslogtreecommitdiff
path: root/mod/logrotate
diff options
context:
space:
mode:
Diffstat (limited to 'mod/logrotate')
-rw-r--r--mod/logrotate/languages/en.php35
-rw-r--r--mod/logrotate/start.php101
-rw-r--r--mod/logrotate/views/default/settings/logrotate/edit.php12
3 files changed, 76 insertions, 72 deletions
diff --git a/mod/logrotate/languages/en.php b/mod/logrotate/languages/en.php
index 5efb51639..e60d1b841 100644
--- a/mod/logrotate/languages/en.php
+++ b/mod/logrotate/languages/en.php
@@ -1,20 +1,19 @@
<?php
- /**
- * Elgg log rotator language pack.
- *
- * @package ElggLogRotate
- */
+/**
+ * Elgg log rotator language pack.
+ *
+ * @package ElggLogRotate
+ */
- $english = array(
- 'logrotate:period' => 'How often should the system log be archived?',
-
- 'logrotate:weekly' => 'Once a week',
- 'logrotate:monthly' => 'Once a month',
- 'logrotate:yearly' => 'Once a year',
-
- 'logrotate:logrotated' => "Log rotated\n",
- 'logrotate:lognotrotated' => "Error rotating log\n",
- );
-
- add_translation("en",$english);
-?> \ No newline at end of file
+$english = array(
+ 'logrotate:period' => 'How often should the system log be archived?',
+
+ 'logrotate:weekly' => 'Once a week',
+ 'logrotate:monthly' => 'Once a month',
+ 'logrotate:yearly' => 'Once a year',
+
+ 'logrotate:logrotated' => "Log rotated\n",
+ 'logrotate:lognotrotated' => "Error rotating log\n",
+);
+
+add_translation("en", $english); \ No newline at end of file
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;
+}
diff --git a/mod/logrotate/views/default/settings/logrotate/edit.php b/mod/logrotate/views/default/settings/logrotate/edit.php
index 19b92c320..db439eaa0 100644
--- a/mod/logrotate/views/default/settings/logrotate/edit.php
+++ b/mod/logrotate/views/default/settings/logrotate/edit.php
@@ -1,6 +1,14 @@
<?php
- $period = $vars['entity']->period;
- if (!$period) $period = 'monthly';
+/**
+ * Elgg log rotator plugin settings.
+ *
+ * @package ElggLogRotate
+ */
+
+$period = $vars['entity']->period;
+if (!$period) {
+ $period = 'monthly';
+}
?>
<p>