function legal_get_accept in Legal 8
Same name and namespace in other branches
- 5 legal.module \legal_get_accept()
- 6.8 legal.module \legal_get_accept()
- 6.7 legal.module \legal_get_accept()
- 7.2 legal.module \legal_get_accept()
- 7 legal.module \legal_get_accept()
- 2.0.x legal.module \legal_get_accept()
Get last version of T&C accepted by a user.
Parameters
int $uid: User ID.
Return value
array Acceptance information.
6 calls to legal_get_accept()
- LegalLogin::buildForm in src/
Form/ LegalLogin.php - Form constructor.
- LegalLogin::submitForm in src/
Form/ LegalLogin.php - Form submission handler.
- legal_display_changes in ./
legal.module - Get all changes since user last accepted.
- legal_form_user_form_alter in ./
legal.module - Implements hook_form_FORM_ID_alter().
- legal_user_login in ./
legal.module - Implements hook_user_login().
File
- ./
legal.module, line 612 - Module file for Legal.
Code
function legal_get_accept($uid) {
$keys = [
'legal_id',
'version',
'revision',
'language',
'uid',
'accepted',
];
$result = \Drupal::database()
->select('legal_accepted', 'la')
->fields('la')
->condition('uid', $uid)
->orderBy('version', 'DESC')
->orderBy('revision', 'DESC')
->execute()
->fetchAllAssoc('legal_id');
$result = count($result) ? array_shift($result) : [];
$accept = [];
foreach ($keys as $key) {
if (isset($result->{$key})) {
$accept[$key] = $result->{$key};
}
}
return $accept;
}