You are here

function legal_version in Legal 7

Same name and namespace in other branches
  1. 8 legal.module \legal_version()
  2. 6.8 legal.admin.inc \legal_version()
  3. 7.2 legal.admin.inc \legal_version()
  4. 2.0.x legal.module \legal_version()

Determine version ID of T&C. 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 legal_version()
legal_administration_submit in ./legal.admin.inc

File

./legal.admin.inc, line 436
Administration UI for the Legal module.

Code

function legal_version($version_handling, $language) {
  $version = (int) db_select('legal_conditions', 'lc')
    ->fields('lc', array(
    'version',
  ))
    ->orderBy('version', 'desc')
    ->range(0, 1)
    ->addTag('legal_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('legal_conditions', 'lc')
      ->fields('lc', array(
      'revision',
    ))
      ->condition('version', $version)
      ->condition('language', $language)
      ->orderBy('revision', 'DESC')
      ->addTag('legal_revision_by_version')
      ->execute()
      ->fetchField();
    $versioning['version'] = $version;
    $versioning['revision'] = empty($revision) ? 1 : $revision + 1;
  }
  return $versioning;
}