You are here

function flag_session_api_cleanup in Flag 6.2

Same name and namespace in other branches
  1. 7.3 flag.module \flag_session_api_cleanup()
  2. 7.2 flag.module \flag_session_api_cleanup()

Implementation of hook_session_api_cleanup().

Clear out anonymous user flaggings during Session API cleanup.

File

./flag.module, line 571
The Flag module.

Code

function flag_session_api_cleanup($arg = 'run') {

  // Session API 1.1 version:
  if ($arg == 'run') {
    $result = db_query("SELECT fc.sid FROM {flag_content} fc LEFT JOIN {session_api} s ON (fc.sid = s.sid) WHERE fc.sid <> 0 AND s.sid IS NULL");
    while ($row = db_fetch_object($result)) {
      db_query("DELETE FROM {flag_content} WHERE sid = %d", $row->sid);
    }
  }
  elseif (is_array($arg)) {
    $outdated_sids = $arg;
    db_query('DELETE FROM {flag_content} WHERE sid IN (' . implode(',', $outdated_sids) . ')');
  }
}