aboutsummaryrefslogtreecommitdiff
path: root/engine/lib/cron.php
diff options
context:
space:
mode:
authorcash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>2010-11-23 22:46:37 +0000
committercash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>2010-11-23 22:46:37 +0000
commit149fc3a347ccde2c18b9912ab8c8e0adaa12e3f1 (patch)
treebf2554917870c19f1082b52eb7b1f0820a79aaab /engine/lib/cron.php
parent9ce3852126ed544301f0822d845cde7af9cecb15 (diff)
downloadelgg-149fc3a347ccde2c18b9912ab8c8e0adaa12e3f1.tar.gz
elgg-149fc3a347ccde2c18b9912ab8c8e0adaa12e3f1.tar.bz2
Fixes #2472 move cron_handler.php logic into cron page handler
git-svn-id: http://code.elgg.org/elgg/trunk@7430 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'engine/lib/cron.php')
-rw-r--r--engine/lib/cron.php56
1 files changed, 32 insertions, 24 deletions
diff --git a/engine/lib/cron.php b/engine/lib/cron.php
index 9d47e95d1..ff57a41f1 100644
--- a/engine/lib/cron.php
+++ b/engine/lib/cron.php
@@ -7,7 +7,7 @@
*/
/**
- * Initialisation
+ * Cron initialization
*
* @return void
*/
@@ -20,7 +20,7 @@ function cron_init() {
}
/**
- * Cron handler for redirecting pages.
+ * Cron handler
*
* @param array $page Pages
*
@@ -29,29 +29,38 @@ function cron_init() {
function cron_page_handler($page) {
global $CONFIG;
- if ($page[0]) {
- switch (strtolower($page[0])) {
- case 'minute' :
- case 'fiveminute' :
- case 'fifteenmin' :
- case 'halfhour' :
- case 'hourly' :
- case 'daily' :
- case 'weekly' :
- case 'monthly':
- case 'yearly' :
- case 'reboot' :
- set_input('period', $page[0]);
- break;
- default :
- throw new CronException(elgg_echo('CronException:unknownperiod', array($page[0])));
- }
-
- // Include cron handler
- include($CONFIG->path . "engine/handlers/cron_handler.php");
- } else {
+ if (!isset($page[0])) {
forward();
}
+
+ $period = strtolower($page[0]);
+
+ $allowed_periods = array(
+ 'minute', 'fiveminute', 'fifteenmin', 'halfhour', 'hourly',
+ 'daily', 'weekly', 'monthly', 'yearly', 'reboot'
+ );
+
+ if (!in_array($period, $allowed_periods)) {
+ throw new CronException(elgg_echo('CronException:unknownperiod', array($period)));
+ }
+
+ // Get a list of parameters
+ $params = array();
+ $params['time'] = time();
+
+ foreach ($CONFIG->input as $k => $v) {
+ $params[$k] = $v;
+ }
+
+ // Data to return to
+ $std_out = "";
+ $old_stdout = "";
+ ob_start();
+
+ $old_stdout = elgg_trigger_plugin_hook('cron', $period, $params, $old_stdout);
+ $std_out = ob_get_clean();
+
+ echo $std_out . $old_stdout;
}
/**
@@ -79,5 +88,4 @@ function cron_public_pages($hook, $type, $return_value, $params) {
return $return_value;
}
-// Register a startup event
elgg_register_event_handler('init', 'system', 'cron_init'); \ No newline at end of file