You are here

function domain_cron in Domain Access 5

Same name and namespace in other branches
  1. 6.2 domain.module \domain_cron()
  2. 7.3 domain.module \domain_cron()
  3. 7.2 domain.module \domain_cron()

Implement hook_cron()

This function invokes hook_domaincron() and allows Domain Access modules to run functions for all active affiliates.

File

./domain.module, line 372
Core module functions for the Domain Access suite.

Code

function domain_cron() {
  global $_domain;

  // Check to see if this function is needed at all.
  $modules = module_implements('domaincron');
  if (!empty($modules)) {

    // Store the current $_domain global.
    $_temp = $_domain;

    // Get the domain list.
    $domains = domain_domains();

    // Run the hook for each active domain.
    foreach ($domains as $domain) {

      // Set the domain-specific variables
      if (function_exists('_domain_conf_load')) {
        _domain_conf_load($domain);
      }

      // Set the global table prefix
      if (function_exists('_domain_prefix_load')) {
        _domain_prefix_load($domain);
      }

      // Set the global to the current $domain.
      $_domain = $domain;
      foreach ($modules as $module) {
        module_invoke($module, 'domaincron', $domain);
      }
    }

    // Set the $_domain global back.
    $_domain = $_temp;
  }
}