Ok, I have gone through the purchasing process, and have a file sitting there in 'my files' waiting for download... however, clicking on 'download' follows the link "http://sitename/store/myfiles/download?file=filename" - which produces a file-not-found error!

I have traced this to the 'ec_file_create_url' function in file.module not taking the user-id into account... So, I've patched it and it now seems to work (test case of 1!)

Patched version is:

function ec_file_create_url($path) {
 global $user;
 if (strpos($path, variable_get('ec_file_directory_path', 'files')) !== false) {
  $path = trim(substr($path, strlen(variable_get('ec_file_directory_path', 'files'))), '\\/');
 }
 return url("store/myfiles/$user->uid/download", 'file='. $path);
}

(additional parts are 'global $user' and the '/$user->uid' in the return.)

Comments

matt westgate’s picture

This has been fixed. Thanks.

Anonymous’s picture

Kirk Zurell’s picture

Version: » 4.7.x-1.x-dev
Component: file.module » file
Status: Closed (fixed) » Active

This bug seems to have reappeared.

function ec_file_create_url($path) {
  global $user;

  $uid = $user->uid;
  if (user_access('administer store')) {
    $uid = arg(2);
  }
  return url("store/myfiles/$uid/download", 'file='. urlencode($path));
}

When accessed through the URL

http://localhost/drupal/store/myfiles

by a user with "administer store" access, arg(2) sets $uid to be null, and the URLs for individual files are broken. They work fine when not able to administer the store.

Thanks for your attention.

Kirk Zurell’s picture

Status: Active » Needs review

At some point, arg(2) will be the user under administration. For now, this completely brainless patch:

function ec_file_create_url($path) {
  global $user;

  $uid = $user->uid;
  if (user_access('administer store')) {
    if(arg(2)) {
      $uid = arg(2);
    }
  }
  return url("store/myfiles/$uid/download", 'file='. urlencode($path));
}
sime’s picture

assigning to me

brmassa’s picture

Status: Needs review » Closed (fixed)

Fixed on eC4