/** * When a post is published, add a cron entry to do pinging * * @param Post $post A post object whose status has been set to published */ public function action_post_status_published($post) { if ($post->status == Post::status('published') && $post->pubdate <= HabariDateTime::date_create()) { CronTab::add_single_cron('ping update sites', array('Autopinger', 'ping_sites'), HabariDateTime::date_create()->int, 'Ping update sites.'); EventLog::log('Crontab added', 'info', 'default', null, null); } }
public function action_plugin_activation($file = '') { if (Plugins::id_from_file($file) == Plugins::id_from_file(__FILE__)) { if (Options::get('database_optimizer__frequency') == null) { Options::set('database_optimizer__frequency', 'weekly'); } // add a cronjob to kick off next and optimize our db now CronTab::add_single_cron('optimize database tables initial', 'optimize_database', HabariDateTime::date_create(time()), 'Optimizes database tables.'); $this->create_cron(); } }
public function test_delete_on_fail() { $job = CronTab::add_single_cron('test_delete_fail', 'this_cron_hook_doesnt_exist', DateTime::create(), 'Test Cron'); for ($z = 0; $z < 10; $z++) { $job = CronTab::get_cronjob('test_delete_fail'); Options::set('next_cron', 0); Options::delete('cron_running'); $job->execute(); } $this->assert_false($job->active, 'The cron is still active after failing more than the allowed number of times.'); CronTab::delete_cronjob('test_delete_fail'); }
/** * function update_scheduled_posts_cronjob * * Creates or recreates the cronjob to publish * scheduled posts. It is called whenever a post * is updated or created * */ public static function update_scheduled_posts_cronjob() { $min_time = DB::get_value('SELECT MIN(pubdate) FROM {posts} WHERE status = ?', array(Post::status('scheduled'))); CronTab::delete_cronjob('publish_scheduled_posts'); if ($min_time) { CronTab::add_single_cron('publish_scheduled_posts', array('Posts', 'publish_scheduled_posts'), $min_time, 'Next run: ' . HabariDateTime::date_create($min_time)->get('c')); } }
/** * Compare the current set of plugins with those we last checked for updates. * This is run by AdminHandler on every page load to make sure we always have fresh data on the dashboard. */ public static function check_plugins() { // register the beacons self::register_beacons(); // get the list we checked last time $checked_list = Options::get('updates_beacons'); // if the lists are different if ($checked_list != self::instance()->beacons) { // remove any stored updates, just to avoid showing stale data Options::delete('updates_available'); // schedule an update check the next time cron runs CronTab::add_single_cron('update_check_single', Method::create('\\Habari\\Update', 'cron'), DateTime::create()->int, _t('Perform a single check for plugin updates, the plugin set has changed.')); } }
public function action_post_status_published($post) { if ($post->status == Post::status('published')) { CronTab::add_single_cron('ping update sites', 'ping_sites', time(), 'Ping update sites.'); } }