You are here

function mobile_detect_import_cron in Mobile Switch 7.2

Implements hook_cron().

File

modules/mobile_detect_import/mobile_detect_import.module, line 34
Update and import functions for the Mobile Detect PHP class.

Code

function mobile_detect_import_cron() {
  if (variable_get('mobile_detect_import_enable_automatic_updates', TRUE) == TRUE) {

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

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

    // Update the Mobile Detect class file if the amount of time
    // specified by the update timer has passed.
    if ($last_imported + $automatic_update_timer < REQUEST_TIME) {

      // Update the Mobile Detect class file.
      _mobile_detect_import_import();

      // Record when the Mobile Detect class file was updated.
      variable_set('mobile_detect_import_imported', REQUEST_TIME);
    }
  }
}