You are here

function upload_settings in Drupal 4

File

modules/upload.module, line 138
File-handling and attaching files to nodes.

Code

function upload_settings() {
  $form['settings_general'] = array(
    '#type' => 'fieldset',
    '#title' => t('General settings'),
  );
  $form['settings_general']['upload_max_resolution'] = array(
    '#type' => 'textfield',
    '#title' => t('Maximum resolution for uploaded images'),
    '#default_value' => variable_get('upload_max_resolution', 0),
    '#size' => 15,
    '#maxlength' => 10,
    '#description' => t('The maximum allowed image size expressed as WIDTHxHEIGHT (e.g. 640x480). Set to 0 for no restriction.'),
  );
  $form['settings_general']['upload_list_default'] = array(
    '#type' => 'select',
    '#title' => t('List files by default'),
    '#default_value' => variable_get('upload_list_default', 1),
    '#options' => array(
      0 => t('No'),
      1 => t('Yes'),
    ),
    '#description' => t('Set whether files attached to nodes are listed or not in the node view by default.'),
  );
  $form['upload_max_size'] = array(
    '#value' => '<p>' . t('Your PHP settings limit the maximum file size per upload to %size MB.', array(
      '%size' => file_upload_max_size(),
    )) . '</p>',
  );
  $roles = user_roles(0, 'upload files');
  $form['roles'] = array(
    '#type' => 'value',
    '#value' => $roles,
  );
  foreach ($roles as $rid => $role) {
    $form["settings_role_{$rid}"] = array(
      '#type' => 'fieldset',
      '#title' => t('Settings for %role', array(
        '%role' => theme('placeholder', $role),
      )),
      '#collapsible' => TRUE,
      '#collapsed' => TRUE,
    );
    $form["settings_role_{$rid}"]["upload_extensions_{$rid}"] = array(
      '#type' => 'textfield',
      '#title' => t('Permitted file extensions'),
      '#default_value' => variable_get("upload_extensions_{$rid}", 'jpg jpeg gif png txt doc xls xls pdf ppt pps odt ods odp'),
      '#maxlength' => 255,
      '#description' => t('Extensions that users in this role can upload. Separate extensions with a space and do not include the leading dot.'),
    );
    $form["settings_role_{$rid}"]["upload_uploadsize_{$rid}"] = array(
      '#type' => 'textfield',
      '#title' => t('Maximum file size per upload'),
      '#default_value' => variable_get("upload_uploadsize_{$rid}", 1),
      '#size' => 5,
      '#maxlength' => 5,
      '#description' => t('The maximum size of a file a user can upload (in megabytes).'),
    );
    $form["settings_role_{$rid}"]["upload_usersize_{$rid}"] = array(
      '#type' => 'textfield',
      '#title' => t('Total file size per user'),
      '#default_value' => variable_get("upload_usersize_{$rid}", 10),
      '#size' => 5,
      '#maxlength' => 5,
      '#description' => t('The maximum size of all files a user can have on the site (in megabytes).'),
    );
  }

  // Note: form_id constructed in system_site_settings() is 'upload_settings_form'
  return $form;
}