function gdpr_consent_get_accept in GDPR Consent 7
Function to get accept.
Parameters
int $uid: User id.
Return value
array Return info about acceptance.
7 calls to gdpr_consent_get_accept()
- gdpr_consent_accept_form in ./
gdpr_consent.module - Consent acceptance form.
- gdpr_consent_display_changes in ./
gdpr_consent.module - Get all changes since user last accepted.
- 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.
File
- ./
gdpr_consent.module, line 780 - Module file for GDPR Consent.
Code
function gdpr_consent_get_accept($uid) {
global $language, $user;
if (!empty($user->language)) {
$lang = $user->language;
}
else {
$lang = $language->language;
}
$keys = array(
'gdpr_consent_id',
'version',
'revision',
'language',
'uid',
'accepted',
'revoked',
);
$result = db_select('gdpr_consent_accepted', 'c')
->fields('c')
->condition('uid', $uid)
->condition('revoked', 0, '=')
->condition('language', $lang, '=')
->orderBy('version', 'DESC')
->orderBy('revision', 'DESC')
->addTag('gdpr_consent_get_accepted')
->execute()
->fetchAllAssoc('gdpr_consent_id');
$result = count($result) ? array_shift($result) : array();
$accept = array();
foreach ($keys as $key) {
if (isset($result->{$key})) {
$accept[$key] = $result->{$key};
}
}
return $accept;
}