Elgg
Version 1.11
Main Page
Related Pages
Namespaces
Classes
Files
Examples
File List
File Members
engine
lib
cron.php
Go to the documentation of this file.
1
<?php
15
function
_elgg_cron_init
() {
16
elgg_register_page_handler
(
'cron'
,
'_elgg_cron_page_handler'
);
17
18
elgg_register_plugin_hook_handler
(
'cron'
,
'all'
,
'_elgg_cron_monitor'
, 1000);
19
20
elgg_set_config
(
'elgg_cron_periods'
, array(
21
'minute'
,
22
'fiveminute'
,
23
'fifteenmin'
,
24
'halfhour'
,
25
'hourly'
,
26
'daily'
,
27
'weekly'
,
28
'monthly'
,
29
'yearly'
,
30
// reboot is deprecated and probably does not work
31
'reboot'
,
32
));
33
34
elgg_register_admin_menu_item
(
'administer'
,
'cron'
,
'statistics'
);
35
}
36
46
function
_elgg_cron_page_handler
($page) {
47
if
(!isset($page[0])) {
48
forward
();
49
}
50
51
$period = strtolower($page[0]);
52
53
$allowed_periods =
elgg_get_config
(
'elgg_cron_periods'
);
54
55
if
(!in_array($period, $allowed_periods)) {
56
throw
new \CronException(
"$period is not a recognized cron period."
);
57
}
58
59
// Get a list of parameters
60
$params
= array();
61
$params
[
'time'
] = time();
62
63
// Data to return to
64
$old_stdout =
""
;
65
ob_start();
66
67
$old_stdout =
elgg_trigger_plugin_hook
(
'cron'
, $period,
$params
, $old_stdout);
68
$std_out = ob_get_clean();
69
70
echo
$std_out . $old_stdout;
71
return
true
;
72
}
73
84
function
_elgg_cron_monitor
($hook, $period,
$output
,
$params
) {
85
$time =
$params
[
'time'
];
86
$periods
=
elgg_get_config
(
'elgg_cron_periods'
);
87
88
if
(in_array($period,
$periods
)) {
89
$key
=
"cron_latest:$period:ts"
;
90
elgg_get_site_entity
()->setPrivateSetting(
$key
, $time);
91
}
92
}
93
94
return
function
(
\Elgg\EventsService
$events,
\Elgg\HooksRegistrationService
$hooks) {
95
$events->registerHandler(
'init'
,
'system'
,
'_elgg_cron_init'
);
96
};
elgg_get_config
elgg_get_config($name, $site_guid=0)
Get an Elgg configuration value.
Definition:
configuration.php:71
elgg_get_site_entity
elgg_get_site_entity($site_guid=0)
Get an entity (default is current site)
Definition:
sites.php:18
_elgg_cron_page_handler
_elgg_cron_page_handler($page)
Cron handler.
Definition:
cron.php:46
Elgg\EventsService
Definition:
EventsService.php:14
forward
elgg forward
Meant to mimic the php forward() function by simply redirecting the user to another page...
Definition:
elgglib.js:419
elgg_register_plugin_hook_handler
elgg_register_plugin_hook_handler($hook, $type, $callback, $priority=500)
Definition:
elgglib.php:703
$params
$params
Definition:
login.php:72
elgg_register_admin_menu_item
elgg_register_admin_menu_item($section, $menu_id, $parent_id=null, $priority=100)
Add an admin area section or child section.
Definition:
admin.php:142
Elgg\HooksRegistrationService
Definition:
HooksRegistrationService.php:15
$key
$key
Definition:
summary.php:34
elgg_set_config
elgg_set_config($name, $value)
Set an Elgg configuration value.
Definition:
configuration.php:86
echo
elgg echo
Translates a string.
Definition:
languages.js:43
elgg_trigger_plugin_hook
elgg_trigger_plugin_hook($hook, $type, $params=null, $returnvalue=null)
Definition:
elgglib.php:775
_elgg_cron_monitor
_elgg_cron_monitor($hook, $period, $output, $params)
Record cron running.
Definition:
cron.php:84
elgg_register_page_handler
elgg_register_page_handler($identifier, $function)
Registers a page handler for a particular identifier.
Definition:
pagehandler.php:34
_elgg_cron_init
_elgg_cron_init()
Cron initialization.
Definition:
cron.php:15
$periods
$periods
Cron statistics.
Definition:
cron.php:7
$output
$output
Definition:
item.php:10
Generated on Mon Dec 30 2024 00:00:48 for Elgg by
1.8.11