You are here

function legal_display_changes in Legal 6.8

Same name and namespace in other branches
  1. 8 legal.module \legal_display_changes()
  2. 5 legal.module \legal_display_changes()
  3. 6.7 legal.module \legal_display_changes()
  4. 7.2 legal.module \legal_display_changes()
  5. 7 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 633
Displays Terms & Conditions, and makes sure they are accepted before registration is accepted.

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_query("SELECT changes FROM {legal_conditions}\n                      WHERE ((version > %d) OR (version = %d AND revision > %d)) AND language = '%s'\n                      ORDER BY revision ASC, version ASC", $last_accepted['version'], $last_accepted['version'], $last_accepted['revision'], $last_accepted['language']);
  if (empty($result)) {
    return $form;
  }
  while ($term = db_fetch_object($result)) {
    $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(
    '#value' => theme('item_list', $bullet_points),
  );
  return $form;
}