blob: 75897fb21ebdaa01e6847981883202f0489d7ea6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
<?php
/**
* Elgg cron library.
*
* @package Elgg
* @subpackage Core
* @author Curverider Ltd
* @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');
// register a hook for Walled Garden public pages
register_plugin_hook('public_pages', 'walled_garden', 'cron_public_pages');
}
/**
* Cron handler for redirecting pages.
*
* @param unknown_type $page
*/
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(sprintf(elgg_echo('CronException:unknownperiod'), $page[0]));
}
// Include cron handler
include($CONFIG->path . "engine/handlers/cron_handler.php");
} else {
forward();
}
}
function cron_public_pages($hook, $type, $return_value, $params) {
global $CONFIG;
$return_value[] = "{$CONFIG->url}pg/cron/minute";
$return_value[] = "{$CONFIG->url}pg/cron/fiveminute";
$return_value[] = "{$CONFIG->url}pg/cron/fifteenmin";
$return_value[] = "{$CONFIG->url}pg/cron/halfhour";
$return_value[] = "{$CONFIG->url}pg/cron/hourly";
$return_value[] = "{$CONFIG->url}pg/cron/daily";
$return_value[] = "{$CONFIG->url}pg/cron/weekly";
$return_value[] = "{$CONFIG->url}pg/cron/monthly";
$return_value[] = "{$CONFIG->url}pg/cron/yearly";
$return_value[] = "{$CONFIG->url}pg/cron/reboot";
return $return_value;
}
// Register a startup event
register_elgg_event_handler('init','system','cron_init');
|