[-] MO : sendtoafriend : #PSFV-764 : Fix smalls bugs && normalize
git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@14595 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
+5
-3
@@ -3,6 +3,7 @@
|
||||
global $_LANGMAIL;
|
||||
$_LANGMAIL = array();
|
||||
$_LANGMAIL['Welcome!'] = 'Bienvenue !';
|
||||
$_LANGMAIL['Process the payment of your order'] = '';
|
||||
$_LANGMAIL['Message from contact form'] = 'Message depuis le formulaire de contact';
|
||||
$_LANGMAIL['Your message has been correctly sent'] = 'Votre message a bien été envoyé';
|
||||
$_LANGMAIL['New credit slip regarding your order'] = 'Nouvel avoir concernant votre commande';
|
||||
@@ -10,7 +11,7 @@ $_LANGMAIL['Virtual product to download'] = 'Produit virtuel à télécharger';
|
||||
$_LANGMAIL['Fwd: Customer message'] = 'TR: Message d\'un client';
|
||||
$_LANGMAIL['Your guest account has been transformed to customer account'] = 'Votre compte invité a été transformé en compte client';
|
||||
$_LANGMAIL['Package in transit'] = 'Livraison en cours';
|
||||
$_LANGMAIL['[Log'] = '[Log';
|
||||
$_LANGMAIL['Log: You have a new alert from your shop'] = '';
|
||||
$_LANGMAIL['Order confirmation'] = 'Confirmation de commande';
|
||||
$_LANGMAIL['Message from a customer'] = 'Message d\'un client';
|
||||
$_LANGMAIL['New message regarding your order'] = 'Nouveau message concernant votre commande';
|
||||
@@ -19,8 +20,8 @@ $_LANGMAIL['Your password'] = 'Votre nouveau mot de passe';
|
||||
$_LANGMAIL['Password query confirmation'] = 'Confirmation de demande de mot de passe';
|
||||
$_LANGMAIL['An answer to your message is available'] = '';
|
||||
$_LANGMAIL['New voucher regarding your order'] = 'Nouveau bon de réduction concernant votre commande';
|
||||
$_LANGMAIL['Happy birthday!'] = 'Bon anniversaire !';
|
||||
$_LANGMAIL['Newsletter confirmation'] = 'Confirmation newsletter';
|
||||
$_LANGMAIL['Email verification'] = '';
|
||||
$_LANGMAIL['Newsletter voucher'] = 'Bon de réduction newsletter';
|
||||
$_LANGMAIL['Your wishlist\\\'s link'] = '';
|
||||
$_LANGMAIL['Message from '] = 'Message de ';
|
||||
@@ -30,10 +31,11 @@ $_LANGMAIL['Thanks for your order'] = 'Merci pour votre commande';
|
||||
$_LANGMAIL['You are one of our best customers'] = 'Vous êtes l\'un de nos meilleurs clients';
|
||||
$_LANGMAIL['We miss you'] = 'Vous nous manquez';
|
||||
$_LANGMAIL['Product available'] = 'Produit disponible';
|
||||
$_LANGMAIL['Stock coverage'] = '';
|
||||
$_LANGMAIL['Product out of stock'] = 'Rupture de stock';
|
||||
$_LANGMAIL['Error reporting from your PayPal module'] = '';
|
||||
$_LANGMAIL['Congratulations!'] = 'Bravo !';
|
||||
$_LANGMAIL['Referral Program'] = 'Programme de parrainage';
|
||||
$_LANGMAIL['A friend sent you a link to'] = 'Un ami vous a envoyé un lien vers';
|
||||
$_LANGMAIL['%1$s sent you a link to %2$s'] = '%1$s vous a envoyé un lien vers %2$s';
|
||||
|
||||
?>
|
||||
@@ -33,7 +33,7 @@ $('document').ready(function(){
|
||||
$('#sendEmail').click(function(){
|
||||
var datas = [];
|
||||
$('#fancybox-content').find('input').each(function(index){
|
||||
var o = {}
|
||||
var o = {};
|
||||
o.key = $(this).attr('name');
|
||||
o.value = $(this).val();
|
||||
if (o.value != '')
|
||||
@@ -52,10 +52,7 @@ $('document').ready(function(){
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
$('#send_friend_form_error').show();
|
||||
$('#send_friend_form_error').text('{/literal}{l s="You did not fill required fields" mod=sendtoafriend}{literal}');
|
||||
}
|
||||
$('#send_friend_form_error').text('{/literal}{l s="You did not fill required fields" mod='sendtoafriend'}{literal}');
|
||||
});
|
||||
});
|
||||
{/literal}
|
||||
@@ -90,7 +87,7 @@ $('document').ready(function(){
|
||||
<p class="txt_required"><sup class="required">*</sup> {l s='Required fields' mod='sendtoafriend'}</p>
|
||||
</div>
|
||||
<p class="submit">
|
||||
<input id="id_product_comment_send" name="id_product" type="hidden" value='{$stf_id_product}'></input>
|
||||
<input id="id_product_comment_send" name="id_product" type="hidden" value="{$stf_product->id}" />
|
||||
<a href="#" onclick="$.fancybox.close();">{l s='Cancel' mod='sendtoafriend'}</a> {l s='or' mod='sendtoafriend'}
|
||||
<input id="sendEmail" class="button" name="sendEmail" type="submit" value="{l s='Send' mod='sendtoafriend'}" />
|
||||
</p>
|
||||
|
||||
@@ -32,6 +32,7 @@ class sendToAFriend extends Module
|
||||
{
|
||||
private $_html = '';
|
||||
private $_postErrors = array();
|
||||
public $context;
|
||||
|
||||
function __construct($dontTranslate = false)
|
||||
{
|
||||
@@ -42,9 +43,12 @@ class sendToAFriend extends Module
|
||||
$this->need_instance = 0;
|
||||
$this->secure_key = Tools::encrypt($this->name);
|
||||
|
||||
// Get the context for the module
|
||||
$this->context = Context::getContext();
|
||||
|
||||
parent::__construct();
|
||||
|
||||
if(!$dontTranslate)
|
||||
if (!$dontTranslate)
|
||||
{
|
||||
$this->displayName = $this->l('Send to a Friend module');
|
||||
$this->description = $this->l('Allows customers to send a product link to a friend.');
|
||||
@@ -53,29 +57,25 @@ class sendToAFriend extends Module
|
||||
|
||||
public function install()
|
||||
{
|
||||
return (parent::install() AND $this->registerHook('extraLeft')
|
||||
AND $this->registerHook('header'));
|
||||
return (parent::install() && $this->registerHook('extraLeft') && $this->registerHook('header'));
|
||||
}
|
||||
|
||||
public function uninstall()
|
||||
{
|
||||
return (parent::uninstall() AND $this->unregisterHook('header') AND $this->unregisterHook('extraLeft'));
|
||||
return (parent::uninstall() && $this->unregisterHook('header') && $this->unregisterHook('extraLeft'));
|
||||
}
|
||||
|
||||
public function hookExtraLeft($params)
|
||||
{
|
||||
/* Product informations */
|
||||
$product = new Product((int)Tools::getValue('id_product'), false, $this->context->language->id);
|
||||
$productLink = $this->context->link->getProductLink($product);
|
||||
$image = Product::getCover((int)($_GET['id_product']));
|
||||
$image = Product::getCover((int)$product->id);
|
||||
|
||||
|
||||
Context::getContext()->smarty->assign(array(
|
||||
'stf_id_product' => (int)Tools::getValue('id_product'),
|
||||
'stf_product' => new Product((int)Tools::getValue('id_product'), false, $this->context->language->id),
|
||||
'stf_product_link' => $productLink,
|
||||
'stf_product_cover' => (int)Tools::getValue('id_product').'-'.(int)$image['id_image'],
|
||||
'stf_secure_key' => $this->secure_key,
|
||||
$this->context->smarty->assign(array(
|
||||
'stf_product' => $product,
|
||||
'stf_product_cover' => (int)$product->id.'-'.(int)$image['id_image'],
|
||||
'stf_secure_key' => $this->secure_key
|
||||
));
|
||||
|
||||
return $this->display(__FILE__, 'sendtoafriend-extra.tpl');
|
||||
|
||||
@@ -32,49 +32,48 @@ include_once(dirname(__FILE__).'/../../classes/Product.php');
|
||||
|
||||
$module = new SendToAFriend();
|
||||
|
||||
if (Tools::getValue('action') == 'sendToMyFriend' AND
|
||||
Tools::getValue('secure_key') == $module->secure_key
|
||||
AND Context::getContext()->cookie->id_customer)
|
||||
if (Tools::getValue('action') == 'sendToMyFriend' && Tools::getValue('secure_key') == $module->secure_key)
|
||||
{
|
||||
$friendInfos = Tools::jsonDecode(Tools::getValue('friend'));
|
||||
$friend_infos = Tools::jsonDecode(Tools::getValue('friend'));
|
||||
$friendName = "";
|
||||
$friendMail = "";
|
||||
$id_product = null;
|
||||
foreach ($friendInfos as $entry)
|
||||
foreach ($friend_infos as $entry)
|
||||
{
|
||||
if ($entry->key == "friend_name")
|
||||
$friendName = $entry->value;
|
||||
elseif ($entry->key == "friend_email")
|
||||
else if ($entry->key == "friend_email")
|
||||
$friendMail = $entry->value;
|
||||
elseif ($entry->key == "id_product")
|
||||
else if ($entry->key == "id_product")
|
||||
$id_product = $entry->value;
|
||||
}
|
||||
if (!$friendName OR !$friendMail OR !$id_product)
|
||||
if (!$friendName || !$friendMail || !$id_product)
|
||||
die('0');
|
||||
|
||||
/* Email generation */
|
||||
$product = new Product((int)$id_product, false, Context::getContext()->language->id);
|
||||
$productLink = Context::getContext()->link->getProductLink($product);
|
||||
$subject = (Context::getContext()->cookie->customer_firstname ? Context::getContext()->cookie->customer_firstname.' '.Context::getContext()->cookie->customer_lastname : $module->l('A friend')).' '.$module->l('sent you a link to').' '.$product->name;
|
||||
$product = new Product((int)$id_product, false, $module->context->language->id);
|
||||
$productLink = $module->context->link->getProductLink($product);
|
||||
$customer = $module->context->cookie->customer_firstname ? $module->context->cookie->customer_firstname.' '.$module->context->cookie->customer_lastname : $module->l('A friend', 'sendtoafriend_ajax');
|
||||
|
||||
$templateVars = array(
|
||||
'{product}' => $product->name,
|
||||
'{product_link}' => $productLink,
|
||||
'{customer}' => (Context::getContext()->cookie->customer_firstname ? Context::getContext()->cookie->customer_firstname.' '.Context::getContext()->cookie->customer_lastname : $module->l('A friend')),
|
||||
'{name}' => Tools::safeOutput($friendName)
|
||||
'{product}' => $product->name,
|
||||
'{product_link}' => $productLink,
|
||||
'{customer}' => $customer,
|
||||
'{name}' => Tools::safeOutput($friendName)
|
||||
);
|
||||
|
||||
/* Email sending */
|
||||
if (!Mail::Send((int)Context::getContext()->cookie->id_lang,
|
||||
if (!Mail::Send((int)$module->context->cookie->id_lang,
|
||||
'send_to_a_friend',
|
||||
Mail::l('A friend sent you a link to', (int)Context::getContext()->cookie->id_lang).' '.$product->name,
|
||||
sprintf(Mail::l('%1$s sent you a link to %2$s', (int)$module->context->cookie->id_lang), $customer, $product->name),
|
||||
$templateVars, $friendMail,
|
||||
NULL,
|
||||
(Context::getContext()->cookie->email ? Context::getContext()->cookie->email : NULL),
|
||||
(Context::getContext()->cookie->customer_firstname ? Context::getContext()->cookie->customer_firstname.' '.Context::getContext()->cookie->customer_lastname : NULL),
|
||||
NULL,
|
||||
NULL,
|
||||
null,
|
||||
($module->context->cookie->email ? $module->context->cookie->email : null),
|
||||
($module->context->cookie->customer_firstname ? $module->context->cookie->customer_firstname.' '.$module->context->cookie->customer_lastname : null),
|
||||
null,
|
||||
null,
|
||||
dirname(__FILE__).'/mails/'))
|
||||
die('0');
|
||||
die('1');
|
||||
}
|
||||
die('1');
|
||||
die('0');
|
||||
|
||||
Reference in New Issue
Block a user