function legal_get_conditions in Legal 8
Same name and namespace in other branches
- 5 legal.module \legal_get_conditions()
- 6.8 legal.module \legal_get_conditions()
- 6.7 legal.module \legal_get_conditions()
- 7.2 legal.module \legal_get_conditions()
- 7 legal.module \legal_get_conditions()
- 2.0.x legal.module \legal_get_conditions()
Get latest T&C.
Parameters
string $language: Language code.
Return value
array T&C conditions content and metadata.
9 calls to legal_get_conditions()
- LegalAdminTermsForm::buildForm in src/
Form/ LegalAdminTermsForm.php - Module settings form.
- LegalAdminTermsForm::legalConditionsUpdated in src/
Form/ LegalAdminTermsForm.php - Check if T&Cs have been updated.
- LegalController::legalPageAction in src/
Controller/ LegalController.php - Page callback.
- LegalLogin::buildForm in src/
Form/ LegalLogin.php - Form constructor.
- legal_form_user_form_alter in ./
legal.module - Implements hook_form_FORM_ID_alter().
File
- ./
legal.module, line 677 - Module file for Legal.
Code
function legal_get_conditions($language = '') {
$keys = [
'tc_id',
'version',
'revision',
'language',
'conditions',
'format',
'date',
'extras',
'changes',
];
if (!empty($language)) {
$result = \Drupal::database()
->select('legal_conditions', 'lc')
->fields('lc')
->condition('language', $language)
->orderBy('version', 'DESC')
->orderBy('revision', 'DESC')
->range(0, 1)
->execute()
->fetchAllAssoc('tc_id');
$result = (array) array_shift($result);
}
else {
$result = \Drupal::database()
->select('legal_conditions', 'lc')
->fields('lc')
->orderBy('tc_id', 'DESC')
->execute()
->fetchAllAssoc('tc_id');
$result = (array) array_shift($result);
}
foreach ($keys as $key) {
$conditions[$key] = isset($result[$key]) ? $result[$key] : '';
}
$conditions['extras'] = empty($conditions['extras']) ? [] : unserialize($conditions['extras']);
return $conditions;
}