After forgetting to turn my sites back on during upgrades for the second time, I decided to write a simple module to send me an email if the site was offline for longer than I expected. As it was just as easy to do this right as to hardcode everything, I created a fairly generic module and created a drupal.org project. I am having an issue in getting the code right.

Currently, I check to see if the site is offline on a cron run. This is a really bad way to do this as it takes a minimum of two cron runs to alert you. So even if I have a period of an hour specified, if cron runs every hour, it could be two hours before I get notified. Is there any way to insert a hook that runs when the offline preference is set?

The relevant code in drupal 6 is in modules/system/system.admin.inc at line 1629. Drupal builds the form here. The code for my project is here: http://drupal.org/project/offline_reminder .

Any ideas?

Any other suggestions, code review, or constructive criticism is welcomed. I hope this module is useful for any other forgetful people out there.

Thanks!

Comments

will_in_wi’s picture

I figured out a possible way, but I am doubting whether this method is encouraged.

I implemented the system_site_maintenance_settings_validate() function. Within this function I could run my code using the $form_state['values']['site_offline'] variable to tell what the current state of the offline mode is.

Is this a good way to do this?

Thanks!