You are here

function legal_display_changes in Legal 7

Same name and namespace in other branches
  1. 8 legal.module \legal_display_changes()
  2. 5 legal.module \legal_display_changes()
  3. 6.8 legal.module \legal_display_changes()
  4. 6.7 legal.module \legal_display_changes()
  5. 7.2 legal.module \legal_display_changes()
  6. 2.0.x legal.module \legal_display_changes()

Get all changes since user last accepted.

1 call to legal_display_changes()
legal_login in ./legal.module
Require registered users to accept new T&C.

File

./legal.module, line 939
Module file for Legal.

Code

function legal_display_changes($form, $uid) {
  $is_list = FALSE;
  $bullet_points = array();
  $last_accepted = legal_get_accept($uid);
  if (empty($last_accepted)) {
    return $form;
  }
  $result = db_select('legal_conditions', 'lc')
    ->fields('lc')
    ->condition(db_or()
    ->condition('version', $last_accepted['version'], '>')
    ->condition(db_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 = filter_xss_admin($term->changes);
    if (!empty($changes)) {
      $bullet_points = array_merge($bullet_points, explode("\r\n", $changes));
    }
  }
  if (empty($bullet_points)) {
    return $form;
  }
  $form['changes'] = array(
    '#type' => 'fieldset',
    '#title' => t('Changes List'),
    '#description' => t('Changes to the Terms & Conditions since last accepted:'),
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
    '#tree' => TRUE,
  );
  $form['changes']['bullet_points'] = array(
    '#markup' => theme('item_list', array(
      'items' => $bullet_points,
    )),
  );
  return $form;
}