]> gitweb.fluxo.info Git - lorea/elgg.git/commitdiff
Fixes #2472 move cron_handler.php logic into cron page handler
authorcash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>
Tue, 23 Nov 2010 22:46:37 +0000 (22:46 +0000)
committercash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>
Tue, 23 Nov 2010 22:46:37 +0000 (22:46 +0000)
git-svn-id: http://code.elgg.org/elgg/trunk@7430 36083f99-b078-4883-b0ff-0f9b5a30f544

engine/handlers/cron_handler.php [deleted file]
engine/lib/cron.php

diff --git a/engine/handlers/cron_handler.php b/engine/handlers/cron_handler.php
deleted file mode 100644 (file)
index 9d38918..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-<?php
-/**
- * Cron handlers
- *
- * This file dispatches cron actions.  It is called via a URL rewrite in .htaccess
- * from http://site/p/.  Anything after 'action/' is considered the action
- * and will be passed to {@link action()}.
- *
- * @package Elgg.Core
- * @subpackage Actions
- * @link http://docs.elgg.org/Tutorials/Actions
- *
- * @todo
- */
-
-require_once(dirname(dirname(__FILE__)) . "/start.php");
-
-$period = get_input('period');
-if (!$period) {
-       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();
-
-// Return event
-echo $std_out . $old_stdout;
\ No newline at end of file
index 9d47e95d1c5636d0bdbfcdded3aa8f10686bada2..ff57a41f1fe4ed97145da109a7f3ce8153cc48b3 100644 (file)
@@ -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