You are here

function browscap_cron in Browscap 8

Same name and namespace in other branches
  1. 8.3 browscap.module \browscap_cron()
  2. 5 browscap.module \browscap_cron()
  3. 6.2 browscap.module \browscap_cron()
  4. 6 browscap.module \browscap_cron()
  5. 7.2 browscap.module \browscap_cron()
  6. 7 browscap.module \browscap_cron()

Implements hook_cron().

File

./browscap.module, line 50
Replacement for PHP's get_browser() function.

Code

function browscap_cron() {
  if (variable_get('browscap_enable_automatic_updates', TRUE) == TRUE) {

    // Check the current update timer
    $automatic_update_timer = variable_get('browscap_automatic_updates_timer', 604800);

    // Check when the last update occurred
    $last_imported = variable_get('browscap_imported', REQUEST_TIME);

    // Update the browscap data if the amount of time specified by the update
    // timer has passed
    if ($last_imported + $automatic_update_timer < REQUEST_TIME) {

      // Update the browscap information
      _browscap_import();

      // Record when the browscap information was updated
      variable_set('browscap_imported', REQUEST_TIME);
    }
  }
}