aboutsummaryrefslogtreecommitdiff
path: root/mod/garbagecollector
diff options
context:
space:
mode:
Diffstat (limited to 'mod/garbagecollector')
-rw-r--r--mod/garbagecollector/languages/en.php53
-rw-r--r--mod/garbagecollector/start.php101
-rw-r--r--mod/garbagecollector/views/default/settings/garbagecollector/edit.php12
3 files changed, 80 insertions, 86 deletions
diff --git a/mod/garbagecollector/languages/en.php b/mod/garbagecollector/languages/en.php
index fbebf54b4..b32670a0c 100644
--- a/mod/garbagecollector/languages/en.php
+++ b/mod/garbagecollector/languages/en.php
@@ -1,32 +1,25 @@
<?php
- /**
- * Elgg garbage collector language pack.
- *
- * @package ElggGarbageCollector
- */
+/**
+ * Elgg garbage collector language pack.
+ *
+ * @package ElggGarbageCollector
+ */
- $english = array(
-
- /**
- * Menu items and titles
- */
-
- 'garbagecollector:period' => 'How often should the Elgg garbage collector run?',
-
- 'garbagecollector:weekly' => 'Once a week',
- 'garbagecollector:monthly' => 'Once a month',
- 'garbagecollector:yearly' => 'Once a year',
-
- 'garbagecollector' => "GARBAGE COLLECTOR\n",
- 'garbagecollector:done' => "DONE\n",
- 'garbagecollector:optimize' => "Optimizing %s ",
-
- 'garbagecollector:error' => "ERROR",
- 'garbagecollector:ok' => "OK",
-
- 'garbagecollector:gc:metastrings' => 'Cleaning up unlinked metastrings: ',
-
- );
-
- add_translation("en",$english);
-?> \ No newline at end of file
+$english = array(
+ 'garbagecollector:period' => 'How often should the Elgg garbage collector run?',
+
+ 'garbagecollector:weekly' => 'Once a week',
+ 'garbagecollector:monthly' => 'Once a month',
+ 'garbagecollector:yearly' => 'Once a year',
+
+ 'garbagecollector' => "GARBAGE COLLECTOR\n",
+ 'garbagecollector:done' => "DONE\n",
+ 'garbagecollector:optimize' => "Optimizing %s ",
+
+ 'garbagecollector:error' => "ERROR",
+ 'garbagecollector:ok' => "OK",
+
+ 'garbagecollector:gc:metastrings' => 'Cleaning up unlinked metastrings: ',
+);
+
+add_translation("en", $english); \ No newline at end of file
diff --git a/mod/garbagecollector/start.php b/mod/garbagecollector/start.php
index 26a462207..6267ab1ba 100644
--- a/mod/garbagecollector/start.php
+++ b/mod/garbagecollector/start.php
@@ -1,71 +1,64 @@
<?php
- /**
- * Elgg garbage collector.
- *
- * @package ElggGarbageCollector
- */
+/**
+ * Elgg garbage collector.
+ *
+ * @package ElggGarbageCollector
+ */
- /**
- * Initialise the plugin.
- *
- */
- function garbagecollector_init()
- {
- $period = get_plugin_setting('period','garbagecollector');
- switch ($period)
- {
- case 'weekly':
- case 'monthly' :
- case 'yearly' :
- break;
- default: $period = 'monthly';
- }
+elgg_register_event_handler('init', 'system', 'garbagecollector_init');
- // Register cron hook
- elgg_register_plugin_hook_handler('cron', $period, 'garbagecollector_cron');
+function garbagecollector_init() {
+ $period = get_plugin_setting('period', 'garbagecollector');
+ switch ($period) {
+ case 'weekly':
+ case 'monthly':
+ case 'yearly':
+ break;
+ default:
+ $period = 'monthly';
}
- /**
- * Cron job
- *
- */
- function garbagecollector_cron($hook, $entity_type, $returnvalue, $params)
- {
- global $CONFIG;
+ // Register cron hook
+ elgg_register_plugin_hook_handler('cron', $period, 'garbagecollector_cron');
+}
- echo elgg_echo('garbagecollector');
+/**
+ * Cron job
+ */
+function garbagecollector_cron($hook, $entity_type, $returnvalue, $params) {
+ global $CONFIG;
- // Garbage collect metastrings
- echo elgg_echo('garbagecollector:gc:metastrings');
+ echo elgg_echo('garbagecollector');
- if (delete_orphaned_metastrings()!==false) {
- echo elgg_echo('garbagecollector:ok');
- } else
- echo elgg_echo('garbagecollector:error');
+ // Garbage collect metastrings
+ echo elgg_echo('garbagecollector:gc:metastrings');
- echo "\n";
+ if (delete_orphaned_metastrings() !== false) {
+ echo elgg_echo('garbagecollector:ok');
+ } else {
+ echo elgg_echo('garbagecollector:error');
+ }
- // Now, because we are nice, trigger a plugin hook to let other plugins do some GC
- $rv = true;
- $period = get_plugin_setting('period','garbagecollector');
- elgg_trigger_plugin_hook('gc', 'system', array('period' => $period));
+ echo "\n";
- // Now we optimize all tables
- $tables = get_db_tables();
- foreach ($tables as $table) {
- echo elgg_echo('garbagecollector:optimize', array($table));
+ // Now, because we are nice, trigger a plugin hook to let other plugins do some GC
+ $rv = true;
+ $period = get_plugin_setting('period','garbagecollector');
+ elgg_trigger_plugin_hook('gc', 'system', array('period' => $period));
- if (optimize_table($table)!==false)
- echo elgg_echo('garbagecollector:ok');
- else
- echo elgg_echo('garbagecollector:error');
+ // Now we optimize all tables
+ $tables = get_db_tables();
+ foreach ($tables as $table) {
+ echo elgg_echo('garbagecollector:optimize', array($table));
- echo "\n";
+ if (optimize_table($table) !== false) {
+ echo elgg_echo('garbagecollector:ok');
+ } else {
+ echo elgg_echo('garbagecollector:error');
}
- echo elgg_echo('garbagecollector:done');
+ echo "\n";
}
- // Initialise plugin
- elgg_register_event_handler('init','system','garbagecollector_init');
-?> \ No newline at end of file
+ echo elgg_echo('garbagecollector:done');
+}
diff --git a/mod/garbagecollector/views/default/settings/garbagecollector/edit.php b/mod/garbagecollector/views/default/settings/garbagecollector/edit.php
index 19ae3d245..e05b5d778 100644
--- a/mod/garbagecollector/views/default/settings/garbagecollector/edit.php
+++ b/mod/garbagecollector/views/default/settings/garbagecollector/edit.php
@@ -1,6 +1,14 @@
<?php
- $period = $vars['entity']->period;
- if (!$period) $period = 'monthly';
+/**
+ * Elgg garbage collector plugin settings.
+ *
+ * @package ElggGarbageCollector
+ */
+
+$period = $vars['entity']->period;
+if (!$period) {
+ $period = 'monthly';
+}
?>
<p>