You are here

function filebrowser_admin_settings_validate_add in Filebrowser 6

1 string reference to 'filebrowser_admin_settings_validate_add'
filebrowser_admin_settings in ./filebrowser.module

File

./filebrowser.module, line 211

Code

function filebrowser_admin_settings_validate_add($form, &$form_state) {
  $path = $form_state['values']['path'];
  $location = $form_state['values']['location'];

  // Verify the Drupal path
  // Check that the path isn't already in use
  $path_exists = db_result(db_query('SELECT COUNT(1) FROM {menu_router} mr, {menu_links} ml WHERE mr.path = "%s" OR ml.link_path = "%s"', $path, $path));
  if ($path_exists) {
    form_set_error('path', t('You must specify an unused Drupal path'));
  }

  // Verify the file system location
  // Check that it's a directory
  if (!is_dir($location)) {
    form_set_error('location', t('You must specify a valid directory.'));
  }

  // Check that it's readable
  if (!is_readable($location)) {
    form_set_error('location', t('The directory %dir is not readable.', array(
      '%dir' => $location,
    )));
  }
}