? browscap-interval.patch Index: browscap.install =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/browscap/Attic/browscap.install,v retrieving revision 1.1.2.1.2.2 diff -u -p -r1.1.2.1.2.2 browscap.install --- browscap.install 8 Jun 2009 11:43:12 -0000 1.1.2.1.2.2 +++ browscap.install 19 Sep 2009 22:24:50 -0000 @@ -49,6 +49,7 @@ function browscap_uninstall() { variable_del('browscap_monitor'); variable_del('browscap_imported'); variable_del('browscap_version'); + variable_del('browscap_interval'); } // browscap_uninstall /** Index: browscap.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/browscap/browscap.module,v retrieving revision 1.6.2.3.2.10 diff -u -p -r1.6.2.3.2.10 browscap.module --- browscap.module 17 Sep 2009 16:15:45 -0000 1.6.2.3.2.10 +++ browscap.module 19 Sep 2009 22:24:50 -0000 @@ -107,9 +107,14 @@ function browscap_exit() { * Implementation of hook_cron(). */ function browscap_cron() { - // Has it been a week since the last (attempt to) import? + // How often should module import (in days)? + $import_interval = variable_get('browscap_interval', 7); + if (!$import_interval) { + return; + } + // Has it been long enough since the last (attempt to) import? $last_imported = variable_get('browscap_imported', 0); - if (($last_imported + 60*60*24*7) < time()) { + if (($last_imported + 60 * 60 * 24 * $import_interval) < time()) { _browscap_import(); variable_set('browscap_imported', time()); } @@ -121,7 +126,7 @@ function browscap_cron() { /** * Callback for settings form. - * Turn monitoring on or off and refresh the reference data. + * Turn monitoring on or off, refresh the reference data, set update interval. * * @return array */ @@ -143,10 +148,30 @@ function browscap_settings() { '!reports' => url('admin/reports/browscap'), )), ); + $form['browscap_interval'] = array( + '#type' => 'textfield', + '#title' => t('Import interval'), + '#default_value' => variable_get('browscap_interval', 7), + '#description' => t('Update the browscap data this often. Enter 0 to disable updating.'), + '#field_suffix' => t('days'), + '#size' => 4, + ); return system_settings_form($form); } /** + * Validate settings form + * Ensure browscap_interval is a non-negatove number + */ +function browscap_settings_validate($form, $form_state) { + $interval = $form_state['values']['browscap_interval']; + if (!is_numeric($interval) || $interval < 0) { + form_set_error('browscap_interval', + t('Please enter a non-negative number.')); + } +} + +/** * Simple page callback to manually refresh the data. * */