Projet

Général

Profil

Révision e33d3026

Ajouté par Julien Enselme il y a presque 10 ans

Update drupal to 7.30

Voir les différences:

drupal7/modules/file/file.module
478 478
 */
479 479
function file_managed_file_value(&$element, $input = FALSE, $form_state = NULL) {
480 480
  $fid = 0;
481
  $force_default = FALSE;
481 482

  
482 483
  // Find the current value of this field from the form state.
483 484
  $form_state_fid = $form_state['values'];
......
510 511
          $callback($element, $input, $form_state);
511 512
        }
512 513
      }
513
      // Load file and check access if the FID has changed, to confirm it
514
      // exists and that the current user has access to it.
515
      if (isset($input['fid']) && ($file = file_load($input['fid'])) && file_download_access($file->uri)) {
516
        $fid = $file->fid;
514
      // If a FID was submitted, load the file (and check access if it's not a
515
      // public file) to confirm it exists and that the current user has access
516
      // to it.
517
      if (isset($input['fid']) && ($file = file_load($input['fid']))) {
518
        if (file_uri_scheme($file->uri) == 'public' || file_download_access($file->uri)) {
519
          $fid = $file->fid;
520
        }
521
        // If the current user doesn't have access, don't let the file be
522
        // changed.
523
        else {
524
          $force_default = TRUE;
525
        }
517 526
      }
518 527
    }
519 528
  }
520 529

  
521
  // If there is no input, set the default value.
522
  else {
530
  // If there is no input or if the default value was requested above, use the
531
  // default value.
532
  if ($input === FALSE || $force_default) {
523 533
    if ($element['#extended']) {
524 534
      $default_fid = isset($element['#default_value']['fid']) ? $element['#default_value']['fid'] : 0;
525 535
      $return = isset($element['#default_value']) ? $element['#default_value'] : array('fid' => 0);

Formats disponibles : Unified diff