You are here

function hook_domaincron in Domain Access 5

Same name and namespace in other branches
  1. 6.2 API.php \hook_domaincron()
  2. 7.2 domain.api.php \hook_domaincron()

Enables Domain Access modules to fire cron hooks across all active domains.

Each module implementing this hook will have the function run once per active domain record. The global $_domain variable will be set to the current $domain passed as an argument.

This function is especially useful if you need to run node queries that obey node access rules.

Note that Domain Prefix and Domain Conf are activated by this hook. That means each domain will have its tables and variables loaded before your function fires.

Parameters

$domain: The information for the current domain record, taken from {domain}.

Related topics

1 invocation of hook_domaincron()
domain_cron in ./domain.module
Implement hook_cron()

File

./API.php, line 210
API documentation file.

Code

function hook_domaincron($domain) {

  // Run a node query.
  $result = db_query_range(db_rewrite_sql("SELECT n.nid FROM {node} n ORDER BY n.changed"), 0, 1);
  $node = db_fetch_object($result);

  // Set a variable for each domain containing the last node updated.
  variable_set('domain_' . $domain['domain_id'] . '_lastnode', $node->nid);
}