aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mod/crontrigger/manifest.xml8
-rw-r--r--mod/crontrigger/start.php82
2 files changed, 90 insertions, 0 deletions
diff --git a/mod/crontrigger/manifest.xml b/mod/crontrigger/manifest.xml
new file mode 100644
index 000000000..c5bc2cdad
--- /dev/null
+++ b/mod/crontrigger/manifest.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<plugin_manifest>
+ <field key="author" value="Curverider Ltd" />
+ <field key="version" value="1.0" />
+ <field key="description" value="Provides a poor man's cron trigger to trigger cron scripts based on site visits." />
+ <field key="website" value="http://www.elgg.org/" />
+ <field key="copyright" value="(C) Curverider 2008" />
+</plugin_manifest> \ No newline at end of file
diff --git a/mod/crontrigger/start.php b/mod/crontrigger/start.php
new file mode 100644
index 000000000..f0f72f291
--- /dev/null
+++ b/mod/crontrigger/start.php
@@ -0,0 +1,82 @@
+<?php
+ /**
+ * Elgg Cron trigger.
+ * When enabled this plugin provides "poor man's cron" functionality to trigger elgg cron scripts without the need
+ * to install the cron script.
+ *
+ * Note, this is a substitute and not a replacement for the cron script. It is recommended that you use the cron script
+ * where possible.
+ *
+ * @package ElggCronTrigger
+ * @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 crontrigger_init()
+ {
+ register_elgg_event_handler('shutdown', 'system', 'crontrigger_shutdownhook');
+ }
+
+ function crontrigger_trigger($period) { trigger_plugin_hook('cron', $period); }
+
+ function crontrigger_minute() { crontrigger_trigger('minute'); }
+
+ function crontrigger_fiveminute() { crontrigger_trigger('fiveminute'); }
+
+ function crontrigger_fifteenmin() { crontrigger_trigger('fifteenmin'); }
+
+ function crontrigger_halfhour() { crontrigger_trigger('halfhour'); }
+
+ function crontrigger_hourly() { crontrigger_trigger('hourly'); }
+
+ function crontrigger_daily() { crontrigger_trigger('daily'); }
+
+ function crontrigger_weekly() { crontrigger_trigger('weekly'); }
+
+ function crontrigger_monthly() { crontrigger_trigger('monthly'); }
+
+ function crontrigger_yearly() { crontrigger_trigger('yearly'); }
+
+ /**
+ * Call cron hooks after a page has been displayed (so user won't notice any slowdown).
+ *
+ * It uses a mod of now and needs someone to view the page within a certain time period
+ *
+ */
+ function crontrigger_shutdownhook()
+ {
+ global $CONFIG;
+
+ $minute = 60;
+ $fiveminute = $minute*5;
+ $fifteenmin = $minute*15;
+ $halfhour = $minute*30;
+ $hour = 3600;
+ $day = $hour*24;
+ $week = $day * 7;
+ $month = $week * 4;
+ $year = $month * 12;
+
+ $now = time();
+
+ run_function_once('crontrigger_minute', $now - $minute);
+ run_function_once('crontrigger_fiveminute', $now - $fiveminute);
+ run_function_once('crontrigger_fifteenmin', $now - $fifteenmin);
+ run_function_once('crontrigger_halfhour', $now - $halfhour);
+ run_function_once('crontrigger_hourly', $now - $hour);
+ run_function_once('crontrigger_daily', $now - $day);
+ run_function_once('crontrigger_weekly', $now - $week);
+ run_function_once('crontrigger_monthly', $now - $month);
+ run_function_once('crontrigger_yearly', $now - $year);
+ }
+
+
+ // Initialise plugin
+ register_elgg_event_handler('init','system','crontrigger_init');
+?> \ No newline at end of file