[-] 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:
lLefevre
2012-04-12 08:35:18 +00:00
parent 244a2f9102
commit 08244ef34b
4 changed files with 42 additions and 44 deletions
+5 -3
View File
@@ -3,6 +3,7 @@
global $_LANGMAIL; global $_LANGMAIL;
$_LANGMAIL = array(); $_LANGMAIL = array();
$_LANGMAIL['Welcome!'] = 'Bienvenue !'; $_LANGMAIL['Welcome!'] = 'Bienvenue !';
$_LANGMAIL['Process the payment of your order'] = '';
$_LANGMAIL['Message from contact form'] = 'Message depuis le formulaire de contact'; $_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['Your message has been correctly sent'] = 'Votre message a bien été envoyé';
$_LANGMAIL['New credit slip regarding your order'] = 'Nouvel avoir concernant votre commande'; $_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['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['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['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['Order confirmation'] = 'Confirmation de commande';
$_LANGMAIL['Message from a customer'] = 'Message d\'un client'; $_LANGMAIL['Message from a customer'] = 'Message d\'un client';
$_LANGMAIL['New message regarding your order'] = 'Nouveau message concernant votre commande'; $_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['Password query confirmation'] = 'Confirmation de demande de mot de passe';
$_LANGMAIL['An answer to your message is available'] = ''; $_LANGMAIL['An answer to your message is available'] = '';
$_LANGMAIL['New voucher regarding your order'] = 'Nouveau bon de réduction concernant votre commande'; $_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['Newsletter confirmation'] = 'Confirmation newsletter';
$_LANGMAIL['Email verification'] = '';
$_LANGMAIL['Newsletter voucher'] = 'Bon de réduction newsletter'; $_LANGMAIL['Newsletter voucher'] = 'Bon de réduction newsletter';
$_LANGMAIL['Your wishlist\\\'s link'] = ''; $_LANGMAIL['Your wishlist\\\'s link'] = '';
$_LANGMAIL['Message from '] = 'Message de '; $_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['You are one of our best customers'] = 'Vous êtes l\'un de nos meilleurs clients';
$_LANGMAIL['We miss you'] = 'Vous nous manquez'; $_LANGMAIL['We miss you'] = 'Vous nous manquez';
$_LANGMAIL['Product available'] = 'Produit disponible'; $_LANGMAIL['Product available'] = 'Produit disponible';
$_LANGMAIL['Stock coverage'] = '';
$_LANGMAIL['Product out of stock'] = 'Rupture de stock'; $_LANGMAIL['Product out of stock'] = 'Rupture de stock';
$_LANGMAIL['Error reporting from your PayPal module'] = ''; $_LANGMAIL['Error reporting from your PayPal module'] = '';
$_LANGMAIL['Congratulations!'] = 'Bravo !'; $_LANGMAIL['Congratulations!'] = 'Bravo !';
$_LANGMAIL['Referral Program'] = 'Programme de parrainage'; $_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(){ $('#sendEmail').click(function(){
var datas = []; var datas = [];
$('#fancybox-content').find('input').each(function(index){ $('#fancybox-content').find('input').each(function(index){
var o = {} var o = {};
o.key = $(this).attr('name'); o.key = $(this).attr('name');
o.value = $(this).val(); o.value = $(this).val();
if (o.value != '') if (o.value != '')
@@ -52,10 +52,7 @@ $('document').ready(function(){
}); });
} }
else else
{ $('#send_friend_form_error').text('{/literal}{l s="You did not fill required fields" mod='sendtoafriend'}{literal}');
$('#send_friend_form_error').show();
$('#send_friend_form_error').text('{/literal}{l s="You did not fill required fields" mod=sendtoafriend}{literal}');
}
}); });
}); });
{/literal} {/literal}
@@ -90,7 +87,7 @@ $('document').ready(function(){
<p class="txt_required"><sup class="required">*</sup> {l s='Required fields' mod='sendtoafriend'}</p> <p class="txt_required"><sup class="required">*</sup> {l s='Required fields' mod='sendtoafriend'}</p>
</div> </div>
<p class="submit"> <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>&nbsp;{l s='or' mod='sendtoafriend'}&nbsp; <a href="#" onclick="$.fancybox.close();">{l s='Cancel' mod='sendtoafriend'}</a>&nbsp;{l s='or' mod='sendtoafriend'}&nbsp;
<input id="sendEmail" class="button" name="sendEmail" type="submit" value="{l s='Send' mod='sendtoafriend'}" /> <input id="sendEmail" class="button" name="sendEmail" type="submit" value="{l s='Send' mod='sendtoafriend'}" />
</p> </p>
+12 -12
View File
@@ -32,6 +32,7 @@ class sendToAFriend extends Module
{ {
private $_html = ''; private $_html = '';
private $_postErrors = array(); private $_postErrors = array();
public $context;
function __construct($dontTranslate = false) function __construct($dontTranslate = false)
{ {
@@ -42,9 +43,12 @@ class sendToAFriend extends Module
$this->need_instance = 0; $this->need_instance = 0;
$this->secure_key = Tools::encrypt($this->name); $this->secure_key = Tools::encrypt($this->name);
// Get the context for the module
$this->context = Context::getContext();
parent::__construct(); parent::__construct();
if(!$dontTranslate) if (!$dontTranslate)
{ {
$this->displayName = $this->l('Send to a Friend module'); $this->displayName = $this->l('Send to a Friend module');
$this->description = $this->l('Allows customers to send a product link to a friend.'); $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() public function install()
{ {
return (parent::install() AND $this->registerHook('extraLeft') return (parent::install() && $this->registerHook('extraLeft') && $this->registerHook('header'));
AND $this->registerHook('header'));
} }
public function uninstall() 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) public function hookExtraLeft($params)
{ {
/* Product informations */ /* Product informations */
$product = new Product((int)Tools::getValue('id_product'), false, $this->context->language->id); $product = new Product((int)Tools::getValue('id_product'), false, $this->context->language->id);
$productLink = $this->context->link->getProductLink($product); $image = Product::getCover((int)$product->id);
$image = Product::getCover((int)($_GET['id_product']));
Context::getContext()->smarty->assign(array( $this->context->smarty->assign(array(
'stf_id_product' => (int)Tools::getValue('id_product'), 'stf_product' => $product,
'stf_product' => new Product((int)Tools::getValue('id_product'), false, $this->context->language->id), 'stf_product_cover' => (int)$product->id.'-'.(int)$image['id_image'],
'stf_product_link' => $productLink, 'stf_secure_key' => $this->secure_key
'stf_product_cover' => (int)Tools::getValue('id_product').'-'.(int)$image['id_image'],
'stf_secure_key' => $this->secure_key,
)); ));
return $this->display(__FILE__, 'sendtoafriend-extra.tpl'); return $this->display(__FILE__, 'sendtoafriend-extra.tpl');
+22 -23
View File
@@ -32,49 +32,48 @@ include_once(dirname(__FILE__).'/../../classes/Product.php');
$module = new SendToAFriend(); $module = new SendToAFriend();
if (Tools::getValue('action') == 'sendToMyFriend' AND if (Tools::getValue('action') == 'sendToMyFriend' && Tools::getValue('secure_key') == $module->secure_key)
Tools::getValue('secure_key') == $module->secure_key
AND Context::getContext()->cookie->id_customer)
{ {
$friendInfos = Tools::jsonDecode(Tools::getValue('friend')); $friend_infos = Tools::jsonDecode(Tools::getValue('friend'));
$friendName = ""; $friendName = "";
$friendMail = ""; $friendMail = "";
$id_product = null; $id_product = null;
foreach ($friendInfos as $entry) foreach ($friend_infos as $entry)
{ {
if ($entry->key == "friend_name") if ($entry->key == "friend_name")
$friendName = $entry->value; $friendName = $entry->value;
elseif ($entry->key == "friend_email") else if ($entry->key == "friend_email")
$friendMail = $entry->value; $friendMail = $entry->value;
elseif ($entry->key == "id_product") else if ($entry->key == "id_product")
$id_product = $entry->value; $id_product = $entry->value;
} }
if (!$friendName OR !$friendMail OR !$id_product) if (!$friendName || !$friendMail || !$id_product)
die('0'); die('0');
/* Email generation */ /* Email generation */
$product = new Product((int)$id_product, false, Context::getContext()->language->id); $product = new Product((int)$id_product, false, $module->context->language->id);
$productLink = Context::getContext()->link->getProductLink($product); $productLink = $module->context->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; $customer = $module->context->cookie->customer_firstname ? $module->context->cookie->customer_firstname.' '.$module->context->cookie->customer_lastname : $module->l('A friend', 'sendtoafriend_ajax');
$templateVars = array( $templateVars = array(
'{product}' => $product->name, '{product}' => $product->name,
'{product_link}' => $productLink, '{product_link}' => $productLink,
'{customer}' => (Context::getContext()->cookie->customer_firstname ? Context::getContext()->cookie->customer_firstname.' '.Context::getContext()->cookie->customer_lastname : $module->l('A friend')), '{customer}' => $customer,
'{name}' => Tools::safeOutput($friendName) '{name}' => Tools::safeOutput($friendName)
); );
/* Email sending */ /* Email sending */
if (!Mail::Send((int)Context::getContext()->cookie->id_lang, if (!Mail::Send((int)$module->context->cookie->id_lang,
'send_to_a_friend', '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, $templateVars, $friendMail,
NULL, null,
(Context::getContext()->cookie->email ? Context::getContext()->cookie->email : NULL), ($module->context->cookie->email ? $module->context->cookie->email : null),
(Context::getContext()->cookie->customer_firstname ? Context::getContext()->cookie->customer_firstname.' '.Context::getContext()->cookie->customer_lastname : NULL), ($module->context->cookie->customer_firstname ? $module->context->cookie->customer_firstname.' '.$module->context->cookie->customer_lastname : null),
NULL, null,
NULL, null,
dirname(__FILE__).'/mails/')) dirname(__FILE__).'/mails/'))
die('0'); die('0');
die('1'); die('1');
} }
die('1'); die('0');