You are here

function agreement_form in Agreement 7.2

Same name and namespace in other branches
  1. 6.2 agreement.module \agreement_form()
  2. 6 agreement.module \agreement_form()

FAPI definition for the agreement form.

Parameters

array $form: The form array.

array &$form_state: The form state array.

bool $status: Whether the user has agreed or not.

array $info: The agreement type.

object $account: The user account.

Return value

array The form array.

See also

agreement_form_validate()

agreement_form_submit()

1 string reference to 'agreement_form'
agreement_page in ./agreement.pages.inc
Callback for agreement URL.

File

./agreement.pages.inc, line 58
Agreement page callbacks.

Code

function agreement_form($form, &$form_state, $status, $info, $account) {
  $form['text'] = array(
    '#type' => 'container',
    '#attributes' => array(
      'class' => array(
        'agreement-text',
      ),
    ),
    'terms' => array(
      '#markup' => check_markup($info['agreement'], $info['settings']['format']),
    ),
  );
  $form_state['account'] = $account;
  $form_state['info'] = $info;
  $form_state['agreed'] = $status;
  $can_revoke = user_access('revoke own agreement');

  // Only display the agree checkbox and submit button when the user needs to
  // agree. All other users may only see the agreement.
  if ((!$status || $can_revoke) && !user_access('bypass agreement') && _agreement_user_has_role($account, $info['settings']['role'])) {
    $form['agree'] = array(
      '#default_value' => $status,
      '#title' => check_plain($info['settings']['checkbox']),
      '#type' => 'checkbox',
    );
    $form['submit'] = array(
      '#type' => 'submit',
      '#value' => check_plain($info['settings']['submit']),
    );
  }
  return $form;
}