You are here

function regcode_clean in Registration codes 7

Same name and namespace in other branches
  1. 8 regcode.module \regcode_clean()
  2. 6.2 regcode.module \regcode_clean()
  3. 7.2 regcode.module \regcode_clean()

Delete regcode codes.

Parameters

int $op: The operation ID.

Return value

bool|object|int Boolean false if nothing happened. True if tables were empties. The number of deleted rows otherwise.

1 call to regcode_clean()
regcode_admin_manage_submit in ./regcode.admin.php
Manage action handler.

File

./regcode.module, line 594
Main functionality and hooks of regcode module.

Code

function regcode_clean($op) {
  $res = FALSE;
  switch ($op) {
    case REGCODE_CLEAN_TRUNCATE:
      db_query('TRUNCATE {regcode}');
      db_query('TRUNCATE {regcode_term}');
      $res = TRUE;
      break;
    case REGCODE_CLEAN_EXPIRED:
      $res = db_delete('regcode')
        ->condition('expires', REQUEST_TIME, '<')
        ->execute();
      break;
    case REGCODE_CLEAN_INACTIVE:
      $res = db_delete('regcode')
        ->condition('is_active', 0)
        ->execute();
      break;
  }
  return $res;
}