You are here

function elysia_cron_initialize in Elysia Cron 7.2

Same name and namespace in other branches
  1. 5.2 elysia_cron.module \elysia_cron_initialize()
  2. 5 elysia_cron.module \elysia_cron_initialize()
  3. 6.2 elysia_cron.module \elysia_cron_initialize()
  4. 6 elysia_cron.module \elysia_cron_initialize()
  5. 7 elysia_cron.module \elysia_cron_initialize()
9 calls to elysia_cron_initialize()
drush_elysia_cron_run_wrapper in ./elysia_cron.drush.inc
Custom callback for 'elysia-cron' drush command.
elysia_cron_admin_menu in ./elysia_cron.module
Implements hook_admin_menu().
elysia_cron_admin_page in ./elysia_cron.admin.inc
Page callback for 'admin/config/system/cron' path.
elysia_cron_is_running in ./elysia_cron.module
Check if cron is currently running. (Not used by elysia_cron, can be used by external modules)
elysia_cron_reset_stats in ./elysia_cron.module

... See full list

File

./elysia_cron.module, line 1066

Code

function elysia_cron_initialize($skipscript = FALSE) {
  global $_elysia_cron_settings, $_elysia_cron_settings_by_channel;
  if (empty($_elysia_cron_settings)) {
    $_elysia_cron_settings = array();
    $_elysia_cron_settings_by_channel = array();
    foreach (elysia_cron_module_jobs() as $job => $jobpars) {
      $channel = elysia_cron_get_job_channel($job, 'default');
      $defrule = !empty($jobpars['rule']) ? $jobpars['rule'] : elysia_cron_get_channel_rule($channel);
      if (!$defrule) {
        $defrule = variable_get('elysia_cron_default_rule', '0 * * * *');
      }
      $defweight = !empty($jobpars['weight']) ? $jobpars['weight'] : 0;
      if (!is_numeric($defweight)) {
        $defweight = 0;
      }
      $_elysia_cron_settings[$job] = array(
        'key' => $job,
        'channel' => $channel,
        'rule' => elysia_cron_get_job_rule($job, $defrule),
        'default_rule' => $defrule,
        'weight' => elysia_cron_get_job_weight($job, $defweight),
        'default_weight' => $defweight,
        'disabled' => elysia_cron_is_job_disabled($job),
        'running' => elysia_cron_is_job_running($job),
      ) + $jobpars;
    }
    if (!$skipscript) {
      $script = variable_get('elysia_cron_script', FALSE);
      if ($script) {
        elysia_cron_decode_script($script);
      }
    }
    uasort($_elysia_cron_settings, '_elysia_cron_sort');
    foreach ($_elysia_cron_settings as $job => &$conf) {
      $stats = elysia_cron_get_job_stats($job);
      foreach ($stats as $sk => $sv) {
        $conf[$sk] = $sv;
      }
      $_elysia_cron_settings_by_channel[$conf['channel']][$job] =& $_elysia_cron_settings[$job];
    }
    foreach ($_elysia_cron_settings_by_channel as $channel => $data) {
      uasort($_elysia_cron_settings_by_channel[$channel], '_elysia_cron_sort');
      $_elysia_cron_settings_by_channel[$channel]['#data'] = elysia_cron_get_channel_stats($channel);
      $_elysia_cron_settings_by_channel[$channel]['#data']['disabled'] = elysia_cron_is_channel_disabled($channel);
    }
  }
}