You are here

function gdpr_consent_version_check in GDPR Consent 7

Check if user has accepted latest version of consent.

Parameters

int $uid: User id.

int $version: Version id.

int $revision: Revision id.

array $gdpr_consent_account: Array of GDPR details on account.

Return value

bool Returns boolean if user has accepted version or not.

5 calls to gdpr_consent_version_check()
gdpr_consent_accept_form in ./gdpr_consent.module
Consent acceptance form.
gdpr_consent_form_user_profile_form_alter in ./gdpr_consent.module
Implements hook_form_FORM_ID_alter().
gdpr_consent_redirect_to_consent in ./gdpr_consent.module
Custom function to handle redirects.
gdpr_consent_save_accept in ./gdpr_consent.module
Function to save acceptance.
gdpr_consent_user_login in ./gdpr_consent.module
Implements hook_user_login().

File

./gdpr_consent.module, line 1043
Module file for GDPR Consent.

Code

function gdpr_consent_version_check($uid, $version, $revision, array $gdpr_consent_account) {
  $accepted = FALSE;
  if (empty($gdpr_consent_account)) {
    $gdpr_consent_account = gdpr_consent_get_accept($uid);
  }

  // Major version check.
  $query = db_select('gdpr_consent_conditions');
  $query
    ->addExpression('MAX(version)');
  $latest_version = $query
    ->execute()
    ->fetchField();
  if ($latest_version > $version) {
    return FALSE;
  }
  if (array_key_exists('version', $gdpr_consent_account) && array_key_exists('revision', $gdpr_consent_account)) {
    if ($gdpr_consent_account['version'] == $version && $gdpr_consent_account['revision'] == $revision) {
      $accepted = TRUE;
    }
  }
  return $accepted;
}