function legal_display_changes in Legal 8
Same name and namespace in other branches
- 5 legal.module \legal_display_changes()
- 6.8 legal.module \legal_display_changes()
- 6.7 legal.module \legal_display_changes()
- 7.2 legal.module \legal_display_changes()
- 7 legal.module \legal_display_changes()
- 2.0.x legal.module \legal_display_changes()
Get all changes since user last accepted.
1 call to legal_display_changes()
- LegalLogin::buildForm in src/
Form/ LegalLogin.php - Form constructor.
File
- ./
legal.module, line 722 - Module file for Legal.
Code
function legal_display_changes($form, $uid) {
$bullet_points = [];
$last_accepted = legal_get_accept($uid);
if (empty($last_accepted)) {
return $form;
}
$result = \Drupal::database()
->select('legal_conditions', 'lc')
->fields('lc')
->condition((new Condition('OR'))
->condition('version', $last_accepted['version'], '>')
->condition((new Condition('AND'))
->condition('version', $last_accepted['version'])
->condition('revision', $last_accepted['revision'], '>')))
->condition('language', $last_accepted['language'])
->orderBy('revision', 'ASC')
->orderBy('version', 'ASC')
->execute()
->fetchAllAssoc('tc_id');
if (empty($result)) {
return $form;
}
foreach ($result as $term) {
$changes = Xss::filterAdmin($term->changes);
if (!empty($changes)) {
$bullet_points = array_merge($bullet_points, explode("\r\n", $changes));
}
}
if (empty($bullet_points)) {
return $form;
}
$form['changes'] = [
'#type' => 'details',
'#title' => t('Changes List'),
'#description' => t('Changes to the Terms & Conditions since last accepted:'),
'#tree' => TRUE,
];
$form['changes']['bullet_points'] = [
'#theme' => 'item_list',
'#items' => $bullet_points,
];
return $form;
}