aboutsummaryrefslogtreecommitdiff
path: root/mod
diff options
context:
space:
mode:
Diffstat (limited to 'mod')
-rw-r--r--mod/logrotate/languages/en.php24
-rw-r--r--mod/logrotate/manifest.xml9
-rw-r--r--mod/logrotate/start.php47
-rw-r--r--mod/logrotate/views/default/settings/logrotate/edit.php20
4 files changed, 100 insertions, 0 deletions
diff --git a/mod/logrotate/languages/en.php b/mod/logrotate/languages/en.php
new file mode 100644
index 000000000..eb837c2e1
--- /dev/null
+++ b/mod/logrotate/languages/en.php
@@ -0,0 +1,24 @@
+<?php
+ /**
+ * Elgg log rotator language pack.
+ *
+ * @package ElggLogRotate
+ * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
+ * @author Curverider Ltd
+ * @copyright Curverider Ltd 2008
+ * @link http://elgg.com/
+ */
+
+ $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/manifest.xml b/mod/logrotate/manifest.xml
new file mode 100644
index 000000000..47fabce1b
--- /dev/null
+++ b/mod/logrotate/manifest.xml
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<plugin_manifest>
+ <field key="author" value="Marcus Povey" />
+ <field key="version" value="1.0" />
+ <field key="description" value="Rotate the system log at specific intervals" />
+ <field key="website" value="http://www.elgg.org/" />
+ <field key="copyright" value="(C) Curverider 2008" />
+ <field key="licence" value="GNU Public License version 2" />
+</plugin_manifest> \ No newline at end of file
diff --git a/mod/logrotate/start.php b/mod/logrotate/start.php
new file mode 100644
index 000000000..f9a9a0449
--- /dev/null
+++ b/mod/logrotate/start.php
@@ -0,0 +1,47 @@
+<?php
+ /**
+ * Elgg log rotator.
+ *
+ * @package ElggLogRotate
+ * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
+ * @author Curverider Ltd
+ * @copyright Curverider Ltd 2008
+ * @link http://elgg.com/
+ */
+
+ /**
+ * Initialise the plugin.
+ *
+ */
+ function logrotate_init()
+ {
+ $period = get_plugin_setting('period','logrotate');
+ switch ($period)
+ {
+ case 'weekly':
+ case 'monthly' :
+ case 'yearly' :
+ break;
+ default: $period = 'monthly';
+ }
+
+ // Register cron hook
+ register_plugin_hook('cron', $period, 'logrotate_cron');
+ }
+
+ /**
+ * Trigger the log rotation.
+ *
+ */
+ function logrotate_cron($hook, $entity_type, $returnvalue, $params)
+ {
+ $resulttext = elgg_echo("logrotate:logrotated");
+ if (!archive_log())
+ $resulttext = elgg_echo("logrotate:lognotrotated");
+
+ return $returnvalue . $resulttext;
+ }
+
+ // Initialise plugin
+ register_elgg_event_handler('init','system','logrotate_init');
+?> \ No newline at end of file
diff --git a/mod/logrotate/views/default/settings/logrotate/edit.php b/mod/logrotate/views/default/settings/logrotate/edit.php
new file mode 100644
index 000000000..19b92c320
--- /dev/null
+++ b/mod/logrotate/views/default/settings/logrotate/edit.php
@@ -0,0 +1,20 @@
+<?php
+ $period = $vars['entity']->period;
+ if (!$period) $period = 'monthly';
+
+?>
+<p>
+ <?php echo elgg_echo('logrotate:period'); ?>
+
+ <?php
+ echo elgg_view('input/pulldown', array(
+ 'internalname' => 'params[period]',
+ 'options_values' => array(
+ 'weekly' => elgg_echo('logrotate:weekly'),
+ 'monthly' => elgg_echo('logrotate:monthly'),
+ 'yearly' => elgg_echo('logrotate:yearly'),
+ ),
+ 'value' => $period
+ ));
+ ?>
+</p>