You are here

function _ultimate_cron_import_parallel_cron in Ultimate Cron 6

Import settings from Parallel Cron

1 call to _ultimate_cron_import_parallel_cron()
ultimate_cron_import_form_submit in ./ultimate_cron.admin.inc
Submit handler for import.

File

./ultimate_cron.admin.inc, line 635

Code

function _ultimate_cron_import_parallel_cron() {
  $result = db_query("SELECT j.function, j.rule, j.active, g.name AS `group` FROM {parallel_cron_jobs} j LEFT JOIN {parallel_cron_groups} g ON j.gid = g.gid");
  $imported = 0;
  $conf = array();
  while ($row = db_fetch_object($result)) {
    $conf = ultimate_cron_get_settings($row->function);
    if (!is_null($conf)) {
      $conf['enabled'] = $row->active ? 1 : 0;
      $rule = trim($row->rule);
      if (!empty($rule)) {
        $conf['rules'] = array(
          trim($row->rule),
        );
      }
      $conf['service_group'] = $row->group;
      ultimate_cron_set_settings($row->function, $conf);
      drupal_set_message(t('Imported %function', array(
        '%function' => $row->function,
      )));
      $imported++;
    }
  }
  drupal_set_message(t('Imported %imported settings', array(
    '%imported' => $imported,
  )));
}