Ubercart marketplace validation
| Project: | Ubercart Marketplace |
| Version: | 6.x-1.x-dev |
| Component: | Code |
| Category: | support request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | active |
Jump to:
Hi,
I have created an mp3 store using the market place module and have found it to be excellent. I had been looking for something like this for a while and to find something that fits so perfectly is superb!
My issue primarilarly concerns file downloads and in particular the MP_File module. I understand that the module sanitises file names and moves them to a different directory for security reasons. However, i need the file names to be left intact and the files left where they are. I also need the "commit file to function" checkbox to be validated\ automated.
How would i go about removing the code to stop this security feature?
How can i implement simple validation or automation of the "commit file to function" checkbox?
I will be very gratefull to anyone that can help me with this.
Thanks

#1
Re: automation - there is a setting in the marketplace settings to turn on "auto commit to product feature"
#2
Hi Turgid, thanks for your reply. I already have "Allow sellers to commit files" selected in seller settings.
Even with this ticked once an upload has finished users have to tick a checkbox next to the the upload file field to get the file to commit to product feature.
The problem im having with this is that if people forget to tick this checkbox it still allows them to enter a product but the product has no file commited to it so when a buyer purchases the product they will have no file link to download.
I was hoping that there was a way of validating this field somehow so that sellers must check it to upload the product.
How do i stop the files from being renamed\moved?
#3
A hook_form_alter implementation can be used for validation (or autofilling and hiding) the checkbox.
mp_file will have to be hacked to fix the renaming. If you know your way around PHP, it should be an easy to see where the name is being changed in this short module. Simply do not overwrite the name. I cannot assist further without knowing your programming level.
#4
Thanks for your quick reply Turgid, its much apreciated.
I like the idea of autofilling the check box as i want to keep the form as simple as possible to the user. How would i go about doing this?
My PHP knowledge is basic, but i am willing to learn. I find it easier to learn once im pointed in the right direction and your post has certainly helped.
#5
Since you will be hacking anyways, you might as well change this value directly in mp_file.
function mp_file_filefield($op, $node, $field, $file, &$form = NULL) {if($op == 'file_form' && in_array($node->type, module_invoke_all('product_types'))) {
$form['url']['#access'] = user_access('administer product features');
$form['previous_filepath']['#type'] = 'value';
$form['commit'] = array(
'#type' => 'checkbox',
'#title' => t('Commit file to product feature'),
'#default_value' => FALSE, // ***CHANGE TO*** TRUE
'#access' => user_access('administer product features'),
);
}
}
Edit: this will only affect admins, see next comment.
#6
Actually, auto commit to feature SHOULD be doing what you want. Do your sellers have the "administer product features" permission? If they do, remove it, because sellers should not have this permission. If you enable the auto commit setting and do not give sellers that permission, the files will be commited automatically with no need for the checkbox.
#7
Yes you are right Turgid, my sellers did have the administer product features permission, turned that off and now its working fine, many many thanks!
Thanks for your time on this its helped me loads.
Alas I am still having trouble with removing the code for the file renaming\moving in mp_file.
Can you please tell me what piece of code to remove? Is it something to do with the variable $sanitized_name?
#8
Subscrive