Download & Extend

filefield_widget_file_path is hardcoded to global $user

Project:FileField
Version:6.x-3.x-dev
Component:Code
Category:feature request
Priority:normal
Assigned:Unassigned
Status:closed (fixed)

Issue Summary

I'm trying to generate the path for a file based on a user which isn't currently logged in. filefield_widget_file_path() uses the currently logged in user; is there any reason why $user can't be a function parameter? If not, let me know and I'll work on a patch.

Thanks!

Comments

#1

Category:bug report» feature request

I'd be happy to change this to using an $account parameter.

<?php
function filefield_widget_file_path($field_instance, $account = NULL) {
 
$account = isset($account) ? $account : $GLOBALS['user'];
?>

Patchin' finger is ready. ;-)

#2

Status:active» needs review

Here it is! I've also corrected the phpdoc for the first parameter.

AttachmentSize
419616_account_parameter.patch 1.07 KB

#3

Status:needs review» fixed

Thanks, committed!

#4

Nice, I just realized i needed this, thanks guys :)

#5

I noticed that field_file_save_file() suffers from the same issue?
#439952: Global user used to set the $file->uid]

#6

Status:fixed» closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.