You are here

function gdpr_consent_version in GDPR Consent 7

Determine version ID of Consent.

If it's new version determine next version id, if it's a revision return the ID of the current version increment revision ID by 1.

1 call to gdpr_consent_version()
gdpr_consent_administration_submit in ./gdpr_consent.admin.inc
Implements hook_form_id_submit().

File

./gdpr_consent.admin.inc, line 490
Administration UI for the GDPR Consent module.

Code

function gdpr_consent_version($version_handling, $language) {
  $version = (int) db_select('gdpr_consent_conditions', 'lc')
    ->fields('lc', array(
    'version',
  ))
    ->orderBy('version', 'desc')
    ->range(0, 1)
    ->addTag('gdpr_consent_version')
    ->execute()
    ->fetchField();

  // Make new version.
  if ($version_handling == 'version') {
    $versioning['version'] = empty($version) ? 1 : $version + 1;
    $versioning['revision'] = 1;
  }

  // Make new revision.
  if ($version_handling == 'revision') {
    $revision = db_select('gdpr_consent_conditions', 'lc')
      ->fields('lc', array(
      'revision',
    ))
      ->condition('version', $version)
      ->condition('language', $language)
      ->orderBy('revision', 'DESC')
      ->addTag('gdpr_consent_revision_by_version')
      ->execute()
      ->fetchField();
    $versioning['version'] = $version;
    $versioning['revision'] = empty($revision) ? 1 : $revision + 1;
  }
  return $versioning;
}