You are here

function private_files_download_permission_get_preferences_form in Private files download permission 7.2

(Form callback.) Displays a form to set preferences.

1 string reference to 'private_files_download_permission_get_preferences_form'
private_files_download_permission_set_preferences in ./private_files_download_permission.module
(Page callback.) Sets module preferences.

File

./private_files_download_permission.module, line 523
Handles both module settings and its behaviour.

Code

function private_files_download_permission_get_preferences_form($form, &$form_state) {

  // Prepare settings.
  $form['private_files_download_permission_by_user_checks'] = array(
    '#type' => 'checkbox',
    '#title' => t('Enable by-user checks'),
    '#default_value' => variable_get('private_files_download_permission_by_user_checks'),
    '#description' => t('You may wish to disable this feature if there are plenty of users, as it may slow down the entire site.'),
  );
  $form['private_files_download_permission_cache_users'] = array(
    '#type' => 'checkbox',
    '#title' => t('Cache user list'),
    '#default_value' => variable_get('private_files_download_permission_cache_users'),
    '#description' => t('For sites with lots of users, this will save on load time when editing directory settings.'),
    '#states' => array(
      'visible' => array(
        ':input[name="by_user_checks"]' => array(
          'checked' => TRUE,
        ),
      ),
      'enabled' => array(
        ':input[name="by_user_checks"]' => array(
          'checked' => TRUE,
        ),
      ),
    ),
  );
  $form['private_files_download_permission_attachment_mode'] = array(
    '#type' => 'checkbox',
    '#title' => t('Enable attachment mode'),
    '#default_value' => variable_get('private_files_download_permission_attachment_mode'),
    '#description' => t('Have files downloaded as attachments instead of displayed inline in the browser.'),
  );
  $form['private_files_download_permission_debug_mode'] = array(
    '#type' => 'checkbox',
    '#title' => t('Enable debug mode'),
    '#default_value' => variable_get('private_files_download_permission_debug_mode'),
    '#description' => t('Turn on logging to debug issues.'),
  );

  // Prepare the submit button.
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Save preferences'),
  );

  // Return form.
  return $form;
}