| 1 |
$Id: API.txt,v 1.1 2005/06/03 04:02:09 syscrusher Exp $
|
| 2 |
|
| 3 |
INFORMATION FOR DEVELOPERS USING THE CRONPLUS HOOKS
|
| 4 |
|
| 5 |
|
| 6 |
CronPlus implements some very simple hooks that can be used by
|
| 7 |
developers in other modules.
|
| 8 |
|
| 9 |
The following functions are available to you; in this document,
|
| 10 |
replace the word "module" in function names with the actual name
|
| 11 |
of your module. For example, if you create "foo_bar.module", then
|
| 12 |
the hourly hook you can define (if you wish) is:
|
| 13 |
|
| 14 |
function foo_bar_cronplus_hourly($now, $last_cron, $last_this) {
|
| 15 |
// This code will be executed approximately once per hour
|
| 16 |
}
|
| 17 |
|
| 18 |
The parameters for the functions are all the same:
|
| 19 |
|
| 20 |
$now This is the integer timestamp (seconds since the
|
| 21 |
epoch, 1970-01-01 00:00:00 UTC) at which this
|
| 22 |
run of CronPlus began. Applications should normally
|
| 23 |
use this value as the nominal time at which their
|
| 24 |
internal events occur, although that is not
|
| 25 |
enforced in any way by CronPlus itself. The reason
|
| 26 |
for this suggestion is that this timestamp can
|
| 27 |
then uniquely identify a particular run of CronPlus.
|
| 28 |
|
| 29 |
$last_cron This is the integer timestamp (same semantics
|
| 30 |
as $now) of the most recent previous run of CronPlus.
|
| 31 |
Note that this is *NOT* necessarily the same as the
|
| 32 |
last previous run of the specific hook being invoked
|
| 33 |
now.
|
| 34 |
|
| 35 |
$last_this This is the integer timestamp (same semantics
|
| 36 |
as $now) of the most recent previous run of this
|
| 37 |
specific hook. Note that this value was a copy of
|
| 38 |
$now for that run, and *NOT* the actual clock time
|
| 39 |
at which the local module's function call was
|
| 40 |
invoked.
|
| 41 |
|
| 42 |
If applicable, the time values default to zero to represent "never".
|
| 43 |
|
| 44 |
In addition to the separate hook functions, CronPlus will call a
|
| 45 |
"multiplex hook" that passes the $period ('hourly', 'daily', and
|
| 46 |
so on) as the first parameter, then the other parameters the same
|
| 47 |
as above. This is useful if the module wants to handle its own
|
| 48 |
internal table of events that happen with each time period. The
|
| 49 |
helper function cronplus_periods() can be used to obtain a list
|
| 50 |
(with translations) of the available time periods, so that modules
|
| 51 |
can build their internal table options dynamically without needing
|
| 52 |
to worry about the specific periods.
|
| 53 |
|
| 54 |
Here are the hook functions:
|
| 55 |
|
| 56 |
function module_cronplus_hourly($now, $last_cron, $last_this)
|
| 57 |
|
| 58 |
function module_cronplus_daily($now, $last_cron, $last_this)
|
| 59 |
|
| 60 |
function module_cronplus_weekly($now, $last_cron, $last_this)
|
| 61 |
|
| 62 |
function module_cronplus_monthly($now, $last_cron, $last_this)
|
| 63 |
|
| 64 |
function module_cronplus_yearly($now, $last_cron, $last_this)
|
| 65 |
|
| 66 |
function module_cronplus($period, $now, $last_cron, $last_this)
|