* 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 <*****@*****.**>
*  @copyright  2007-2012 PrestaShop SA
*  @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' && Tools::getValue('secure_key') == $module->secure_key) {
    $friend_infos = Tools::jsonDecode(Tools::getValue('friend'));
    $friendName = "";
    $friendMail = "";
    $id_product = null;
    foreach ($friend_infos as $entry) {
        if ($entry->key == "friend_name") {
            $friendName = $entry->value;
        } else {
            if ($entry->key == "friend_email") {
                $friendMail = $entry->value;
            } else {
                if ($entry->key == "id_product") {
                    $id_product = $entry->value;
                }
*
* 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 <*****@*****.**>
*  @copyright  2007-2016 PrestaShop SA
*  @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';
$module = new SendToAFriend();
if (Module::isEnabled('sendtoafriend') && Tools::getValue('action') == 'sendToMyFriend' && Tools::getValue('secure_key') == $module->secure_key) {
    // Retrocompatibilty with old theme
    if ($friend = Tools::getValue('friend')) {
        $friend = Tools::jsonDecode($friend, true);
        foreach ($friend as $key => $value) {
            if ($value['key'] == 'friend_name') {
                $friendName = $value['value'];
            } elseif ($value['key'] == 'friend_email') {
                $friendMail = $value['value'];
            } elseif ($value['key'] == 'id_product') {
                $id_product = $value['value'];
            }
        }
    } else {
        $friendName = Tools::getValue('name');