You are here

function masquerade_cron in Masquerade 5

Same name and namespace in other branches
  1. 6 masquerade.module \masquerade_cron()
  2. 7 masquerade.module \masquerade_cron()

Implementation of hook_cron().

Cleanup masquerade records where people didn't use the switch back link that would have cleanly removed the user switch record.

File

./masquerade.module, line 51
masquerade.module

Code

function masquerade_cron() {

  // see http://drupal.org/node/268487 before modifying this query
  if (in_array($GLOBALS['db_type'], array(
    'mysql',
    'mysqli',
  ))) {
    db_query('DELETE {masquerade} FROM {masquerade} LEFT JOIN {sessions} ON {masquerade}.sid = {sessions}.sid WHERE {sessions}.sid IS NULL');
  }
  elseif ($GLOBALS['db_type'] == 'pgsql') {
    db_query('DELETE FROM {masquerade} WHERE {masquerade}.sid NOT IN ( SELECT {sessions}.sid FROM {sessions} )');
  }
}