You are here

function imce_clean_profile_fields in IMCE 6

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

Unset empty fields in thumbnails and directory paths.

1 call to imce_clean_profile_fields()
imce_profile_submit in inc/admin.inc
Profile form submit.

File

inc/admin.inc, line 578

Code

function imce_clean_profile_fields(&$profile) {
  $clean = array();
  foreach ($profile['thumbnails'] as $thumb) {
    if (trim($thumb['name']) != '' && preg_match('/^\\d+x\\d+$/', $thumb['dimensions'])) {
      $clean[] = $thumb;
    }
  }
  $profile['thumbnails'] = $clean;
  $clean = array();
  $names = array();
  foreach ($profile['directories'] as $dir) {
    $dir['name'] = trim($dir['name'], '/ ');
    if ($dir['name'] == '') {
      continue;
    }
    if (isset($names[$dir['name']])) {
      drupal_set_message(t('Duplicate directory paths are not allowed.'), 'error');
      continue;
    }
    if (!imce_reg_dir($dir['name'])) {
      drupal_set_message(t('%dirname is not accepted as a proper directory name.', array(
        '%dirname' => $dir['name'],
      )), 'error');
      continue;
    }
    $clean[] = $dir;
    $names[$dir['name']] = 1;
  }
  $profile['directories'] = $clean;
}