This repository has been archived on 2024-04-08. You can view files and clone it, but cannot push or open issues or pull requests.
2013-03-20 23:04:51 +11:00

47 lines
1.2 KiB
PHP

<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* Run active tasks according to their CRON schedule
*
* @package Task
* @category Tasks
* @author Deon George
* @copyright (c) 2009-2013 Open Source Billing
* @license http://dev.osbill.net/license.html
*/
class Task_Task_Run extends Task {
protected function _execute(array $params) {
if ($params['id']) {
$to = ORM::factory('Task',$params['id']);
if ($to->loaded()) {
if (! $to->status)
throw new Minion_Exception_InvalidTask('Task :task (:name) NOT active',array(':task'=>$params['id'],':name'=>$to->name));
if (! Kohana::$config->load('debug')->task_sim)
$to->run($params['force']);
else
printf('Would Run task: (%s) %s',$params['id'],$to->name);
echo "\n";
} else
throw new Minion_Exception_InvalidTask('Unknown task :task',array(':task'=>$params['id']));
} else {
$tlo = ORM::factory('Task');
$t = time();
foreach ($tlo->list_active() as $to)
if ($to['next'] < $t) {
if (! Kohana::$config->load('debug')->task_sim)
$to['task']->run();
else
printf('Would Run task: (%s) %s',$to['task']->id,$to['task']->name);
echo "\n";
}
}
}
}
?>