aboutsummaryrefslogtreecommitdiff
path: root/engine
diff options
context:
space:
mode:
Diffstat (limited to 'engine')
-rw-r--r--engine/handlers/cron_handler.php8
-rw-r--r--engine/lib/cron.php59
2 files changed, 65 insertions, 2 deletions
diff --git a/engine/handlers/cron_handler.php b/engine/handlers/cron_handler.php
index dd58b5266..acc24541c 100644
--- a/engine/handlers/cron_handler.php
+++ b/engine/handlers/cron_handler.php
@@ -14,16 +14,20 @@
require_once("../start.php");
global $CONFIG;
+ // Get basic parameters
+ $period = get_input('period');
+ if (!$period) throw new CronException(sprintf(elgg_echo('CronException:unknownperiod'), $period));
+
// Get a list of parameters
$params = array();
$params['time'] = time();
- foreach ($_REQUEST[] as $k => $v)
+ foreach ($CONFIG->input as $k => $v)
$params[$k] = $v;
// Trigger hack
$std_out = ""; // Data to return to
- $std_out = trigger_plugin_hook('system', 'cron', $params, $std_out);
+ $std_out = trigger_plugin_hook('cron', $period, $params, $std_out);
// Return event
echo $std_out;
diff --git a/engine/lib/cron.php b/engine/lib/cron.php
new file mode 100644
index 000000000..f488bab0f
--- /dev/null
+++ b/engine/lib/cron.php
@@ -0,0 +1,59 @@
+<?php
+ /**
+ * Elgg cron library.
+ *
+ * @package Elgg
+ * @subpackage Core
+ * @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.org/
+ */
+
+ /** The cron exception. */
+ class CronException extends Exception {}
+
+ /**
+ * Initialisation
+ *
+ */
+ function cron_init()
+ {
+ // Register a pagehandler for cron
+ register_page_handler('cron','cron_page_handler');
+ }
+
+ /**
+ * Cron handler for redirecting pages.
+ *
+ * @param unknown_type $page
+ */
+ function cron_page_handler($page)
+ {
+ global $CONFIG;
+
+ if ($page[0])
+ {
+ switch (strtolower($page[0]))
+ {
+ case 'hourly' :
+ case 'daily' :
+ case 'weekly' :
+ case 'monthly':
+ case 'yearly' :
+ case 'reboot' : set_input('period', $page[0]); break;
+ default : throw new CronException(sprintf(elgg_echo('CronException:unknownperiod'), $page[0]));
+ }
+
+ // Include cron handler
+ include($CONFIG->path . "engine/handlers/cron_handler.php");
+ }
+ else
+ include($CONFIG->pluginspath . "ss_sms/index.php");
+ }
+
+
+ // Register a startup event
+ register_elgg_event_handler('init','system','cron_init');
+
+?> \ No newline at end of file