- Posts: 298
- Thank you received: 7
Displaying an uploaded image in the notification email
3 years 8 months ago #348432
by a2zcs
Displaying an uploaded image in the notification email was created by a2zcs
-- url of the page with the problem -- :
bromarprintstore.com/
-- HikaShop version -- : 4.7.0
-- Joomla version -- : 4.2.6
-- PHP version -- : 8.1.14
-- Error-message(debug-mod must be tuned on) -- : n/a
On our catalog, we have a field that allows customers to upload an image to be included on the product they are ordering. My question is how can that image be included in the notification email without the need to be logged in to see it. This is for a very busy print shop that finds it very cumbersome to have to login just to retrieve an image from the order.
Thanks
-- HikaShop version -- : 4.7.0
-- Joomla version -- : 4.2.6
-- PHP version -- : 8.1.14
-- Error-message(debug-mod must be tuned on) -- : n/a
On our catalog, we have a field that allows customers to upload an image to be included on the product they are ordering. My question is how can that image be included in the notification email without the need to be logged in to see it. This is for a very busy print shop that finds it very cumbersome to have to login just to retrieve an image from the order.
Thanks
Please Log in or Create an account to join the conversation.
3 years 8 months ago #348434
by nicolas
Replied by nicolas on topic Displaying an uploaded image in the notification email
Hi,
That's a security measure to avoid non authorized users to be able to view files uploaded by users.
The dirty solution would be to:
- remove the htaccess on the media/com_hikashop/upload/safe/ folder so that anyone could access the uploaded files (provided they know the name of the file).
- change the line:
to:
in the file administrator/com_hikashop/com_hikashop/classes/field.php
That way, the admin email will contain the direct URL to the file so the admin receiving it will just have to click on the link to get the file, without any login needed.
This means anyone with the URL can access the file and also that you'll have to redo the change after each update of HikaShop.
A cleaner solution would be to develop a plugin to create your own custom field type extending from the "ajax image" or "ajax file" type and overridding the _showOne function to add some kind of password in the download URL provided in the admin email. With your custom type, the download URL will trigger the onFieldFileDownload(&$found, $name, $field_table, $field_namekey, $options) event. So you can implement that event to check the password in the URL (in $_GET) to allow the download by changing the $found variable to true.
That's a security measure to avoid non authorized users to be able to view files uploaded by users.
The dirty solution would be to:
- remove the htaccess on the media/com_hikashop/upload/safe/ folder so that anyone could access the uploaded files (provided they know the name of the file).
- change the line:
Code:
return '<a target="_blank" class="'.$class.'" href="'.HIKASHOP_LIVE.'administrator/index.php?option=com_hikashop&ctrl='.$download_link.'">'.$value.'</a>';
Code:
return '<a target="_blank" class="'.$class.'" href="'.HIKASHOP_LIVE.'media/com_hikashop/upload/safe/'.$value.'">'.$value.'</a>';
That way, the admin email will contain the direct URL to the file so the admin receiving it will just have to click on the link to get the file, without any login needed.
This means anyone with the URL can access the file and also that you'll have to redo the change after each update of HikaShop.
A cleaner solution would be to develop a plugin to create your own custom field type extending from the "ajax image" or "ajax file" type and overridding the _showOne function to add some kind of password in the download URL provided in the admin email. With your custom type, the download URL will trigger the onFieldFileDownload(&$found, $name, $field_table, $field_namekey, $options) event. So you can implement that event to check the password in the URL (in $_GET) to allow the download by changing the $found variable to true.
Please Log in or Create an account to join the conversation.
3 years 8 months ago #348449
by a2zcs
Replied by a2zcs on topic Displaying an uploaded image in the notification email
Good morning,
Thanks for the response. Developing a plugin is beyond my knowledge and ability. Is this something you could do or know of someone that can? Cost?
In the meantime I'll try the other solution.
Cheers,
Matt
Thanks for the response. Developing a plugin is beyond my knowledge and ability. Is this something you could do or know of someone that can? Cost?
In the meantime I'll try the other solution.
Cheers,
Matt
Please Log in or Create an account to join the conversation.
3 years 8 months ago - 3 years 8 months ago #348455
by a2zcs
Replied by a2zcs on topic Displaying an uploaded image in the notification email
Hi,
Unfortunately, that didn't work. When clicking on the link it still takes me to the admin login.
I've renamed the .htaccess file in the safe folder.
This is the line inserted into the field.php:
Thoughts?
Unfortunately, that didn't work. When clicking on the link it still takes me to the admin login.
I've renamed the .htaccess file in the safe folder.
This is the line inserted into the field.php:
Code:
return '<a target="_blank" class="'.$class.'" href="'.HIKASHOP_LIVE.'media/com_hikashop/upload/safe/'.$value.'">'.$value.'</a>';
Thoughts?
Last edit: 3 years 8 months ago by a2zcs.
Please Log in or Create an account to join the conversation.
3 years 8 months ago #348456
by nicolas
Replied by nicolas on topic Displaying an uploaded image in the notification email
Hi,
This means that the line is not being used.
Could you provide :
- a screenshot of the resulting email
- a screenshot of the area where you did the change in administrator/com_hikashop/com_hikashop/classes/field.php
We could work on it, yes. The cost would be 300€
This means that the line is not being used.
Could you provide :
- a screenshot of the resulting email
- a screenshot of the area where you did the change in administrator/com_hikashop/com_hikashop/classes/field.php
We could work on it, yes. The cost would be 300€
Please Log in or Create an account to join the conversation.
3 years 8 months ago #348493
by a2zcs
Replied by a2zcs on topic Displaying an uploaded image in the notification email
Here are the attached screenshots of the resulting email and of the area the new code was placed.
Thanks
Thanks
Please Log in or Create an account to join the conversation.
3 years 8 months ago #348494
by nicolas
Replied by nicolas on topic Displaying an uploaded image in the notification email
Hi,
Can you confirm that the email you're looking at is the "order admin notification" and not another one ?
If it's another one, it would also require changing the line:
to:
in the "preload" section of the email in the menu System>Emails.
Can you confirm that the email you're looking at is the "order admin notification" and not another one ?
If it's another one, it would also require changing the line:
Code:
$t .= '<p>'.$fieldsClass->getFieldName($field).': '.$fieldsClass->show($field,$item->$namekey,'user_email').'</p>';
Code:
$t .= '<p>'.$fieldsClass->getFieldName($field).': '.$fieldsClass->show($field,$item->$namekey,'admin_email').'</p>';
Please Log in or Create an account to join the conversation.
3 years 8 months ago #348504
by a2zcs
Replied by a2zcs on topic Displaying an uploaded image in the notification email
Hi,
Yes it was the Order Administrator Notification and the line below was in the preload section of it.
Yes it was the Order Administrator Notification and the line below was in the preload section of it.
Code:
$t .= '<p>'.$fieldsClass->getFieldName($field).': '.$fieldsClass->show($field,$item->$namekey,'admin_email').'</p>';
Please Log in or Create an account to join the conversation.
3 years 8 months ago #348510
by nicolas
Replied by nicolas on topic Displaying an uploaded image in the notification email
Hi,
Then, I don't see how it cannot work.
Then, I don't see how it cannot work.
Please Log in or Create an account to join the conversation.
Time to create page: 0.177 seconds