You are here

function regcode_clean in Registration codes 8

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

Deletes regcode codes.

Parameters

int $op: The operation ID.

Return value

bool|object|int The number of deleted rows or FALSE if nothing happened or TRUE if tables were empty.

1 call to regcode_clean()
RegcodeAdminManageForm::submitForm in src/Form/RegcodeAdminManageForm.php
Form submission handler.

File

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

Code

function regcode_clean($op) {
  $result = FALSE;
  switch ($op) {
    case REGCODE_CLEAN_TRUNCATE:
      \Drupal::database()
        ->truncate('regcode')
        ->execute();
      $result = TRUE;
      break;
    case REGCODE_CLEAN_EXPIRED:
      $result = \Drupal::database()
        ->delete('regcode')
        ->condition('expires', \Drupal::time()
        ->getRequestTime(), '<')
        ->execute();
      break;
    case REGCODE_CLEAN_INACTIVE:
      $result = \Drupal::database()
        ->delete('regcode')
        ->condition('is_active', 0)
        ->execute();
      break;
  }
  return $result;
}