You are here

function shoutbox_cron in Shoutbox 6.2

Same name and namespace in other branches
  1. 5 shoutbox.module \shoutbox_cron()
  2. 6 shoutbox.module \shoutbox_cron()
  3. 7.2 shoutbox.module \shoutbox_cron()
  4. 7 shoutbox.module \shoutbox_cron()

Implementation of hook_cron().

File

./shoutbox.module, line 122
Shout box module displays a block for users to create short messages for the whole site. Uses AHAH to update the database and display content.

Code

function shoutbox_cron() {
  $expiration = variable_get('shoutbox_expire', 0);

  // Check if expiration is turned on
  if ($expiration > 0) {

    // Fetch shouts that have passed the expiration date
    $shouts = db_query("SELECT * FROM {shoutbox} WHERE created < %d", time() - 60 * 60 * 24 * $expiration);
    while ($shout = db_fetch_object($shouts)) {

      // Delete the shout
      shoutbox_delete_shout($shout);
    }
  }
}