You are here

function imce_profile_form in IMCE 6.2

Same name and namespace in other branches
  1. 6 inc/admin.inc \imce_profile_form()
  2. 7 inc/imce.admin.inc \imce_profile_form()

Profile form.

1 string reference to 'imce_profile_form'
imce_profile_operations in inc/imce.admin.inc
Add-Edit-Delete profiles.

File

inc/imce.admin.inc, line 195
Serves administration pages of IMCE.

Code

function imce_profile_form(&$form_state, $pid = 0) {
  if ($pid && ($profile = imce_load_profile($pid))) {
    drupal_set_title($profile['name']);
  }
  else {
    $pid = 0;
    $profile = imce_sample_profile();
    $profile['name'] = '';
  }

  //import profile
  if (isset($_GET['import']) && ($imported = imce_load_profile($_GET['import']))) {
    if (empty($form_state['post'])) {
      drupal_set_message(t('Settings were imported from the profile %name', array(
        '%name' => $imported['name'],
      )));
    }
    $imported['name'] = $profile['name'];

    //preserve the original name.
    $profile = $imported;
  }
  $form_state['profile'] = $profile;

  //store the original profile just in case.
  $form = array(
    '#tree' => TRUE,
  );
  $form['name'] = array(
    '#type' => 'textfield',
    '#title' => t('Profile name'),
    '#default_value' => $profile['name'],
    '#description' => t('Give a name to this profile.'),
    '#required' => TRUE,
  );
  $form['import'] = array(
    '#type' => 'markup',
    '#value' => imce_profile_import_html($pid),
  );
  $form['usertab'] = array(
    '#type' => 'checkbox',
    '#title' => t('Display file browser tab in user profile pages.'),
    '#default_value' => $profile['usertab'],
  );
  $form['filesize'] = array(
    '#type' => 'textfield',
    '#title' => t('Maximum file size per upload'),
    '#default_value' => $profile['filesize'],
    '#description' => t('Set to 0 to use the maximum value available.') . ' ' . t('Your PHP settings limit the maximum file size per upload to %size.', array(
      '%size' => format_size(file_upload_max_size()),
    )),
    '#field_suffix' => t('MB'),
  );
  $form['quota'] = array(
    '#type' => 'textfield',
    '#title' => t('Directory quota'),
    '#default_value' => $profile['quota'],
    '#description' => t('Define the upload quota per directory. Total user quota is proportional to the number of directories that the user has upload access to.') . ' ' . t('Set to 0 to use the maximum value available.'),
    '#field_suffix' => t('MB'),
  );
  $form['tuquota'] = array(
    '#type' => 'textfield',
    '#title' => t('Total user quota'),
    '#default_value' => $profile['tuquota'],
    '#description' => t('You can force total user quota to be a value independent of directory quota. <strong>This quota is calculated using the files table in the database, so that it will not include the files uploaded via FTP or by previous versions of IMCE(4.7.x and 5.x)</strong>. You can either use both quotations together or safely ignore this by setting the value to 0.'),
    '#field_suffix' => t('MB'),
  );
  $form['extensions'] = array(
    '#type' => 'textfield',
    '#title' => t('Permitted file extensions'),
    '#default_value' => $profile['extensions'],
    '#maxlength' => 255,
    '#description' => t('Extensions that users in this role can upload. Separate extensions with a space and do not include the leading dot.') . ' ' . t('Set to * to remove the restriction.'),
  );
  $form['dimensions'] = array(
    '#type' => 'textfield',
    '#title' => t('Maximum image dimensions'),
    '#default_value' => $profile['dimensions'],
    '#description' => t('The maximum allowed image size (e.g. 640x480). Set to 0 for no restriction. If an <a href="!image-toolkit-link">image toolkit</a> is installed, files exceeding this value will be scaled down to fit.', array(
      '!image-toolkit-link' => url('admin/settings/image-toolkit'),
    )),
    '#field_suffix' => '<kbd>' . t('WIDTHxHEIGHT') . '</kbd>',
  );
  $form['filenum'] = array(
    '#type' => 'textfield',
    '#title' => t('Maximum number of files per operation'),
    '#default_value' => $profile['filenum'],
    '#description' => t('You can allow users to select multiple files for operations such as delete, resize, etc. Entire batch file operation is executed in a single drupal load, which may be good. However there will be an increase in script execution time, cpu load and memory consumption possibly exceeding the limits of your server, which is really bad. For unlimited number of file handling, set this to 0.'),
  );

  //Directories
  $form['directories']['#theme'] = 'imce_directories';
  $form['directories']['#weight'] = 1;
  for ($i = 0; $i < count($profile['directories']); $i++) {
    $form['directories'][$i] = imce_directory_form($profile['directories'][$i]);
  }
  $form['directories'][$i] = imce_directory_form();
  $form['directories'][$i + 1] = imce_directory_form();

  //Thumbnails
  $form['thumbnails']['#theme'] = 'imce_thumbnails';
  $form['thumbnails']['#weight'] = 2;
  for ($i = 0; $i < count($profile['thumbnails']); $i++) {
    $form['thumbnails'][$i] = imce_thumbnail_form($profile['thumbnails'][$i]);
  }
  $form['thumbnails'][$i] = imce_thumbnail_form();
  $form['thumbnails'][$i + 1] = imce_thumbnail_form();
  $form = array(
    'profile' => $form,
  );
  $form['pid'] = array(
    '#type' => 'hidden',
    '#value' => $pid,
  );
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Save configuration'),
  );
  $form['#validate'][] = 'imce_profile_validate';
  $form['#submit'][] = 'imce_profile_submit';
  return $form;
}