Dotclear


Version 11 (modified by Tomtom33, 14 years ago) (diff)

Added icon

Français

source:plugins/dcCron/icon.png

dcCron

Schedule any tasks

Author/Contributors?

Development

Bugs and features requests

Repository

Recent Changes

[2656] by Tomtom33 on 09/21/10 12:33:53

dcCron:

  • Updated link with dcLog plugin
  • Updated CSS class for tasks list

[2654] by Tomtom33 on 09/21/10 11:28:34

dcCron 2.0-RC2:

  • Exception management for check() function
  • Improved filters
  • Improved UI

[2650] by Tomtom33 on 09/20/10 20:06:11

dcCron 2.0-RC1:

  • Lock file support
  • Fixed date concurrency
  • Improved tasks check
  • Improved UI

Documentation

dcCron is a generic plugin can be called by others to schedule tasks. It provides a simply API to use it.

Add / Modify task

To add a task in dcCron, just put this in your code :

if (isset($core->blog->dcCron)) {
 $core->blog->dcCron->put('taskNameId','interval','callback');
}
  • taskNameId must be an alphanumeric string. That's means just contains letters and numbers.
  • interval must be an interger. Second is the unit.
  • callback must be an array with class name or object in first argument and function in second. Function used for callback must be a static method. You can not specify an object.

If a task is already defined, function will update task with new parameters and execute the callback. If one or more parameters are invalid, function will generate exceptions displayed like errors in admin interface with prefix [dcCron].

Delete on or more tasks

To delete tasks just put this in your code :

if (isset($core->blog->dcCron)) {
 $array = array(
  'taskNameId1',
  'taskNameId2',
  ...
 $core->blog->dcCron->del($array);
}
  • $array must be an array containning tasks names id. These task names id must be an alphanumeric string. That's means just contains letters and numbers.

Verify if task exists

To verify if task exists or not, just put this code :

if ($core->blog->dcCron->taskExists('taskNameId')) {
 # Task exists at this point
}
  • taskNameId must be a valide task name id.

Enable / Disable task

To enable / disable task, just put this code :

if (isset($core->blog->dcCron)) {
 # To enable task
 $core->blog->dcCron->enable('taskNameId');
 # To disable task
 $core->blog->dcCron->disable('taskNameId');
}
  • taskNameId must be a valide task name id. If not, an exception will be generated.

Disabled task won't be execited even if interval is exceeded. It's can be usefull for tests or integration in other plugins.

Get task interval

To get task interval, just put this code :

$core->blog->dcCron->getTaskInterval('taskNameId');
  • taskNameId must be a valide task name id. If task doesn't exists, function returns false, else returns interval in second

Get remaining time

To get task remaining time, just put this code :

$core->blog->dcCron->getRemainingTime('taskNameId');
  • taskNameId must be a valide task name id. If task doesn't exists, function returns false, else returns remaining time in second

Get next run date of task

To get the next run date of task, just put this code :

$core->blog->dcCron->getNextRunDate('taskNameId');
  • taskNameId must be a valide task name id. If task doesn't exists, function returns false, else returns timestamp of the next run

Attachments

Sites map