[*] MO : SendToAFriend - 1.5 Supported / Pop-in instead of form
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
<module>
|
<module>
|
||||||
<name>sendtoafriend</name>
|
<name>sendtoafriend</name>
|
||||||
<displayName><![CDATA[Send to a Friend module]]></displayName>
|
<displayName><![CDATA[Send to a Friend module]]></displayName>
|
||||||
<version><![CDATA[1.1]]></version>
|
<version><![CDATA[1.2]]></version>
|
||||||
<description><![CDATA[Allows customers to send a product link to a friend.]]></description>
|
<description><![CDATA[Allows customers to send a product link to a friend.]]></description>
|
||||||
<author><![CDATA[PrestaShop]]></author>
|
<author><![CDATA[PrestaShop]]></author>
|
||||||
<tab><![CDATA[front_office_features]]></tab>
|
<tab><![CDATA[front_office_features]]></tab>
|
||||||
|
|||||||
@@ -2,19 +2,15 @@
|
|||||||
|
|
||||||
global $_MODULE;
|
global $_MODULE;
|
||||||
$_MODULE = array();
|
$_MODULE = array();
|
||||||
$_MODULE['<{sendtoafriend}prestashop>product_page_2107f6398c37b4b9ee1e1b5afb5d3b2a'] = 'Envoyer à un ami';
|
$_MODULE['<{sendtoafriend}prestashop>sendtoafriend-extra_2107f6398c37b4b9ee1e1b5afb5d3b2a'] = 'Envoyer à un ami';
|
||||||
|
$_MODULE['<{sendtoafriend}prestashop>sendtoafriend-extra_5d6103b662f41b07e10687f03aca8fdc'] = 'Destinataire';
|
||||||
|
$_MODULE['<{sendtoafriend}prestashop>sendtoafriend-extra_bb6aa0be8236a10e6d3b315ebd5f2547'] = 'Nom de votre ami';
|
||||||
|
$_MODULE['<{sendtoafriend}prestashop>sendtoafriend-extra_099bc8914b5be9e522a29e48cb3c01c4'] = 'Adresse email de votre ami';
|
||||||
|
$_MODULE['<{sendtoafriend}prestashop>sendtoafriend-extra_ea4788705e6873b424c65e91c2846b19'] = 'Annuler';
|
||||||
|
$_MODULE['<{sendtoafriend}prestashop>sendtoafriend-extra_e81c4e4f2b7b93b481e13a8553c2ae1b'] = 'ou';
|
||||||
|
$_MODULE['<{sendtoafriend}prestashop>sendtoafriend-extra_94966d90747b97d1f0f206c98a8b1ac3'] = 'Envoyer';
|
||||||
|
$_MODULE['<{sendtoafriend}prestashop>sendtoafriend-extra_70397c4b252a5168c5ec003931cea215'] = 'Champs requis';
|
||||||
$_MODULE['<{sendtoafriend}prestashop>sendtoafriend_2074615eb70699e55b1f9289c6c77c25'] = 'Module envoyer à un ami';
|
$_MODULE['<{sendtoafriend}prestashop>sendtoafriend_2074615eb70699e55b1f9289c6c77c25'] = 'Module envoyer à un ami';
|
||||||
$_MODULE['<{sendtoafriend}prestashop>sendtoafriend_3234e2609dd694d8763c390fe97eba04'] = 'Permet à vos clients d\'envoyer des liens à leurs amis';
|
$_MODULE['<{sendtoafriend}prestashop>sendtoafriend_3234e2609dd694d8763c390fe97eba04'] = 'Permet à vos clients d\'envoyer des liens à leurs amis';
|
||||||
$_MODULE['<{sendtoafriend}prestashop>sendtoafriend_666f6333e43c215212b916fef3d94af0'] = 'Vous devez remplir tous les champs.';
|
$_MODULE['<{sendtoafriend}prestashop>sendtoafriend_ajax_22c4733a9ceb239bf825a0cecd1cfaec'] = 'Un ami';
|
||||||
$_MODULE['<{sendtoafriend}prestashop>sendtoafriend_ed95f7e7c4691956e0d6f2cd0136d483'] = 'L\'email de votre ami est invalide.';
|
$_MODULE['<{sendtoafriend}prestashop>sendtoafriend_ajax_ffa719e6b8863717a9e86579249c7d9b'] = 'vous à envoyé un lien vers';
|
||||||
$_MODULE['<{sendtoafriend}prestashop>sendtoafriend_0e2a8a9d9c363a1ed93e7822eb3fc0ca'] = 'Le nom de votre ami est invalide.';
|
|
||||||
$_MODULE['<{sendtoafriend}prestashop>sendtoafriend_98db77c121d8acdba66ec89626ae896c'] = 'Une erreur est survenue durant le processus.';
|
|
||||||
$_MODULE['<{sendtoafriend}prestashop>sendtoafriend_22c4733a9ceb239bf825a0cecd1cfaec'] = 'Un ami';
|
|
||||||
$_MODULE['<{sendtoafriend}prestashop>sendtoafriend_ffa719e6b8863717a9e86579249c7d9b'] = 'vous a envoyé un lien pour';
|
|
||||||
$_MODULE['<{sendtoafriend}prestashop>sendtoafriend_2107f6398c37b4b9ee1e1b5afb5d3b2a'] = 'Envoyer à un ami';
|
|
||||||
$_MODULE['<{sendtoafriend}prestashop>sendtoafriend_20589174124c25654cac3736e737d2a3'] = 'Envoyer cette page à un ami susceptible d\'être intéressé par le produit ci-dessous';
|
|
||||||
$_MODULE['<{sendtoafriend}prestashop>sendtoafriend_b31afdfa73c89b567778f15180c2dd6c'] = 'Votre email a bien été envoyé';
|
|
||||||
$_MODULE['<{sendtoafriend}prestashop>sendtoafriend_19d305aea0ccec77d23362111ebdb6b4'] = 'Nom de votre ami :';
|
|
||||||
$_MODULE['<{sendtoafriend}prestashop>sendtoafriend_7ae8a9a7a5d8fa40d4515fc52f16bb2e'] = 'Email de votre ami :';
|
|
||||||
$_MODULE['<{sendtoafriend}prestashop>sendtoafriend_2541d938b0a58946090d7abdde0d3890'] = 'Envoyer';
|
|
||||||
$_MODULE['<{sendtoafriend}prestashop>sendtoafriend_68728c1897e5936032fe21ffb6b10c2e'] = 'Retour à la fiche produit';
|
|
||||||
|
|||||||
@@ -1,27 +0,0 @@
|
|||||||
{*
|
|
||||||
* 2007-2011 PrestaShop
|
|
||||||
*
|
|
||||||
* NOTICE OF LICENSE
|
|
||||||
*
|
|
||||||
* This source file is subject to the Academic Free License (AFL 3.0)
|
|
||||||
* that is bundled with this package in the file LICENSE.txt.
|
|
||||||
* It is also available through the world-wide-web at this URL:
|
|
||||||
* http://opensource.org/licenses/afl-3.0.php
|
|
||||||
* If you did not receive a copy of the license and are unable to
|
|
||||||
* obtain it through the world-wide-web, please send an email
|
|
||||||
* to license@prestashop.com so we can send you a copy immediately.
|
|
||||||
*
|
|
||||||
* DISCLAIMER
|
|
||||||
*
|
|
||||||
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
|
|
||||||
* versions in the future. If you wish to customize PrestaShop for your
|
|
||||||
* needs please refer to http://www.prestashop.com for more information.
|
|
||||||
*
|
|
||||||
* @author PrestaShop SA <contact@prestashop.com>
|
|
||||||
* @copyright 2007-2011 PrestaShop SA
|
|
||||||
* @version Release: $Revision: 6844 $
|
|
||||||
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
|
||||||
* International Registered Trademark & Property of PrestaShop SA
|
|
||||||
*}
|
|
||||||
|
|
||||||
<li class="sendtofriend"><a href="{$this_path}sendtoafriend-form.php?id_product={$smarty.get.id_product|intval}">{l s='Send to a friend' mod='sendtoafriend'}</a></li>
|
|
||||||
@@ -0,0 +1,104 @@
|
|||||||
|
{*
|
||||||
|
* 2007-2011 PrestaShop
|
||||||
|
*
|
||||||
|
* NOTICE OF LICENSE
|
||||||
|
*
|
||||||
|
* This source file is subject to the Academic Free License (AFL 3.0)
|
||||||
|
* that is bundled with this package in the file LICENSE.txt.
|
||||||
|
* It is also available through the world-wide-web at this URL:
|
||||||
|
* http://opensource.org/licenses/afl-3.0.php
|
||||||
|
* If you did not receive a copy of the license and are unable to
|
||||||
|
* obtain it through the world-wide-web, please send an email
|
||||||
|
* to license@prestashop.com so we can send you a copy immediately.
|
||||||
|
*
|
||||||
|
* DISCLAIMER
|
||||||
|
*
|
||||||
|
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
|
||||||
|
* versions in the future. If you wish to customize PrestaShop for your
|
||||||
|
* needs please refer to http://www.prestashop.com for more information.
|
||||||
|
*
|
||||||
|
* @author PrestaShop SA <contact@prestashop.com>
|
||||||
|
* @copyright 2007-2011 PrestaShop SA
|
||||||
|
* @version Release: $Revision$
|
||||||
|
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
||||||
|
* International Registered Trademark & Property of PrestaShop SA
|
||||||
|
*}
|
||||||
|
<script text="javascript">
|
||||||
|
{literal}
|
||||||
|
$('document').ready(function(){
|
||||||
|
$('#send_friend_button').fancybox({
|
||||||
|
'hideOnContentClick': false,
|
||||||
|
'onClosed': function(){
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#sendEmail').click(function(){
|
||||||
|
var datas = [];
|
||||||
|
$('#fancybox-content').find('input').each(function(index){
|
||||||
|
var o = {}
|
||||||
|
o.key = $(this).attr('name');
|
||||||
|
o.value = $(this).val();
|
||||||
|
if (o.value != '')
|
||||||
|
datas.push(o);
|
||||||
|
});
|
||||||
|
|
||||||
|
if (datas.length == 3)
|
||||||
|
{
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
{/literal}url: "{$module_dir}sendtoafriend_ajax.php",{literal}
|
||||||
|
post: "POST",
|
||||||
|
data: {action: 'sendToMyFriend', secure_key: '{/literal}{$stf_secure_key}{literal}', friend: JSON.stringify(datas)},{/literal}{literal}
|
||||||
|
dataType: "json",
|
||||||
|
success: function(result){
|
||||||
|
$.fancybox.close();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$('#send_friend_form_error').show();
|
||||||
|
$('#send_friend_form_error').text('{/literal}{l s="You did not fill required fields" mod=sendtoafriend}{literal}');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
{/literal}
|
||||||
|
</script>
|
||||||
|
<li class="sendtofriend">
|
||||||
|
<a id="send_friend_button" href="#send_friend_form">{l s='Send to a friend' mod='sendtoafriend'}</a>
|
||||||
|
</li>
|
||||||
|
|
||||||
|
<div style="display: none;">
|
||||||
|
<div id="send_friend_form">
|
||||||
|
<h2 class="title">{l s='Send to a friend' mod='sendtoafriend'}</h2>
|
||||||
|
<div class="product clearfix">
|
||||||
|
<img src="{$link->getImageLink($product->link_rewrite, $stf_product_cover, 'home')}" height="{$homeSize.height}" width="{$homeSize.width}" alt="{$product->name|escape:html:'UTF-8'}" />
|
||||||
|
<div class="product_desc">
|
||||||
|
<p class="product_name"><strong>{$product->name}</strong></p>
|
||||||
|
{$product->description_short}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="send_friend_form_content">
|
||||||
|
<p class="intro_form">{l s='Recipient' mod='sendtoafriend'} :</p>
|
||||||
|
<div id="send_friend_form_error"></div>
|
||||||
|
<div class="form_container">
|
||||||
|
<p class="text">
|
||||||
|
<label for="friend_name">{l s='Name of your friend' mod='sendtoafriend'}* :</label>
|
||||||
|
<input id="friend_name" name="friend_name" type="text" value=""/>
|
||||||
|
</p>
|
||||||
|
<p class="text">
|
||||||
|
<label for="friend_email">{l s='E-mail address of your friend' mod='sendtoafriend'}* :</label>
|
||||||
|
<input id="friend_email" name="friend_email" type="text" value=""/>
|
||||||
|
</p>
|
||||||
|
<br /><br />
|
||||||
|
<p class="submit">
|
||||||
|
<input id="id_product_comment_send" name="id_product" type="hidden" value='{$stf_id_product}'></input>
|
||||||
|
<a href="#" onclick="$.fancybox.close();">{l s='Cancel' mod='sendtoafriend'}</a> {l s='or' mod='sendtoafriend'}
|
||||||
|
<button id="sendEmail" name="sendEmail" type="submit">{l s='Send' mod='sendtoafriend'}</button>
|
||||||
|
</p>
|
||||||
|
<p class="txt_required">* {l s='Required fields' mod='sendtoafriend'}</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
<?php
|
|
||||||
/*
|
|
||||||
* 2007-2011 PrestaShop
|
|
||||||
*
|
|
||||||
* NOTICE OF LICENSE
|
|
||||||
*
|
|
||||||
* This source file is subject to the Academic Free License (AFL 3.0)
|
|
||||||
* that is bundled with this package in the file LICENSE.txt.
|
|
||||||
* It is also available through the world-wide-web at this URL:
|
|
||||||
* http://opensource.org/licenses/afl-3.0.php
|
|
||||||
* If you did not receive a copy of the license and are unable to
|
|
||||||
* obtain it through the world-wide-web, please send an email
|
|
||||||
* to license@prestashop.com so we can send you a copy immediately.
|
|
||||||
*
|
|
||||||
* DISCLAIMER
|
|
||||||
*
|
|
||||||
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
|
|
||||||
* versions in the future. If you wish to customize PrestaShop for your
|
|
||||||
* needs please refer to http://www.prestashop.com for more information.
|
|
||||||
*
|
|
||||||
* @author PrestaShop SA <contact@prestashop.com>
|
|
||||||
* @copyright 2007-2011 PrestaShop SA
|
|
||||||
* @version Release: $Revision: 7040 $
|
|
||||||
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
|
||||||
* International Registered Trademark & Property of PrestaShop SA
|
|
||||||
*/
|
|
||||||
|
|
||||||
include(dirname(__FILE__).'/../../config/config.inc.php');
|
|
||||||
require_once(dirname(__FILE__).'/sendtoafriend.php');
|
|
||||||
|
|
||||||
$sendtoafriend = new sendToAFriend($dontTranslate = true);
|
|
||||||
echo $sendtoafriend->displayPageForm();
|
|
||||||
|
|
||||||
@@ -0,0 +1,99 @@
|
|||||||
|
#fancybox-wrap {width:585px !important}
|
||||||
|
#fancybox-content {
|
||||||
|
width:585px !important;
|
||||||
|
border-width:0 !important
|
||||||
|
}
|
||||||
|
|
||||||
|
#send_friend_form {
|
||||||
|
width:585px;
|
||||||
|
color: #333;
|
||||||
|
text-align: left;
|
||||||
|
background-color: #fff
|
||||||
|
}
|
||||||
|
#send_friend_form .title {
|
||||||
|
padding:10px;
|
||||||
|
font-size: 13px;
|
||||||
|
color: #fff;
|
||||||
|
text-transform: uppercase;
|
||||||
|
background: #333
|
||||||
|
}
|
||||||
|
|
||||||
|
#send_friend_form .product {padding:15px}
|
||||||
|
#send_friend_form .product img {
|
||||||
|
float:left;
|
||||||
|
border: 1px solid #ccc;
|
||||||
|
}
|
||||||
|
#send_friend_form .product .product_desc {
|
||||||
|
float:left;
|
||||||
|
margin-left:15px;
|
||||||
|
width:300px;
|
||||||
|
line-height:18px;
|
||||||
|
color:#666
|
||||||
|
}
|
||||||
|
#send_friend_form .product .product_desc .product_name {
|
||||||
|
padding-bottom:5px;
|
||||||
|
font-size:13px;
|
||||||
|
color:#000
|
||||||
|
}
|
||||||
|
|
||||||
|
.send_friend_form_content {
|
||||||
|
padding:15px;
|
||||||
|
background:#f8f8f8
|
||||||
|
}
|
||||||
|
.send_friend_form_content .intro_form {
|
||||||
|
padding-bottom: 10px;
|
||||||
|
font-weight: bold;
|
||||||
|
font-size: 12px
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#send_friend_form .form_container {
|
||||||
|
clear:both;
|
||||||
|
margin-top:20px
|
||||||
|
}
|
||||||
|
#send_friend_form p.text {
|
||||||
|
margin-bottom:0;
|
||||||
|
padding-bottom:0
|
||||||
|
}
|
||||||
|
#send_friend_form p.text label, #send_friend_form p.textarea label {
|
||||||
|
display: block;
|
||||||
|
margin:12px 0 4px 0;
|
||||||
|
font-weight: bold;
|
||||||
|
font-size: 12px;
|
||||||
|
}
|
||||||
|
#send_friend_form p.text input {
|
||||||
|
padding: 0 5px;
|
||||||
|
height: 28px;
|
||||||
|
width: 540px;
|
||||||
|
border: 1px solid #ccc;
|
||||||
|
background: url(../img/bg_input.png) repeat-x scroll 0 0 #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
#send_friend_form .submit {
|
||||||
|
padding:0;
|
||||||
|
font-size:13px;
|
||||||
|
text-align:right
|
||||||
|
}
|
||||||
|
#send_friend_form button {
|
||||||
|
cursor: pointer;
|
||||||
|
cursor: pointer;
|
||||||
|
display: inline-block;
|
||||||
|
padding: 4px 7px 3px 7px;
|
||||||
|
border: 1px solid #CC9900;
|
||||||
|
border-radius: 3px 3px 3px 3px;
|
||||||
|
font-weight: bold;
|
||||||
|
color: #000;
|
||||||
|
background: url(../img/bg_bt.gif) repeat-x scroll 0 0 #F4B61B
|
||||||
|
}
|
||||||
|
#send_friend_form .submit .txt_required {
|
||||||
|
float:left;
|
||||||
|
font-size:12px;
|
||||||
|
font-style:italic;
|
||||||
|
color:#666
|
||||||
|
}
|
||||||
|
#send_friend_form_error {
|
||||||
|
color:red;
|
||||||
|
font-size:13px;
|
||||||
|
text-align:left;
|
||||||
|
display:hidden;
|
||||||
|
}
|
||||||
@@ -30,110 +30,58 @@ if (!defined('_PS_VERSION_'))
|
|||||||
|
|
||||||
class sendToAFriend extends Module
|
class sendToAFriend extends Module
|
||||||
{
|
{
|
||||||
|
private $_html = '';
|
||||||
|
private $_postErrors = array();
|
||||||
|
|
||||||
function __construct($dontTranslate = false)
|
function __construct($dontTranslate = false)
|
||||||
{
|
{
|
||||||
$this->name = 'sendtoafriend';
|
$this->name = 'sendtoafriend';
|
||||||
$this->version = '1.1';
|
$this->version = '1.2';
|
||||||
$this->author = 'PrestaShop';
|
$this->author = 'PrestaShop';
|
||||||
$this->tab = 'front_office_features';
|
$this->tab = 'front_office_features';
|
||||||
$this->need_instance = 0;
|
$this->need_instance = 0;
|
||||||
|
$this->secure_key = Tools::encrypt($this->name);
|
||||||
|
|
||||||
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.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function install()
|
public function install()
|
||||||
{
|
{
|
||||||
return (parent::install() AND $this->registerHook('extraLeft'));
|
return (parent::install() AND $this->registerHook('extraLeft')
|
||||||
|
AND $this->registerHook('header'));
|
||||||
}
|
}
|
||||||
|
|
||||||
function hookExtraLeft($params)
|
public function uninstall()
|
||||||
{
|
{
|
||||||
$this->context->smarty->assign('this_path', $this->_path);
|
return (parent::uninstall() AND $this->unregisterHook('header') AND $this->unregisterHook('extraLeft'));
|
||||||
return $this->display(__FILE__, 'product_page.tpl');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function displayPageForm()
|
public function hookExtraLeft($params)
|
||||||
{
|
{
|
||||||
if (!$this->active)
|
/* Product informations */
|
||||||
Tools::display404Error();
|
$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']));
|
||||||
|
|
||||||
include(dirname(__FILE__).'/../../header.php');
|
|
||||||
echo $this->displayFrontForm();
|
|
||||||
include(dirname(__FILE__).'/../../footer.php');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function displayFrontForm()
|
Context::getContext()->smarty->assign(array(
|
||||||
{
|
'stf_id_product' => (int)Tools::getValue('id_product'),
|
||||||
$error = false;
|
'stf_product_link' => $productLink,
|
||||||
$confirm = false;
|
'stf_product_cover' => (int)Tools::getValue('id_product').'-'.(int)$image['id_image'],
|
||||||
|
'stf_secure_key' => $this->secure_key,
|
||||||
if (isset($_POST['submitAddtoafriend']))
|
|
||||||
{
|
|
||||||
/* Product informations */
|
|
||||||
$product = new Product((int)Tools::getValue('id_product'), false, $this->context->language->id);
|
|
||||||
$productLink = $this->context->link->getProductLink($product);
|
|
||||||
|
|
||||||
/* Fields verifications */
|
|
||||||
if (empty($_POST['email']) OR empty($_POST['name']))
|
|
||||||
$error = $this->l('You must fill in all fields.');
|
|
||||||
elseif (empty($_POST['email']) OR !Validate::isEmail($_POST['email']))
|
|
||||||
$error = $this->l('The e-mail given is invalid.');
|
|
||||||
elseif (!Validate::isName($_POST['name']))
|
|
||||||
$error = $this->l('The name given is invalid.');
|
|
||||||
elseif (!isset($_GET['id_product']) OR !is_numeric($_GET['id_product']))
|
|
||||||
$error = $this->l('An error occurred during the process.');
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* Email generation */
|
|
||||||
$subject = ($cookie->customer_firstname ? $cookie->customer_firstname.' '.$cookie->customer_lastname : $this->l('A friend')).' '.$this->l('sent you a link to').' '.$product->name;
|
|
||||||
$templateVars = array(
|
|
||||||
'{product}' => $product->name,
|
|
||||||
'{product_link}' => $productLink,
|
|
||||||
'{customer}' => ($cookie->customer_firstname ? $cookie->customer_firstname.' '.$cookie->customer_lastname : $this->l('A friend')),
|
|
||||||
'{name}' => Tools::safeOutput($_POST['name'])
|
|
||||||
);
|
|
||||||
|
|
||||||
/* Email sending */
|
|
||||||
if (!Mail::Send((int)$cookie->id_lang, 'send_to_a_friend', Mail::l('A friend sent you a link to').' '.$product->name, $templateVars, $_POST['email'], NULL, ($cookie->email ? $cookie->email : NULL), ($cookie->customer_firstname ? $cookie->customer_firstname.' '.$cookie->customer_lastname : NULL), NULL, NULL, dirname(__FILE__).'/mails/'))
|
|
||||||
$error = $this->l('An error occurred during the process.');
|
|
||||||
else
|
|
||||||
Tools::redirect(_MODULE_DIR_.'/'.$this->name.'/sendtoafriend-form.php?id_product='.(int)$product->id.'&submited');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* Product informations */
|
|
||||||
$product = new Product((int)Tools::getValue('id_product'), false, $this->context->language->id);
|
|
||||||
$productLink = $this->context->link->getProductLink($product);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Image */
|
|
||||||
$images = $product->getImages((int)$cookie->id_lang);
|
|
||||||
foreach ($images AS $k => $image)
|
|
||||||
if ($image['cover'])
|
|
||||||
{
|
|
||||||
$cover['id_image'] = (int)$product->id.'-'.(int)$image['id_image'];
|
|
||||||
$cover['legend'] = $image['legend'];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!isset($cover))
|
|
||||||
$cover = array('id_image' => $this->context->language->iso_code.'-default', 'legend' => 'No picture');
|
|
||||||
|
|
||||||
$this->context->smarty->assign(array(
|
|
||||||
'cover' => $cover,
|
|
||||||
'errors' => $error,
|
|
||||||
'confirm' => $confirm,
|
|
||||||
'product' => $product,
|
|
||||||
'productLink' => $productLink
|
|
||||||
));
|
));
|
||||||
|
|
||||||
return $this->display(__FILE__, 'sendtoafriend.tpl');
|
return $this->display(__FILE__, 'sendtoafriend-extra.tpl');
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
public function hookHeader($params)
|
||||||
|
{
|
||||||
|
$this->context->controller->addCSS($this->_path.'sendtoafriend.css', 'all');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,64 +0,0 @@
|
|||||||
{*
|
|
||||||
* 2007-2011 PrestaShop
|
|
||||||
*
|
|
||||||
* NOTICE OF LICENSE
|
|
||||||
*
|
|
||||||
* This source file is subject to the Academic Free License (AFL 3.0)
|
|
||||||
* that is bundled with this package in the file LICENSE.txt.
|
|
||||||
* It is also available through the world-wide-web at this URL:
|
|
||||||
* http://opensource.org/licenses/afl-3.0.php
|
|
||||||
* If you did not receive a copy of the license and are unable to
|
|
||||||
* obtain it through the world-wide-web, please send an email
|
|
||||||
* to license@prestashop.com so we can send you a copy immediately.
|
|
||||||
*
|
|
||||||
* DISCLAIMER
|
|
||||||
*
|
|
||||||
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
|
|
||||||
* versions in the future. If you wish to customize PrestaShop for your
|
|
||||||
* needs please refer to http://www.prestashop.com for more information.
|
|
||||||
*
|
|
||||||
* @author PrestaShop SA <contact@prestashop.com>
|
|
||||||
* @copyright 2007-2011 PrestaShop SA
|
|
||||||
* @version Release: $Revision: 6844 $
|
|
||||||
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
|
||||||
* International Registered Trademark & Property of PrestaShop SA
|
|
||||||
*}
|
|
||||||
|
|
||||||
{capture name=path}{l s='Send to a friend' mod='sendtoafriend'}{/capture}
|
|
||||||
{include file="$tpl_dir./breadcrumb.tpl"}
|
|
||||||
|
|
||||||
<h1>{l s='Send to a friend' mod='sendtoafriend'}</h1>
|
|
||||||
|
|
||||||
<p class="bold">{l s='Send this page to a friend who might be interested in the item below.' mod='sendtoafriend'}.</p>
|
|
||||||
{include file="$tpl_dir./errors.tpl"}
|
|
||||||
|
|
||||||
{if isset($smarty.get.submited)}
|
|
||||||
<p class="success">{l s='Your email has been sent successfully' mod='sendtoafriend'}</p>
|
|
||||||
{else}
|
|
||||||
<form method="post" action="{$request_uri}" class="std" id="sendfriendform">
|
|
||||||
<fieldset>
|
|
||||||
<p class="product">
|
|
||||||
<a href="{$productLink}"><img src="{$link->getImageLink($product->link_rewrite, $cover.id_image, 'small')}" alt="" title="{$cover.legend}" /></a><br/>
|
|
||||||
<a href="{$productLink}">{$product->name}</a>
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<p class="text">
|
|
||||||
<label for="friend-name">{l s='Friend\'s name:' mod='sendtoafriend'}</label>
|
|
||||||
<input type="text" id="friend-name" name="name" value="{if isset($smarty.post.name)}{$smarty.post.name|escape:'htmlall':'UTF-8'|stripslashes}{/if}" />
|
|
||||||
</p>
|
|
||||||
<p class="text">
|
|
||||||
<label for="friend-address">{l s='Friend\'s email:' mod='sendtoafriend'}</label>
|
|
||||||
<input type="text" id="friend-address" name="email" value="{if isset($smarty.post.name)}{$smarty.post.email|escape:'htmlall'|stripslashes}{/if}" />
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<p class="submit clearfix">
|
|
||||||
<input type="submit" name="submitAddtoafriend" value="{l s='send' mod='sendtoafriend'}" class="button" />
|
|
||||||
</p>
|
|
||||||
</fieldset>
|
|
||||||
</form>
|
|
||||||
{/if}
|
|
||||||
|
|
||||||
<ul class="footer_links">
|
|
||||||
<li><a href="{$productLink}">« {l s='Back to product page' mod='sendtoafriend'}</a></li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
@@ -0,0 +1,80 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
* 2007-2011 PrestaShop
|
||||||
|
*
|
||||||
|
* NOTICE OF LICENSE
|
||||||
|
*
|
||||||
|
* This source file is subject to the Academic Free License (AFL 3.0)
|
||||||
|
* that is bundled with this package in the file LICENSE.txt.
|
||||||
|
* It is also available through the world-wide-web at this URL:
|
||||||
|
* http://opensource.org/licenses/afl-3.0.php
|
||||||
|
* If you did not receive a copy of the license and are unable to
|
||||||
|
* obtain it through the world-wide-web, please send an email
|
||||||
|
* to license@prestashop.com so we can send you a copy immediately.
|
||||||
|
*
|
||||||
|
* DISCLAIMER
|
||||||
|
*
|
||||||
|
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
|
||||||
|
* versions in the future. If you wish to customize PrestaShop for your
|
||||||
|
* needs please refer to http://www.prestashop.com for more information.
|
||||||
|
*
|
||||||
|
* @author PrestaShop SA <contact@prestashop.com>
|
||||||
|
* @copyright 2007-2011 PrestaShop SA
|
||||||
|
* @version Release: $Revision$
|
||||||
|
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
||||||
|
* International Registered Trademark & Property of PrestaShop SA
|
||||||
|
*/
|
||||||
|
|
||||||
|
require_once(dirname(__FILE__).'/../../config/config.inc.php');
|
||||||
|
require_once(dirname(__FILE__).'/../../init.php');
|
||||||
|
include_once(dirname(__FILE__).'/sendtoafriend.php');
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
$friendInfos = Tools::jsonDecode(Tools::getValue('friend'));
|
||||||
|
$friendName = "";
|
||||||
|
$friendMail = "";
|
||||||
|
$id_product = null;
|
||||||
|
foreach ($friendInfos as $entry)
|
||||||
|
{
|
||||||
|
if ($entry->key == "friend_name")
|
||||||
|
$friendName = $entry->value;
|
||||||
|
elseif ($entry->key == "friend_email")
|
||||||
|
$friendMail = $entry->value;
|
||||||
|
elseif ($entry->key == "id_product")
|
||||||
|
$id_product = $entry->value;
|
||||||
|
}
|
||||||
|
if (!$friendName OR !$friendMail OR !$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;
|
||||||
|
$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)
|
||||||
|
);
|
||||||
|
|
||||||
|
/* Email sending */
|
||||||
|
if (!Mail::Send((int)Context::getContext()->cookie->id_lang,
|
||||||
|
'send_to_a_friend',
|
||||||
|
Mail::l('A friend sent you a link to').' '.$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,
|
||||||
|
dirname(__FILE__).'/mails/'))
|
||||||
|
die('0');
|
||||||
|
die('1');
|
||||||
|
}
|
||||||
|
die('1');
|
||||||
Reference in New Issue
Block a user