function legal_administration in Legal 7
Same name and namespace in other branches
- 5 legal.module \legal_administration()
- 6.8 legal.admin.inc \legal_administration()
- 6.7 legal.module \legal_administration()
- 7.2 legal.admin.inc \legal_administration()
Module settings form.
1 string reference to 'legal_administration'
- legal_menu in ./
legal.module - Implements hook_menu().
File
- ./
legal.admin.inc, line 87 - Administration UI for the Legal module.
Code
function legal_administration($form_state) {
$form = array();
$conditions = legal_get_conditions(NULL, TRUE);
if (module_exists('locale')) {
$languages = locale_language_list();
$language_default = language_default();
$language = $language_default->language;
$version_options = array(
'version' => t('All users (new version)'),
'revision' => t('Language specific users (a revision)'),
);
$version_handling = 'version';
}
else {
$languages = array(
'en' => t('English'),
);
$language = 'en';
$version_handling = 'version';
}
$form = array_merge($form, legal_display_fields($conditions));
$form['conditions'] = array(
'#type' => 'text_format',
'#title' => t('Terms & Conditions'),
'#default_value' => $conditions['conditions'],
'#description' => t('Your Terms & Conditions'),
'#format' => empty($conditions['format']) ? NULL : $conditions['format'],
'#required' => TRUE,
'#rows' => 20,
'#weight' => -1,
);
// Set this here or array will flatten out and override real values.
$form['legal']['#tree'] = TRUE;
// Overide accept checbox requirement on preview.
$form['legal']['legal_accept']['#required'] = FALSE;
// Only display options if there's more than one language available.
if (count($languages) > 1) {
// Language and version handling options.
$form['language'] = array(
'#type' => 'fieldset',
'#title' => t('Language'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
$form['language']['language'] = array(
'#type' => 'select',
'#title' => t('Language'),
'#options' => $languages,
'#default_value' => $language,
);
$form['language']['version_handling'] = array(
'#type' => 'select',
'#title' => t('Ask To Re-accept'),
'#description' => t('<strong>All users</strong>: all users will be asked to accept the new version of the T&C, including users who accepted a previous version.<br />
<strong>Language specific</strong>: only new users, and users who accepted the T&C in the same language as this new revision will be asked to re-accept.'),
'#options' => $version_options,
'#default_value' => $version_handling,
);
}
else {
$form['language']['language'] = array(
'#type' => 'value',
'#value' => $language,
);
$form['language']['version_handling'] = array(
'#type' => 'value',
'#value' => $version_handling,
);
}
legal_display_form_element($form);
// Additional checkboxes.
$form['extras'] = array(
'#type' => 'fieldset',
'#title' => t('Additional Checkboxes'),
'#description' => t('Each field will be shown as a checkbox which the user must tick to register.'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#tree' => TRUE,
);
$extras_count = count($conditions['extras']) < 10 ? 10 : count($conditions['extras']);
for ($counter = 1; $counter <= $extras_count; $counter++) {
$extra = isset($conditions['extras']['extras-' . $counter]) ? $conditions['extras']['extras-' . $counter] : '';
$form['extras']['extras-' . $counter] = array(
'#type' => 'textarea',
'#title' => t('Label'),
'#default_value' => $extra,
);
// Overide extra checkboxes.
if (!empty($conditions['extras']['extras-' . $counter])) {
$form['legal']['extras-' . $counter] = array(
'#type' => 'checkbox',
'#title' => filter_xss_admin($extra),
'#default_value' => 0,
'#weight' => 2,
'#required' => FALSE,
);
}
}
// Notes about changes to T&C.
$form['changes'] = array(
'#type' => 'fieldset',
'#title' => t('Explain Changes'),
'#description' => t('Explain what changes were made to the T&C since the last version. This will only be shown to users who accepted a previous version. Each line will automatically be shown as a bullet point.'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
$form['changes']['changes'] = array(
'#type' => 'textarea',
'#title' => t('Changes'),
);
$form['#after_build'] = array(
'legal_preview',
);
$form['preview'] = array(
'#type' => 'button',
'#value' => t('Preview'),
);
$form['save'] = array(
'#type' => 'submit',
'#value' => t('Save'),
);
return $form;
}