* @package ow_cron * @since 1.0 */ define('_OW_', true); define('DS', DIRECTORY_SEPARATOR); define('OW_DIR_ROOT', substr(dirname(__FILE__), 0, - strlen('ow_cron'))); $_SERVER['REQUEST_URI'] = ''; // just a hack that kills the annoying notice require_once(OW_DIR_ROOT . 'ow_includes' . DS . 'init.php'); $application = OW_Application::getInstance(); $application->init(); $plugins = BOL_PluginService::getInstance()->findActivePlugins(); foreach ( $plugins as $plugin ) { /* @var $plugin BOL_Plugin */ $pluginRootDir = OW::getPluginManager()->getPlugin($plugin->getKey())->getRootDir(); if ( file_exists($pluginRootDir . DS . 'cron.php') ) { include $pluginRootDir . DS . 'cron.php'; $className = strtoupper($plugin->getKey()) . '_Cron'; $cron = new $className; $runJobs = array(); $newRunJobDtos = array(); foreach ( BOL_CronService::getInstance()->findJobList() as $runJob ) { /* @var $runJob BOL_CronJob */ $runJobs[$runJob->methodName] = $runJob->runStamp; } $jobs = $cron->getJobList(); foreach ( $jobs as $job => $interval ) { $methodName = $className . '::' . $job; $runStamp = ( isset($runJobs[$methodName]) ) ? $runJobs[$methodName] : 0; $currentStamp = time(); if ( ( $currentStamp - $runStamp ) > ( $interval * 60 ) ) { $cron->$job(); $runJobDto = new BOL_CronJob(); $runJobDto->methodName = $methodName; $runJobDto->runStamp = $currentStamp; $newRunJobDtos[] = $runJobDto; } } if ( count($newRunJobDtos) > 0 ) { BOL_CronService::getInstance()->batchSave($newRunJobDtos); } } }