diff --git a/modules/blockwishlist/WishList.php b/modules/blockwishlist/WishList.php deleted file mode 100644 index 23e57cdbe..000000000 --- a/modules/blockwishlist/WishList.php +++ /dev/null @@ -1,553 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -if (!defined('_PS_VERSION_')) - exit; - -class WishList extends ObjectModel -{ - /** @var integer Wishlist ID */ - public $id; - - /** @var integer Customer ID */ - public $id_customer; - - /** @var integer Token */ - public $token; - - /** @var integer Name */ - public $name; - - /** @var string Object creation date */ - public $date_add; - - /** @var string Object last modification date */ - public $date_upd; - - /** @var string Object last modification date */ - public $id_shop; - - /** @var string Object last modification date */ - public $id_shop_group; - /** - * @see ObjectModel::$definition - */ - public static $definition = array( - 'table' => 'wishlist', - 'primary' => 'id_wishlist', - 'fields' => array( - 'id_customer' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true), - 'token' => array('type' => self::TYPE_STRING, 'validate' => 'isMessage', 'required' => true), - 'name' => array('type' => self::TYPE_STRING, 'validate' => 'isMessage', 'required' => true), - 'date_add' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'), - 'date_upd' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'), - 'id_shop' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'), - 'id_shop_group' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'), - ) - ); - - public function delete() - { - Db::getInstance()->execute('DELETE FROM `'._DB_PREFIX_.'wishlist_email` WHERE `id_wishlist` = '.(int)($this->id)); - Db::getInstance()->execute('DELETE FROM `'._DB_PREFIX_.'wishlist_product` WHERE `id_wishlist` = '.(int)($this->id)); - if (isset($this->context->cookie->id_wishlist)) - unset($this->context->cookie->id_wishlist); - - return (parent::delete()); - } - - /** - * Increment counter - * - * @return boolean succeed - */ - public static function incCounter($id_wishlist) - { - if (!Validate::isUnsignedId($id_wishlist)) - die (Tools::displayError()); - $result = Db::getInstance()->getRow(' - SELECT `counter` - FROM `'._DB_PREFIX_.'wishlist` - WHERE `id_wishlist` = '.(int)$id_wishlist - ); - if ($result == false || !count($result) || empty($result) === true) - return (false); - - return Db::getInstance()->execute(' - UPDATE `'._DB_PREFIX_.'wishlist` SET - `counter` = '.(int)($result['counter'] + 1).' - WHERE `id_wishlist` = '.(int)$id_wishlist - ); - } - - - public static function isExistsByNameForUser($name) - { - if (Shop::getContextShopID()) - $shop_restriction = 'AND id_shop = '.(int)Shop::getContextShopID(); - elseif (Shop::getContextShopGroupID()) - $shop_restriction = 'AND id_shop_group = '.(int)Shop::getContextShopGroupID(); - else - $shop_restriction = ''; - - $context = Context::getContext(); - return Db::getInstance()->getValue(' - SELECT COUNT(*) AS total - FROM `'._DB_PREFIX_.'wishlist` - WHERE `name` = \''.pSQL($name).'\' - AND `id_customer` = '.(int)$context->customer->id.' - '.$shop_restriction - ); - } - - /** - * Return true if wishlist exists else false - * - * @return boolean exists - */ - public static function exists($id_wishlist, $id_customer, $return = false) - { - if (!Validate::isUnsignedId($id_wishlist) OR - !Validate::isUnsignedId($id_customer)) - die (Tools::displayError()); - $result = Db::getInstance()->getRow(' - SELECT `id_wishlist`, `name`, `token` - FROM `'._DB_PREFIX_.'wishlist` - WHERE `id_wishlist` = '.(int)($id_wishlist).' - AND `id_customer` = '.(int)($id_customer)); - if (empty($result) === false AND $result != false AND sizeof($result)) - { - if ($return === false) - return (true); - else - return ($result); - } - return (false); - } - - /** - * Get ID wishlist by Token - * - * @return array Results - */ - public static function getByToken($token) - { - if (!Validate::isMessage($token)) - die (Tools::displayError()); - return (Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow(' - SELECT w.`id_wishlist`, w.`name`, w.`id_customer`, c.`firstname`, c.`lastname` - FROM `'._DB_PREFIX_.'wishlist` w - INNER JOIN `'._DB_PREFIX_.'customer` c ON c.`id_customer` = w.`id_customer` - WHERE `token` = \''.pSQL($token).'\'')); - } - - /** - * Get Wishlists by Customer ID - * - * @return array Results - */ - public static function getByIdCustomer($id_customer) - { - if (!Validate::isUnsignedId($id_customer)) - die (Tools::displayError()); - if (Shop::getContextShopID()) - $shop_restriction = 'AND id_shop = '.(int)Shop::getContextShopID(); - elseif (Shop::getContextShopGroupID()) - $shop_restriction = 'AND id_shop_group = '.(int)Shop::getContextShopGroupID(); - else - $shop_restriction = ''; - - $cache_id = 'WhishList::getByIdCustomer_'.(int)$id_customer.'-'.(int)Shop::getContextShopID().'-'.(int)Shop::getContextShopGroupID(); - if (!Cache::isStored($cache_id)) - { - $result = Db::getInstance()->executeS(' - SELECT w.`id_wishlist`, w.`name`, w.`token`, w.`date_add`, w.`date_upd`, w.`counter` - FROM `'._DB_PREFIX_.'wishlist` w - WHERE `id_customer` = '.(int)($id_customer).' - '.$shop_restriction.' - ORDER BY w.`name` ASC'); - Cache::store($cache_id, $result); - } - return Cache::retrieve($cache_id); - } - - public static function refreshWishList($id_wishlist) - { - $old_carts = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS(' - SELECT wp.id_product, wp.id_product_attribute, wpc.id_cart, UNIX_TIMESTAMP(NOW()) - UNIX_TIMESTAMP(wpc.date_add) AS timecart - FROM `'._DB_PREFIX_.'wishlist_product_cart` wpc - JOIN `'._DB_PREFIX_.'wishlist_product` wp ON (wp.id_wishlist_product = wpc.id_wishlist_product) - JOIN `'._DB_PREFIX_.'cart` c ON (c.id_cart = wpc.id_cart) - JOIN `'._DB_PREFIX_.'cart_product` cp ON (wpc.id_cart = cp.id_cart) - LEFT JOIN `'._DB_PREFIX_.'orders` o ON (o.id_cart = c.id_cart) - WHERE (wp.id_wishlist='.(int)($id_wishlist).' AND o.id_cart IS NULL) - HAVING timecart >= 3600*6'); - - if (isset($old_carts) AND $old_carts != false) - foreach ($old_carts AS $old_cart) - Db::getInstance()->execute(' - DELETE FROM `'._DB_PREFIX_.'cart_product` - WHERE id_cart='.(int)($old_cart['id_cart']).' AND id_product='.(int)($old_cart['id_product']).' AND id_product_attribute='.(int)($old_cart['id_product_attribute']) - ); - - $freshwish = Db::getInstance()->executeS(' - SELECT wpc.id_cart, wpc.id_wishlist_product - FROM `'._DB_PREFIX_.'wishlist_product_cart` wpc - JOIN `'._DB_PREFIX_.'wishlist_product` wp ON (wpc.id_wishlist_product = wp.id_wishlist_product) - JOIN `'._DB_PREFIX_.'cart` c ON (c.id_cart = wpc.id_cart) - LEFT JOIN `'._DB_PREFIX_.'cart_product` cp ON (cp.id_cart = wpc.id_cart AND cp.id_product = wp.id_product AND cp.id_product_attribute = wp.id_product_attribute) - WHERE (wp.id_wishlist = '.(int)($id_wishlist).' AND ((cp.id_product IS NULL AND cp.id_product_attribute IS NULL))) - '); - $res = Db::getInstance()->executeS(' - SELECT wp.id_wishlist_product, cp.quantity AS cart_quantity, wpc.quantity AS wish_quantity, wpc.id_cart - FROM `'._DB_PREFIX_.'wishlist_product_cart` wpc - JOIN `'._DB_PREFIX_.'wishlist_product` wp ON (wp.id_wishlist_product = wpc.id_wishlist_product) - JOIN `'._DB_PREFIX_.'cart` c ON (c.id_cart = wpc.id_cart) - JOIN `'._DB_PREFIX_.'cart_product` cp ON (cp.id_cart = wpc.id_cart AND cp.id_product = wp.id_product AND cp.id_product_attribute = wp.id_product_attribute) - WHERE wp.id_wishlist='.(int)($id_wishlist) - ); - - if (isset($res) AND $res != false) - foreach ($res AS $refresh) - if ($refresh['wish_quantity'] > $refresh['cart_quantity']) - { - Db::getInstance()->execute(' - UPDATE `'._DB_PREFIX_.'wishlist_product` - SET `quantity`= `quantity` + '.((int)($refresh['wish_quantity']) - (int)($refresh['cart_quantity'])).' - WHERE id_wishlist_product='.(int)($refresh['id_wishlist_product']) - ); - Db::getInstance()->execute(' - UPDATE `'._DB_PREFIX_.'wishlist_product_cart` - SET `quantity`='.(int)($refresh['cart_quantity']).' - WHERE id_wishlist_product='.(int)($refresh['id_wishlist_product']).' AND id_cart='.(int)($refresh['id_cart']) - ); - } - if (isset($freshwish) AND $freshwish != false) - foreach ($freshwish AS $prodcustomer) - { - Db::getInstance()->execute(' - UPDATE `'._DB_PREFIX_.'wishlist_product` SET `quantity`=`quantity` + - ( - SELECT `quantity` FROM `'._DB_PREFIX_.'wishlist_product_cart` - WHERE `id_wishlist_product`='.(int)($prodcustomer['id_wishlist_product']).' AND `id_cart`='.(int)($prodcustomer['id_cart']).' - ) - WHERE `id_wishlist_product`='.(int)($prodcustomer['id_wishlist_product']).' AND `id_wishlist`='.(int)($id_wishlist) - ); - Db::getInstance()->execute(' - DELETE FROM `'._DB_PREFIX_.'wishlist_product_cart` - WHERE `id_wishlist_product`='.(int)($prodcustomer['id_wishlist_product']).' AND `id_cart`='.(int)($prodcustomer['id_cart']) - ); - } - } - - /** - * Get Wishlist products by Customer ID - * - * @return array Results - */ - public static function getProductByIdCustomer($id_wishlist, $id_customer, $id_lang, $id_product = null, $quantity = false) - { - if (!Validate::isUnsignedId($id_customer) OR - !Validate::isUnsignedId($id_lang) OR - !Validate::isUnsignedId($id_wishlist)) - die (Tools::displayError()); - $products = Db::getInstance()->executeS(' - SELECT wp.`id_product`, wp.`quantity`, p.`quantity` AS product_quantity, pl.`name`, wp.`id_product_attribute`, wp.`priority`, pl.link_rewrite, cl.link_rewrite AS category_rewrite - FROM `'._DB_PREFIX_.'wishlist_product` wp - LEFT JOIN `'._DB_PREFIX_.'product` p ON p.`id_product` = wp.`id_product` - '.Shop::addSqlAssociation('product', 'p').' - LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON pl.`id_product` = wp.`id_product`'.Shop::addSqlRestrictionOnLang('pl').' - LEFT JOIN `'._DB_PREFIX_.'wishlist` w ON w.`id_wishlist` = wp.`id_wishlist` - LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON cl.`id_category` = product_shop.`id_category_default` AND cl.id_lang='.(int)$id_lang.Shop::addSqlRestrictionOnLang('cl').' - WHERE w.`id_customer` = '.(int)($id_customer).' - AND pl.`id_lang` = '.(int)($id_lang).' - AND wp.`id_wishlist` = '.(int)($id_wishlist). - (empty($id_product) === false ? ' AND wp.`id_product` = '.(int)($id_product) : ''). - ($quantity == true ? ' AND wp.`quantity` != 0': '').' - GROUP BY p.id_product, wp.id_product_attribute'); - if (empty($products) === true OR !sizeof($products)) - return array(); - for ($i = 0; $i < sizeof($products); ++$i) - { - if (isset($products[$i]['id_product_attribute']) AND - Validate::isUnsignedInt($products[$i]['id_product_attribute'])) - { - $result = Db::getInstance()->executeS(' - SELECT al.`name` AS attribute_name, pa.`quantity` AS "attribute_quantity" - FROM `'._DB_PREFIX_.'product_attribute_combination` pac - LEFT JOIN `'._DB_PREFIX_.'attribute` a ON (a.`id_attribute` = pac.`id_attribute`) - LEFT JOIN `'._DB_PREFIX_.'attribute_group` ag ON (ag.`id_attribute_group` = a.`id_attribute_group`) - LEFT JOIN `'._DB_PREFIX_.'attribute_lang` al ON (a.`id_attribute` = al.`id_attribute` AND al.`id_lang` = '.(int)($id_lang).') - LEFT JOIN `'._DB_PREFIX_.'attribute_group_lang` agl ON (ag.`id_attribute_group` = agl.`id_attribute_group` AND agl.`id_lang` = '.(int)($id_lang).') - LEFT JOIN `'._DB_PREFIX_.'product_attribute` pa ON (pac.`id_product_attribute` = pa.`id_product_attribute`) - '.Shop::addSqlAssociation('product_attribute', 'pa').' - WHERE pac.`id_product_attribute` = '.(int)($products[$i]['id_product_attribute'])); - $products[$i]['attributes_small'] = ''; - if ($result) - foreach ($result AS $k => $row) - $products[$i]['attributes_small'] .= $row['attribute_name'].', '; - $products[$i]['attributes_small'] = rtrim($products[$i]['attributes_small'], ', '); - if (isset($result[0])) - $products[$i]['attribute_quantity'] = $result[0]['attribute_quantity']; - } - else - $products[$i]['attribute_quantity'] = $products[$i]['product_quantity']; - } - return ($products); - } - - /** - * Get Wishlists number products by Customer ID - * - * @return array Results - */ - public static function getInfosByIdCustomer($id_customer) - { - if (Shop::getContextShopID()) - $shop_restriction = 'AND id_shop = '.(int)Shop::getContextShopID(); - elseif (Shop::getContextShopGroupID()) - $shop_restriction = 'AND id_shop_group = '.(int)Shop::getContextShopGroupID(); - else - $shop_restriction = ''; - - if (!Validate::isUnsignedId($id_customer)) - die (Tools::displayError()); - return (Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS(' - SELECT SUM(wp.`quantity`) AS nbProducts, wp.`id_wishlist` - FROM `'._DB_PREFIX_.'wishlist_product` wp - INNER JOIN `'._DB_PREFIX_.'wishlist` w ON (w.`id_wishlist` = wp.`id_wishlist`) - WHERE w.`id_customer` = '.(int)($id_customer).' - '.$shop_restriction.' - GROUP BY w.`id_wishlist` - ORDER BY w.`name` ASC')); - } - - /** - * Add product to ID wishlist - * - * @return boolean succeed - */ - public static function addProduct($id_wishlist, $id_customer, $id_product, $id_product_attribute, $quantity) - { - if (!Validate::isUnsignedId($id_wishlist) OR - !Validate::isUnsignedId($id_customer) OR - !Validate::isUnsignedId($id_product) OR - !Validate::isUnsignedId($quantity)) - die (Tools::displayError()); - $result = Db::getInstance()->getRow(' - SELECT wp.`quantity` - FROM `'._DB_PREFIX_.'wishlist_product` wp - JOIN `'._DB_PREFIX_.'wishlist` w ON (w.`id_wishlist` = wp.`id_wishlist`) - WHERE wp.`id_wishlist` = '.(int)($id_wishlist).' - AND w.`id_customer` = '.(int)($id_customer).' - AND wp.`id_product` = '.(int)($id_product).' - AND wp.`id_product_attribute` = '.(int)($id_product_attribute)); - if (empty($result) === false AND sizeof($result)) - { - if (($result['quantity'] + $quantity) <= 0) - return (WishList::removeProduct($id_wishlist, $id_customer, $id_product, $id_product_attribute)); - else - return (Db::getInstance()->execute(' - UPDATE `'._DB_PREFIX_.'wishlist_product` SET - `quantity` = '.(int)($quantity + $result['quantity']).' - WHERE `id_wishlist` = '.(int)($id_wishlist).' - AND `id_product` = '.(int)($id_product).' - AND `id_product_attribute` = '.(int)($id_product_attribute))); - } - else - return (Db::getInstance()->execute(' - INSERT INTO `'._DB_PREFIX_.'wishlist_product` (`id_wishlist`, `id_product`, `id_product_attribute`, `quantity`, `priority`) VALUES( - '.(int)($id_wishlist).', - '.(int)($id_product).', - '.(int)($id_product_attribute).', - '.(int)($quantity).', 1)')); - - } - - /** - * Update product to wishlist - * - * @return boolean succeed - */ - public static function updateProduct($id_wishlist, $id_product, $id_product_attribute, $priority, $quantity) - { - if (!Validate::isUnsignedId($id_wishlist) OR - !Validate::isUnsignedId($id_product) OR - !Validate::isUnsignedId($quantity) OR - $priority < 0 OR $priority > 2) - die (Tools::displayError()); - return (Db::getInstance()->execute(' - UPDATE `'._DB_PREFIX_.'wishlist_product` SET - `priority` = '.(int)($priority).', - `quantity` = '.(int)($quantity).' - WHERE `id_wishlist` = '.(int)($id_wishlist).' - AND `id_product` = '.(int)($id_product).' - AND `id_product_attribute` = '.(int)($id_product_attribute))); - } - - /** - * Remove product from wishlist - * - * @return boolean succeed - */ - public static function removeProduct($id_wishlist, $id_customer, $id_product, $id_product_attribute) - { - if (!Validate::isUnsignedId($id_wishlist) OR - !Validate::isUnsignedId($id_customer) OR - !Validate::isUnsignedId($id_product)) - die (Tools::displayError()); - $result = Db::getInstance()->getRow(' - SELECT w.`id_wishlist`, wp.`id_wishlist_product` - FROM `'._DB_PREFIX_.'wishlist` w - LEFT JOIN `'._DB_PREFIX_.'wishlist_product` wp ON (wp.`id_wishlist` = w.`id_wishlist`) - WHERE `id_customer` = '.(int)($id_customer).' - AND w.`id_wishlist` = '.(int)($id_wishlist)); - if (empty($result) === true OR - $result === false OR - !sizeof($result) OR - $result['id_wishlist'] != $id_wishlist) - return (false); - // Delete product in wishlist_product_cart - Db::getInstance()->execute(' - DELETE FROM `'._DB_PREFIX_.'wishlist_product_cart` - WHERE `id_wishlist_product` = '.(int)($result['id_wishlist_product']) - ); - return Db::getInstance()->execute(' - DELETE FROM `'._DB_PREFIX_.'wishlist_product` - WHERE `id_wishlist` = '.(int)($id_wishlist).' - AND `id_product` = '.(int)($id_product).' - AND `id_product_attribute` = '.(int)($id_product_attribute) - ); - } - - /** - * Return bought product by ID wishlist - * - * @return Array results - */ - public static function getBoughtProduct($id_wishlist) - { - - if (!Validate::isUnsignedId($id_wishlist)) - die (Tools::displayError()); - return (Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS(' - SELECT wp.`id_product`, wp.`id_product_attribute`, wpc.`quantity`, wpc.`date_add`, cu.`lastname`, cu.`firstname` - FROM `'._DB_PREFIX_.'wishlist_product_cart` wpc - JOIN `'._DB_PREFIX_.'wishlist_product` wp ON (wp.id_wishlist_product = wpc.id_wishlist_product) - JOIN `'._DB_PREFIX_.'cart` ca ON (ca.id_cart = wpc.id_cart) - JOIN `'._DB_PREFIX_.'customer` cu ON (cu.`id_customer` = ca.`id_customer`) - WHERE wp.`id_wishlist` = '.(int)($id_wishlist))); - } - - /** - * Add bought product - * - * @return boolean succeed - */ - public static function addBoughtProduct($id_wishlist, $id_product, $id_product_attribute, $id_cart, $quantity) - { - if (!Validate::isUnsignedId($id_wishlist) OR - !Validate::isUnsignedId($id_product) OR - !Validate::isUnsignedId($quantity)) - die (Tools::displayError()); - $result = Db::getInstance()->getRow(' - SELECT `quantity`, `id_wishlist_product` - FROM `'._DB_PREFIX_.'wishlist_product` wp - WHERE `id_wishlist` = '.(int)($id_wishlist).' - AND `id_product` = '.(int)($id_product).' - AND `id_product_attribute` = '.(int)($id_product_attribute)); - - if (!sizeof($result) OR - ($result['quantity'] - $quantity) < 0 OR - $quantity > $result['quantity']) - return (false); - - Db::getInstance()->executeS(' - SELECT * - FROM `'._DB_PREFIX_.'wishlist_product_cart` - WHERE `id_wishlist_product`='.(int)($result['id_wishlist_product']).' AND `id_cart`='.(int)($id_cart) - ); - - if (Db::getInstance()->NumRows() > 0) - $result2= Db::getInstance()->execute(' - UPDATE `'._DB_PREFIX_.'wishlist_product_cart` - SET `quantity`=`quantity` + '.(int)($quantity).' - WHERE `id_wishlist_product`='.(int)($result['id_wishlist_product']).' AND `id_cart`='.(int)($id_cart) - ); - - else - $result2 = Db::getInstance()->execute(' - INSERT INTO `'._DB_PREFIX_.'wishlist_product_cart` - (`id_wishlist_product`, `id_cart`, `quantity`, `date_add`) VALUES( - '.(int)($result['id_wishlist_product']).', - '.(int)($id_cart).', - '.(int)($quantity).', - \''.pSQL(date('Y-m-d H:i:s')).'\')'); - - if ($result2 === false) - return (false); - return (Db::getInstance()->execute(' - UPDATE `'._DB_PREFIX_.'wishlist_product` SET - `quantity` = '.(int)($result['quantity'] - $quantity).' - WHERE `id_wishlist` = '.(int)($id_wishlist).' - AND `id_product` = '.(int)($id_product).' - AND `id_product_attribute` = '.(int)($id_product_attribute))); - } - - /** - * Add email to wishlist - * - * @return boolean succeed - */ - public static function addEmail($id_wishlist, $email) - { - if (!Validate::isUnsignedId($id_wishlist) OR empty($email) OR !Validate::isEmail($email)) - return false; - return (Db::getInstance()->execute(' - INSERT INTO `'._DB_PREFIX_.'wishlist_email` (`id_wishlist`, `email`, `date_add`) VALUES( - '.(int)($id_wishlist).', - \''.pSQL($email).'\', - \''.pSQL(date('Y-m-d H:i:s')).'\')')); - } - - /** - * Get email from wishlist - * - * @return Array results - */ - public static function getEmail($id_wishlist, $id_customer) - { - if (!Validate::isUnsignedId($id_wishlist) OR - !Validate::isUnsignedId($id_customer)) - die (Tools::displayError()); - return (Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS(' - SELECT we.`email`, we.`date_add` - FROM `'._DB_PREFIX_.'wishlist_email` we - INNER JOIN `'._DB_PREFIX_.'wishlist` w ON w.`id_wishlist` = we.`id_wishlist` - WHERE we.`id_wishlist` = '.(int)($id_wishlist).' - AND w.`id_customer` = '.(int)($id_customer))); - } -}; diff --git a/modules/blockwishlist/blockwishlist-ajax.tpl b/modules/blockwishlist/blockwishlist-ajax.tpl deleted file mode 100644 index a3f2d5f3a..000000000 --- a/modules/blockwishlist/blockwishlist-ajax.tpl +++ /dev/null @@ -1,49 +0,0 @@ -{* -* 2007-2013 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 -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*} - -{if $products} -
- {foreach from=$products item=product name=i} -
- {$product.quantity|intval}x - {$product.name|truncate:13:'...'|escape:'html':'UTF-8'} - {l s='Delete'} -
- {if isset($product.attributes_small)} -
- {$product.attributes_small|escape:'html':'UTF-8'} -
- {/if} - {/foreach} -
-{else} -
- {if isset($error) && $error} -
{l s='You must create a wishlist before adding products' mod='blockwishlist'}
- {else} -
{l s='No products' mod='blockwishlist'}
- {/if} -
-{/if} diff --git a/modules/blockwishlist/blockwishlist-extra.tpl b/modules/blockwishlist/blockwishlist-extra.tpl deleted file mode 100644 index b1a77c38f..000000000 --- a/modules/blockwishlist/blockwishlist-extra.tpl +++ /dev/null @@ -1,28 +0,0 @@ -{* -* 2007-2013 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 -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*} - -

- » {l s='Add to my wishlist' mod='blockwishlist'} -

diff --git a/modules/blockwishlist/blockwishlist.css b/modules/blockwishlist/blockwishlist.css deleted file mode 100644 index 8f0c50613..000000000 --- a/modules/blockwishlist/blockwishlist.css +++ /dev/null @@ -1,248 +0,0 @@ -/* module blockwishlist */ - -/* lnk on detail product page */ -#wishlist_button { - padding:2px 0 2px 20px; - background:url(img/icon/add.png) no-repeat 0 0 transparent -} - - -/* bt add */ -.add_wishlist_button a {padding:5px 7px 5px 18px} -.add_wishlist_button a span { - z-index:10; - display:block; - position:absolute; - top:-1px; - left:-12px; - height:26px; - width:26px; - background:url(img/icon/pict_add_wishlist.png) no-repeat 0 0 transparent -} - -/* bloc */ -#wishlist_block #wishlist_block_list { - margin:5px 0 10px 0; - padding-bottom:10px; - border-bottom:1px dotted #ccc -} -#wishlist_block_list dt { - position:relative; - margin-top:5px; - padding-right:20px -} - -#wishlist_block_list .quantity-formated { - display:inline-block; - margin-right:5px; - width:15px -} -#wishlist_block_list .cart_block_product_name {font-weight:bold} -#wishlist_block_list .ajax_cart_block_remove_link { - display:inline-block; - position:absolute; - right:0; - top:0; - margin:1px 0 0 5px; - height:12px; - width:12px -} -#wishlist_block_list dd {margin:0 0 0 24px} - - -#wishlist_block_list .ajax_cart_block_remove_link a { - display:inline-block; - height:12px; - width:12px; - background: url(img/icon/delete.gif) no-repeat 0 0 -} -#wishlist_block_list .price { - float:right -} - -#wishlist_block select#wishlists { - margin-bottom:10px; - width:99%; - border:1px solid #ccc; -} -#wishlist_block .lnk {padding:0} -#wishlist_block .lnk a { - display:block; - font-weight:bold; - text-align:right -} - -/* page in my account ************************************************************************* */ -#module-blockwishlist-mywishlist #left_column {display:none} -#module-blockwishlist-mywishlist #center_column{width:757px} - -#module-blockwishlist-mywishlist #mywishlist fieldset { - padding:10px; - -moz-border-radius:3px; - -webkit-border-radius:3px; - border-radius:3px; - background:#eee -} -#module-blockwishlist-mywishlist #mywishlist p.text label { - display:inline-block; - padding-right:10px; - width:174px; - font-weight:bold; - font-size:12px; - text-align:right -} -#module-blockwishlist-mywishlist #mywishlist p.text input { - padding:0 5px; - height:20px; - width:288px; - border:1px solid #ccc; -} -#module-blockwishlist-mywishlist #mywishlist p.submit { - margin-right:25px; - padding-bottom:5px; - text-align:right -} - -#mywishlist td.wishlist_delete { - text-align:center; - border-right: 1px solid #999 -} -#mywishlist td.wishlist_delete a { - display:inline-block; - font-size:8px; - padding:1px 2px; - -moz-border-radius:3px; - -webkit-border-radius:3px; - border-radius:3px; - color:#666; - text-shadow:0 1px 0 #fff; - text-transform:uppercase; - background: none repeat scroll 0 0 #ccc; -} - - -/* form add ****************************************** */ -#form_wishlist {} -#form_wishlist fieldset { padding: 20px } -#form_wishlist label { - display:inline-block; - padding:6px 15px; - width:150px; - font-size:12px; - text-align:right; -} -#form_wishlist input.inputTxt { - padding:0 5px; - height:26px; - width:260px; - font-size:12px; - color:#666; - border:1px solid #ccc; -} - -/* block-order-detail ********************************** */ -#module-blockwishlist-mywishlist #block-order-detail {margin-top:20px} - -/* wishlistLinkTop */ -#module-blockwishlist-mywishlist #block-order-detail #hideSendWishlist { - display:inline-block; - height:12px; - width:12px; - background: url(img/icon/delete.gif) no-repeat 0 0 -} - -#module-blockwishlist-mywishlist .wishlistLinkTop {} -#module-blockwishlist-mywishlist .wishlistLinkTop ul { - list-style-type:none; - border-bottom:1px dotted #ccc -} - #module-blockwishlist-mywishlist .wishlistLinkTop ul.wlp_bought_list {border:none;} -#module-blockwishlist-mywishlist .wishlistLinkTop li {float:left} -#module-blockwishlist-mywishlist .wishlistLinkTop .display_list li a { - display:inline-block; - padding:7px 11px 5px 22px; - color: #333; - background:url(img/arrow_right_2.png) no-repeat 10px 10px transparent -} - -#module-blockwishlist-mywishlist .wishlistLinkTop #hideSendWishlist { - float:right; - display:block; - height:12px; - width:12px; - text-indent:-5000px; - background: url(img/icon/delete.gif) no-repeat 0 0 -} -#module-blockwishlist-mywishlist .wishlistLinkTop #showBoughtProducts, -#module-blockwishlist-mywishlist .wishlistLinkTop #hideBoughtProductsInfos {display:none} - -/* wishlisturl */ -#module-blockwishlist-mywishlist .wishlisturl { - margin:20px 0; - padding:10px; - background:#eee -} -#module-blockwishlist-mywishlist .wishlisturl input { - padding:2px 5px; - border:1px solid #ccc -} - - -/* wlp_bought ****************************************** */ - -/* wlp_bought_list */ -ul.wlp_bought_list { - list-style-type:none; - margin-bottom:20px -} -ul.wlp_bought_list li { - position:relative; - float:left; - margin:20px 20px 0 0; - padding:5px; - width:218px;/* 230 */ - border:1px solid #d1d1d1; - -moz-border-radius:3px; - -webkit-border-radius:3px; - border-radius:3px; -} -ul.wlp_bought_list li .product_image { - float:left; - width:82px -} -ul.wlp_bought_list li .product_image a { - display:block; - padding:0; - border:1px solid #d1d1d1 -} - -ul.wlp_bought_list li .product_infos { - float:left; - margin-left:10px; - width:126px -} -ul.wlp_bought_list li .product_infos .s_title_block.product_name { - padding:5px 0; - font-size:12px; - color:#222 -} -ul.wlp_bought_list li .product_infos .wishlist_product_detail input, -ul.wlp_bought_list li .product_infos .wishlist_product_detail select { - border:1px solid #d1d1d1 -} - -ul.wlp_bought_list li .btn_action { - clear:both; - margin-top:10px -} -ul.wlp_bought_list li .btn_action .lnksave {float:right} -ul.wlp_bought_list li .lnkdel { - position:absolute; - top:5px; - right:5px; - display:block; - height:12px; - width:12px; - text-indent:-5000px; - background: url(img/icon/delete.gif) no-repeat 0 0 -} diff --git a/modules/blockwishlist/blockwishlist.php b/modules/blockwishlist/blockwishlist.php deleted file mode 100644 index 074e72b61..000000000 --- a/modules/blockwishlist/blockwishlist.php +++ /dev/null @@ -1,455 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -if (!defined('_PS_VERSION_')) - exit; - -class BlockWishList extends Module -{ - const INSTALL_SQL_FILE = 'install.sql'; - - private $_html = ''; - private $_postErrors = array(); - - public function __construct() - { - $this->name = 'blockwishlist'; - $this->tab = 'front_office_features'; - $this->version = 0.4; - $this->author = 'PrestaShop'; - $this->need_instance = 0; - - $this->bootstrap = true; - parent::__construct(); - - $this->displayName = $this->l('Wishlist block'); - $this->description = $this->l('Adds a block containing the customer\'s wishlists.'); - $this->default_wishlist_name = $this->l('My wishlist'); - } - - public function install() - { - if (!file_exists(dirname(__FILE__).'/'.self::INSTALL_SQL_FILE)) - return (false); - else if (!$sql = file_get_contents(dirname(__FILE__).'/'.self::INSTALL_SQL_FILE)) - return (false); - $sql = str_replace(array('PREFIX_', 'ENGINE_TYPE'), array(_DB_PREFIX_, _MYSQL_ENGINE_), $sql); - $sql = preg_split("/;\s*[\r\n]+/", $sql); - foreach ($sql AS $query) - if($query) - if(!Db::getInstance()->execute(trim($query))) - return false; - if (!parent::install() || - !$this->registerHook('rightColumn') || - !$this->registerHook('productActions') || - !$this->registerHook('cart') || - !$this->registerHook('customerAccount') || - !$this->registerHook('header') || - !$this->registerHook('adminCustomers') || - !$this->registerHook('displayProductListFunctionalButtons') || - !$this->registerHook('top') - ) - return false; - /* This hook is optional */ - $this->registerHook('displayMyAccountBlock'); - return true; - } - - public function uninstall() - { - return ( - Db::getInstance()->execute('DROP TABLE '._DB_PREFIX_.'wishlist') && - Db::getInstance()->execute('DROP TABLE '._DB_PREFIX_.'wishlist_email') && - Db::getInstance()->execute('DROP TABLE '._DB_PREFIX_.'wishlist_product') && - Db::getInstance()->execute('DROP TABLE '._DB_PREFIX_.'wishlist_product_cart') && - parent::uninstall() - ); - } - - public function getContent() - { - $this->_html = '

'.$this->displayName.'

'; - if (Tools::isSubmit('submitSettings')) - { - $activated = Tools::getValue('activated'); - if ($activated != 0 AND $activated != 1) - $this->_html .= '
'.$this->l('Activate module : Invalid choice.').'
'; - $this->_html .= '
'.$this->l('Settings updated').'
'; - } - - $this->_html .= $this->renderJS(); - $this->_html .= $this->renderForm(); - if (Tools::getValue('id_customer') && Tools::getValue('id_wishlist')) - $this->_html .= $this->renderList((int)Tools::getValue('id_wishlist')); - - - return $this->_html; - } - - public function hookDisplayProductListFunctionalButtons($params) - { - //TODO : Add cache - $this->smarty->assign('product', $params['product']); - return $this->display(__FILE__, 'blockwishlist_button.tpl'); - } - - public function hookTop($params) - { - - global $errors; - - require_once(dirname(__FILE__).'/WishList.php'); - if ($this->context->customer->isLogged()) - { - $wishlists = Wishlist::getByIdCustomer($this->context->customer->id); - if (empty($this->context->cookie->id_wishlist) === true || - WishList::exists($this->context->cookie->id_wishlist, $this->context->customer->id) === false) - { - if (!sizeof($wishlists)) - $id_wishlist = false; - else - { - $id_wishlist = (int)($wishlists[0]['id_wishlist']); - $this->context->cookie->id_wishlist = (int)($id_wishlist); - } - } - else - $id_wishlist = $this->context->cookie->id_wishlist; - - - $this->smarty->assign(array( - 'id_wishlist' => $id_wishlist, - 'isLogged' => true, - 'wishlist_products' => ($id_wishlist == false ? false : WishList::getProductByIdCustomer($id_wishlist, $this->context->customer->id, $this->context->language->id, null, true)), - 'wishlists' => $wishlists, - 'ptoken' => Tools::getToken(false))); - } - else - $this->smarty->assign(array('wishlist_products' => false, 'wishlists' => false)); - - return $this->display(__FILE__, 'blockwishlist_top.tpl'); - } - - public function hookHeader($params) - { - $this->context->controller->addCSS(($this->_path).'blockwishlist.css', 'all'); - $this->context->controller->addJS(($this->_path).'js/ajax-wishlist.js'); - - $this->smarty->assign(array('wishlist_link' => $this->context->link->getModuleLink('blockwishlist', 'mywishlist'))); - } - - public function hookRightColumn($params) - { - global $errors; - - require_once(dirname(__FILE__).'/WishList.php'); - if ($this->context->customer->isLogged()) - { - $wishlists = Wishlist::getByIdCustomer($this->context->customer->id); - if (empty($this->context->cookie->id_wishlist) === true || - WishList::exists($this->context->cookie->id_wishlist, $this->context->customer->id) === false) - { - if (!sizeof($wishlists)) - $id_wishlist = false; - else - { - $id_wishlist = (int)($wishlists[0]['id_wishlist']); - $this->context->cookie->id_wishlist = (int)($id_wishlist); - } - } - else - $id_wishlist = $this->context->cookie->id_wishlist; - $this->smarty->assign(array( - 'id_wishlist' => $id_wishlist, - 'isLogged' => true, - 'wishlist_products' => ($id_wishlist == false ? false : WishList::getProductByIdCustomer($id_wishlist, $this->context->customer->id, $this->context->language->id, null, true)), - 'wishlists' => $wishlists, - 'ptoken' => Tools::getToken(false))); - } - else - $this->smarty->assign(array('wishlist_products' => false, 'wishlists' => false)); - - return ($this->display(__FILE__, 'blockwishlist.tpl')); - } - - public function hookLeftColumn($params) - { - return $this->hookRightColumn($params); - } - - public function hookProductActions($params) - { - $this->smarty->assign('id_product', (int)(Tools::getValue('id_product'))); - return ($this->display(__FILE__, 'blockwishlist-extra.tpl')); - } - - public function hookCustomerAccount($params) - { - return $this->display(__FILE__, 'my-account.tpl'); - } - - public function hookDisplayMyAccountBlock($params) - { - return $this->hookCustomerAccount($params); - } - - private function _displayProducts($id_wishlist) - { - include_once(dirname(__FILE__).'/WishList.php'); - - $wishlist = new WishList($id_wishlist); - $products = WishList::getProductByIdCustomer($id_wishlist, $wishlist->id_customer, $this->context->language->id); - for ($i = 0; $i < sizeof($products); ++$i) - { - $obj = new Product((int)($products[$i]['id_product']), false, $this->context->language->id); - if (!Validate::isLoadedObject($obj)) - continue; - else - { - $images = $obj->getImages($this->context->language->id); - foreach ($images AS $k => $image) - { - if ($image['cover']) - { - $products[$i]['cover'] = $obj->id.'-'.$image['id_image']; - break; - } - } - if (!isset($products[$i]['cover'])) - $products[$i]['cover'] = $this->context->language->iso_code.'-default'; - } - } - $this->_html .= ' - - - - - - - - - '; - $priority = array($this->l('High'), $this->l('Medium'), $this->l('Low')); - foreach ($products as $product) - { - $this->_html .= ' - - - - - '; - } - $this->_html .= '
'.$this->l('Product').''.$this->l('Quantity').''.$this->l('Priority').'
- '.htmlentities($product['name'], ENT_COMPAT, 'UTF-8').' - '.$product['name']; - if (isset($product['attributes_small'])) - $this->_html .= '
'.htmlentities($product['attributes_small'], ENT_COMPAT, 'UTF-8').''; - $this->_html .= ' -
'.(int)($product['quantity']).''.$priority[(int)($product['priority']) % 3].'
'; - } - - public function hookAdminCustomers($params) - { - require_once(dirname(__FILE__).'/WishList.php'); - - $customer = new Customer((int)($params['id_customer'])); - if (!Validate::isLoadedObject($customer)) - die (Tools::displayError()); - - $this->_html = '

'.$this->l('Wishlists').'

'; - - $wishlists = WishList::getByIdCustomer((int)($customer->id)); - if (!sizeof($wishlists)) - $this->_html .= $customer->lastname.' '.$customer->firstname.' '.$this->l('No wishlist.'); - else - { - $this->_html .= '
'; - - $id_wishlist = (int)(Tools::getValue('id_wishlist')); - if (!$id_wishlist) - $id_wishlist = $wishlists[0]['id_wishlist']; - - $this->_html .= ''.$this->l('Wishlist').': '; - - $this->_displayProducts((int)($id_wishlist)); - - $this->_html .= '

'; - - return $this->_html; - } - } - /* - * Display Error from controler - */ - public function errorLogged() - { - return $this->l('You must be logged in to manage your wishlists.'); - } - - public function renderJS() - { - return ""; - } - - public function renderForm() - { - $customers = Customer::getCustomers(); - foreach ($customers as $key => $val) - $customers[$key]['name'] = $val['firstname'].' '.$val['lastname']; - - $fields_form = array( - 'form' => array( - 'legend' => array( - 'title' => $this->l('Listing'), - 'icon' => 'icon-cogs' - ), - 'input' => array( - array( - 'type' => 'select', - 'label' => $this->l('Customers :'), - 'name' => 'id_customer', - 'options' => array( - 'default' => array('value' => 0, 'label' => $this->l('Choose customer')), - 'query' => $customers, - 'id' => 'id_customer', - 'name' => 'name' - ), - ) - ), - ), - ); - - if ($id_customer = Tools::getValue('id_customer')) - { - require_once(dirname(__FILE__).'/WishList.php'); - $wishlists = WishList::getByIdCustomer($id_customer); - $fields_form['form']['input'][] = array( - 'type' => 'select', - 'label' => $this->l('Wishlist :'), - 'name' => 'id_wishlist', - 'options' => array( - 'default' => array('value' => 0, 'label' => $this->l('Choose wishlist')), - 'query' => $wishlists, - 'id' => 'id_wishlist', - 'name' => 'name' - ), - ); - } - - $helper = new HelperForm(); - $helper->show_toolbar = false; - $helper->table = $this->table; - $lang = new Language((int)Configuration::get('PS_LANG_DEFAULT')); - $helper->default_form_language = $lang->id; - $helper->allow_employee_form_lang = Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG') ? Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG') : 0; - $this->fields_form = array(); - - $helper->identifier = $this->identifier; - $helper->submit_action = 'submitModule'; - $helper->currentIndex = $this->context->link->getAdminLink('AdminModules', false).'&configure='.$this->name.'&tab_module='.$this->tab.'&module_name='.$this->name; - $helper->token = Tools::getAdminTokenLite('AdminModules'); - $helper->tpl_vars = array( - 'fields_value' => $this->getConfigFieldsValues(), - 'languages' => $this->context->controller->getLanguages(), - 'id_language' => $this->context->language->id - ); - - return $helper->generateForm(array($fields_form)); - } - - public function getConfigFieldsValues() - { - return array( - 'id_customer' => Tools::getValue('id_customer'), - 'id_wishlist' => Tools::getValue('id_wishlist'), - ); - } - - public function renderList($id_wishlist) - { - $wishlist = new WishList($id_wishlist); - $products = WishList::getProductByIdCustomer($id_wishlist, $wishlist->id_customer, $this->context->language->id); - - foreach ($products as $key => $val) - { - $image = Image::getCover($val['id_product']); - $products[$key]['image'] = $this->context->link->getImageLink($val['link_rewrite'], $image['id_image'], ImageType::getFormatedName('small')); - } - - $fields_list = array( - 'image' => array( - 'title' => $this->l('Image'), - 'type' => 'image', - ), - 'name' => array( - 'title' => $this->l('Product'), - 'type' => 'text', - ), - 'attributes_small' => array( - 'title' => $this->l('Combination'), - 'type' => 'text', - ), - 'quantity' => array( - 'title' => $this->l('Quantity'), - 'type' => 'text', - ), - 'priority' => array( - 'title' => $this->l('Priority'), - 'type' => 'priority', - 'values' => array($this->l('High'), $this->l('Medium'), $this->l('Low')), - ) - ); - - - $helper = new HelperList(); - $helper->shopLinkType = ''; - $helper->simple_header = true; - $helper->actions = array(); - $helper->show_toolbar = false; - $helper->module = $this; - $helper->identifier = 'image'; - $helper->title = $this->l('Product list'); - $helper->table = $this->name; - $helper->token = Tools::getAdminTokenLite('AdminModules'); - $helper->currentIndex = AdminController::$currentIndex.'&configure='.$this->name; - $helper->tpl_vars = array('priority' => array($this->l('High'), $this->l('Medium'), $this->l('Low'))); - - return $helper->generateList($products, $fields_list); - } -} \ No newline at end of file diff --git a/modules/blockwishlist/blockwishlist.tpl b/modules/blockwishlist/blockwishlist.tpl deleted file mode 100644 index dd68e8412..000000000 --- a/modules/blockwishlist/blockwishlist.tpl +++ /dev/null @@ -1,65 +0,0 @@ -{* -* 2007-2013 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 -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*} - - diff --git a/modules/blockwishlist/blockwishlist_button.tpl b/modules/blockwishlist/blockwishlist_button.tpl deleted file mode 100644 index c339a9b59..000000000 --- a/modules/blockwishlist/blockwishlist_button.tpl +++ /dev/null @@ -1,28 +0,0 @@ -{* -* 2007-2013 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 -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*} - - \ No newline at end of file diff --git a/modules/blockwishlist/blockwishlist_top.tpl b/modules/blockwishlist/blockwishlist_top.tpl deleted file mode 100644 index a7e5a6463..000000000 --- a/modules/blockwishlist/blockwishlist_top.tpl +++ /dev/null @@ -1,28 +0,0 @@ -{* -* 2007-2013 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 -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*} - - \ No newline at end of file diff --git a/modules/blockwishlist/buywishlistproduct.php b/modules/blockwishlist/buywishlistproduct.php deleted file mode 100644 index 68d1111fb..000000000 --- a/modules/blockwishlist/buywishlistproduct.php +++ /dev/null @@ -1,56 +0,0 @@ - -* @copyright 2007-2013 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'); -require_once(dirname(__FILE__).'/WishList.php'); - - -$error = ''; - -// Instance of module class for translations -$module = new BlockWishList(); - -$token = Tools::getValue('token'); -$id_product = (int)Tools::getValue('id_product'); -$id_product_attribute = (int)Tools::getValue('id_product_attribute'); -if (Configuration::get('PS_TOKEN_ENABLE') == 1 && strcmp(Tools::getToken(false), Tools::getValue('static_token'))) - $error = $module->l('Invalid token', 'buywishlistproduct'); - -if (!strlen($error) && - empty($token) === false && - empty($id_product) === false) -{ - $wishlist = WishList::getByToken($token); - if ($wishlist !== false) - WishList::addBoughtProduct($wishlist['id_wishlist'], $id_product, $id_product_attribute, $cart->id, 1); -} -else - $error = $module->l('You must log in', 'buywishlistproduct'); - -if (empty($error) === false) - echo $error; - diff --git a/modules/blockwishlist/cart.php b/modules/blockwishlist/cart.php deleted file mode 100644 index 6ab2311ca..000000000 --- a/modules/blockwishlist/cart.php +++ /dev/null @@ -1,86 +0,0 @@ - -* @copyright 2007-2013 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'); -require_once(dirname(__FILE__).'/WishList.php'); -require_once(dirname(__FILE__).'/blockwishlist.php'); - -$context = Context::getContext(); -$action = Tools::getValue('action'); -$add = (!strcmp($action, 'add') ? 1 : 0); -$delete = (!strcmp($action, 'delete') ? 1 : 0); -$id_wishlist = (int)(Tools::getValue('id_wishlist')); -$id_product = (int)(Tools::getValue('id_product')); -$quantity = (int)(Tools::getValue('quantity')); -$id_product_attribute = (int)(Tools::getValue('id_product_attribute')); - -// Instance of module class for translations -$module = new BlockWishList(); - -if (Configuration::get('PS_TOKEN_ENABLE') == 1 AND - strcmp(Tools::getToken(false), Tools::getValue('token')) AND - $context->customer->isLogged() === true) - echo $module->l('Invalid token', 'cart'); -if ($context->customer->isLogged()) -{ - if ($id_wishlist AND WishList::exists($id_wishlist, $context->customer->id) === true) - $context->cookie->id_wishlist = (int)($id_wishlist); - if (empty($context->cookie->id_wishlist) === true OR $context->cookie->id_wishlist == false) - $context->smarty->assign('error', true); - if (($add OR $delete) AND empty($id_product) === false) - { - if(!isset($context->cookie->id_wishlist) OR $context->cookie->id_wishlist == '') - { - $wishlist = new WishList(); - $wishlist->id_shop = $context->shop->id; - $wishlist->id_shop_group = $context->shop->id_shop_group; - - $modWishlist = new BlockWishList(); - $wishlist->name = $modWishlist->default_wishlist_name; - $wishlist->id_customer = (int)($context->customer->id); - list($us, $s) = explode(' ', microtime()); - srand($s * $us); - $wishlist->token = strtoupper(substr(sha1(uniqid(rand(), true)._COOKIE_KEY_.$context->customer->id), 0, 16)); - $wishlist->add(); - $context->cookie->id_wishlist = (int)($wishlist->id); - } - if ($add AND $quantity) - WishList::addProduct($context->cookie->id_wishlist, $context->customer->id, $id_product, $id_product_attribute, $quantity); - else if ($delete) - WishList::removeProduct($context->cookie->id_wishlist, $context->customer->id, $id_product, $id_product_attribute); - } - $context->smarty->assign('products', WishList::getProductByIdCustomer($context->cookie->id_wishlist, $context->customer->id, $context->language->id, null, true)); - - if (Tools::file_exists_cache(_PS_THEME_DIR_.'modules/blockwishlist/blockwishlist-ajax.tpl')) - $context->smarty->display(_PS_THEME_DIR_.'modules/blockwishlist/blockwishlist-ajax.tpl'); - elseif (Tools::file_exists_cache(dirname(__FILE__).'/blockwishlist-ajax.tpl')) - $context->smarty->display(dirname(__FILE__).'/blockwishlist-ajax.tpl'); - else - echo $module->l('No template found', 'cart'); -} -else - echo $module->l('You must be logged in to manage your wishlist.', 'cart'); diff --git a/modules/blockwishlist/config.xml b/modules/blockwishlist/config.xml deleted file mode 100755 index 1bd0cf514..000000000 --- a/modules/blockwishlist/config.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - blockwishlist - - - - - - 1 - 0 - - \ No newline at end of file diff --git a/modules/blockwishlist/controllers/front/index.php b/modules/blockwishlist/controllers/front/index.php deleted file mode 100644 index 3f6561f72..000000000 --- a/modules/blockwishlist/controllers/front/index.php +++ /dev/null @@ -1,35 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); - -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); - -header("Location: ../"); -exit; \ No newline at end of file diff --git a/modules/blockwishlist/controllers/front/mywishlist.php b/modules/blockwishlist/controllers/front/mywishlist.php deleted file mode 100644 index cfa1b32d9..000000000 --- a/modules/blockwishlist/controllers/front/mywishlist.php +++ /dev/null @@ -1,129 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -/** - * @since 1.5.0 - */ -class BlockWishListMyWishListModuleFrontController extends ModuleFrontController -{ - public $ssl = true; - public $display_column_left = false; - - public function __construct() - { - parent::__construct(); - $this->context = Context::getContext(); - include_once($this->module->getLocalPath().'WishList.php'); - } - - /** - * @see FrontController::initContent() - */ - public function initContent() - { - parent::initContent(); - $this->assign(); - } - - /** - * Assign wishlist template - */ - public function assign() - { - $errors = array(); - - if ($this->context->customer->isLogged()) - { - $add = Tools::getIsset('add'); - $add = (empty($add) === false ? 1 : 0); - $delete = Tools::getIsset('deleted'); - $delete = (empty($delete) === false ? 1 : 0); - $id_wishlist = Tools::getValue('id_wishlist'); - if (Tools::isSubmit('submitWishlist')) - { - if (Configuration::get('PS_TOKEN_ACTIVATED') == 1 && strcmp(Tools::getToken(), Tools::getValue('token'))) - $errors[] = $this->module->l('Invalid token', 'mywishlist'); - if (!count($errors)) - { - $name = Tools::getValue('name'); - if (empty($name)) - $errors[] = $this->module->l('You must specify a name.', 'mywishlist'); - if (WishList::isExistsByNameForUser($name)) - $errors[] = $this->module->l('This name is already used by another list.', 'mywishlist'); - - if (!count($errors)) - { - $wishlist = new WishList(); - $wishlist->id_shop = $this->context->shop->id; - $wishlist->id_shop_group = $this->context->shop->id_shop_group; - $wishlist->name = $name; - $wishlist->id_customer = (int)$this->context->customer->id; - list($us, $s) = explode(' ', microtime()); - srand($s * $us); - $wishlist->token = strtoupper(substr(sha1(uniqid(rand(), true)._COOKIE_KEY_.$this->context->customer->id), 0, 16)); - $wishlist->add(); - Mail::Send( - $this->context->language->id, - 'wishlink', - Mail::l('Your wishlist\'s link', $this->context->language->id), - array( - '{wishlist}' => $wishlist->name, - '{message}' => Tools::getProtocol().htmlentities($_SERVER['HTTP_HOST'], ENT_COMPAT, 'UTF-8').__PS_BASE_URI__.'modules/blockwishlist/view.php?token='.$wishlist->token), - $this->context->customer->email, - $this->context->customer->firstname.' '.$this->context->customer->lastname, - null, - strval(Configuration::get('PS_SHOP_NAME')), - null, - null, - $this->module->getLocalPath().'mails/'); - } - } - } - else if ($add) - WishList::addCardToWishlist($this->context->customer->id, Tools::getValue('id_wishlist'), $this->context->language->id); - elseif ($delete && empty($id_wishlist) === false) - { - $wishlist = new WishList((int)($id_wishlist)); - if (Validate::isLoadedObject($wishlist)) - $wishlist->delete(); - else - $errors[] = $this->module->l('Cannot delete this wishlist', 'mywishlist'); - } - $this->context->smarty->assign('wishlists', WishList::getByIdCustomer($this->context->customer->id)); - $this->context->smarty->assign('nbProducts', WishList::getInfosByIdCustomer($this->context->customer->id)); - } - else - Tools::redirect('index.php?controller=authentication&back='.urlencode($this->context->link->getModuleLink('blockwishlist', 'mywishlist'))); - - $this->context->smarty->assign(array( - 'id_customer' => (int)$this->context->customer->id, - 'errors' => $errors, - 'form_link' => $errors, - )); - - $this->setTemplate('mywishlist.tpl'); - } -} diff --git a/modules/blockwishlist/controllers/index.php b/modules/blockwishlist/controllers/index.php deleted file mode 100644 index 3f6561f72..000000000 --- a/modules/blockwishlist/controllers/index.php +++ /dev/null @@ -1,35 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); - -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); - -header("Location: ../"); -exit; \ No newline at end of file diff --git a/modules/blockwishlist/img/arrow_right_2.png b/modules/blockwishlist/img/arrow_right_2.png deleted file mode 100644 index c970f18ef..000000000 Binary files a/modules/blockwishlist/img/arrow_right_2.png and /dev/null differ diff --git a/modules/blockwishlist/img/delete.gif b/modules/blockwishlist/img/delete.gif deleted file mode 100644 index 43c6ca876..000000000 Binary files a/modules/blockwishlist/img/delete.gif and /dev/null differ diff --git a/modules/blockwishlist/img/gift.gif b/modules/blockwishlist/img/gift.gif deleted file mode 100644 index d1908313f..000000000 Binary files a/modules/blockwishlist/img/gift.gif and /dev/null differ diff --git a/modules/blockwishlist/img/icon/add.png b/modules/blockwishlist/img/icon/add.png deleted file mode 100644 index 0e3147594..000000000 Binary files a/modules/blockwishlist/img/icon/add.png and /dev/null differ diff --git a/modules/blockwishlist/img/icon/delete.gif b/modules/blockwishlist/img/icon/delete.gif deleted file mode 100644 index 6d186d193..000000000 Binary files a/modules/blockwishlist/img/icon/delete.gif and /dev/null differ diff --git a/modules/blockwishlist/img/icon/delete.png b/modules/blockwishlist/img/icon/delete.png deleted file mode 100644 index 08f249365..000000000 Binary files a/modules/blockwishlist/img/icon/delete.png and /dev/null differ diff --git a/modules/blockwishlist/img/icon/index.php b/modules/blockwishlist/img/icon/index.php deleted file mode 100644 index 3f6561f72..000000000 --- a/modules/blockwishlist/img/icon/index.php +++ /dev/null @@ -1,35 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); - -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); - -header("Location: ../"); -exit; \ No newline at end of file diff --git a/modules/blockwishlist/img/icon/package.png b/modules/blockwishlist/img/icon/package.png deleted file mode 100644 index da3c2a2d7..000000000 Binary files a/modules/blockwishlist/img/icon/package.png and /dev/null differ diff --git a/modules/blockwishlist/img/icon/package_go.png b/modules/blockwishlist/img/icon/package_go.png deleted file mode 100644 index aace63ad6..000000000 Binary files a/modules/blockwishlist/img/icon/package_go.png and /dev/null differ diff --git a/modules/blockwishlist/img/index.php b/modules/blockwishlist/img/index.php deleted file mode 100644 index 3f6561f72..000000000 --- a/modules/blockwishlist/img/index.php +++ /dev/null @@ -1,35 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); - -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); - -header("Location: ../"); -exit; \ No newline at end of file diff --git a/modules/blockwishlist/img/star.gif b/modules/blockwishlist/img/star.gif deleted file mode 100644 index d0948a708..000000000 Binary files a/modules/blockwishlist/img/star.gif and /dev/null differ diff --git a/modules/blockwishlist/index.php b/modules/blockwishlist/index.php deleted file mode 100644 index a230e5ac6..000000000 --- a/modules/blockwishlist/index.php +++ /dev/null @@ -1,35 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); - -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); - -header("Location: ../"); -exit; \ No newline at end of file diff --git a/modules/blockwishlist/install.sql b/modules/blockwishlist/install.sql deleted file mode 100644 index fbcdc2e31..000000000 --- a/modules/blockwishlist/install.sql +++ /dev/null @@ -1,35 +0,0 @@ -CREATE TABLE IF NOT EXISTS `PREFIX_wishlist` ( - `id_wishlist` int(10) unsigned NOT NULL auto_increment, - `id_customer` int(10) unsigned NOT NULL, - `token` varchar(64) character set utf8 NOT NULL, - `name` varchar(64) character set utf8 NOT NULL, - `counter` int(10) unsigned NULL, - `id_shop` int(10) unsigned default 1, - `id_shop_group` int(10) unsigned default 1, - `date_add` datetime NOT NULL, - `date_upd` datetime NOT NULL, - PRIMARY KEY (`id_wishlist`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8; - -CREATE TABLE IF NOT EXISTS `PREFIX_wishlist_email` ( - `id_wishlist` int(10) unsigned NOT NULL, - `email` varchar(128) character set utf8 NOT NULL, - `date_add` datetime NOT NULL -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8; - -CREATE TABLE IF NOT EXISTS `PREFIX_wishlist_product` ( - `id_wishlist_product` int(10) NOT NULL auto_increment, - `id_wishlist` int(10) unsigned NOT NULL, - `id_product` int(10) unsigned NOT NULL, - `id_product_attribute` int(10) unsigned NOT NULL, - `quantity` int(10) unsigned NOT NULL, - `priority` int(10) unsigned NOT NULL, - PRIMARY KEY (`id_wishlist_product`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8; - -CREATE TABLE IF NOT EXISTS `PREFIX_wishlist_product_cart` ( - `id_wishlist_product` int(10) unsigned NOT NULL, - `id_cart` int(10) unsigned NOT NULL, - `quantity` int(10) unsigned NOT NULL, - `date_add` datetime NOT NULL -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8; diff --git a/modules/blockwishlist/js/ajax-wishlist.js b/modules/blockwishlist/js/ajax-wishlist.js deleted file mode 100644 index 8e748dd9a..000000000 --- a/modules/blockwishlist/js/ajax-wishlist.js +++ /dev/null @@ -1,253 +0,0 @@ -/* -* 2007-2013 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 -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -/** - * Update WishList Cart by adding, deleting, updating objects - * - * @return void - */ -function WishlistCart(id, action, id_product, id_product_attribute, quantity) -{ - $.ajax({ - type: 'GET', - url: baseDir + 'modules/blockwishlist/cart.php', - async: true, - cache: false, - data: 'action=' + action + '&id_product=' + id_product + '&quantity=' + quantity + '&token=' + static_token + '&id_product_attribute=' + id_product_attribute, - success: function(data) - { - if (action == 'add') - { - var $element = $('#bigpic'); - if (!$element.length) - var $element = $('#wishlist_button'); - var $picture = $element.clone(); - var pictureOffsetOriginal = $element.offset(); - $picture.css({'position': 'absolute', 'top': pictureOffsetOriginal.top, 'left': pictureOffsetOriginal.left}); - var pictureOffset = $picture.offset(); - var wishlistBlockOffset = $('#wishlist_block').offset(); - - $picture.appendTo('body'); - $picture.css({ 'position': 'absolute', 'top': $picture.css('top'), 'left': $picture.css('left') }) - .animate({ 'width': $element.attr('width')*0.66, 'height': $element.attr('height')*0.66, 'opacity': 0.2, 'top': wishlistBlockOffset.top + 30, 'left': wishlistBlockOffset.left + 15 }, 1000) - .fadeOut(800); - } - - if($('#' + id).length != 0) - { - $('#' + id).slideUp('normal'); - $('#' + id).html(data); - $('#' + id).slideDown('normal'); - } - } - }); -} - -/** - * Change customer default wishlist - * - * @return void - */ -function WishlistChangeDefault(id, id_wishlist) -{ - $.ajax({ - type: 'GET', - url: baseDir + 'modules/blockwishlist/cart.php', - async: true, - data: 'id_wishlist=' + id_wishlist + '&token=' + static_token, - cache: false, - success: function(data) - { - $('#' + id).slideUp('normal'); - $('#' + id).html(data); - $('#' + id).slideDown('normal'); - } - }); -} - -/** - * Buy Product - * - * @return void - */ -function WishlistBuyProduct(token, id_product, id_product_attribute, id_quantity, button, ajax) -{ - if(ajax) - ajaxCart.add(id_product, id_product_attribute, false, button, 1, [token, id_quantity]); - else - { - $('#' + id_quantity).val(0); - WishlistAddProductCart(token, id_product, id_product_attribute, id_quantity) - document.forms['addtocart' + '_' + id_product + '_' + id_product_attribute].method='POST'; - document.forms['addtocart' + '_' + id_product + '_' + id_product_attribute].action=baseUri + '?controller=cart'; - document.forms['addtocart' + '_' + id_product + '_' + id_product_attribute].elements['token'].value = static_token; - document.forms['addtocart' + '_' + id_product + '_' + id_product_attribute].submit(); - } - return (true); -} - -function WishlistAddProductCart(token, id_product, id_product_attribute, id_quantity) -{ - if ($('#' + id_quantity).val() <= 0) - return (false); - $.ajax({ - type: 'GET', - url: baseDir + 'modules/blockwishlist/buywishlistproduct.php', - data: 'token=' + token + '&static_token=' + static_token + '&id_product=' + id_product + '&id_product_attribute=' + id_product_attribute, - async: true, - cache: false, - success: function(data) - { - if (data) - alert(data); - else - { - $('#' + id_quantity).val($('#' + id_quantity).val() - 1); - } - } - }); - return (true); -} - -/** - * Show wishlist managment page - * - * @return void - */ -function WishlistManage(id, id_wishlist) -{ - $.ajax({ - type: 'GET', - async: true, - url: baseDir + 'modules/blockwishlist/managewishlist.php', - data: 'id_wishlist=' + id_wishlist + '&refresh=' + false, - cache: false, - success: function(data) - { - $('#' + id).hide(); - $('#' + id).html(data); - $('#' + id).fadeIn('slow'); - } - }); -} - -/** - * Show wishlist product managment page - * - * @return void - */ -function WishlistProductManage(id, action, id_wishlist, id_product, id_product_attribute, quantity, priority) -{ - $.ajax({ - type: 'GET', - async: true, - url: baseDir + 'modules/blockwishlist/managewishlist.php', - data: 'action=' + action + '&id_wishlist=' + id_wishlist + '&id_product=' + id_product + '&id_product_attribute=' + id_product_attribute + '&quantity=' + quantity + '&priority=' + priority + '&refresh=' + true, - cache: false, - success: function(data) - { - if (action == 'delete') - $('#wlp_' + id_product + '_' + id_product_attribute).fadeOut('fast'); - else if (action == 'update') - { - $('#wlp_' + id_product + '_' + id_product_attribute).fadeOut('fast'); - $('#wlp_' + id_product + '_' + id_product_attribute).fadeIn('fast'); - } - } - }); -} - -/** - * Delete wishlist - * - * @return boolean succeed - */ -function WishlistDelete(id, id_wishlist, msg) -{ - var res = confirm(msg); - if (res == false) - return (false); - $.ajax({ - type: 'GET', - async: true, - url: baseDir + 'modules/blockwishlist/mywishlist.php', - cache: false, - data: 'deleted&id_wishlist=' + id_wishlist, - success: function(data) - { - $('#' + id).fadeOut('slow'); - } - }); -} - -/** - * Hide/Show bought product - * - * @return void - */ -function WishlistVisibility(bought_class, id_button) -{ - if ($('#hide' + id_button).css('display') == 'none') - { - $('.' + bought_class).slideDown('fast'); - $('#show' + id_button).hide(); - $('#hide' + id_button).css('display', 'block'); - } - else - { - $('.' + bought_class).slideUp('fast'); - $('#hide' + id_button).hide(); - $('#show' + id_button).css('display', 'block'); - } -} - -/** - * Send wishlist by email - * - * @return void - */ -function WishlistSend(id, id_wishlist, id_email) -{ - $.post(baseDir + 'modules/blockwishlist/sendwishlist.php', - { token: static_token, - id_wishlist: id_wishlist, - email1: $('#' + id_email + '1').val(), - email2: $('#' + id_email + '2').val(), - email3: $('#' + id_email + '3').val(), - email4: $('#' + id_email + '4').val(), - email5: $('#' + id_email + '5').val(), - email6: $('#' + id_email + '6').val(), - email7: $('#' + id_email + '7').val(), - email8: $('#' + id_email + '8').val(), - email9: $('#' + id_email + '9').val(), - email10: $('#' + id_email + '10').val() }, - function(data) - { - if (data) - alert(data); - else - WishlistVisibility(id, 'hideSendWishlist'); - }); -} diff --git a/modules/blockwishlist/js/index.php b/modules/blockwishlist/js/index.php deleted file mode 100644 index 3f6561f72..000000000 --- a/modules/blockwishlist/js/index.php +++ /dev/null @@ -1,35 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); - -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); - -header("Location: ../"); -exit; \ No newline at end of file diff --git a/modules/blockwishlist/logo.gif b/modules/blockwishlist/logo.gif deleted file mode 100644 index da3c2a2d7..000000000 Binary files a/modules/blockwishlist/logo.gif and /dev/null differ diff --git a/modules/blockwishlist/logo.png b/modules/blockwishlist/logo.png deleted file mode 100755 index 2251c3419..000000000 Binary files a/modules/blockwishlist/logo.png and /dev/null differ diff --git a/modules/blockwishlist/mails/en/index.php b/modules/blockwishlist/mails/en/index.php deleted file mode 100644 index 3f6561f72..000000000 --- a/modules/blockwishlist/mails/en/index.php +++ /dev/null @@ -1,35 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); - -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); - -header("Location: ../"); -exit; \ No newline at end of file diff --git a/modules/blockwishlist/mails/en/wishlink.html b/modules/blockwishlist/mails/en/wishlink.html deleted file mode 100644 index 0b3bf9e47..000000000 --- a/modules/blockwishlist/mails/en/wishlink.html +++ /dev/null @@ -1,112 +0,0 @@ - - - - - - - Message from {shop_name} - - - - - - - - - - - - -
  - - - - - - - - - - - - - - - - - - - - - -
- Hi, -
-

- Message from {shop_name}

- - {shop_name} invites you to send this link to your friends, so they can see your wishlist: {wishlist}

- {message} -
-
-
 
- - \ No newline at end of file diff --git a/modules/blockwishlist/mails/en/wishlink.txt b/modules/blockwishlist/mails/en/wishlink.txt deleted file mode 100644 index 98e61a513..000000000 --- a/modules/blockwishlist/mails/en/wishlink.txt +++ /dev/null @@ -1,15 +0,0 @@ - -[{shop_url}] - -Hi, - -Message from {shop_name} - -{shop_name} invites you to send this link to your friends, so they -can see your wishlist: {wishlist} - -{message} [{message}] - -{shop_name} [{shop_url}] powered by -PrestaShop(tm) [http://www.prestashop.com/] - diff --git a/modules/blockwishlist/mails/en/wishlist.html b/modules/blockwishlist/mails/en/wishlist.html deleted file mode 100644 index ef220f26d..000000000 --- a/modules/blockwishlist/mails/en/wishlist.html +++ /dev/null @@ -1,112 +0,0 @@ - - - - - - - Message from {shop_name} - - - - - - - - - - - - -
  - - - - - - - - - - - - - - - - - - - - - -
- Hi, -
-

- Message from {shop_name}

- - {firstname} {lastname} indicated you may want to see his/her wishlist: {wishlist}

- {wishlist} -
-
-
 
- - \ No newline at end of file diff --git a/modules/blockwishlist/mails/en/wishlist.txt b/modules/blockwishlist/mails/en/wishlist.txt deleted file mode 100644 index 65697c159..000000000 --- a/modules/blockwishlist/mails/en/wishlist.txt +++ /dev/null @@ -1,15 +0,0 @@ - -[{shop_url}] - -Hi, - -Message from {shop_name} - -{firstname} {lastname} indicated you may want to see his/her -wishlist: {wishlist} - -{wishlist} [{message}] - -{shop_name} [{shop_url}] powered by -PrestaShop(tm) [http://www.prestashop.com/] - diff --git a/modules/blockwishlist/mails/index.php b/modules/blockwishlist/mails/index.php deleted file mode 100644 index 6f5ff3bab..000000000 --- a/modules/blockwishlist/mails/index.php +++ /dev/null @@ -1,35 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); - -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); - -header("Location: ../"); -exit; \ No newline at end of file diff --git a/modules/blockwishlist/managewishlist.php b/modules/blockwishlist/managewishlist.php deleted file mode 100644 index 5dd8f8ff7..000000000 --- a/modules/blockwishlist/managewishlist.php +++ /dev/null @@ -1,124 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -/* SSL Management */ -$useSSL = true; - -require_once(dirname(__FILE__).'/../../config/config.inc.php'); -require_once(dirname(__FILE__).'/../../init.php'); -require_once(dirname(__FILE__).'/WishList.php'); -require_once(dirname(__FILE__).'/blockwishlist.php'); -$context = Context::getContext(); -if ($context->customer->isLogged()) -{ - $action = Tools::getValue('action'); - $id_wishlist = (int)Tools::getValue('id_wishlist'); - $id_product = (int)Tools::getValue('id_product'); - $id_product_attribute = (int)Tools::getValue('id_product_attribute'); - $quantity = (int)Tools::getValue('quantity'); - $priority = Tools::getValue('priority'); - $wishlist = new WishList((int)($id_wishlist)); - $refresh = (($_GET['refresh'] == 'true') ? 1 : 0); - if (empty($id_wishlist) === false) - { - if (!strcmp($action, 'update')) - { - WishList::updateProduct($id_wishlist, $id_product, $id_product_attribute, $priority, $quantity); - } - else - { - if (!strcmp($action, 'delete')) - WishList::removeProduct($id_wishlist, (int)$context->customer->id, $id_product, $id_product_attribute); - - $products = WishList::getProductByIdCustomer($id_wishlist, $context->customer->id, $context->language->id); - $bought = WishList::getBoughtProduct($id_wishlist); - - for ($i = 0; $i < sizeof($products); ++$i) - { - $obj = new Product((int)($products[$i]['id_product']), false, $context->language->id); - if (!Validate::isLoadedObject($obj)) - continue; - else - { - if ($products[$i]['id_product_attribute'] != 0) - { - $combination_imgs = $obj->getCombinationImages($context->language->id); - if (isset($combination_imgs[$products[$i]['id_product_attribute']][0])) - $products[$i]['cover'] = $obj->id.'-'.$combination_imgs[$products[$i]['id_product_attribute']][0]['id_image']; - else - { - $cover = Product::getCover($obj->id); - $products[$i]['cover'] = $obj->id.'-'.$cover['id_image']; - } - } - else - { - $images = $obj->getImages($context->language->id); - foreach ($images AS $k => $image) - if ($image['cover']) - { - $products[$i]['cover'] = $obj->id.'-'.$image['id_image']; - break; - } - } - if (!isset($products[$i]['cover'])) - $products[$i]['cover'] = $context->language->iso_code.'-default'; - } - $products[$i]['bought'] = false; - for ($j = 0, $k = 0; $j < sizeof($bought); ++$j) - { - if ($bought[$j]['id_product'] == $products[$i]['id_product'] AND - $bought[$j]['id_product_attribute'] == $products[$i]['id_product_attribute']) - $products[$i]['bought'][$k++] = $bought[$j]; - } - } - - $productBoughts = array(); - - foreach ($products as $product) - if (sizeof($product['bought'])) - $productBoughts[] = $product; - $context->smarty->assign(array( - 'products' => $products, - 'productsBoughts' => $productBoughts, - 'id_wishlist' => $id_wishlist, - 'refresh' => $refresh, - 'token_wish' => $wishlist->token - )); - - // Instance of module class for translations - $module = new BlockWishList(); - - if (Tools::file_exists_cache(_PS_THEME_DIR_.'modules/blockwishlist/managewishlist.tpl')) - $context->smarty->display(_PS_THEME_DIR_.'modules/blockwishlist/managewishlist.tpl'); - elseif (Tools::file_exists_cache(dirname(__FILE__).'/managewishlist.tpl')) - $context->smarty->display(dirname(__FILE__).'/managewishlist.tpl'); - else - echo $module->l('No template found', 'managewishlist'); - } - } -} - diff --git a/modules/blockwishlist/managewishlist.tpl b/modules/blockwishlist/managewishlist.tpl deleted file mode 100644 index 82990caba..000000000 --- a/modules/blockwishlist/managewishlist.tpl +++ /dev/null @@ -1,140 +0,0 @@ -{* -* 2007-2013 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 -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*} - -{if $products} - {if !$refresh} -
- - -

{l s='Permalink' mod='blockwishlist'}:

-

- -

- {/if} -
- -
- {if !$refresh} - - {if count($productsBoughts)} - - - - - - - {foreach from=$productsBoughts item=product name=i} - {foreach from=$product.bought item=bought name=j} - {if $bought.quantity > 0} - - - - - - - {/if} - {/foreach} - {/foreach} - - - {/if} - {/if} -{else} -

{l s='No products' mod='blockwishlist'}

-{/if} \ No newline at end of file diff --git a/modules/blockwishlist/my-account.tpl b/modules/blockwishlist/my-account.tpl deleted file mode 100644 index 14d690af8..000000000 --- a/modules/blockwishlist/my-account.tpl +++ /dev/null @@ -1,33 +0,0 @@ -{* -* 2007-2013 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 -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*} - - -
  • - - {l s='My wishlists' mod='blockwishlist'} - {l s='My wishlists' mod='blockwishlist'} - -
  • - \ No newline at end of file diff --git a/modules/blockwishlist/mywishlist.php b/modules/blockwishlist/mywishlist.php deleted file mode 100644 index 5cce77395..000000000 --- a/modules/blockwishlist/mywishlist.php +++ /dev/null @@ -1,113 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -/* SSL Management */ -$useSSL = true; - -include(dirname(__FILE__).'/../../config/config.inc.php'); -include(dirname(__FILE__).'/../../header.php'); -include_once(dirname(__FILE__).'/WishList.php'); - -$context = Context::getContext(); -$errors = array(); - -Tools::displayFileAsDeprecated(); - -// Instance of module class for translations -$module = new BlockWishList(); - -if ($context->customer->isLogged()) -{ - $add = Tools::getIsset('add'); - $add = (empty($add) === false ? 1 : 0); - $delete = Tools::getIsset('deleted'); - $delete = (empty($delete) === false ? 1 : 0); - $id_wishlist = Tools::getValue('id_wishlist'); - if (Tools::isSubmit('submitWishlist')) - { - if (Configuration::get('PS_TOKEN_ACTIVATED') == 1 AND - strcmp(Tools::getToken(), Tools::getValue('token'))) - $errors[] = $module->l('Invalid token', 'mywishlist'); - if (!sizeof($errors)) - { - $name = Tools::getValue('name'); - if (empty($name)) - $errors[] = $module->l('You must specify a name.', 'mywishlist'); - if (WishList::isExistsByNameForUser($name)) - $errors[] = $module->l('This name is already used by another list.', 'mywishlist'); - - if(!sizeof($errors)) - { - $wishlist = new WishList(); - $wishlist->name = $name; - $wishlist->id_customer = (int)$context->customer->id; - $wishlist->id_shop = $context->shop->id; - $wishlist->id_shop_group = $context->shop->id_shop_group; - list($us, $s) = explode(' ', microtime()); - srand($s * $us); - $wishlist->token = strtoupper(substr(sha1(uniqid(rand(), true)._COOKIE_KEY_.$context->customer->id), 0, 16)); - $wishlist->add(); - Mail::Send($context->language->id, 'wishlink', Mail::l('Your wishlist\'s link', $context->language->id), - array( - '{wishlist}' => $wishlist->name, - '{message}' => Tools::getProtocol().htmlentities($_SERVER['HTTP_HOST'], ENT_COMPAT, 'UTF-8').__PS_BASE_URI__.'modules/blockwishlist/view.php?token='.$wishlist->token), - $context->customer->email, $context->customer->firstname.' '.$context->customer->lastname, NULL, strval(Configuration::get('PS_SHOP_NAME')), NULL, NULL, dirname(__FILE__).'/mails/'); - } - } - } - else if ($add) - WishList::addCardToWishlist($context->customer->id, Tools::getValue('id_wishlist'), $context->language->id); - else if ($delete AND empty($id_wishlist) === false) - { - $wishlist = new WishList((int)($id_wishlist)); - if (Validate::isLoadedObject($wishlist)) - $wishlist->delete(); - else - $errors[] = $module->l('Cannot delete this wishlist', 'mywishlist'); - } - $context->smarty->assign('wishlists', WishList::getByIdCustomer($context->customer->id)); - $context->smarty->assign('nbProducts', WishList::getInfosByIdCustomer($context->customer->id)); -} -else -{ - Tools::redirect('index.php?controller=authentication&back=modules/blockwishlist/mywishlist.php'); -} - -$context->smarty->assign(array( - 'id_customer' => (int)$context->customer->id, - 'errors' => $errors -)); - -if (Tools::file_exists_cache(_PS_THEME_DIR_.'modules/blockwishlist/mywishlist.tpl')) - $context->smarty->display(_PS_THEME_DIR_.'modules/blockwishlist/mywishlist.tpl'); -elseif (Tools::file_exists_cache(dirname(__FILE__).'/views/templates/front/mywishlist.tpl')) - $context->smarty->display(dirname(__FILE__).'/views/templates/front/mywishlist.tpl'); -else - echo $module->l('No template found', 'mywishlist'); - -include(dirname(__FILE__).'/../../footer.php'); - - diff --git a/modules/blockwishlist/sendwishlist.php b/modules/blockwishlist/sendwishlist.php deleted file mode 100644 index c0eb98c78..000000000 --- a/modules/blockwishlist/sendwishlist.php +++ /dev/null @@ -1,69 +0,0 @@ - -* @copyright 2007-2013 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'); -require_once(dirname(__FILE__).'/WishList.php'); -require_once(dirname(__FILE__).'/blockwishlist.php'); - -$context = Context::getContext(); - -// Instance of module class for translations -$module = new BlockWishList(); - -if (Configuration::get('PS_TOKEN_ENABLE') == 1 AND - strcmp(Tools::getToken(false), Tools::getValue('token')) AND - $context->customer->isLogged() === true) - exit($module->l('invalid token', 'sendwishlist')); - -if ($context->customer->isLogged()) -{ - $id_wishlist = (int)(Tools::getValue('id_wishlist')); - if (empty($id_wishlist) === true) - exit($module->l('Invalid wishlist', 'sendwishlist')); - for ($i = 1; empty($_POST['email'.strval($i)]) === false; ++$i) - { - $to = Tools::getValue('email'.$i); - $wishlist = WishList::exists($id_wishlist, $context->customer->id, true); - if ($wishlist === false) - exit($module->l('Invalid wishlist', 'sendwishlist')); - if (WishList::addEmail($id_wishlist, $to) === false) - exit($module->l('Wishlist send error', 'sendwishlist')); - $toName = strval(Configuration::get('PS_SHOP_NAME')); - $customer = $context->customer; - if (Validate::isLoadedObject($customer)) - Mail::Send( - $context->language->id, - 'wishlist', - sprintf(Mail::l('Message from %1$s %2$s', $context->language->id), $customer->lastname, $customer->firstname), - array( - '{lastname}' => $customer->lastname, - '{firstname}' => $customer->firstname, - '{wishlist}' => $wishlist['name'], - '{message}' => Tools::getProtocol().htmlentities($_SERVER['HTTP_HOST'], ENT_COMPAT, 'UTF-8').__PS_BASE_URI__.'modules/blockwishlist/view.php?token='.$wishlist['token']), - $to, $toName, $customer->email, $customer->firstname.' '.$customer->lastname, NULL, NULL, dirname(__FILE__).'/mails/'); - } -} diff --git a/modules/blockwishlist/translations/index.php b/modules/blockwishlist/translations/index.php deleted file mode 100644 index 3f6561f72..000000000 --- a/modules/blockwishlist/translations/index.php +++ /dev/null @@ -1,35 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); - -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); - -header("Location: ../"); -exit; \ No newline at end of file diff --git a/modules/blockwishlist/upgrade/install-0.3.php b/modules/blockwishlist/upgrade/install-0.3.php deleted file mode 100644 index 1d2b8f3d3..000000000 --- a/modules/blockwishlist/upgrade/install-0.3.php +++ /dev/null @@ -1,9 +0,0 @@ -registerHook('displayProductListFunctionalButtons') && $object->registerHook('top')); -} diff --git a/modules/blockwishlist/view.php b/modules/blockwishlist/view.php deleted file mode 100644 index 0d02e7b6d..000000000 --- a/modules/blockwishlist/view.php +++ /dev/null @@ -1,110 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -/* SSL Management */ -$useSSL = true; - -require_once(dirname(__FILE__).'/../../config/config.inc.php'); -require_once(dirname(__FILE__).'/../../header.php'); -require_once(dirname(__FILE__).'/WishList.php'); - -error_reporting(0); - -$context = Context::getContext(); -$token = Tools::getValue('token'); - -// Instance of module class for translations -$module = new BlockWishList(); - -if (empty($token) === false) -{ - $wishlist = WishList::getByToken($token); - if (empty($result) === true || $result === false) - $errors[] = $module->l('Invalid wishlist token', 'view'); - WishList::refreshWishList($wishlist['id_wishlist']); - $products = WishList::getProductByIdCustomer((int)($wishlist['id_wishlist']), (int)($wishlist['id_customer']), $context->language->id, null, true); - - for ($i = 0; $i < sizeof($products); ++$i) - { - $obj = new Product((int)($products[$i]['id_product']), false, $context->language->id); - if (!Validate::isLoadedObject($obj)) - continue; - else - { - $quantity = Product::getQuantity((int)$products[$i]['id_product'], $products[$i]['id_product_attribute']); - $products[$i]['attribute_quantity'] = $quantity; - $products[$i]['product_quantity'] = $quantity; - if ($products[$i]['id_product_attribute'] != 0) - { - $combination_imgs = $obj->getCombinationImages($context->language->id); - if (isset($combination_imgs[$products[$i]['id_product_attribute']][0])) - $products[$i]['cover'] = $obj->id.'-'.$combination_imgs[$products[$i]['id_product_attribute']][0]['id_image']; - else - { - $cover = Product::getCover($obj->id); - $products[$i]['cover'] = $obj->id.'-'.$cover['id_image']; - } - } - else - { - $images = $obj->getImages($context->language->id); - foreach ($images AS $k => $image) - if ($image['cover']) - { - $products[$i]['cover'] = $obj->id.'-'.$image['id_image']; - break; - } - } - if (!isset($products[$i]['cover'])) - $products[$i]['cover'] = $context->language->iso_code.'-default'; - } - $products[$i]['bought'] = false; - for ($j = 0, $k = 0; $j < sizeof($bought); ++$j) - { - if ($bought[$j]['id_product'] == $products[$i]['id_product'] AND - $bought[$j]['id_product_attribute'] == $products[$i]['id_product_attribute']) - $products[$i]['bought'][$k++] = $bought[$j]; - } - } - - WishList::incCounter((int)($wishlist['id_wishlist'])); - $ajax = Configuration::get('PS_BLOCK_CART_AJAX'); - $context->smarty->assign(array ( - 'current_wishlist' => $wishlist, - 'token' => $token, - 'ajax' => ((isset($ajax) AND (int)($ajax) == 1) ? '1' : '0'), - 'wishlists' => WishList::getByIdCustomer((int)($wishlist['id_customer'])), - 'products' => $products)); -} - -if (Tools::file_exists_cache(_PS_THEME_DIR_.'modules/blockwishlist/view.tpl')) - $context->smarty->display(_PS_THEME_DIR_.'modules/blockwishlist/view.tpl'); -elseif (Tools::file_exists_cache(dirname(__FILE__).'/view.tpl')) - $context->smarty->display(dirname(__FILE__).'/view.tpl'); -else - echo $module->l('No template found', 'view'); - -require(dirname(__FILE__).'/../../footer.php'); diff --git a/modules/blockwishlist/view.tpl b/modules/blockwishlist/view.tpl deleted file mode 100644 index 5d10b5717..000000000 --- a/modules/blockwishlist/view.tpl +++ /dev/null @@ -1,92 +0,0 @@ -{* -* 2007-2013 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 -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*} - -
    -

    {l s='Wishlist' mod='blockwishlist'}

    -{if $wishlists} -

    - {l s='Other wishlists of' mod='blockwishlist'} {$current_wishlist.firstname} {$current_wishlist.lastname}: - {foreach from=$wishlists item=wishlist name=i} - {if $wishlist.id_wishlist != $current_wishlist.id_wishlist} - {$wishlist.name} - {if !$smarty.foreach.i.last} - / - {/if} - {/if} - {/foreach} -

    -{/if} - -
    -
      - {foreach from=$products item=product name=i} -
    • -
      -
      - - {$product.name|escape:'html':'UTF-8'} - -
      -
      -

      {$product.name|truncate:30:'...'|escape:'html':'UTF-8'}

      - - {if isset($product.attributes_small)} - {$product.attributes_small|escape:'html':'UTF-8'} - {/if} -
      {l s='Quantity' mod='blockwishlist'}: -

      - {l s='Priority' mod='blockwishlist'}: - -
      -
      -
      -
      - {l s='View' mod='blockwishlist'} - {if isset($product.attribute_quantity) AND $product.attribute_quantity >= 1 OR !isset($product.attribute_quantity) AND $product.product_quantity >= 1} - {if !$ajax} -
      - -
      - {/if} - {l s='Add to cart' mod='blockwishlist'} - {else} - {l s='Add to cart' mod='blockwishlist'} - {/if} -
      -
    • - {/foreach} -
    -
    - -
    diff --git a/modules/blockwishlist/views/index.php b/modules/blockwishlist/views/index.php deleted file mode 100644 index 3f6561f72..000000000 --- a/modules/blockwishlist/views/index.php +++ /dev/null @@ -1,35 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); - -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); - -header("Location: ../"); -exit; \ No newline at end of file diff --git a/modules/blockwishlist/views/templates/admin/_configure/helpers/index.php b/modules/blockwishlist/views/templates/admin/_configure/helpers/index.php deleted file mode 100644 index 3f6561f72..000000000 --- a/modules/blockwishlist/views/templates/admin/_configure/helpers/index.php +++ /dev/null @@ -1,35 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); - -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); - -header("Location: ../"); -exit; \ No newline at end of file diff --git a/modules/blockwishlist/views/templates/admin/_configure/helpers/list/index.php b/modules/blockwishlist/views/templates/admin/_configure/helpers/list/index.php deleted file mode 100644 index 3f6561f72..000000000 --- a/modules/blockwishlist/views/templates/admin/_configure/helpers/list/index.php +++ /dev/null @@ -1,35 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); - -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); - -header("Location: ../"); -exit; \ No newline at end of file diff --git a/modules/blockwishlist/views/templates/admin/_configure/helpers/list/list_content.tpl b/modules/blockwishlist/views/templates/admin/_configure/helpers/list/list_content.tpl deleted file mode 100644 index ab842ec66..000000000 --- a/modules/blockwishlist/views/templates/admin/_configure/helpers/list/list_content.tpl +++ /dev/null @@ -1,37 +0,0 @@ -{* -* 2007-2013 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 -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*} - -{extends file="helpers/list/list_content.tpl"} - -{block name="td_content"} - {if isset($params.type) && $params.type == 'priority'} - {$priority[$tr.$key]} - {elseif isset($params.type) && $params.type == 'image'} - - {else} - {$smarty.block.parent} - {/if} - -{/block} diff --git a/modules/blockwishlist/views/templates/admin/_configure/index.php b/modules/blockwishlist/views/templates/admin/_configure/index.php deleted file mode 100644 index 3f6561f72..000000000 --- a/modules/blockwishlist/views/templates/admin/_configure/index.php +++ /dev/null @@ -1,35 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); - -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); - -header("Location: ../"); -exit; \ No newline at end of file diff --git a/modules/blockwishlist/views/templates/admin/index.php b/modules/blockwishlist/views/templates/admin/index.php deleted file mode 100644 index 3f6561f72..000000000 --- a/modules/blockwishlist/views/templates/admin/index.php +++ /dev/null @@ -1,35 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); - -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); - -header("Location: ../"); -exit; \ No newline at end of file diff --git a/modules/blockwishlist/views/templates/front/index.php b/modules/blockwishlist/views/templates/front/index.php deleted file mode 100644 index 3f6561f72..000000000 --- a/modules/blockwishlist/views/templates/front/index.php +++ /dev/null @@ -1,35 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); - -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); - -header("Location: ../"); -exit; \ No newline at end of file diff --git a/modules/blockwishlist/views/templates/front/mywishlist.tpl b/modules/blockwishlist/views/templates/front/mywishlist.tpl deleted file mode 100644 index d1ee85356..000000000 --- a/modules/blockwishlist/views/templates/front/mywishlist.tpl +++ /dev/null @@ -1,99 +0,0 @@ -{* -* 2007-2013 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 -* @copyright 2007-2013 PrestaShop SA -* @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='My account' mod='blockwishlist'}{$navigationPipe}{l s='My wishlists' mod='blockwishlist'}{/capture} - {include file="$tpl_dir./breadcrumb.tpl"} - -

    {l s='My wishlists' mod='blockwishlist'}

    - - {include file="$tpl_dir./errors.tpl"} - - {if $id_customer|intval neq 0} -
    -
    -

    {l s='New wishlist' mod='blockwishlist'}

    -

    - - - -

    -

    - -

    -
    -
    - {if $wishlists} -
    - - - - - - - - - - - - - {section name=i loop=$wishlists} - - - - - - - - - {/section} - -
    {l s='Name' mod='blockwishlist'}{l s='Qty' mod='blockwishlist'}{l s='Viewed' mod='blockwishlist'}{l s='Created' mod='blockwishlist'}{l s='Direct Link' mod='blockwishlist'}{l s='Delete' mod='blockwishlist'}
    - {$wishlists[i].name|truncate:30:'...'|escape:'html':'UTF-8'} - - {assign var=n value=0} - {foreach from=$nbProducts item=nb name=i} - {if $nb.id_wishlist eq $wishlists[i].id_wishlist} - {assign var=n value=$nb.nbProducts|intval} - {/if} - {/foreach} - {if $n} - {$n|intval} - {else} - 0 - {/if} - {$wishlists[i].counter|intval}{$wishlists[i].date_add|date_format:"%Y-%m-%d"}{l s='View' mod='blockwishlist'} - {l s='Delete' mod='blockwishlist'} -
    -
    -
     
    - {/if} - {/if} - - -
    diff --git a/modules/blockwishlist/views/templates/index.php b/modules/blockwishlist/views/templates/index.php deleted file mode 100644 index 3f6561f72..000000000 --- a/modules/blockwishlist/views/templates/index.php +++ /dev/null @@ -1,35 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); - -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); - -header("Location: ../"); -exit; \ No newline at end of file diff --git a/modules/carriercompare/ajax.php b/modules/carriercompare/ajax.php deleted file mode 100644 index 7b90d3b33..000000000 --- a/modules/carriercompare/ajax.php +++ /dev/null @@ -1,53 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -/* SSL Management */ -$useSSL = true; - -require_once(dirname(__FILE__).'../../../config/config.inc.php'); -require_once(dirname(__FILE__).'../../../init.php'); -require_once(dirname(__FILE__).'/carriercompare.php'); - -$carrierCompare = new CarrierCompare(); - -switch (Tools::getValue('method')) -{ - case 'getStates': - if (!(int)Tools::getValue('id_country')) - exit; - die(Tools::jsonEncode($carrierCompare->getStatesByIdCountry((int)Tools::getValue('id_country')))); - break; - case 'getCarriers': - die(Tools::jsonEncode($carrierCompare->getCarriersListByIdZone((int)Tools::getValue('id_country'), (int)Tools::getValue('id_state', 0), Tools::safeOutput(Tools::getValue('zipcode', 0))))); - break; - case 'saveSelection': - $errors = $carrierCompare->saveSelection((int)Tools::getValue('id_country'), (int)Tools::getValue('id_state', 0), Tools::getValue('zipcode', 0), (int)Tools::getValue('id_carrier', 0)); - die(Tools::jsonEncode($errors)); - break; - default: - exit; -} -exit; diff --git a/modules/carriercompare/carriercompare.js b/modules/carriercompare/carriercompare.js deleted file mode 100644 index a3a63459c..000000000 --- a/modules/carriercompare/carriercompare.js +++ /dev/null @@ -1,194 +0,0 @@ -/* -* 2007-2013 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 -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -function PS_SE_HandleEvent() -{ - $(document).ready(function() { - $('#id_country').change(function() { - resetAjaxQueries(); - updateStateByIdCountry(); - }); - - if (SE_RefreshMethod == 0) - { - $('#id_state').change(function() { - resetAjaxQueries(); - updateCarriersList(); - }); - - $('#zipcode').bind('keyup',function(e) { - if (e.keyCode == '13') - { - resetAjaxQueries(); - updateCarriersList(); - } - }); - } - - $('#update_carriers_list').click(function() { - updateCarriersList(); - }); - - $('#carriercompare_submit').click(function() { - resetAjaxQueries(); - saveSelection(); - return false; - }); - - updateStateByIdCountry(); - }); -} - -function displayWaitingAjax(type, message) -{ - $('#SE_AjaxDisplay').find('p').html(message); - $('#SE_AjaxDisplay').css('display', type); -} - -function updateStateByIdCountry() -{ - $('#id_state').children().remove(); - $('#availableCarriers').slideUp('fast'); - $('#states').slideUp('fast'); - displayWaitingAjax('block', SE_RefreshStateTS); - - var query = $.ajax({ - type: 'POST', - headers: { "cache-control": "no-cache" }, - url: baseDir + 'modules/carriercompare/ajax.php' + '?rand=' + new Date().getTime(), - data: 'method=getStates&id_country=' + $('#id_country').val(), - dataType: 'json', - success: function(json) { - if (json.length) - { - for (state in json) - { - $('#id_state').append(''); - } - $('#states').slideDown('fast'); - } - if (SE_RefreshMethod == 0) - updateCarriersList(); - displayWaitingAjax('none', ''); - } - }); - ajaxQueries.push(query); -} - -function updateCarriersList() -{ - $('#carriercompare_errors_list').children().remove(); - $('#availableCarriers').slideUp('normal', function(){ - $(this).find(('tbody')).children().remove(); - $('#noCarrier').slideUp('fast'); - displayWaitingAjax('block', SE_RetrievingInfoTS); - - var query = $.ajax({ - type: 'POST', - headers: { "cache-control": "no-cache" }, - url: baseDir + 'modules/carriercompare/ajax.php' + '?rand=' + new Date().getTime(), - data: 'method=getCarriers&id_country=' + $('#id_country').val() + '&id_state=' + $('#id_state').val() + '&zipcode=' + $('#zipcode').val(), - dataType: 'json', - success: function(json) { - if (json.length) - { - for (carrier in json) - { - var html = ''+ - ''+ - ''+ - ''+ - ''+ - ''+ - ''+ - ''+((json[carrier].delay != null) ? json[carrier].delay : '') +''+ - ''; - - if (json[carrier].price) - { - html += ''+(displayPrice == 1 ? formatCurrency(json[carrier].price_tax_exc, currencyFormat, currencySign, currencyBlank) : formatCurrency(json[carrier].price, currencyFormat, currencySign, currencyBlank))+''; - } - else - { - html += txtFree; - } - html += ''+ - ''; - $('#carriers_list').append(html); - } - displayWaitingAjax('none', ''); - $('#availableCarriers').slideDown(); - } - else - { - displayWaitingAjax('none', ''); - $('#noCarrier').slideDown(); - } - } - }); - ajaxQueries.push(query); - }); -} - -function saveSelection() -{ - $('#carriercompare_errors').slideUp(); - $('#carriercompare_errors_list').children().remove(); - displayWaitingAjax('block', SE_RedirectTS); - - var query = $.ajax({ - type: 'POST', - headers: { "cache-control": "no-cache" }, - url: baseDir + 'modules/carriercompare/ajax.php' + '?rand=' + new Date().getTime(), - data: 'method=saveSelection&' + $('#compare_shipping_form').serialize(), - dataType: 'json', - success: function(json) { - if (json.length) - { - for (error in json) - $('#carriercompare_errors_list').append('
  • '+json[error]+'
  • '); - $('#carriercompare_errors').slideDown(); - displayWaitingAjax('none', ''); - } - else - { - $('.SE_SubmitRefreshCard').fadeOut('fast'); - location.reload(true); - } - } - }); - ajaxQueries.push(query); - return false; -} - -var ajaxQueries = new Array(); -function resetAjaxQueries() -{ - for (i = 0; i < ajaxQueries.length; ++i) - ajaxQueries[i].abort(); - ajaxQueries = new Array(); -} \ No newline at end of file diff --git a/modules/carriercompare/carriercompare.php b/modules/carriercompare/carriercompare.php deleted file mode 100755 index 34c4bb308..000000000 --- a/modules/carriercompare/carriercompare.php +++ /dev/null @@ -1,341 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -if (!defined('_PS_VERSION_')) - exit; - -class CarrierCompare extends Module -{ - public $template_directory = ''; - public $smarty; - - public function __construct() - { - $this->name = 'carriercompare'; - $this->tab = 'shipping_logistics'; - $this->version = '1.2'; - $this->author = 'PrestaShop'; - $this->need_instance = 0; - - $this->bootstrap = true; - parent::__construct(); - - $this->displayName = $this->l('Shipping Estimate'); - $this->description = $this->l('Compares carrier choices before checkout.'); - $this->template_directory = dirname(__FILE__).'/template/'; - $this->initRetroCompatibilityVar(); - } - - // Retro-compatibiliy 1.4/1.5 - private function initRetroCompatibilityVar() - { - if (class_exists('Context')) - $smarty = Context::getContext()->smarty; - else - global $smarty; - - $this->smarty = $smarty; - } - - public function install() - { - if (!parent::install() OR !$this->registerHook('shoppingCart') OR !$this->registerHook('header')) - return false; - return true; - } - - public function getContent() - { - $output = ''; - if (Tools::isSubmit('setGlobalConfiguration')) - if (Configuration::updateValue('SE_RERESH_METHOD', (int)Tools::getValue('SE_RERESH_METHOD'))) - $output .= $this->displayConfirmation('Configuration updated'); - - return $output.$this->renderForm(); - } - - public function hookHeader($params) - { - if (!$this->isModuleAvailable()) - return; - $this->context->controller->addCSS(($this->_path).'style.css', 'all'); - $this->context->controller->addJS(($this->_path).'carriercompare.js'); - } - - /* - ** Hook Shopping Cart Process - */ - public function hookShoppingCart($params) - { - if (!$this->isModuleAvailable()) - return; - - if (!isset($this->context->cart) || $this->context->cart->getProducts() == 0) - return; - - $protocol = (Configuration::get('PS_SSL_ENABLED') || (!empty($_SERVER['HTTPS']) - && strtolower($_SERVER['HTTPS']) != 'off')) ? 'https://' : 'http://'; - - $endURL = __PS_BASE_URI__.'modules/carriercompare/'; - - if (method_exists('Tools', 'getShopDomainSsl')) - $moduleURL = $protocol.Tools::getShopDomainSsl().$endURL; - else - $moduleURL = $protocol.$_SERVER['HTTP_HOST'].$endURL; - - $refresh_method = Configuration::get('SE_RERESH_METHOD'); - - if(isset($this->context->cookie->id_country) && $this->context->cookie->id_country > 0) - $id_country = (int)$this->context->cookie->id_country; - if(!isset($id_country)) - $id_country = (isset($this->context->customer->geoloc_id_country) ? (int)$this->context->customer->geoloc_id_country : (int)Configuration::get('PS_COUNTRY_DEFAULT')); - if (isset($this->context->customer->id) && $this->context->customer->id && isset($this->context->cart->id_address_delivery) && $this->context->cart->id_address_delivery) - { - $address = new Address((int)($this->context->cart->id_address_delivery)); - $id_country = (int)$address->id_country; - } - - - if(isset($this->context->cookie->id_state) && $this->context->cookie->id_state > 0) - $id_state = (int)$this->context->cookie->id_state; - if(!isset($id_state)) - $id_state = (isset($this->context->customer->geoloc_id_state) ? (int)$this->context->customer->geoloc_id_state : 0); - - if(isset($this->context->cookie->postcode) && $this->context->cookie->postcode > 0) - $zipcode = Tools::safeOutput($this->context->cookie->postcode); - if(!isset($zipcode)) - $zipcode = (isset($this->context->customer->geoloc_postcode) ? $this->context->customer->geoloc_postcode : ''); - - $this->smarty->assign(array( - 'countries' => Country::getCountries((int)$this->context->cookie->id_lang, true), - 'id_carrier' => ($params['cart']->id_carrier ? $params['cart']->id_carrier : Configuration::get('PS_CARRIER_DEFAULT')), - 'id_country' => $id_country, - 'id_state' => $id_state, - 'zipcode' => $zipcode, - 'currencySign' => $this->context->currency->sign, - 'currencyRate' => $this->context->currency->conversion_rate, - 'currencyFormat' => $this->context->currency->format, - 'currencyBlank' => $this->context->currency->blank, - 'new_base_dir' => $moduleURL, - 'refresh_method' => ($refresh_method === false) ? 0 : $refresh_method - )); - - return $this->display(__FILE__, 'template/carriercompare.tpl'); - } - - /* - ** Get states by Country id, called by the ajax process - ** id_state allow to preselect the selection option - */ - public function getStatesByIdCountry($id_country, $id_state = '') - { - $states = State::getStatesByIdCountry($id_country); - - return (sizeof($states) ? $states : array()); - } - - /* - ** Get carriers by country id, called by the ajax process - */ - public function getCarriersListByIdZone($id_country, $id_state = 0, $zipcode = 0) - { - // cookie saving/updating - $this->context->cookie->id_country = $id_country; - if ($id_state != 0) - $this->context->cookie->id_state = $id_state; - if ($zipcode != 0) - $this->context->cookie->postcode = $zipcode; - - $id_zone = 0; - if ($id_state != 0) - $id_zone = State::getIdZone($id_state); - if (!$id_zone) - $id_zone = Country::getIdZone($id_country); - - // Need to set the infos for carrier module ! - $this->context->cookie->id_country = $id_country; - $this->context->cookie->id_state = $id_state; - $this->context->cookie->postcode = $zipcode; - - $carriers = Carrier::getCarriersForOrder((int)$id_zone); - - return (sizeof($carriers) ? $carriers : array()); - } - - public function saveSelection($id_country, $id_state, $zipcode, $id_carrier) - { - $errors = array(); - - if (!Validate::isInt($id_state)) - $errors[] = $this->l('Invalid State ID'); - if ($id_state != 0 && !Validate::isLoadedObject(new State($id_state))) - $errors[] = $this->l('Please select a state'); - if (!Validate::isInt($id_country) || !Validate::isLoadedObject(new Country($id_country))) - $errors[] = $this->l('Please select a country'); - if (!$this->checkZipcode($zipcode, $id_country)) - $errors[] = $this->l('Depending on your country selection, please use a valid zip/postal code.'); - if (!Validate::isInt($id_carrier) || !Validate::isLoadedObject(new Carrier($id_carrier))) - $errors[] = $this->l('Please select a carrier'); - - if (sizeof($errors)) - return $errors; - - $ids_carrier = array(); - foreach (self::getCarriersListByIdZone($id_country, $id_state, $zipcode) as $carrier) - $ids_carrier[] = $carrier['id_carrier']; - if (!in_array($id_carrier, $ids_carrier)) - $errors[] = $this->l('The carrier ID isn\'t available for your selection'); - - if (sizeof($errors)) - return $errors; - - $this->context->cookie->id_country = $id_country; - $this->context->cookie->id_state = $id_state; - $this->context->cookie->postcode = $zipcode; - $this->context->cart->id_carrier = $id_carrier; - $delivery_option_list = $this->context->cart->getDeliveryOptionList(); - - $delivery_option = reset($delivery_option_list); - $id_carrier = (string)$id_carrier; - $id_carrier .= ','; - foreach ($delivery_option_list as $id_address => $options) - if (isset($options[$id_carrier])) - $this->context->cart->setDeliveryOption(array($id_address => $id_carrier)); - - if (!$this->context->cart->update()) - return array($this->l('Cannot update the shopping cart.')); - return array(); - } - - /* - ** Check the validity of the zipcode format depending of the country - */ - private function checkZipcode($zipcode, $id_country) - { - $country = new Country((int)$id_country); - if (!Validate::isLoadedObject($country)) - return true; - $zipcodeFormat = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue(' - SELECT `zip_code_format` - FROM `'._DB_PREFIX_.'country` - WHERE `id_country` = '.(int)$id_country); - - if (!$country->need_zip_code || !$country->zip_code_format) - return true; - - $regxMask = str_replace( - array('N', 'C', 'L'), - array( - '[0-9]', - $country->iso_code, - '[a-zA-Z]'), - $country->zip_code_format); - if (preg_match('/'.$regxMask.'/', $zipcode)) - return true; - return false; - } - - /** - * This module is shown on front office, in only some conditions - * @return bool - */ - private function isModuleAvailable() - { - $fileName = basename($_SERVER['SCRIPT_FILENAME']); - /** - * This module is only available on standard order process because - * on One Page Checkout the carrier list is already available. - */ - if (Configuration::get('PS_ORDER_PROCESS_TYPE') == 1) - return false; - /** - * If visitor is logged, the module isn't available on Front office, - * we use the account informations for carrier selection and taxes. - */ - /*if (Context::getContext()->customer->id) - return false;*/ - return true; - } - - public function renderForm() - { - $fields_form = array( - 'form' => array( - 'legend' => array( - 'title' => $this->l('Settings'), - 'icon' => 'icon-cogs' - ), - 'input' => array( - array( - 'type' => 'select', - 'label' => $this->l('How to refresh the carrier list?'), - 'name' => 'SE_RERESH_METHOD', - 'required' => false, - 'desc' => $this->l('This determines when the list of carriers presented to the customer is updated.'), - 'default_value' => (int)$this->context->country->id, - 'options' => array( - 'query' => array( - array('id' => 0, 'name' => $this->l('Automatically with each field change')), - array('id' => 1, 'name' => $this->l('When the customer clicks on the "Estimate Shipping Cost" button')) - ), - 'id' => 'id', - 'name' => 'name', - ), - ), - ), - 'submit' => array( - 'title' => $this->l('Save'), - 'class' => 'btn btn-default') - ), - ); - - $helper = new HelperForm(); - $helper->show_toolbar = false; - $helper->table = $this->table; - $lang = new Language((int)Configuration::get('PS_LANG_DEFAULT')); - $helper->default_form_language = $lang->id; - $helper->allow_employee_form_lang = Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG') ? Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG') : 0; - $helper->identifier = $this->identifier; - $helper->submit_action = 'setGlobalConfiguration'; - $helper->currentIndex = $this->context->link->getAdminLink('AdminModules', false).'&configure='.$this->name.'&tab_module='.$this->tab.'&module_name='.$this->name; - $helper->token = Tools::getAdminTokenLite('AdminModules'); - $helper->tpl_vars = array( - 'fields_value' => $this->getConfigFieldsValues(), - 'languages' => $this->context->controller->getLanguages(), - 'id_language' => $this->context->language->id - ); - - return $helper->generateForm(array($fields_form)); - } - - public function getConfigFieldsValues() - { - return array( - 'SE_RERESH_METHOD' => Tools::getValue('SE_RERESH_METHOD', Configuration::get('SE_RERESH_METHOD')), - ); - } -} - diff --git a/modules/carriercompare/config.xml b/modules/carriercompare/config.xml deleted file mode 100644 index 7c07a8bb2..000000000 --- a/modules/carriercompare/config.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - carriercompare - - - - - - 1 - 0 - - \ No newline at end of file diff --git a/modules/carriercompare/index.php b/modules/carriercompare/index.php deleted file mode 100644 index a230e5ac6..000000000 --- a/modules/carriercompare/index.php +++ /dev/null @@ -1,35 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); - -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); - -header("Location: ../"); -exit; \ No newline at end of file diff --git a/modules/carriercompare/loader.gif b/modules/carriercompare/loader.gif deleted file mode 100755 index cd4e37cc2..000000000 Binary files a/modules/carriercompare/loader.gif and /dev/null differ diff --git a/modules/carriercompare/logo.gif b/modules/carriercompare/logo.gif deleted file mode 100644 index 482ceea3c..000000000 Binary files a/modules/carriercompare/logo.gif and /dev/null differ diff --git a/modules/carriercompare/logo.png b/modules/carriercompare/logo.png deleted file mode 100755 index 2d9094e5e..000000000 Binary files a/modules/carriercompare/logo.png and /dev/null differ diff --git a/modules/carriercompare/style.css b/modules/carriercompare/style.css deleted file mode 100644 index 34eec6256..000000000 --- a/modules/carriercompare/style.css +++ /dev/null @@ -1,44 +0,0 @@ -#compare_shipping .center {text-align: center;} - -#compare_shipping { - padding: 10px; -} - -#compare_shipping #availableCarriers { - margin-bottom: 20px; -} - -#compare_shipping #availableCarriers_table { - margin: auto; -} - -#compare_shipping ul#carriercompare_errors_list { - color: red; -} - -#compare_shipping ul#carriercompare_errors_list li { - margin-left: 30px; - text-decoration: none; - list-style: none; -} - -#SE_AjaxDisplay -{ - text-align: center; - display: none; -} - -#SE_AjaxDisplay img -{ - width: 15px; -} - -.SE_SubmitRefreshCard -{ - text-align: center; -} - -.SE_SubmitRefreshCard input -{ - display: inline; -} \ No newline at end of file diff --git a/modules/carriercompare/template/carriercompare.tpl b/modules/carriercompare/template/carriercompare.tpl deleted file mode 100755 index 8896bbcbc..000000000 --- a/modules/carriercompare/template/carriercompare.tpl +++ /dev/null @@ -1,95 +0,0 @@ -{* -* 2007-2013 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 -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*} - -{if !$opc} - -
    -
    -

    {l s='Estimate the cost of shipping & taxes.' mod='carriercompare'}

    -

    - - -

    - -

    - - ({l s='Needed for certain carriers.' mod='carriercompare'}) -

    - -
    - Loading data
    -

    -
    - - -

    - - -

    -
    -
    -{/if} diff --git a/modules/carriercompare/template/configuration.tpl b/modules/carriercompare/template/configuration.tpl deleted file mode 100644 index f698d2846..000000000 --- a/modules/carriercompare/template/configuration.tpl +++ /dev/null @@ -1,27 +0,0 @@ -{if isset($display_error)} - {if $display_error} -
    {l s='An error occured during form validation.' mod='carriercompare'}
    - {else} -
    {l s='Configuration updated' mod='carriercompare'}
    - {/if} -{/if} - -
    -
    -
    {l s='This module is only available during the standard five-step checkout process. The carrier list has already been defined for one-page checkout. ' mod='carriercompare'}.
    - {l s='Global Configuration' mod='carriercompare'} - - -
    - -

    {l s='How would you like to refresh information for a customer?' mod='carriercompare'}

    -
    - -
    - -
    -
    -
    \ No newline at end of file diff --git a/modules/carriercompare/template/index.php b/modules/carriercompare/template/index.php deleted file mode 100644 index 3f6561f72..000000000 --- a/modules/carriercompare/template/index.php +++ /dev/null @@ -1,35 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); - -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); - -header("Location: ../"); -exit; \ No newline at end of file diff --git a/modules/carriercompare/translations/index.php b/modules/carriercompare/translations/index.php deleted file mode 100644 index 3f6561f72..000000000 --- a/modules/carriercompare/translations/index.php +++ /dev/null @@ -1,35 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); - -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); - -header("Location: ../"); -exit; \ No newline at end of file diff --git a/modules/cashondelivery/cashondelivery.gif b/modules/cashondelivery/cashondelivery.gif deleted file mode 100755 index 926ce1d7c..000000000 Binary files a/modules/cashondelivery/cashondelivery.gif and /dev/null differ diff --git a/modules/cashondelivery/cashondelivery.jpg b/modules/cashondelivery/cashondelivery.jpg deleted file mode 100755 index cb9c6a523..000000000 Binary files a/modules/cashondelivery/cashondelivery.jpg and /dev/null differ diff --git a/modules/cashondelivery/cashondelivery.php b/modules/cashondelivery/cashondelivery.php deleted file mode 100755 index 38467d993..000000000 --- a/modules/cashondelivery/cashondelivery.php +++ /dev/null @@ -1,92 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -if (!defined('_PS_VERSION_')) - exit; - -class CashOnDelivery extends PaymentModule -{ - public function __construct() - { - $this->name = 'cashondelivery'; - $this->tab = 'payments_gateways'; - $this->version = '0.4'; - $this->author = 'PrestaShop'; - $this->need_instance = 1; - - $this->currencies = false; - - parent::__construct(); - - $this->displayName = $this->l('Cash on delivery (COD)'); - $this->description = $this->l('Accept cash on delivery payments'); - - /* For 1.4.3 and less compatibility */ - $updateConfig = array('PS_OS_CHEQUE', 'PS_OS_PAYMENT', 'PS_OS_PREPARATION', 'PS_OS_SHIPPING', 'PS_OS_CANCELED', 'PS_OS_REFUND', 'PS_OS_ERROR', 'PS_OS_OUTOFSTOCK', 'PS_OS_BANKWIRE', 'PS_OS_PAYPAL', 'PS_OS_WS_PAYMENT'); - if (!Configuration::get('PS_OS_PAYMENT')) - foreach ($updateConfig as $u) - if (!Configuration::get($u) && defined('_'.$u.'_')) - Configuration::updateValue($u, constant('_'.$u.'_')); - } - - public function install() - { - if (!parent::install() OR !$this->registerHook('payment') OR !$this->registerHook('paymentReturn')) - return false; - return true; - } - - public function hookPayment($params) - { - if (!$this->active) - return ; - - global $smarty; - - // Check if cart has product download - foreach ($params['cart']->getProducts() AS $product) - { - $pd = ProductDownload::getIdFromIdProduct((int)($product['id_product'])); - if ($pd AND Validate::isUnsignedInt($pd)) - return false; - } - - $smarty->assign(array( - 'this_path' => $this->_path, //keep for retro compat - 'this_path_cod' => $this->_path, - 'this_path_ssl' => Tools::getShopDomainSsl(true, true).__PS_BASE_URI__.'modules/'.$this->name.'/' - )); - return $this->display(__FILE__, 'payment.tpl'); - } - - public function hookPaymentReturn($params) - { - if (!$this->active) - return ; - - return $this->display(__FILE__, 'confirmation.tpl'); - } -} diff --git a/modules/cashondelivery/config.xml b/modules/cashondelivery/config.xml deleted file mode 100755 index 3af2893aa..000000000 --- a/modules/cashondelivery/config.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - cashondelivery - - - - - - 0 - 1 - - \ No newline at end of file diff --git a/modules/cashondelivery/controllers/front/index.php b/modules/cashondelivery/controllers/front/index.php deleted file mode 100644 index 3f6561f72..000000000 --- a/modules/cashondelivery/controllers/front/index.php +++ /dev/null @@ -1,35 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); - -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); - -header("Location: ../"); -exit; \ No newline at end of file diff --git a/modules/cashondelivery/controllers/front/validation.php b/modules/cashondelivery/controllers/front/validation.php deleted file mode 100644 index 97ec4bbb9..000000000 --- a/modules/cashondelivery/controllers/front/validation.php +++ /dev/null @@ -1,80 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -/** - * @since 1.5.0 - */ -class CashondeliveryValidationModuleFrontController extends ModuleFrontController -{ - public $ssl = true; - public $display_column_left = false; - - public function postProcess() - { - if ($this->context->cart->id_customer == 0 || $this->context->cart->id_address_delivery == 0 || $this->context->cart->id_address_invoice == 0 || !$this->module->active) - Tools::redirectLink(__PS_BASE_URI__.'order.php?step=1'); - - // Check that this payment option is still available in case the customer changed his address just before the end of the checkout process - $authorized = false; - foreach (Module::getPaymentModules() as $module) - if ($module['name'] == 'cashondelivery') - { - $authorized = true; - break; - } - if (!$authorized) - die(Tools::displayError('This payment method is not available.')); - - $customer = new Customer($this->context->cart->id_customer); - if (!Validate::isLoadedObject($customer)) - Tools::redirectLink(__PS_BASE_URI__.'order.php?step=1'); - - if (Tools::getValue('confirm')) - { - $customer = new Customer((int)$this->context->cart->id_customer); - $total = $this->context->cart->getOrderTotal(true, Cart::BOTH); - $this->module->validateOrder((int)$this->context->cart->id, Configuration::get('PS_OS_PREPARATION'), $total, $this->module->displayName, null, array(), null, false, $customer->secure_key); - Tools::redirectLink(__PS_BASE_URI__.'order-confirmation.php?key='.$customer->secure_key.'&id_cart='.(int)$this->context->cart->id.'&id_module='.(int)$this->module->id.'&id_order='.(int)$this->module->currentOrder); - } - } - - /** - * @see FrontController::initContent() - */ - public function initContent() - { - parent::initContent(); - - $this->context->smarty->assign(array( - 'total' => $this->context->cart->getOrderTotal(true, Cart::BOTH), - 'this_path' => $this->module->getPathUri(),//keep for retro compat - 'this_path_cod' => $this->module->getPathUri(), - 'this_path_ssl' => Tools::getShopDomainSsl(true, true).__PS_BASE_URI__.'modules/'.$this->module->name.'/' - )); - - $this->setTemplate('validation.tpl'); - } -} diff --git a/modules/cashondelivery/controllers/index.php b/modules/cashondelivery/controllers/index.php deleted file mode 100644 index 3f6561f72..000000000 --- a/modules/cashondelivery/controllers/index.php +++ /dev/null @@ -1,35 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); - -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); - -header("Location: ../"); -exit; \ No newline at end of file diff --git a/modules/cashondelivery/index.php b/modules/cashondelivery/index.php deleted file mode 100755 index 3f6561f72..000000000 --- a/modules/cashondelivery/index.php +++ /dev/null @@ -1,35 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); - -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); - -header("Location: ../"); -exit; \ No newline at end of file diff --git a/modules/cashondelivery/logo.gif b/modules/cashondelivery/logo.gif deleted file mode 100755 index a08249944..000000000 Binary files a/modules/cashondelivery/logo.gif and /dev/null differ diff --git a/modules/cashondelivery/logo.png b/modules/cashondelivery/logo.png deleted file mode 100644 index 2b7b2685a..000000000 Binary files a/modules/cashondelivery/logo.png and /dev/null differ diff --git a/modules/cashondelivery/translations/index.php b/modules/cashondelivery/translations/index.php deleted file mode 100644 index 3f6561f72..000000000 --- a/modules/cashondelivery/translations/index.php +++ /dev/null @@ -1,35 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); - -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); - -header("Location: ../"); -exit; \ No newline at end of file diff --git a/modules/cashondelivery/views/index.php b/modules/cashondelivery/views/index.php deleted file mode 100644 index 3f6561f72..000000000 --- a/modules/cashondelivery/views/index.php +++ /dev/null @@ -1,35 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); - -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); - -header("Location: ../"); -exit; \ No newline at end of file diff --git a/modules/cashondelivery/views/templates/front/index.php b/modules/cashondelivery/views/templates/front/index.php deleted file mode 100644 index 3f6561f72..000000000 --- a/modules/cashondelivery/views/templates/front/index.php +++ /dev/null @@ -1,35 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); - -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); - -header("Location: ../"); -exit; \ No newline at end of file diff --git a/modules/cashondelivery/views/templates/front/validation.tpl b/modules/cashondelivery/views/templates/front/validation.tpl deleted file mode 100755 index 9ea4c7d13..000000000 --- a/modules/cashondelivery/views/templates/front/validation.tpl +++ /dev/null @@ -1,57 +0,0 @@ -{* -* 2007-2013 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 -* @copyright 2007-2013 PrestaShop SA -* @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='Shipping' mod='cashondelivery'}{/capture} -{include file="$tpl_dir./breadcrumb.tpl"} - -

    {l s='Order summation' mod='cashondelivery'}

    - -{assign var='current_step' value='payment'} -{include file="$tpl_dir./order-steps.tpl"} - -

    {l s='Cash on delivery (COD) payment' mod='cashondelivery'}

    - -
    - -

    - {l s='Cash on delivery (COD) payment' mod='cashondelivery'} - {l s='You have chosen the cash on delivery method.' mod='cashondelivery'} -

    - {l s='The total amount of your order is' mod='cashondelivery'} - {convertPrice price=$total} - {if $use_taxes == 1} - {l s='(tax incl.)' mod='cashondelivery'} - {/if} -

    -

    -

    -

    - {l s='Please confirm your order by clicking \'I confirm my order\'' mod='cashondelivery'}. -

    -

    - {l s='Other payment methods' mod='cashondelivery'} - -

    -
    diff --git a/modules/cashondelivery/views/templates/hook/confirmation.tpl b/modules/cashondelivery/views/templates/hook/confirmation.tpl deleted file mode 100755 index 2081949c9..000000000 --- a/modules/cashondelivery/views/templates/hook/confirmation.tpl +++ /dev/null @@ -1,31 +0,0 @@ -{* -* 2007-2013 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 -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*} - -

    {l s='Your order on' mod='cashondelivery'} {$shop_name} {l s='is complete.' mod='cashondelivery'} -

    - {l s='You have chosen the cash on delivery method.' mod='cashondelivery'} -

    {l s='Your order will be sent very soon.' mod='cashondelivery'} -

    {l s='For any questions or for further information, please contact our' mod='cashondelivery'} {l s='customer support' mod='cashondelivery'}. -

    diff --git a/modules/cashondelivery/views/templates/hook/index.php b/modules/cashondelivery/views/templates/hook/index.php deleted file mode 100644 index 3f6561f72..000000000 --- a/modules/cashondelivery/views/templates/hook/index.php +++ /dev/null @@ -1,35 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); - -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); - -header("Location: ../"); -exit; \ No newline at end of file diff --git a/modules/cashondelivery/views/templates/hook/payment.tpl b/modules/cashondelivery/views/templates/hook/payment.tpl deleted file mode 100755 index b0f1854bd..000000000 --- a/modules/cashondelivery/views/templates/hook/payment.tpl +++ /dev/null @@ -1,33 +0,0 @@ -{* -* 2007-2013 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 -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*} - -

    - - {l s='Pay with cash on delivery (COD)' mod='cashondelivery'} -
    {l s='Pay with cash on delivery (COD)' mod='cashondelivery'} -
    {l s='You pay for the merchandise upon delivery' mod='cashondelivery'} -
    -
    -

    \ No newline at end of file diff --git a/modules/cashondelivery/views/templates/index.php b/modules/cashondelivery/views/templates/index.php deleted file mode 100644 index 3f6561f72..000000000 --- a/modules/cashondelivery/views/templates/index.php +++ /dev/null @@ -1,35 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); - -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); - -header("Location: ../"); -exit; \ No newline at end of file diff --git a/modules/dateofdelivery/beforeCarrier.tpl b/modules/dateofdelivery/beforeCarrier.tpl deleted file mode 100644 index 9235a59f9..000000000 --- a/modules/dateofdelivery/beforeCarrier.tpl +++ /dev/null @@ -1,91 +0,0 @@ -{* -* 2007-2013 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 -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*} - -{if $datesDelivery|count} - - -
    -

    - {if $nbPackages <= 1} - {l s='Approximate date of delivery with this carrier is between' mod='dateofdelivery'} - {else} - {l s='There are %s packages, that will be approximately delivered with the delivery option you choose between' sprintf=$nbPackages mod='dateofdelivery'} - {/if} - {l s='and' mod='dateofdelivery'} * -
    - * {l s='with direct payment methods (e.g. credit card)' mod='dateofdelivery'} -

    -{/if} diff --git a/modules/dateofdelivery/config.xml b/modules/dateofdelivery/config.xml deleted file mode 100755 index 9fb0e47c3..000000000 --- a/modules/dateofdelivery/config.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - dateofdelivery - - - - - - 1 - 0 - - \ No newline at end of file diff --git a/modules/dateofdelivery/dateofdelivery.php b/modules/dateofdelivery/dateofdelivery.php deleted file mode 100644 index 4524db85f..000000000 --- a/modules/dateofdelivery/dateofdelivery.php +++ /dev/null @@ -1,709 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -if (!defined('_PS_VERSION_')) - exit; - -class DateOfDelivery extends Module -{ - private $_html = ''; - - public function __construct() - { - $this->name = 'dateofdelivery'; - $this->tab = 'shipping_logistics'; - $this->version = '1.2'; - $this->author = 'PrestaShop'; - $this->need_instance = 0; - - $this->bootstrap = true; - parent::__construct(); - - $this->displayName = $this->l('Date of delivery'); - $this->description = $this->l('Displays an approximate date of delivery'); - } - - public function install() - { - if (!parent::install() - || !$this->registerHook('beforeCarrier') - || !$this->registerHook('orderDetailDisplayed') - ||!$this->registerHook('displayPDFInvoice')) - return false; - - if (!Db::getInstance()->execute(' - CREATE TABLE IF NOT EXISTS `'._DB_PREFIX_.'dateofdelivery_carrier_rule` ( - `id_carrier_rule` INT NOT NULL AUTO_INCREMENT PRIMARY KEY, - `id_carrier` INT NOT NULL, - `minimal_time` INT NOT NULL, - `maximal_time` INT NOT NULL, - `delivery_saturday` TINYINT(1) NOT NULL, - `delivery_sunday` TINYINT(1) NOT NULL - ) ENGINE ='._MYSQL_ENGINE_.'; - ')) - return false; - - Configuration::updateValue('DOD_EXTRA_TIME_PRODUCT_OOS', 0); - Configuration::updateValue('DOD_EXTRA_TIME_PREPARATION', 1); - Configuration::updateValue('DOD_PREPARATION_SATURDAY', 1); - Configuration::updateValue('DOD_PREPARATION_SUNDAY', 1); - Configuration::updateValue('DOD_DATE_FORMAT', 'l j F Y'); - - return true; - } - - public function uninstall() - { - Configuration::deleteByName('DOD_EXTRA_TIME_PRODUCT_OOS'); - Configuration::deleteByName('DOD_EXTRA_TIME_PREPARATION'); - Configuration::deleteByName('DOD_PREPARATION_SATURDAY'); - Configuration::deleteByName('DOD_PREPARATION_SUNDAY'); - Configuration::deleteByName('DOD_DATE_FORMAT'); - Db::getInstance()->execute('DROP TABLE IF EXISTS `'._DB_PREFIX_.'dateofdelivery_carrier_rule`'); - - return parent::uninstall(); - } - - public function getContent() - { - $this->_html .= ''; - - $this->_postProcess(); - if (Tools::isSubmit('addCarrierRule') OR (Tools::isSubmit('updatedateofdelivery') AND Tools::isSubmit('id_carrier_rule'))) - $this->_html .= $this->renderAddForm(); - else - { - $this->_html .= $this->renderList(); - $this->_html .= $this->renderForm(); - } - - - return $this->_html; - } - - public function hookBeforeCarrier($params) - { - if (!isset($params['delivery_option_list']) || !count($params['delivery_option_list'])) - return false; - - $package_list = $params['cart']->getPackageList(); - - $datesDelivery = array(); - foreach ($params['delivery_option_list'] as $id_address => $by_address) - { - $datesDelivery[$id_address] = array(); - foreach ($by_address as $key => $delivery_option) - { - $date_from = null; - $date_to = null; - $datesDelivery[$id_address][$key] = array(); - - foreach ($delivery_option['carrier_list'] as $id_carrier => $carrier) - { - foreach ($carrier['package_list'] as $id_package) - { - $package = $package_list[$id_address][$id_package]; - $oos = false; // For out of stock management - foreach ($package['product_list'] as $product) - if (StockAvailable::getQuantityAvailableByProduct($product['id_product'], ($product['id_product_attribute'] ? (int)$product['id_product_attribute'] : null), (int)$this->context->shop->id) <= 0) - { - $oos = true; - break; - } - $available_date = Product::getAvailableDate($product['id_product'], ($product['id_product_attribute'] ? (int)$product['id_product_attribute'] : null), (int)$this->context->shop->id); - $date_range = $this->_getDatesOfDelivery($id_carrier, $oos, $available_date); - if (is_null($date_from) || $date_from < $date_range[0]) - { - $date_from = $date_range[0][1]; - $datesDelivery[$id_address][$key][0] = $date_range[0]; - } - if (is_null($date_to) || $date_to < $date_range[1]) - { - $date_to = $date_range[1][1]; - $datesDelivery[$id_address][$key][1] = $date_range[1]; - } - } - } - } - } - $this->smarty->assign(array( - 'nbPackages' => $params['cart']->getNbOfPackages(), - 'datesDelivery' => $datesDelivery, - 'delivery_option' => $params['delivery_option'] - )); - - return $this->display(__FILE__, 'beforeCarrier.tpl'); - } - - public function hookOrderDetailDisplayed($params) - { - - $oos = false; // For out of stock management - foreach ($params['order']->getProducts() as $product) - if ($product['product_quantity_in_stock'] < 1) - $oos = true; - - $datesDelivery = array(); - $datesDelivery = $this->_getDatesOfDelivery((int)($params['order']->id_carrier), $oos, $params['order']->date_add); - - if (!is_array($datesDelivery) OR !sizeof($datesDelivery)) - return ; - - $this->smarty->assign('datesDelivery', $datesDelivery); - - return $this->display(__FILE__, 'orderDetail.tpl'); - } - - /** - * Displays the delivery dates on the invoice - * - * @param $params contains an instance of OrderInvoice - * @return string - * - */ - public function hookDisplayPDFInvoice($params) - { - $order_invoice = $params['object']; - if (!($order_invoice instanceof OrderInvoice)) - return; - - $order = new Order((int)$order_invoice->id_order); - - $oos = false; // For out of stock management - foreach ($order->getProducts() as $product) - if ($product['product_quantity_in_stock'] < 1) - $oos = true; - - $id_carrier = (int)OrderInvoice::getCarrierId($order_invoice->id); - $return = ''; - if (($datesDelivery = $this->_getDatesOfDelivery($id_carrier, $oos, $order_invoice->date_add)) && isset($datesDelivery[0][0]) && isset($datesDelivery[1][0])) - $return = sprintf($this->l('Approximate date of delivery is between %1$s and %2$s'), $datesDelivery[0][0], $datesDelivery[1][0]); - - return $return; - } - - private function _postProcess() - { - $errors = array(); - if (Tools::isSubmit('submitMoreOptions')) - { - if (Tools::getValue('date_format') == '' OR !Validate::isCleanHtml(Tools::getValue('date_format'))) - $errors[] = $this->l('Date format is invalid'); - - if (!sizeof($errors)) - { - Configuration::updateValue('DOD_EXTRA_TIME_PRODUCT_OOS', (int)Tools::getValue('extra_time_product_oos')); - Configuration::updateValue('DOD_EXTRA_TIME_PREPARATION', (int)Tools::getValue('extra_time_preparation')); - Configuration::updateValue('DOD_PREPARATION_SATURDAY', (int)Tools::getValue('preparation_day_preparation_saturday')); - Configuration::updateValue('DOD_PREPARATION_SUNDAY', (int)Tools::getValue('preparation_day_preparation_sunday')); - Configuration::updateValue('DOD_DATE_FORMAT', Tools::getValue('date_format')); - $this->_html .= $this->displayConfirmation($this->l('Settings are updated')); - } - else - $this->_html .= $this->displayError(implode('
    ', $errors)); - } - - if (Tools::isSubmit('submitCarrierRule')) - { - if (!Validate::isUnsignedInt(Tools::getValue('minimal_time'))) - $errors[] = $this->l('Minimum time is invalid'); - if (!Validate::isUnsignedInt(Tools::getValue('maximal_time'))) - $errors[] = $this->l('Maximum time is invalid'); - if (($carrier = new Carrier((int)Tools::getValue('id_carrier'))) AND !Validate::isLoadedObject($carrier)) - $errors[] = $this->l('Carrier is invalid'); - if ($this->_isAlreadyDefinedForCarrier((int)($carrier->id), (int)(Tools::getValue('id_carrier_rule', 0)))) - $errors[] = $this->l('You cannot use this carrier, a rule has already been saved.'); - - if (!sizeof($errors)) - { - if (Tools::isSubmit('addCarrierRule')) - { - if (Db::getInstance()->execute(' - INSERT INTO `'._DB_PREFIX_.'dateofdelivery_carrier_rule`(`id_carrier`, `minimal_time`, `maximal_time`, `delivery_saturday`, `delivery_sunday`) - VALUES ('.(int)($carrier->id).', '.(int)Tools::getValue('minimal_time').', '.(int)Tools::getValue('maximal_time').', '.(int)Tools::isSubmit('preparation_day_delivery_saturday').', '.(int)Tools::isSubmit('preparation_day_delivery_sunday').') - ')) - Tools::redirectAdmin(AdminController::$currentIndex.'&configure='.$this->name.'&token='.Tools::getAdminTokenLite('AdminModules').'&confirmAddCarrierRule'); - else - $this->_html .= $this->displayError($this->l('An error occurred on adding of carrier rule.')); - } - else - { - if (Db::getInstance()->execute(' - UPDATE `'._DB_PREFIX_.'dateofdelivery_carrier_rule` - SET `id_carrier` = '.(int)($carrier->id).', `minimal_time` = '.(int)Tools::getValue('minimal_time').', `maximal_time` = '.(int)Tools::getValue('maximal_time').', `delivery_saturday` = '.(int)Tools::isSubmit('preparation_day_delivery_saturday').', `delivery_sunday` = '.(int)Tools::isSubmit('preparation_day_delivery_sunday').' - WHERE `id_carrier_rule` = '.(int)Tools::getValue('id_carrier_rule') - )) - Tools::redirectAdmin(AdminController::$currentIndex.'&configure='.$this->name.'&token='.Tools::getAdminTokenLite('AdminModules').'&confirmupdatedateofdelivery'); - else - $this->_html .= $this->displayError($this->l('An error occurred on updating of carrier rule.')); - } - - } - else - $this->_html .= $this->displayError(implode('
    ', $errors)); - } - - if (Tools::isSubmit('deletedateofdelivery') AND Tools::isSubmit('id_carrier_rule') AND (int)Tools::getValue('id_carrier_rule') AND $this->_isCarrierRuleExists((int)Tools::getValue('id_carrier_rule'))) - { - $this->_deleteByIdCarrierRule((int)Tools::getValue('id_carrier_rule')); - $this->_html .= $this->displayConfirmation($this->l('Carrier rule deleted successfully')); - } - - if (Tools::isSubmit('confirmAddCarrierRule')) - $this->_html = $this->displayConfirmation($this->l('Carrier rule added successfully')); - - if (Tools::isSubmit('confirmupdatedateofdelivery')) - $this->_html = $this->displayConfirmation($this->l('Carrier rule updated successfully')); - } - - private function _getCarrierRulesWithCarrierName() - { - return Db::getInstance()->executeS(' - SELECT * - FROM `'._DB_PREFIX_.'dateofdelivery_carrier_rule` dcr - LEFT JOIN `'._DB_PREFIX_.'carrier` c ON (c.`id_carrier` = dcr.`id_carrier`) - '); - } - - private function _getCarrierRule($id_carrier_rule) - { - if (!(int)($id_carrier_rule)) - return false; - return Db::getInstance()->getRow(' - SELECT * - FROM `'._DB_PREFIX_.'dateofdelivery_carrier_rule` - WHERE `id_carrier_rule` = '.(int)($id_carrier_rule) - ); - } - - private function _getCarrierRuleWithIdCarrier($id_carrier) - { - if (!(int)($id_carrier)) - return false; - return Db::getInstance()->getRow(' - SELECT * - FROM `'._DB_PREFIX_.'dateofdelivery_carrier_rule` - WHERE `id_carrier` = '.(int)($id_carrier) - ); - } - - private function _isCarrierRuleExists($id_carrier_rule) - { - if (!(int)($id_carrier_rule)) - return false; - return (bool)Db::getInstance()->getValue(' - SELECT COUNT(*) - FROM `'._DB_PREFIX_.'dateofdelivery_carrier_rule` - WHERE `id_carrier_rule` = '.(int)($id_carrier_rule) - ); - } - - private function _deleteByIdCarrierRule($id_carrier_rule) - { - if (!(int)($id_carrier_rule)) - return false; - return Db::getInstance()->execute(' - DELETE FROM `'._DB_PREFIX_.'dateofdelivery_carrier_rule` - WHERE `id_carrier_rule` = '.(int)($id_carrier_rule) - ); - } - - private function _isAlreadyDefinedForCarrier($id_carrier, $id_carrier_rule = 0) - { - if (!(int)($id_carrier)) - return false; - return (bool)Db::getInstance()->getValue(' - SELECT COUNT(*) - FROM `'._DB_PREFIX_.'dateofdelivery_carrier_rule` - WHERE `id_carrier` = '.(int)($id_carrier).' - '.((int)$id_carrier_rule != 0 ? 'AND `id_carrier_rule` != '.(int)($id_carrier_rule) : '')); - } - - /** - * @param int $id_carrier - * @param bool $product_oos - * @param string $date - * - * @return array|bool returns the min & max delivery date - */ - private function _getDatesOfDelivery($id_carrier, $product_oos = false, $date = null) - { - if (!(int)($id_carrier)) - return false; - $carrier_rule = $this->_getCarrierRuleWithIdCarrier((int)($id_carrier)); - if (empty($carrier_rule)) - return false; - - if ($date != null AND Validate::isDate($date)) - $date_now = strtotime($date); - else - $date_now = time(); // Date on timestamp format - if ($product_oos) - $date_now += Configuration::get('DOD_EXTRA_TIME_PRODUCT_OOS') * 24 * 3600; - if (!Configuration::get('DOD_PREPARATION_SATURDAY') AND date('l', $date_now) == 'Saturday') - $date_now += 24 * 3600; - if (!Configuration::get('DOD_PREPARATION_SUNDAY') AND date('l', $date_now) == 'Sunday') - $date_now += 24 * 3600; - - $date_minimal_time = $date_now + ($carrier_rule['minimal_time'] * 24 * 3600) + (Configuration::get('DOD_EXTRA_TIME_PREPARATION') * 24 * 3600); - $date_maximal_time = $date_now + ($carrier_rule['maximal_time'] * 24 * 3600) + (Configuration::get('DOD_EXTRA_TIME_PREPARATION') * 24 * 3600); - - if (!$carrier_rule['delivery_saturday'] AND date('l', $date_minimal_time) == 'Saturday') - { - $date_minimal_time += 24 * 3600; - $date_maximal_time += 24 * 3600; - } - if (!$carrier_rule['delivery_saturday'] AND date('l', $date_maximal_time) == 'Saturday') - $date_maximal_time += 24 * 3600; - - if (!$carrier_rule['delivery_sunday'] AND date('l', $date_minimal_time) == 'Sunday') - { - $date_minimal_time += 24 * 3600; - $date_maximal_time += 24 * 3600; - } - if (!$carrier_rule['delivery_sunday'] AND date('l', $date_maximal_time) == 'Sunday') - $date_maximal_time += 24 * 3600; - - /* - - // Do not remove this commentary, it's usefull to allow translations of months and days in the translator tool - - $this->l('Sunday'); - $this->l('Monday'); - $this->l('Tuesday'); - $this->l('Wednesday'); - $this->l('Thursday'); - $this->l('Friday'); - $this->l('Saturday'); - - $this->l('January'); - $this->l('February'); - $this->l('March'); - $this->l('April'); - $this->l('May'); - $this->l('June'); - $this->l('July'); - $this->l('August'); - $this->l('September'); - $this->l('October'); - $this->l('November'); - $this->l('December'); - */ - - $date_minimal_string = ''; - $date_maximal_string = ''; - $date_format = preg_split('/([a-z])/Ui', Configuration::get('DOD_DATE_FORMAT'), NULL, PREG_SPLIT_DELIM_CAPTURE); - foreach ($date_format as $elmt) - { - if ($elmt == 'l' OR $elmt == 'F') - { - $date_minimal_string .= $this->l(date($elmt, $date_minimal_time)); - $date_maximal_string .= $this->l(date($elmt, $date_maximal_time)); - } - elseif (preg_match('/[a-z]/Ui', $elmt)) - { - $date_minimal_string .= date($elmt, $date_minimal_time); - $date_maximal_string .= date($elmt, $date_maximal_time); - } - else - { - $date_minimal_string .= $elmt; - $date_maximal_string .= $elmt; - } - } - return array( - array( - $date_minimal_string, - $date_minimal_time - ), - array( - $date_maximal_string, - $date_maximal_time - ) - ); - } - - public function renderForm() - { - $fields_form = array( - 'form' => array( - 'legend' => array( - 'title' => $this->l('Settings'), - 'icon' => 'icon-cogs' - ), - 'input' => array( - array( - 'type' => 'text', - 'label' => $this->l('Extra time when a product is out of stock'), - 'name' => 'extra_time_product_oos', - 'suffix' => $this->l('day(s)'), - ), - array( - 'type' => 'text', - 'label' => $this->l('Extra time for preparation of the order'), - 'name' => 'extra_time_preparation', - 'suffix' => $this->l('day(s)'), - ), - array( - 'type' => 'checkbox', - 'label' => $this->l('Preparation option'), - 'name' => 'preparation_day', - 'values' => array( - 'id' => 'id', - 'name' => 'name', - 'query' => array( - array( - 'id' => 'preparation_saturday', - 'name' => $this->l('Saturday preparation'), - 'val' => 1 - ), - array( - 'id' => 'preparation_sunday', - 'name' => $this->l('Sunday preparation'), - 'val' => 1 - ), - ), - ) - ), - array( - 'type' => 'text', - 'label' => $this->l('Date format:'), - 'name' => 'date_format', - 'desc' => $this->l('You can see all parameters available at:').' http://www.php.net/manual/en/function.date.php', - ), - ), - 'submit' => array( - 'title' => $this->l('Save'), - 'class' => 'btn btn-default') - ), - ); - - $helper = new HelperForm(); - $helper->show_toolbar = false; - $helper->table = $this->table; - $lang = new Language((int)Configuration::get('PS_LANG_DEFAULT')); - $helper->default_form_language = $lang->id; - $helper->allow_employee_form_lang = Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG') ? Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG') : 0; - $this->fields_form = array(); - - $helper->identifier = $this->identifier; - $helper->submit_action = 'submitMoreOptions'; - $helper->currentIndex = $this->context->link->getAdminLink('AdminModules', false).'&configure='.$this->name.'&tab_module='.$this->tab.'&module_name='.$this->name; - $helper->token = Tools::getAdminTokenLite('AdminModules'); - $helper->tpl_vars = array( - 'fields_value' => $this->getConfigFieldsValues(), - 'languages' => $this->context->controller->getLanguages(), - 'id_language' => $this->context->language->id - ); - - return $helper->generateForm(array($fields_form)); - } - - public function renderAddForm() - { - $carriers = Carrier::getCarriers($this->context->language->id, true, false, false, null, Carrier::ALL_CARRIERS); - - foreach ($carriers as $key => $val) - $carriers[$key]['name'] = (!$val['name'] ? Configuration::get('PS_SHOP_NAME') : $val['name']); - - $fields_form = array( - 'form' => array( - 'legend' => array( - 'title' => $this->l('Settings'), - 'icon' => 'icon-cogs' - ), - 'input' => array( - array( - 'type' => 'select', - 'label' => $this->l('Carrier :'), - 'name' => 'id_carrier', - 'options' => array( - 'query' => $carriers, - 'id' => 'id_carrier', - 'name' => 'name' - ) - ), - array( - 'type' => 'text', - 'label' => $this->l('Delivery between'), - 'name' => 'minimal_time', - 'suffix' => $this->l('day(s)'), - ), - array( - 'type' => 'text', - 'label' => $this->l(''), - 'name' => 'maximal_time', - 'suffix' => $this->l('day(s)'), - ), - array( - 'type' => 'checkbox', - 'label' => $this->l('Preparation option'), - 'name' => 'preparation_day', - 'values' => array( - 'id' => 'id', - 'name' => 'name', - 'query' => array( - array( - 'id' => 'delivery_saturday', - 'name' => $this->l('Saturday preparation'), - 'val' => 1 - ), - array( - 'id' => 'delivery_sunday', - 'name' => $this->l('Sunday preparation'), - 'val' => 1 - ), - ), - ) - ) - ), - 'submit' => array( - 'title' => $this->l('Save'), - 'class' => 'btn btn-default', - 'name' => 'submitCarrierRule', - ) - ), - ); - - if (Tools::getValue('id_carrier_rule') && $this->_isCarrierRuleExists(Tools::getValue('id_carrier_rule'))) - $fields_form['form']['input'][] = array('type' => 'hidden', 'name' => 'id_carrier_rule'); - - $helper = new HelperForm(); - $helper->show_toolbar = false; - $helper->table = $this->table; - $lang = new Language((int)Configuration::get('PS_LANG_DEFAULT')); - $helper->default_form_language = $lang->id; - $helper->allow_employee_form_lang = Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG') ? Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG') : 0; - $this->fields_form = array(); - - $helper->identifier = $this->identifier; - - if (Tools::getValue('id_carrier_rule')) - $helper->submit_action = 'updatedateofdelivery'; - else - $helper->submit_action = 'addCarrierRule'; - $helper->currentIndex = $this->context->link->getAdminLink('AdminModules', false).'&configure='.$this->name.'&tab_module='.$this->tab.'&module_name='.$this->name; - $helper->token = Tools::getAdminTokenLite('AdminModules'); - $helper->tpl_vars = array( - 'fields_value' => $this->getCarrierRuleFieldsValues(), - 'languages' => $this->context->controller->getLanguages(), - 'id_language' => $this->context->language->id - ); - - return $helper->generateForm(array($fields_form)); - } - - public function getConfigFieldsValues() - { - return array( - 'extra_time_product_oos' => Tools::getValue('extra_time_product_oos', Configuration::get('DOD_EXTRA_TIME_PRODUCT_OOS')), - 'extra_time_preparation' => Tools::getValue('extra_time_preparation', Configuration::get('DOD_EXTRA_TIME_PREPARATION')), - 'preparation_day_preparation_saturday' => Tools::getValue('preparation_day_preparation_saturday', Configuration::get('DOD_PREPARATION_SATURDAY')), - 'preparation_day_preparation_sunday' => Tools::getValue('preparation_day_preparation_sunday', Configuration::get('DOD_PREPARATION_SUNDAY')), - 'date_format' => Tools::getValue('date_format', Configuration::get('DOD_DATE_FORMAT')), - 'id_carrier' => Tools::getValue('id_carrier'), - ); - } - - public function getCarrierRuleFieldsValues() - { - $fields = array( - 'id_carrier_rule' => Tools::getValue('id_carrier_rule'), - 'id_carrier' => Tools::getValue('id_carrier'), - 'minimal_time' => Tools::getValue('minimal_time'), - 'maximal_time' => Tools::getValue('maximal_time'), - 'delivery_saturday' => Tools::getValue('delivery_saturday'), - 'delivery_sunday' => Tools::getValue('delivery_sunday'), - ); - - if (Tools::isSubmit('updatedateofdelivery') AND $this->_isCarrierRuleExists(Tools::getValue('id_carrier_rule'))) - { - $carrier_rule = $this->_getCarrierRule(Tools::getValue('id_carrier_rule')); - - $fields['id_carrier_rule'] = Tools::getValue('id_carrier_rule', $carrier_rule['id_carrier_rule']); - $fields['id_carrier'] = Tools::getValue('id_carrier', $carrier_rule['id_carrier']); - $fields['minimal_time'] = Tools::getValue('minimal_time', $carrier_rule['minimal_time']); - $fields['maximal_time'] = Tools::getValue('maximal_time', $carrier_rule['maximal_time']); - $fields['preparation_day_delivery_saturday'] = Tools::getValue('preparation_day_delivery_saturday', $carrier_rule['delivery_saturday']); - $fields['preparation_day_delivery_sunday'] = Tools::getValue('preparation_day_delivery_sunday', $carrier_rule['delivery_sunday']); - } - - return $fields; - } - - public function renderList() - { - - $add_url = $this->context->link->getAdminLink('AdminModules').'&configure='.$this->name.'&addCarrierRule=1'; - - $fields_list = array( - 'name' => array( - 'title' => $this->l('Name of carrier'), - 'type' => 'text', - ), - 'delivery_between' => array( - 'title' => $this->l('Delivery between'), - 'type' => 'text', - ), - 'delivery_saturday' => array( - 'title' => $this->l('Saturday delivery'), - 'type' => 'bool', - 'align' => 'center', - 'active' => 'status', - ), - 'delivery_sunday' => array( - 'title' => $this->l('Sunday delivery'), - 'type' => 'bool', - 'align' => 'center', - 'active' => 'status', - ), - ); - $list = $this->_getCarrierRulesWithCarrierName(); - - foreach ($list as $key => $val) - { - if (!$val['name']) - $list[$key]['name'] = Configuration::get('PS_SHOP_NAME'); - $list[$key]['delivery_between'] = sprintf($this->l('%1$d day(s) and %2$d day(s)'), $val['minimal_time'], $val['maximal_time']); - } - - $helper = new HelperList(); - $helper->shopLinkType = ''; - $helper->simple_header = true; - $helper->identifier = 'id_carrier_rule'; - $helper->actions = array('edit', 'delete'); - $helper->show_toolbar = false; - - $helper->title = $this->l('Link list'); - $helper->table = $this->name; - $helper->token = Tools::getAdminTokenLite('AdminModules'); - $helper->currentIndex = AdminController::$currentIndex.'&configure='.$this->name; - - $this->context->smarty->assign(array('add_url' => $add_url)); - - return $this->display(__FILE__, 'button.tpl').$helper->generateList($list, $fields_list).$this->display(__FILE__, 'button.tpl'); - } -} \ No newline at end of file diff --git a/modules/dateofdelivery/img/cross.png b/modules/dateofdelivery/img/cross.png deleted file mode 100755 index 1514d51a3..000000000 Binary files a/modules/dateofdelivery/img/cross.png and /dev/null differ diff --git a/modules/dateofdelivery/img/index.php b/modules/dateofdelivery/img/index.php deleted file mode 100644 index 3f6561f72..000000000 --- a/modules/dateofdelivery/img/index.php +++ /dev/null @@ -1,35 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); - -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); - -header("Location: ../"); -exit; \ No newline at end of file diff --git a/modules/dateofdelivery/img/tick.png b/modules/dateofdelivery/img/tick.png deleted file mode 100755 index a9925a06a..000000000 Binary files a/modules/dateofdelivery/img/tick.png and /dev/null differ diff --git a/modules/dateofdelivery/img/time.png b/modules/dateofdelivery/img/time.png deleted file mode 100755 index 911da3f1d..000000000 Binary files a/modules/dateofdelivery/img/time.png and /dev/null differ diff --git a/modules/dateofdelivery/img/time_add.png b/modules/dateofdelivery/img/time_add.png deleted file mode 100755 index dcc45cb22..000000000 Binary files a/modules/dateofdelivery/img/time_add.png and /dev/null differ diff --git a/modules/dateofdelivery/img/time_delete.png b/modules/dateofdelivery/img/time_delete.png deleted file mode 100755 index 5bf8313c6..000000000 Binary files a/modules/dateofdelivery/img/time_delete.png and /dev/null differ diff --git a/modules/dateofdelivery/index.php b/modules/dateofdelivery/index.php deleted file mode 100644 index 3f6561f72..000000000 --- a/modules/dateofdelivery/index.php +++ /dev/null @@ -1,35 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); - -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); - -header("Location: ../"); -exit; \ No newline at end of file diff --git a/modules/dateofdelivery/logo.gif b/modules/dateofdelivery/logo.gif deleted file mode 100644 index 321c583ad..000000000 Binary files a/modules/dateofdelivery/logo.gif and /dev/null differ diff --git a/modules/dateofdelivery/logo.png b/modules/dateofdelivery/logo.png deleted file mode 100755 index 2b5502d0b..000000000 Binary files a/modules/dateofdelivery/logo.png and /dev/null differ diff --git a/modules/dateofdelivery/orderDetail.tpl b/modules/dateofdelivery/orderDetail.tpl deleted file mode 100644 index 5a55ca505..000000000 --- a/modules/dateofdelivery/orderDetail.tpl +++ /dev/null @@ -1,28 +0,0 @@ -{* -* 2007-2013 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 -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*} -{if $datesDelivery|count} -

    {l s='Approximate date of delivery is between %1$s and %2$s' sprintf=[$datesDelivery.0.0, $datesDelivery.1.0] mod='dateofdelivery'} *

    -

    * {l s='with direct payment methods (e.g. credit card)' mod='dateofdelivery'}

    -{/if} \ No newline at end of file diff --git a/modules/dateofdelivery/translations/index.php b/modules/dateofdelivery/translations/index.php deleted file mode 100644 index 3f6561f72..000000000 --- a/modules/dateofdelivery/translations/index.php +++ /dev/null @@ -1,35 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); - -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); - -header("Location: ../"); -exit; \ No newline at end of file diff --git a/modules/dateofdelivery/views/index.php b/modules/dateofdelivery/views/index.php deleted file mode 100644 index fd6bae0d3..000000000 --- a/modules/dateofdelivery/views/index.php +++ /dev/null @@ -1,35 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); -header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); - -header('Cache-Control: no-store, no-cache, must-revalidate'); -header('Cache-Control: post-check=0, pre-check=0', false); -header('Pragma: no-cache'); - -header('Location: ../../../'); -exit; \ No newline at end of file diff --git a/modules/dateofdelivery/views/templates/hook/button.tpl b/modules/dateofdelivery/views/templates/hook/button.tpl deleted file mode 100644 index b001326e0..000000000 --- a/modules/dateofdelivery/views/templates/hook/button.tpl +++ /dev/null @@ -1,31 +0,0 @@ -{* -* 2007-2013 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 -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*} - - -
    \ No newline at end of file diff --git a/modules/dateofdelivery/views/templates/hook/index.php b/modules/dateofdelivery/views/templates/hook/index.php deleted file mode 100644 index c7a193905..000000000 --- a/modules/dateofdelivery/views/templates/hook/index.php +++ /dev/null @@ -1,35 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); -header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); - -header('Cache-Control: no-store, no-cache, must-revalidate'); -header('Cache-Control: post-check=0, pre-check=0', false); -header('Pragma: no-cache'); - -header('Location: ../../../../../'); -exit; \ No newline at end of file diff --git a/modules/dateofdelivery/views/templates/index.php b/modules/dateofdelivery/views/templates/index.php deleted file mode 100644 index 3f4b16e7e..000000000 --- a/modules/dateofdelivery/views/templates/index.php +++ /dev/null @@ -1,35 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); -header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); - -header('Cache-Control: no-store, no-cache, must-revalidate'); -header('Cache-Control: post-check=0, pre-check=0', false); -header('Pragma: no-cache'); - -header('Location: ../../../../'); -exit; \ No newline at end of file diff --git a/modules/editorial/EditorialClass.php b/modules/editorial/EditorialClass.php deleted file mode 100755 index 5b3d05349..000000000 --- a/modules/editorial/EditorialClass.php +++ /dev/null @@ -1,91 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -class EditorialClass extends ObjectModel -{ - /** @var integer editorial id*/ - public $id; - - /** @var integer editorial id shop*/ - public $id_shop; - - /** @var string body_title*/ - public $body_home_logo_link; - - /** @var string body_title*/ - public $body_title; - - /** @var string body_title*/ - public $body_subheading; - - /** @var string body_title*/ - public $body_paragraph; - - /** @var string body_title*/ - public $body_logo_subheading; - - /** - * @see ObjectModel::$definition - */ - public static $definition = array( - 'table' => 'editorial', - 'primary' => 'id_editorial', - 'multilang' => true, - 'fields' => array( - 'id_shop' => array('type' => self::TYPE_INT, 'validate' => 'isunsignedInt', 'required' => true), - 'body_home_logo_link' => array('type' => self::TYPE_STRING, 'validate' => 'isUrl'), - // Lang fields - 'body_title' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName'), - 'body_subheading' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName'), - 'body_paragraph' => array('type' => self::TYPE_HTML, 'lang' => true, 'validate' => 'isString'), - 'body_logo_subheading' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName'), - ) - ); - - static public function getByIdShop($id_shop) - { - $id = Db::getInstance()->getValue('SELECT `id_editorial` FROM `'._DB_PREFIX_.'editorial` WHERE `id_shop` ='.(int)$id_shop); - return new EditorialClass($id); - } - - public function copyFromPost() - { - /* Classical fields */ - foreach ($_POST AS $key => $value) - if (key_exists($key, $this) AND $key != 'id_'.$this->table) - $this->{$key} = $value; - - /* Multilingual fields */ - if (sizeof($this->fieldsValidateLang)) - { - $languages = Language::getLanguages(false); - foreach ($languages AS $language) - foreach ($this->fieldsValidateLang AS $field => $validation) - if (isset($_POST[$field.'_'.(int)($language['id_lang'])])) - $this->{$field}[(int)($language['id_lang'])] = $_POST[$field.'_'.(int)($language['id_lang'])]; - } - } -} diff --git a/modules/editorial/config.xml b/modules/editorial/config.xml deleted file mode 100755 index 84619c28c..000000000 --- a/modules/editorial/config.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - editorial - - - - - - 1 - 0 - - \ No newline at end of file diff --git a/modules/editorial/editorial.css b/modules/editorial/editorial.css deleted file mode 100644 index 7f9d6244a..000000000 --- a/modules/editorial/editorial.css +++ /dev/null @@ -1,26 +0,0 @@ -/* Block editorial */ -.editorial_block { margin-bottom: 2em } -.editorial_block .rte { background: transparent none repeat scroll 0 0 } -.editorial_block h1 { - margin:40px 0 10px 0; - padding: 0; - background: none; -} -.editorial_block h2 { - padding:0 0 10px 0; - font-size: 12px; - line-height: 1.2em; - color: #666; - text-transform: none; - background: none; -} -#editorial_block_center p { padding-left: 0 } -#editorial_block_center .rte p {color:#666 } - -#editorial_block_center p#editorial_image_legend { - margin: 0 0 10px; - padding:0; - color: #666; - font-size: 10px; -} - diff --git a/modules/editorial/editorial.php b/modules/editorial/editorial.php deleted file mode 100644 index c7ecf4414..000000000 --- a/modules/editorial/editorial.php +++ /dev/null @@ -1,310 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -if (!defined('_PS_VERSION_')) - exit; - -class Editorial extends Module -{ - public function __construct() - { - $this->name = 'editorial'; - $this->tab = 'front_office_features'; - $this->version = '2.0'; - $this->author = 'PrestaShop'; - $this->need_instance = 0; - - parent::__construct(); - - $this->displayName = $this->l('Home text editor'); - $this->description = $this->l('A text-edit module for your homepage.'); - $path = dirname(__FILE__); - if (strpos(__FILE__, 'Module.php') !== false) - $path .= '/../modules/'.$this->name; - include_once $path.'/EditorialClass.php'; - } - - public function install() - { - if (!parent::install() || !$this->registerHook('displayHome') || !$this->registerHook('displayHeader')) - return false; - - $res = Db::getInstance()->execute(' - CREATE TABLE IF NOT EXISTS `'._DB_PREFIX_.'editorial` ( - `id_editorial` int(10) unsigned NOT NULL auto_increment, - `id_shop` int(10) unsigned NOT NULL , - `body_home_logo_link` varchar(255) NOT NULL, - PRIMARY KEY (`id_editorial`)) - ENGINE='._MYSQL_ENGINE_.' DEFAULT CHARSET=utf8'); - - if ($res) - $res &= Db::getInstance()->execute(' - CREATE TABLE IF NOT EXISTS `'._DB_PREFIX_.'editorial_lang` ( - `id_editorial` int(10) unsigned NOT NULL, - `id_lang` int(10) unsigned NOT NULL, - `body_title` varchar(255) NOT NULL, - `body_subheading` varchar(255) NOT NULL, - `body_paragraph` text NOT NULL, - `body_logo_subheading` varchar(255) NOT NULL, - PRIMARY KEY (`id_editorial`, `id_lang`)) - ENGINE='._MYSQL_ENGINE_.' DEFAULT CHARSET=utf8'); - - - if ($res) - foreach - (Shop::getShops(false) as $shop) - $res &= $this->createExampleEditorial($shop['id_shop']); - - if (!$res) - $res &= $this->uninstall(); - - return $res; - } - - private function createExampleEditorial($id_shop) - { - $editorial = new EditorialClass(); - $editorial->id_shop = (int)$id_shop; - $editorial->body_home_logo_link = 'http://www.prestashop.com'; - foreach (Language::getLanguages(false) as $lang) - { - $editorial->body_title[$lang['id_lang']] = 'Lorem ipsum dolor sit amet'; - $editorial->body_subheading[$lang['id_lang']] = 'Excepteur sint occaecat cupidatat non proident'; - $editorial->body_paragraph[$lang['id_lang']] = '

    Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum

    '; - $editorial->body_logo_subheading[$lang['id_lang']] = 'Lorem ipsum presta shop amet'; - } - return $editorial->add(); - } - - public function uninstall() - { - $res = Db::getInstance()->execute('DROP TABLE IF EXISTS `'._DB_PREFIX_.'editorial`'); - $res &= Db::getInstance()->execute('DROP TABLE IF EXISTS `'._DB_PREFIX_.'editorial_lang`'); - - if (!$res || !parent::uninstall()) - return false; - - return true; - } - - private function initForm() - { - $languages = Language::getLanguages(false); - foreach ($languages as $k => $language) - $languages[$k]['is_default'] = (int)($language['id_lang'] == Configuration::get('PS_LANG_DEFAULT')); - - $helper = new HelperForm(); - $helper->module = $this; - $helper->name_controller = 'editorial'; - $helper->identifier = $this->identifier; - $helper->token = Tools::getAdminTokenLite('AdminModules'); - $helper->languages = $languages; - $helper->currentIndex = AdminController::$currentIndex.'&configure='.$this->name; - $helper->default_form_language = (int)Configuration::get('PS_LANG_DEFAULT'); - $helper->allow_employee_form_lang = true; - $helper->toolbar_scroll = true; - $helper->toolbar_btn = $this->initToolbar(); - $helper->title = $this->displayName; - $helper->submit_action = 'submitUpdateEditorial'; - - $this->fields_form[0]['form'] = array( - 'tinymce' => true, - 'legend' => array( - 'title' => $this->displayName, - 'image' => $this->_path.'logo.gif' - ), - 'submit' => array( - 'name' => 'submitUpdateEditorial', - 'title' => $this->l('Save '), - 'class' => 'button' - ), - 'input' => array( - array( - 'type' => 'text', - 'label' => $this->l('Main title'), - 'name' => 'body_title', - 'lang' => true, - 'size' => 64, - 'hint' => $this->l('Appears along top of your homepage'), - ), - array( - 'type' => 'text', - 'label' => $this->l('Subheading'), - 'name' => 'body_subheading', - 'lang' => true, - 'size' => 64, - ), - array( - 'type' => 'textarea', - 'label' => $this->l('Introductory text'), - 'name' => 'body_paragraph', - 'lang' => true, - 'autoload_rte' => true, - 'hint' => $this->l('For example... explain your mission, highlight a new product, or describe a recent event.'), - 'cols' => 60, - 'rows' => 30 - ), - array( - 'type' => 'file', - 'label' => $this->l('Homepage logo'), - 'name' => 'body_homepage_logo', - 'display_image' => true - ), - array( - 'type' => 'text', - 'label' => $this->l('Homepage logo link'), - 'name' => 'body_home_logo_link', - 'size' => 33, - ), - array( - 'type' => 'text', - 'label' => $this->l('Homepage logo subheading'), - 'name' => 'body_logo_subheading', - 'lang' => true, - 'size' => 33, - ), - ) - ); - return $helper; - } - - private function initToolbar() - { - $this->toolbar_btn['save'] = array( - 'href' => '#', - 'desc' => $this->l('Save') - ); - - return $this->toolbar_btn; - } - - public function getContent() - { - $this->_html = ''; - $this->postProcess(); - - $helper = $this->initForm(); - - $id_shop = (int)$this->context->shop->id; - $editorial = EditorialClass::getByIdShop($id_shop); - - if (!$editorial) //if editorial ddo not exist for this shop => create a new example one - $this->createExampleEditorial($id_shop); - - foreach ($this->fields_form[0]['form']['input'] as $input) //fill all form fields - if ($input['name'] != 'body_homepage_logo') - $helper->fields_value[$input['name']] = $editorial->{$input['name']}; - - $helper->fields_value['body_homepage_logo']['image'] = (file_exists(dirname(__FILE__).'/homepage_logo_'.(int)$id_shop.'.jpg') ? '' : ''); - if ($helper->fields_value['body_homepage_logo']) - $helper->fields_value['body_homepage_logo']['size'] = filesize(dirname(__FILE__).'/homepage_logo_'.(int)$id_shop.'.jpg') / 1000; - - $this->_html .= $helper->generateForm($this->fields_form); - return $this->_html; - } - - public function postProcess() - { - $errors = ''; - $id_shop = (int)$this->context->shop->id; - // Delete logo image - if (Tools::isSubmit('deleteImage')) - { - if (!file_exists(dirname(__FILE__).'/homepage_logo_'.(int)$id_shop.'.jpg')) - $errors .= $this->displayError($this->l('This action cannot be made.')); - else - { - unlink(dirname(__FILE__).'/homepage_logo_'.(int)$id_shop.'.jpg'); - Configuration::updateValue('EDITORIAL_IMAGE_DISABLE', 1); - $this->_clearCache('editorial.tpl'); - Tools::redirectAdmin('index.php?tab=AdminModules&configure='.$this->name.'&token='.Tools::getAdminToken('AdminModules'.(int)(Tab::getIdFromClassName('AdminModules')).(int)$this->context->employee->id)); - } - $this->_html .= $errors; - } - - if (Tools::isSubmit('submitUpdateEditorial')) - { - $id_shop = (int)$this->context->shop->id; - $editorial = EditorialClass::getByIdShop($id_shop); - $editorial->copyFromPost(); - $editorial->update(); - - /* upload the image */ - if (isset($_FILES['body_homepage_logo']) && isset($_FILES['body_homepage_logo']['tmp_name']) && !empty($_FILES['body_homepage_logo']['tmp_name'])) - { - Configuration::set('PS_IMAGE_GENERATION_METHOD', 1); - if (file_exists(dirname(__FILE__).'/homepage_logo_'.(int)$id_shop.'.jpg')) - unlink(dirname(__FILE__).'/homepage_logo_'.(int)$id_shop.'.jpg'); - if ($error = ImageManager::validateUpload($_FILES['body_homepage_logo'])) - $errors .= $error; - elseif (!($tmpName = tempnam(_PS_TMP_IMG_DIR_, 'PS')) || !move_uploaded_file($_FILES['body_homepage_logo']['tmp_name'], $tmpName)) - return false; - elseif (!ImageManager::resize($tmpName, dirname(__FILE__).'/homepage_logo_'.(int)$id_shop.'.jpg')) - $errors .= $this->displayError($this->l('An error occurred while attempting to upload the image.')); - if (isset($tmpName)) - unlink($tmpName); - } - $this->_html .= $errors == '' ? $this->displayConfirmation($this->l('Settings updated successfully.')) : $errors; - if (file_exists(dirname(__FILE__).'/homepage_logo_'.(int)$id_shop.'.jpg')) - { - list($width, $height, $type, $attr) = getimagesize(dirname(__FILE__).'/homepage_logo_'.(int)$id_shop.'.jpg'); - Configuration::updateValue('EDITORIAL_IMAGE_WIDTH', (int)round($width)); - Configuration::updateValue('EDITORIAL_IMAGE_HEIGHT', (int)round($height)); - Configuration::updateValue('EDITORIAL_IMAGE_DISABLE', 0); - } - $this->_clearCache('editorial.tpl'); - } - } - - public function hookDisplayHome($params) - { - if (!$this->isCached('editorial.tpl', $this->getCacheId())) - { - $id_shop = (int)$this->context->shop->id; - $editorial = EditorialClass::getByIdShop($id_shop); - if (!$editorial) - return; - $editorial = new EditorialClass((int)$editorial->id, $this->context->language->id); - if (!$editorial) - return; - $this->smarty->assign(array( - 'editorial' => $editorial, - 'default_lang' => (int)$this->context->language->id, - 'image_width' => Configuration::get('EDITORIAL_IMAGE_WIDTH'), - 'image_height' => Configuration::get('EDITORIAL_IMAGE_HEIGHT'), - 'id_lang' => $this->context->language->id, - 'homepage_logo' => !Configuration::get('EDITORIAL_IMAGE_DISABLE') && file_exists('modules/editorial/homepage_logo_'.(int)$id_shop.'.jpg'), - 'image_path' => $this->_path.'homepage_logo_'.(int)$id_shop.'.jpg' - )); - } - return $this->display(__FILE__, 'editorial.tpl', $this->getCacheId()); - } - - public function hookDisplayHeader() - { - $this->context->controller->addCSS(($this->_path).'editorial.css', 'all'); - } -} diff --git a/modules/editorial/editorial.tpl b/modules/editorial/editorial.tpl deleted file mode 100644 index d9331774f..000000000 --- a/modules/editorial/editorial.tpl +++ /dev/null @@ -1,36 +0,0 @@ -{* -* 2007-2013 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 -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*} - - -
    - {if $editorial->body_home_logo_link}{/if} - {if $homepage_logo}{$editorial->body_title|escape:'html':'UTF-8'|stripslashes}{/if} - {if $editorial->body_home_logo_link}{/if} - {if $editorial->body_logo_subheading}

    {$editorial->body_logo_subheading|stripslashes}

    {/if} - {if $editorial->body_title}

    {$editorial->body_title|stripslashes}

    {/if} - {if $editorial->body_subheading}

    {$editorial->body_subheading|stripslashes}

    {/if} - {if $editorial->body_paragraph}
    {$editorial->body_paragraph|stripslashes}
    {/if} -
    - diff --git a/modules/editorial/homepage_logo_1.jpg b/modules/editorial/homepage_logo_1.jpg deleted file mode 100644 index 38a7b65e1..000000000 Binary files a/modules/editorial/homepage_logo_1.jpg and /dev/null differ diff --git a/modules/editorial/index.php b/modules/editorial/index.php deleted file mode 100644 index 3f6561f72..000000000 --- a/modules/editorial/index.php +++ /dev/null @@ -1,35 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); - -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); - -header("Location: ../"); -exit; \ No newline at end of file diff --git a/modules/editorial/logo.gif b/modules/editorial/logo.gif deleted file mode 100644 index fa26b20b5..000000000 Binary files a/modules/editorial/logo.gif and /dev/null differ diff --git a/modules/editorial/logo.png b/modules/editorial/logo.png deleted file mode 100755 index 382ab1dbe..000000000 Binary files a/modules/editorial/logo.png and /dev/null differ diff --git a/modules/editorial/translations/index.php b/modules/editorial/translations/index.php deleted file mode 100644 index 3f6561f72..000000000 --- a/modules/editorial/translations/index.php +++ /dev/null @@ -1,35 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); - -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); - -header("Location: ../"); -exit; \ No newline at end of file diff --git a/modules/favoriteproducts/FavoriteProduct.php b/modules/favoriteproducts/FavoriteProduct.php deleted file mode 100644 index f4ddaec66..000000000 --- a/modules/favoriteproducts/FavoriteProduct.php +++ /dev/null @@ -1,111 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -class FavoriteProduct extends ObjectModel -{ - public $id; - - public $id_product; - - public $id_customer; - - public $id_shop; - - public $date_add; - - public $date_upd; - - /** - * @see ObjectModel::$definition - */ - public static $definition = array( - 'table' => 'favorite_product', - 'primary' => 'id_favorite_product', - 'fields' => array( - 'id_product' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt', 'required' => true), - 'id_customer' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt', 'required' => true), - 'id_shop' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt', 'required' => true), - 'date_add' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'), - 'date_upd' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'), - ), - ); - - public static function getFavoriteProducts($id_customer, $id_lang) - { - return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS(' - SELECT DISTINCT p.`id_product`, fp.`id_shop`, pl.`description_short`, pl.`link_rewrite`, - pl.`name`, i.`id_image`, CONCAT(p.`id_product`, \'-\', i.`id_image`) as image - FROM `'._DB_PREFIX_.'favorite_product` fp - LEFT JOIN `'._DB_PREFIX_.'product` p ON (p.`id_product` = fp.`id_product`) - '.Shop::addSqlAssociation('product', 'p').' - LEFT JOIN `'._DB_PREFIX_.'product_lang` pl - ON p.`id_product` = pl.`id_product` - AND pl.`id_lang` = '.(int)$id_lang - .Shop::addSqlRestrictionOnLang('pl').' - LEFT OUTER JOIN `'._DB_PREFIX_.'product_attribute` pa ON (p.`id_product` = pa.`id_product`) - '.Shop::addSqlAssociation('product_attribute', 'pa', false).' - LEFT JOIN `'._DB_PREFIX_.'image` i ON (i.`id_product` = p.`id_product` AND i.`cover` = 1) - LEFT JOIN `'._DB_PREFIX_.'image_lang` il ON (i.`id_image` = il.`id_image` AND il.`id_lang` = '.(int)$id_lang.') - WHERE product_shop.`active` = 1 - '.($id_customer ? ' AND fp.id_customer = '.(int)$id_customer : '').' - '.Shop::addSqlRestriction(false, 'fp') - ); - } - - public static function getFavoriteProduct($id_customer, $id_product, Shop $shop = null) - { - if (!$shop) - $shop = Context::getContext()->shop; - - $id_favorite_product = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue(' - SELECT `id_favorite_product` - FROM `'._DB_PREFIX_.'favorite_product` - WHERE `id_customer` = '.(int)$id_customer.' - AND `id_product` = '.(int)$id_product.' - AND `id_shop` = '.(int)$shop->id - ); - - if ($id_favorite_product) - return new FavoriteProduct($id_favorite_product); - return null; - } - - public static function isCustomerFavoriteProduct($id_customer, $id_product, Shop $shop = null) - { - if (!$id_customer) - return false; - - if (!$shop) - $shop = Context::getContext()->shop; - - return (bool)Db::getInstance()->getValue(' - SELECT COUNT(*) - FROM `'._DB_PREFIX_.'favorite_product` - WHERE `id_customer` = '.(int)$id_customer.' - AND `id_product` = '.(int)$id_product.' - AND `id_shop` = '.(int)$shop->id); - } -} diff --git a/modules/favoriteproducts/config.xml b/modules/favoriteproducts/config.xml deleted file mode 100644 index f8e8e0682..000000000 --- a/modules/favoriteproducts/config.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - favoriteproducts - - - - - - 0 - 0 - - \ No newline at end of file diff --git a/modules/favoriteproducts/controllers/front/account.php b/modules/favoriteproducts/controllers/front/account.php deleted file mode 100644 index 043141a5c..000000000 --- a/modules/favoriteproducts/controllers/front/account.php +++ /dev/null @@ -1,54 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -/** - * @since 1.5.0 - */ -class FavoriteproductsAccountModuleFrontController extends ModuleFrontController -{ - public $ssl = true; - - public function init() - { - parent::init(); - - require_once($this->module->getLocalPath().'FavoriteProduct.php'); - } - - public function initContent() - { - parent::initContent(); - - if (!Context::getContext()->customer->isLogged()) - Tools::redirect('index.php?controller=authentication&redirect=module&module=favoriteproducts&action=account'); - - if (Context::getContext()->customer->id) - { - $this->context->smarty->assign('favoriteProducts', FavoriteProduct::getFavoriteProducts((int)Context::getContext()->customer->id, (int)Context::getContext()->language->id)); - $this->setTemplate('favoriteproducts-account.tpl'); - } - } -} \ No newline at end of file diff --git a/modules/favoriteproducts/controllers/front/actions.php b/modules/favoriteproducts/controllers/front/actions.php deleted file mode 100644 index 55ab8a2e9..000000000 --- a/modules/favoriteproducts/controllers/front/actions.php +++ /dev/null @@ -1,87 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -/** - * @since 1.5.0 - */ -class FavoriteproductsActionsModuleFrontController extends ModuleFrontController -{ - /** - * @var int - */ - public $id_product; - - public function init() - { - parent::init(); - - require_once($this->module->getLocalPath().'FavoriteProduct.php'); - $this->id_product = (int)Tools::getValue('id_product'); - } - - public function postProcess() - { - if (Tools::getValue('process') == 'remove') - $this->processRemove(); - else if (Tools::getValue('process') == 'add') - $this->processAdd(); - exit; - } - - /** - * Remove a favorite product - */ - public function processRemove() - { - // check if product exists - $product = new Product($this->id_product); - if (!Validate::isLoadedObject($product)) - die('0'); - - $favorite_product = FavoriteProduct::getFavoriteProduct((int)Context::getContext()->cookie->id_customer, (int)$product->id); - if ($favorite_product && $favorite_product->delete()) - die('0'); - die(1); - } - - /** - * Add a favorite product - */ - public function processAdd() - { - $product = new Product($this->id_product); - // check if product exists - if (!Validate::isLoadedObject($product) || FavoriteProduct::isCustomerFavoriteProduct((int)Context::getContext()->cookie->id_customer, (int)$product->id)) - die('1'); - $favorite_product = new FavoriteProduct(); - $favorite_product->id_product = $product->id; - $favorite_product->id_customer = (int)Context::getContext()->cookie->id_customer; - $favorite_product->id_shop = (int)Context::getContext()->shop->id; - if ($favorite_product->add()) - die('0'); - die(1); - } -} \ No newline at end of file diff --git a/modules/favoriteproducts/controllers/front/index.php b/modules/favoriteproducts/controllers/front/index.php deleted file mode 100644 index 3f6561f72..000000000 --- a/modules/favoriteproducts/controllers/front/index.php +++ /dev/null @@ -1,35 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); - -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); - -header("Location: ../"); -exit; \ No newline at end of file diff --git a/modules/favoriteproducts/controllers/index.php b/modules/favoriteproducts/controllers/index.php deleted file mode 100644 index 3f6561f72..000000000 --- a/modules/favoriteproducts/controllers/index.php +++ /dev/null @@ -1,35 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); - -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); - -header("Location: ../"); -exit; \ No newline at end of file diff --git a/modules/favoriteproducts/favoriteproducts-account.php b/modules/favoriteproducts/favoriteproducts-account.php deleted file mode 100644 index 9b7885925..000000000 --- a/modules/favoriteproducts/favoriteproducts-account.php +++ /dev/null @@ -1,41 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -/** - * @deprecated 1.5.0 This file is deprecated, use moduleFrontController instead - */ - -/* SSL Management */ -$useSSL = true; - -require('../../config/config.inc.php'); -Tools::displayFileAsDeprecated(); - -// init front controller in order to use Tools::redirect -$controller = new FrontController(); -$controller->init(); - -Tools::redirect(Context::getContext()->link->getModuleLink('favoriteproducts', 'account')); \ No newline at end of file diff --git a/modules/favoriteproducts/favoriteproducts-ajax.php b/modules/favoriteproducts/favoriteproducts-ajax.php deleted file mode 100644 index cfc395329..000000000 --- a/modules/favoriteproducts/favoriteproducts-ajax.php +++ /dev/null @@ -1,65 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -/** - * @deprecated 1.5.0 This file is deprecated, use moduleFrontController instead - */ - -require_once(dirname(__FILE__).'/../../config/config.inc.php'); -require_once(dirname(__FILE__).'/../../init.php'); -include(dirname(__FILE__).'/FavoriteProduct.php'); - -if (Tools::getValue('action') && Tools::getValue('id_product') && Context::getContext()->cookie->id_customer) -{ - if (Tools::getValue('action') == 'remove') - { - // check if product exists - $product = new Product((int)Tools::getValue('id_product')); - if (!Validate::isLoadedObject($product)) - die('0'); - $favorite_product = FavoriteProduct::getFavoriteProduct((int)Context::getContext()->cookie->id_customer, (int)$product->id); - if ($favorite_product) - if ($favorite_product->delete()) - die('0'); - } - elseif (Tools::getValue('action') == 'add') - { - $product = new Product((int)Tools::getValue('id_product')); - // check if product exists - if (!Validate::isLoadedObject($product) - || FavoriteProduct::isCustomerFavoriteProduct((int)Context::getContext()->cookie->id_customer, (int)$product->id)) - die('1'); - $favorite_product = new FavoriteProduct(); - $favorite_product->id_product = $product->id; - $favorite_product->id_customer = (int)Context::getContext()->cookie->id_customer; - $favorite_product->id_shop = (int)Context::getContext()->shop->id; - if ($favorite_product->add()) - die('0'); - } -} - -die('1'); - diff --git a/modules/favoriteproducts/favoriteproducts.css b/modules/favoriteproducts/favoriteproducts.css deleted file mode 100644 index bb93b7e03..000000000 --- a/modules/favoriteproducts/favoriteproducts.css +++ /dev/null @@ -1,66 +0,0 @@ -#module-favoriteproducts-account #left_column {display:none} -#module-favoriteproducts-account #center_column {width:757px} - -#favoriteproducts_block_account .favoriteproduct { - position:relative; - margin-bottom: 14px; - padding: 12px 8px; - border: 1px solid #eee; - border-radius: 3px 3px 3px 3px; -} - -.favoriteproduct a.product_img_link { - border: 1px solid #CCCCCC; - display: block; - float: left; - margin-right: 14px; - overflow: hidden; - position: relative; -} - -.favoriteproduct h3 { - color: #000000; - font-size: 13px; - padding: 0 0 10px; -} - -.favoriteproduct p.product_desc { - line-height: 16px; - overflow: hidden; - padding: 0; -} - -.favoriteproduct .remove { - position:absolute; - top:10px; - right:10px -} -.favoriteproduct .remove .icon {cursor:pointer} - - -/* lnk fiche produit */ - -#usefull_link_block li#favoriteproducts_block_extra_add { - padding-left:20px; - background:url(img/add_favorite.gif) no-repeat 0 0; - cursor: pointer; -} - -#usefull_link_block li#favoriteproducts_block_extra_remove { - padding-left:20px; - background:url(img/del_favorite.gif) no-repeat 0 0; - cursor: pointer; -} - -ul#usefull_link_block li#favoriteproducts_block_extra_added { - padding-left:20px; - background:url(img/add_favorite.gif) no-repeat 0 0; - cursor: pointer; - display: none; -} -ul#usefull_link_block li#favoriteproducts_block_extra_removed { - padding-left:20px; - background:url(img/add_favorite.gif) no-repeat 0 0; - cursor: pointer; - display: none; -} \ No newline at end of file diff --git a/modules/favoriteproducts/favoriteproducts.js b/modules/favoriteproducts/favoriteproducts.js deleted file mode 100755 index ae490fdbb..000000000 --- a/modules/favoriteproducts/favoriteproducts.js +++ /dev/null @@ -1,78 +0,0 @@ -$('document').ready(function(){ - $('#favoriteproducts_block_extra_add').click(function(){ - $.ajax({ - url: favorite_products_url_add + '&rand=' + new Date().getTime(), - type: "POST", - headers: { "cache-control": "no-cache" }, - data: { - "id_product": favorite_products_id_product - }, - success: function(result){ - if (result == '0') - { - $('#favoriteproducts_block_extra_add').slideUp(function() { - $('#favoriteproducts_block_extra_added').slideDown("slow"); - }); - - } - } - }); - }); - $('#favoriteproducts_block_extra_remove').click(function(){ - $.ajax({ - url: favorite_products_url_remove + '&rand=' + new Date().getTime(), - type: "POST", - headers: { "cache-control": "no-cache" }, - data: { - "id_product": favorite_products_id_product - }, - success: function(result){ - if (result == '0') - { - $('#favoriteproducts_block_extra_remove').slideUp(function() { - $('#favoriteproducts_block_extra_removed').slideDown("slow"); - }); - - } - } - }); - }); - $('#favoriteproducts_block_extra_added').click(function(){ - $.ajax({ - url: favorite_products_url_remove + '&rand=' + new Date().getTime(), - type: "POST", - headers: { "cache-control": "no-cache" }, - data: { - "id_product": favorite_products_id_product - }, - success: function(result){ - if (result == '0') - { - $('#favoriteproducts_block_extra_added').slideUp(function() { - $('#favoriteproducts_block_extra_removed').slideDown("slow"); - }); - - } - } - }); - }); - $('#favoriteproducts_block_extra_removed').click(function(){ - $.ajax({ - url: favorite_products_url_add + '&rand=' + new Date().getTime(), - type: "POST", - headers: { "cache-control": "no-cache" }, - data: { - "id_product": favorite_products_id_product - }, - success: function(result){ - if (result == '0') - { - $('#favoriteproducts_block_extra_removed').slideUp(function() { - $('#favoriteproducts_block_extra_added').slideDown("slow"); - }); - - } - } - }); - }); -}) \ No newline at end of file diff --git a/modules/favoriteproducts/favoriteproducts.php b/modules/favoriteproducts/favoriteproducts.php deleted file mode 100644 index 35a3972de..000000000 --- a/modules/favoriteproducts/favoriteproducts.php +++ /dev/null @@ -1,110 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -if (!defined('_CAN_LOAD_FILES_')) - exit; - -class FavoriteProducts extends Module -{ - public function __construct() - { - $this->name = 'favoriteproducts'; - $this->tab = 'front_office_features'; - $this->version = 1.0; - $this->author = 'PrestaShop'; - $this->need_instance = 0; - - parent::__construct(); - - $this->displayName = $this->l('Favorite Products'); - $this->description = $this->l('Display a page featuring the customer\'s favorite products.'); - } - - public function install() - { - if (!parent::install() - || !$this->registerHook('displayMyAccountBlock') - || !$this->registerHook('displayCustomerAccount') - || !$this->registerHook('displayLeftColumnProduct') - || !$this->registerHook('extraLeft') - || !$this->registerHook('displayHeader')) - return false; - - if (!Db::getInstance()->execute(' - CREATE TABLE `'._DB_PREFIX_.'favorite_product` ( - `id_favorite_product` int(10) unsigned NOT NULL auto_increment, - `id_product` int(10) unsigned NOT NULL, - `id_customer` int(10) unsigned NOT NULL, - `id_shop` int(10) unsigned NOT NULL, - `date_add` datetime NOT NULL, - `date_upd` datetime NOT NULL, - PRIMARY KEY (`id_favorite_product`)) - ENGINE='._MYSQL_ENGINE_.' DEFAULT CHARSET=utf8')) - return false; - - return true; - } - - public function uninstall() - { - if (!parent::uninstall() || !Db::getInstance()->execute('DROP TABLE `'._DB_PREFIX_.'favorite_product`')) - return false; - return true; - } - - public function hookDisplayCustomerAccount($params) - { - $this->smarty->assign('in_footer', false); - return $this->display(__FILE__, 'my-account.tpl'); - } - - public function hookDisplayMyAccountBlock($params) - { - $this->smarty->assign('in_footer', true); - return $this->display(__FILE__, 'my-account.tpl'); - } - - public function hookDisplayLeftColumnProduct($params) - { - include_once(dirname(__FILE__).'/FavoriteProduct.php'); - - $this->smarty->assign(array( - 'isCustomerFavoriteProduct' => (FavoriteProduct::isCustomerFavoriteProduct($this->context->customer->id, Tools::getValue('id_product')) ? 1 : 0), - 'isLogged' => (int)$this->context->customer->logged, - )); - return $this->display(__FILE__, 'favoriteproducts-extra.tpl'); - } - - public function hookDisplayHeader($params) - { - $this->context->controller->addCSS($this->_path.'favoriteproducts.css', 'all'); - $this->context->controller->addJS($this->_path.'favoriteproducts.js'); - return $this->display(__FILE__, 'favoriteproducts-header.tpl'); - } - -} - - diff --git a/modules/favoriteproducts/img/add_favorite.gif b/modules/favoriteproducts/img/add_favorite.gif deleted file mode 100644 index 8b0b263f6..000000000 Binary files a/modules/favoriteproducts/img/add_favorite.gif and /dev/null differ diff --git a/modules/favoriteproducts/img/del_favorite.gif b/modules/favoriteproducts/img/del_favorite.gif deleted file mode 100644 index 8aea7d4f7..000000000 Binary files a/modules/favoriteproducts/img/del_favorite.gif and /dev/null differ diff --git a/modules/favoriteproducts/img/favorites.png b/modules/favoriteproducts/img/favorites.png deleted file mode 100644 index 8197910f3..000000000 Binary files a/modules/favoriteproducts/img/favorites.png and /dev/null differ diff --git a/modules/favoriteproducts/img/index.php b/modules/favoriteproducts/img/index.php deleted file mode 100644 index 3f6561f72..000000000 --- a/modules/favoriteproducts/img/index.php +++ /dev/null @@ -1,35 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); - -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); - -header("Location: ../"); -exit; \ No newline at end of file diff --git a/modules/favoriteproducts/index.php b/modules/favoriteproducts/index.php deleted file mode 100644 index 3f6561f72..000000000 --- a/modules/favoriteproducts/index.php +++ /dev/null @@ -1,35 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); - -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); - -header("Location: ../"); -exit; \ No newline at end of file diff --git a/modules/favoriteproducts/logo.gif b/modules/favoriteproducts/logo.gif deleted file mode 100644 index 8b0b263f6..000000000 Binary files a/modules/favoriteproducts/logo.gif and /dev/null differ diff --git a/modules/favoriteproducts/logo.png b/modules/favoriteproducts/logo.png deleted file mode 100755 index 478d568fa..000000000 Binary files a/modules/favoriteproducts/logo.png and /dev/null differ diff --git a/modules/favoriteproducts/translations/index.php b/modules/favoriteproducts/translations/index.php deleted file mode 100644 index 3f6561f72..000000000 --- a/modules/favoriteproducts/translations/index.php +++ /dev/null @@ -1,35 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); - -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); - -header("Location: ../"); -exit; \ No newline at end of file diff --git a/modules/favoriteproducts/views/index.php b/modules/favoriteproducts/views/index.php deleted file mode 100644 index 3f6561f72..000000000 --- a/modules/favoriteproducts/views/index.php +++ /dev/null @@ -1,35 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); - -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); - -header("Location: ../"); -exit; \ No newline at end of file diff --git a/modules/favoriteproducts/views/templates/front/favoriteproducts-account.tpl b/modules/favoriteproducts/views/templates/front/favoriteproducts-account.tpl deleted file mode 100644 index a5ebf872f..000000000 --- a/modules/favoriteproducts/views/templates/front/favoriteproducts-account.tpl +++ /dev/null @@ -1,89 +0,0 @@ -{* -* 2007-2013 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 -* @copyright 2007-2013 PrestaShop SA -* @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='My account' mod='favoriteproducts'} - {$navigationPipe}{l s='My favorite products.' mod='favoriteproducts'} -{/capture} -{include file="$tpl_dir./breadcrumb.tpl"} - -
    -

    {l s='My favorite products.' mod='favoriteproducts'}

    - {if $favoriteProducts} -
    - {foreach from=$favoriteProducts item=favoriteProduct} -
    - - -

    {$favoriteProduct.name|escape:'html':'UTF-8'}

    -
    {$favoriteProduct.description_short|strip_tags|escape:'html':'UTF-8'}
    - -
    - -
    -
    - {/foreach} -
    - {else} -

    {l s='No favorite products have been determined just yet. ' mod='favoriteproducts'}

    - {/if} - - -
    \ No newline at end of file diff --git a/modules/favoriteproducts/views/templates/front/index.php b/modules/favoriteproducts/views/templates/front/index.php deleted file mode 100644 index 3f6561f72..000000000 --- a/modules/favoriteproducts/views/templates/front/index.php +++ /dev/null @@ -1,35 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); - -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); - -header("Location: ../"); -exit; \ No newline at end of file diff --git a/modules/favoriteproducts/views/templates/hook/favoriteproducts-extra.tpl b/modules/favoriteproducts/views/templates/hook/favoriteproducts-extra.tpl deleted file mode 100644 index 7bd3e1df7..000000000 --- a/modules/favoriteproducts/views/templates/hook/favoriteproducts-extra.tpl +++ /dev/null @@ -1,42 +0,0 @@ -{* -* 2007-2013 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 -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*} - -{if !$isCustomerFavoriteProduct AND $isLogged} -
  • - {l s='Add this product to my list of favorites.' mod='favoriteproducts'} -
  • -{/if} -{if $isCustomerFavoriteProduct AND $isLogged} -
  • - {l s='Remove this product from my favorite\'s list. ' mod='favoriteproducts'} -
  • -{/if} - -
  • - {l s='Remove this product from my favorite\'s list. ' mod='favoriteproducts'} -
  • -
  • - {l s='Add this product to my list of favorites.' mod='favoriteproducts'} -
  • \ No newline at end of file diff --git a/modules/favoriteproducts/views/templates/hook/favoriteproducts-header.tpl b/modules/favoriteproducts/views/templates/hook/favoriteproducts-header.tpl deleted file mode 100755 index 669a45eec..000000000 --- a/modules/favoriteproducts/views/templates/hook/favoriteproducts-header.tpl +++ /dev/null @@ -1,31 +0,0 @@ -{* -* 2007-2013 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 -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*} - diff --git a/modules/favoriteproducts/views/templates/hook/index.php b/modules/favoriteproducts/views/templates/hook/index.php deleted file mode 100644 index 3f6561f72..000000000 --- a/modules/favoriteproducts/views/templates/hook/index.php +++ /dev/null @@ -1,35 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); - -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); - -header("Location: ../"); -exit; \ No newline at end of file diff --git a/modules/favoriteproducts/views/templates/hook/my-account.tpl b/modules/favoriteproducts/views/templates/hook/my-account.tpl deleted file mode 100644 index b2cd80e49..000000000 --- a/modules/favoriteproducts/views/templates/hook/my-account.tpl +++ /dev/null @@ -1,31 +0,0 @@ -{* -* 2007-2013 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 -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*} - -
  • - - {if !$in_footer}{l s='My favorite products.' mod='favoriteproducts'}{/if} - {l s='My favorite products.' mod='favoriteproducts'} - -
  • diff --git a/modules/favoriteproducts/views/templates/index.php b/modules/favoriteproducts/views/templates/index.php deleted file mode 100644 index 3f6561f72..000000000 --- a/modules/favoriteproducts/views/templates/index.php +++ /dev/null @@ -1,35 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); - -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); - -header("Location: ../"); -exit; \ No newline at end of file diff --git a/modules/feeder/config.xml b/modules/feeder/config.xml deleted file mode 100755 index 58ba3ce4a..000000000 --- a/modules/feeder/config.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - feeder - - - - - - 0 - 0 - - \ No newline at end of file diff --git a/modules/feeder/feeder.php b/modules/feeder/feeder.php deleted file mode 100644 index 6382a0637..000000000 --- a/modules/feeder/feeder.php +++ /dev/null @@ -1,79 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -if (!defined('_PS_VERSION_')) - exit; - -class Feeder extends Module -{ - private $_postErrors = array(); - - public function __construct() - { - $this->name = 'feeder'; - $this->tab = 'front_office_features'; - $this->version = 0.4; - $this->author = 'PrestaShop'; - $this->need_instance = 0; - - $this->_directory = dirname(__FILE__).'/../../'; - parent::__construct(); - - $this->displayName = $this->l('RSS products feed.'); - $this->description = $this->l('Generate an RSS products feed.'); - } - - function install() - { - return (parent::install() && $this->registerHook('header')); - } - - function hookHeader($params) - { - if (!($id_category = (int)Tools::getValue('id_category'))) - { - if (isset($_SERVER['HTTP_REFERER']) && strstr($_SERVER['HTTP_REFERER'], Tools::getHttpHost()) && preg_match('!^(.*)\/([0-9]+)\-(.*[^\.])|(.*)id_category=([0-9]+)(.*)$!', $_SERVER['HTTP_REFERER'], $regs)) - { - if (isset($regs[2]) && is_numeric($regs[2])) - $id_category = (int)($regs[2]); - elseif (isset($regs[5]) && is_numeric($regs[5])) - $id_category = (int)$regs[5]; - } - elseif ($id_product = (int)Tools::getValue('id_product')) - { - $product = new Product($id_product); - $id_category = $product->id_category_default; - } - } - - $orderBy = Tools::getProductsOrder('by', Tools::getValue('orderby')); - $orderWay = Tools::getProductsOrder('way', Tools::getValue('orderway')); - $this->smarty->assign(array( - 'feedUrl' => Tools::getShopDomain(true, true).__PS_BASE_URI__.'modules/'.$this->name.'/rss.php?id_category='.$id_category.'&orderby='.$orderBy.'&orderway='.$orderWay, - )); - return $this->display(__FILE__, 'feederHeader.tpl'); - } -} diff --git a/modules/feeder/feederHeader.tpl b/modules/feeder/feederHeader.tpl deleted file mode 100644 index c05a8b5a1..000000000 --- a/modules/feeder/feederHeader.tpl +++ /dev/null @@ -1,26 +0,0 @@ -{* -* 2007-2013 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 -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*} - - \ No newline at end of file diff --git a/modules/feeder/index.php b/modules/feeder/index.php deleted file mode 100644 index 3f6561f72..000000000 --- a/modules/feeder/index.php +++ /dev/null @@ -1,35 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); - -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); - -header("Location: ../"); -exit; \ No newline at end of file diff --git a/modules/feeder/logo.gif b/modules/feeder/logo.gif deleted file mode 100644 index 7a5e0099f..000000000 Binary files a/modules/feeder/logo.gif and /dev/null differ diff --git a/modules/feeder/logo.png b/modules/feeder/logo.png deleted file mode 100755 index 8b2c0d516..000000000 Binary files a/modules/feeder/logo.png and /dev/null differ diff --git a/modules/feeder/rss.php b/modules/feeder/rss.php deleted file mode 100644 index 046650c4e..000000000 --- a/modules/feeder/rss.php +++ /dev/null @@ -1,82 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @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__).'/../../init.php'); - -if (!Module::getInstanceByName('feeder')->active) - exit; - -// Get data -$number = ((int)(Tools::getValue('n')) ? (int)(Tools::getValue('n')) : 10); -$orderBy = Tools::getProductsOrder('by', Tools::getValue('orderby')); -$orderWay = Tools::getProductsOrder('way', Tools::getValue('orderway')); -$id_category = ((int)(Tools::getValue('id_category')) ? (int)(Tools::getValue('id_category')) : Configuration::get('PS_HOME_CATEGORY')); -$products = Product::getProducts((int)Context::getContext()->language->id, 0, ($number > 10 ? 10 : $number), $orderBy, $orderWay, $id_category, true); -$currency = new Currency((int)Context::getContext()->currency->id); -$affiliate = (Tools::getValue('ac') ? '?ac='.(int)(Tools::getValue('ac')) : ''); -$metas = Meta::getMetaByPage('index', (int)Context::getContext()->language->id); - -// Send feed -header("Content-Type:text/xml; charset=utf-8"); -echo ''."\n"; -?> - - - <![CDATA[<?php echo Configuration::get('PS_SHOP_NAME') ?>]]> - ]]> - - - PrestaShop - language->iso_code; ?> - - <![CDATA[<?php echo Configuration::get('PS_SHOP_NAME') ?>]]> - - - -id_lang), $product['id_product']); - echo "\t\t\n"; - echo "\t\t\t<![CDATA[".$product['name']." - ".html_entity_decode(Tools::displayPrice(Product::getPriceStatic($product['id_product']), $currency), ENT_COMPAT, 'UTF-8')." ]]>\n"; - echo "\t\t\t"; - $cdata = true; - if (is_array($image) AND sizeof($image)) - { - $imageObj = new Image($image[0]['id_image']); - echo "getImageLink($product['link_rewrite'], $image[0]['id_image'], 'small_default')."' title='".str_replace('&', '', $product['name'])."' alt='thumb' />"; - $cdata = false; - } - if ($cdata) - echo "\n"; - - echo "\t\t\tgetproductLink($product['id_product'], $product['link_rewrite'], Category::getLinkRewrite((int)($product['id_category_default']), $cookie->id_lang)))).$affiliate."]]>\n"; - echo "\t\t\n"; - } -?> - - \ No newline at end of file diff --git a/modules/feeder/translations/index.php b/modules/feeder/translations/index.php deleted file mode 100644 index 3f6561f72..000000000 --- a/modules/feeder/translations/index.php +++ /dev/null @@ -1,35 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); - -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); - -header("Location: ../"); -exit; \ No newline at end of file diff --git a/modules/followup/config.xml b/modules/followup/config.xml deleted file mode 100755 index 54ea7dfa1..000000000 --- a/modules/followup/config.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - followup - - - - - - Are you sure you want to delete all settings and your logs? - 1 - 0 - - \ No newline at end of file diff --git a/modules/followup/cron.php b/modules/followup/cron.php deleted file mode 100644 index c6099b094..000000000 --- a/modules/followup/cron.php +++ /dev/null @@ -1,40 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @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'); -include(dirname(__FILE__).'/followup.php'); - -if (isset($_GET['secure_key'])) -{ - $secureKey = Configuration::get('PS_FOLLOWUP_SECURE_KEY'); - if (!empty($secureKey) AND $secureKey === $_GET['secure_key']) - { - $followup = new Followup(); - if ($followup->active) - $followup->cronTask(); - } -} - diff --git a/modules/followup/followup.php b/modules/followup/followup.php deleted file mode 100644 index a884911d4..000000000 --- a/modules/followup/followup.php +++ /dev/null @@ -1,698 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -if (!defined('_PS_VERSION_')) - exit; - -class Followup extends Module -{ - function __construct() - { - $this->name = 'followup'; - $this->tab = 'advertising_marketing'; - $this->version = '1.0'; - $this->author = 'PrestaShop'; - $this->need_instance = 0; - - $this->confKeys = array( - 'PS_FOLLOW_UP_ENABLE_1', 'PS_FOLLOW_UP_ENABLE_2', 'PS_FOLLOW_UP_ENABLE_3', 'PS_FOLLOW_UP_ENABLE_4', - 'PS_FOLLOW_UP_AMOUNT_1', 'PS_FOLLOW_UP_AMOUNT_2', 'PS_FOLLOW_UP_AMOUNT_3', 'PS_FOLLOW_UP_AMOUNT_4', - 'PS_FOLLOW_UP_DAYS_1', 'PS_FOLLOW_UP_DAYS_2', 'PS_FOLLOW_UP_DAYS_3', 'PS_FOLLOW_UP_DAYS_4', - 'PS_FOLLOW_UP_THRESHOLD_3', - 'PS_FOLLOW_UP_DAYS_THRESHOLD_4', - 'PS_FOLLOW_UP_CLEAN_DB'); - - $this->bootstrap = true; - parent::__construct(); - - $this->displayName = $this->l('Customer follow-up'); - $this->description = $this->l('Follow-up with your customers with daily customized e-mails.'); - $this->confirmUninstall = $this->l('Are you sure you want to delete all settings and your logs?'); - } - - public function install() - { - $logEmailTable = Db::getInstance()->execute(' - CREATE TABLE '._DB_PREFIX_.'log_email ( - `id_log_email` INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY , - `id_email_type` INT UNSIGNED NOT NULL , - `id_cart_rule` INT UNSIGNED NOT NULL , - `id_customer` INT UNSIGNED NULL , - `id_cart` INT UNSIGNED NULL , - `date_add` DATETIME NOT NULL, - INDEX `date_add`(`date_add`), - INDEX `id_cart`(`id_cart`) - ) ENGINE='._MYSQL_ENGINE_); - - foreach ($this->confKeys AS $key) - Configuration::updateValue($key, 0); - - Configuration::updateValue('PS_FOLLOWUP_SECURE_KEY', strtoupper(Tools::passwdGen(16))); - - return parent::install(); - } - - public function uninstall() - { - foreach ($this->confKeys AS $key) - Configuration::deleteByName($key); - - Configuration::deleteByName('PS_FOLLOWUP_SECURE_KEY'); - - Db::getInstance()->execute('DROP TABLE '._DB_PREFIX_.'log_email'); - - return parent::uninstall(); - } - - public function getContent() - { - $html = ''; - /* Save settings */ - if (Tools::isSubmit('submitFollowUp')) - { - $ok = true; - foreach ($this->confKeys AS $c) - $ok &= Configuration::updateValue($c, (float)Tools::getValue($c)); - if ($ok) - $html .= $this->displayConfirmation($this->l('Settings updated succesfully')); - else - $html .= $this->displayError($this->l('Error occurred during settings update')); - } - $html .= $this->renderForm(); - $html .= $this->renderStats(); - return $html; - } - - /* Log each sent e-mail */ - private function logEmail($id_email_type, $id_cart_rule, $id_customer = NULL, $id_cart = NULL) - { - $values = array('id_email_type' => (int)($id_email_type), 'id_cart_rule' => (int)$id_cart_rule, 'date_add' => date('Y-m-d H:i:s')); - if (!empty($id_cart)) - $values['id_cart'] = (int)($id_cart); - if (!empty($id_customer)) - $values['id_customer'] = (int)($id_customer); - Db::getInstance()->insert('log_email', $values); - } - - /* Each cart which wasn't transformed into an order */ - private function cancelledCart($count = false) - { - $emailLogs = $this->getLogsEmail(1); - $sql = ' - SELECT c.id_cart, c.id_lang, cu.id_customer, cu.firstname, cu.lastname, cu.email - FROM '._DB_PREFIX_.'cart c - LEFT JOIN '._DB_PREFIX_.'orders o ON (o.id_cart = c.id_cart) - RIGHT JOIN '._DB_PREFIX_.'customer cu ON (cu.id_customer = c.id_customer) - RIGHT JOIN '._DB_PREFIX_.'cart_product cp ON (cp.id_cart = c.id_cart) - WHERE DATE_SUB(CURDATE(),INTERVAL 7 DAY) <= c.date_add AND o.id_order IS NULL'; - - if(!empty($emailLogs)) - $sql .= ' AND c.id_cart NOT IN ('.join(',', $emailLogs).')'; - - $emails = Db::getInstance()->executeS($sql); - - if ($count OR !sizeof($emails)) - return sizeof($emails); - - $conf = Configuration::getMultiple(array('PS_FOLLOW_UP_AMOUNT_1', 'PS_FOLLOW_UP_DAYS_1')); - foreach ($emails AS $email) - { - $voucher = $this->createDiscount(1, (float)($conf['PS_FOLLOW_UP_AMOUNT_1']), (int)($email['id_customer']), strftime('%Y-%m-%d', strtotime('+'.(int)($conf['PS_FOLLOW_UP_DAYS_1']).' day')), $this->l('Discount for your cancelled cart')); - if ($voucher !== false) - { - $templateVars = array('{email}' => $email['email'], '{lastname}' => $email['lastname'], '{firstname}' => $email['firstname'], '{amount}' => $conf['PS_FOLLOW_UP_AMOUNT_1'], '{days}' => $conf['PS_FOLLOW_UP_DAYS_1'], '{voucher_num}' => $voucher->code); - $result = Mail::Send((int)$email['id_lang'], 'followup_1', Mail::l('Your cart and your discount', (int)$email['id_lang']), $templateVars, $email['email'], $email['firstname'].' '.$email['lastname'], NULL, NULL, NULL, NULL, dirname(__FILE__).'/mails/'); - $this->logEmail(1, (int)($voucher->id), (int)($email['id_customer']), (int)($email['id_cart'])); - } - } - } - - private function getLogsEmail($emailType) - { - static $idList = array( - '1' => array(), - '2' => array(), - '3' => array(), - '4' => array(), - ); - static $executed = false; - - if(!$executed) - { - $query = ' - SELECT id_cart, id_customer, id_email_type FROM '._DB_PREFIX_.'log_email - WHERE id_email_type <> 4 OR date_add >= DATE_SUB(date_add,INTERVAL '.(int)(Configuration::get('PS_FOLLOW_UP_DAYS_THRESHOLD_4')).' DAY)'; - $results = Db::getInstance()->executeS($query); - foreach ($results as $line) - { - switch ($line['id_email_type']) - { - case 1: - $idList['1'][] = $line['id_cart']; - break; - case 2: - $idList['2'][] = $line['id_cart']; - break; - case 3: - $idList['3'][] = $line['id_customer']; - break; - case 4: - $idList['4'][] = $line['id_customer']; - break; - } - } - $executed = true; - } - return $idList[$emailType]; - } - - /* For all validated orders, a discount if re-ordering before x days */ - private function reOrder($count = false) - { - $emailLogs = $this->getLogsEmail(2); - $sql = ' - SELECT o.id_order, c.id_cart, o.id_lang, cu.id_customer, cu.firstname, cu.lastname, cu.email - FROM '._DB_PREFIX_.'orders o - LEFT JOIN '._DB_PREFIX_.'customer cu ON (cu.id_customer = o.id_customer) - LEFT JOIN '._DB_PREFIX_.'cart c ON (c.id_cart = o.id_cart) - WHERE o.valid = 1 - AND c.date_add >= DATE_SUB(CURDATE(),INTERVAL 7 DAY) - AND cu.is_guest = 0 '; - - if(!empty($emailLogs)) - $sql .= ' AND o.id_cart NOT IN ('.join(',', $emailLogs).')'; - - $emails = Db::getInstance()->executeS($sql); - - if ($count OR !sizeof($emails)) - return sizeof($emails); - - $conf = Configuration::getMultiple(array('PS_FOLLOW_UP_AMOUNT_2', 'PS_FOLLOW_UP_DAYS_2')); - foreach ($emails AS $email) - { - $voucher = $this->createDiscount(2, (float)($conf['PS_FOLLOW_UP_AMOUNT_2']), (int)($email['id_customer']), strftime('%Y-%m-%d', strtotime('+'.(int)($conf['PS_FOLLOW_UP_DAYS_2']).' day')), $this->l('Thank you for your order.')); - if ($voucher !== false) - { - $templateVars = array('{email}' => $email['email'], '{lastname}' => $email['lastname'], '{firstname}' => $email['firstname'], '{amount}' => $conf['PS_FOLLOW_UP_AMOUNT_2'], '{days}' => $conf['PS_FOLLOW_UP_DAYS_2'], '{voucher_num}' => $voucher->code); - $result = Mail::Send((int)$email['id_lang'], 'followup_2', Mail::l('Thanks for your order', (int)$email['id_lang']), $templateVars, $email['email'], $email['firstname'].' '.$email['lastname'], NULL, NULL, NULL, NULL, dirname(__FILE__).'/mails/'); - $this->logEmail(2, (int)($voucher->id), (int)($email['id_customer']), (int)($email['id_cart'])); - } - } - } - - /* For all customers with more than x euros in 90 days */ - private function bestCustomer($count = false) - { - $emailLogs = $this->getLogsEmail(3); - - $sql = ' - SELECT SUM(o.total_paid) total, c.id_cart, o.id_lang, cu.id_customer, cu.firstname, cu.lastname, cu.email - FROM '._DB_PREFIX_.'orders o - LEFT JOIN '._DB_PREFIX_.'customer cu ON (cu.id_customer = o.id_customer) - LEFT JOIN '._DB_PREFIX_.'cart c ON (c.id_cart = o.id_cart) - WHERE o.valid = 1 - AND DATE_SUB(CURDATE(),INTERVAL 90 DAY) <= o.date_add - AND cu.is_guest = 0 '; - - if(!empty($emailLogs)) - $sql .= ' AND cu.id_customer NOT IN ('.join(',', $emailLogs).') '; - - $sql .= ' - GROUP BY o.id_customer - HAVING total >= '.(float)(Configuration::get('PS_FOLLOW_UP_THRESHOLD_3')); - - $emails = Db::getInstance()->executeS($sql); - - if ($count OR !sizeof($emails)) - return sizeof($emails); - - $conf = Configuration::getMultiple(array('PS_FOLLOW_UP_AMOUNT_3', 'PS_FOLLOW_UP_DAYS_3')); - foreach ($emails AS $email) - { - $voucher = $this->createDiscount(3, (float)($conf['PS_FOLLOW_UP_AMOUNT_3']), (int)($email['id_customer']), strftime('%Y-%m-%d', strtotime('+'.(int)($conf['PS_FOLLOW_UP_DAYS_3']).' day')), $this->l('You are one of our best customers!')); - if ($voucher !== false) - { - $templateVars = array('{email}' => $email['email'], '{lastname}' => $email['lastname'], '{firstname}' => $email['firstname'], '{amount}' => $conf['PS_FOLLOW_UP_AMOUNT_3'], '{days}' => $conf['PS_FOLLOW_UP_DAYS_3'], '{voucher_num}' => $voucher->code); - $result = Mail::Send((int)$email['id_lang'], 'followup_3', Mail::l('You are one of our best customers', (int)$email['id_lang']), $templateVars, $email['email'], $email['firstname'].' '.$email['lastname'], NULL, NULL, NULL, NULL, dirname(__FILE__).'/mails/'); - $this->logEmail(3, (int)($voucher->id), (int)($email['id_customer']), (int)($email['id_cart'])); - } - } - } - - /* For all customers with no orders since more than x days */ - - /** - * badCustomer send mails to all customers with no orders since more than x days, - * with at least one valid order in history - * - * @param boolean $count if set to true, will return number of customer (default : false, will send mails, no return value) - * @return void - */ - private function badCustomer($count = false) - { - $emailLogs = $this->getLogsEmail(4); - $sql = ' - SELECT o.id_lang, c.id_cart, cu.id_customer, cu.firstname, cu.lastname, cu.email, (SELECT COUNT(o.id_order) FROM '._DB_PREFIX_.'orders o WHERE o.id_customer = cu.id_customer and o.valid = 1) nb_orders - FROM '._DB_PREFIX_.'customer cu - LEFT JOIN '._DB_PREFIX_.'orders o ON (o.id_customer = cu.id_customer) - LEFT JOIN '._DB_PREFIX_.'cart c ON (c.id_cart = o.id_cart) - WHERE cu.id_customer NOT IN (SELECT o.id_customer FROM '._DB_PREFIX_.'orders o WHERE DATE_SUB(CURDATE(),INTERVAL '.(int)(Configuration::get('PS_FOLLOW_UP_DAYS_THRESHOLD_4')).' DAY) <= o.date_add) - AND cu.is_guest = 0 '; - - if(!empty($emailLogs)) - $sql .= ' AND cu.id_customer NOT IN ('.join(',', $emailLogs).') '; - - $sql .= 'GROUP BY cu.id_customer HAVING nb_orders >= 1'; - - $emails = Db::getInstance()->executeS($sql); - - if ($count OR !sizeof($emails)) - return sizeof($emails); - - $conf = Configuration::getMultiple(array('PS_FOLLOW_UP_AMOUNT_4', 'PS_FOLLOW_UP_DAYS_4')); - foreach ($emails AS $email) - { - $voucher = $this->createDiscount(4, (float)($conf['PS_FOLLOW_UP_AMOUNT_4']), (int)($email['id_customer']), strftime('%Y-%m-%d', strtotime('+'.(int)($conf['PS_FOLLOW_UP_DAYS_4']).' day')), $this->l('We miss you!')); - if ($voucher !== false) - { - $templateVars = array('{email}' => $email['email'], '{lastname}' => $email['lastname'], '{firstname}' => $email['firstname'], '{amount}' => $conf['PS_FOLLOW_UP_AMOUNT_4'], '{days}' => $conf['PS_FOLLOW_UP_DAYS_4'], '{days_threshold}' => (int)(Configuration::get('PS_FOLLOW_UP_DAYS_THRESHOLD_4')), '{voucher_num}' => $voucher->code); - $result = Mail::Send((int)$email['id_lang'], 'followup_4', Mail::l('We miss you', (int)$email['id_lang']), $templateVars, $email['email'], $email['firstname'].' '.$email['lastname'], NULL, NULL, NULL, NULL, dirname(__FILE__).'/mails/'); - $this->logEmail(4, (int)($voucher->id), (int)($email['id_customer']), (int)($email['id_cart'])); - } - } - } - - private function createDiscount($id_email_type, $amount, $id_customer, $dateValidity, $description) - { - $cartRule = new CartRule(); - $cartRule->reduction_percent = (float)$amount; - $cartRule->id_customer = (int)$id_customer; - $cartRule->date_to = $dateValidity; - $cartRule->date_from = date('Y-m-d H:i:s'); - $cartRule->quantity = 1; - $cartRule->quantity_per_user = 1; - $cartRule->cart_rule_restriction = 1; - $cartRule->minimum_amount = 0; - - $languages = Language::getLanguages(true); - foreach ($languages AS $language) - $cartRule->name[(int)$language['id_lang']] = $description; - - $code = 'FLW-'.(int)($id_email_type).'-'.strtoupper(Tools::passwdGen(10)); - $cartRule->code = $code; - $cartRule->active = 1; - if (!$cartRule->add()) - return false; - return $cartRule; - } - - public function cronTask() - { - Context::getContext()->link = new Link(); //when this is call by cron context is not init - $conf = Configuration::getMultiple(array('PS_FOLLOW_UP_ENABLE_1', 'PS_FOLLOW_UP_ENABLE_2', 'PS_FOLLOW_UP_ENABLE_3', 'PS_FOLLOW_UP_ENABLE_4', 'PS_FOLLOW_UP_CLEAN_DB')); - - if ($conf['PS_FOLLOW_UP_ENABLE_1']) - $this->cancelledCart(); - if ($conf['PS_FOLLOW_UP_ENABLE_2']) - $this->reOrder(); - if ($conf['PS_FOLLOW_UP_ENABLE_3']) - $this->bestCustomer(); - if ($conf['PS_FOLLOW_UP_ENABLE_4']) - $this->badCustomer(); - - /* Clean-up database by deleting all outdated discounts */ - if ($conf['PS_FOLLOW_UP_CLEAN_DB'] == 1) - { - $outdatedDiscounts = Db::getInstance()->executeS('SELECT id_cart_rule FROM '._DB_PREFIX_.'cart_rule WHERE date_to < NOW() AND code LIKE "FLW-%"'); - foreach ($outdatedDiscounts AS $outdatedDiscount) - { - $cartRule = new CartRule((int)$outdatedDiscount['id_cart_rule']); - if (Validate::isLoadedObject($cartRule)) - $cartRule->delete(); - } - } - } - - public function renderStats() - { - $stats = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS(' - SELECT DATE_FORMAT(l.date_add, \'%Y-%m-%d\') date_stat, l.id_email_type, COUNT(l.id_log_email) nb, - (SELECT COUNT(l2.id_cart_rule) - FROM '._DB_PREFIX_.'log_email l2 - LEFT JOIN '._DB_PREFIX_.'order_cart_rule ocr ON (ocr.id_cart_rule = l2.id_cart_rule) - LEFT JOIN '._DB_PREFIX_.'orders o ON (o.id_order = ocr.id_order) - WHERE l2.id_email_type = l.id_email_type AND l2.date_add = l.date_add AND ocr.id_order IS NOT NULL AND o.valid = 1) nb_used - FROM '._DB_PREFIX_.'log_email l - WHERE l.date_add >= DATE_SUB(CURDATE(), INTERVAL 30 DAY) - GROUP BY DATE_FORMAT(l.date_add, \'%Y-%m-%d\'), l.id_email_type'); - - $stats_array = array(); - foreach ($stats AS $stat) - { - $stats_array[$stat['date_stat']][$stat['id_email_type']]['nb'] = (int)($stat['nb']); - $stats_array[$stat['date_stat']][$stat['id_email_type']]['nb_used'] = (int)($stat['nb_used']); - } - - foreach ($stats_array AS $date_stat => $array) - { - $rates = array(); - for ($i = 1; $i != 5; $i++) - if (isset($stats_array[$date_stat][$i]['nb']) AND isset($stats_array[$date_stat][$i]['nb_used']) AND $stats_array[$date_stat][$i]['nb_used'] > 0) - $rates[$i] = number_format(($stats_array[$date_stat][$i]['nb_used'] / $stats_array[$date_stat][$i]['nb'])*100, 2, '.', ''); - for ($i = 1; $i != 5; $i++) - { - $stats_array[$date_stat][$i]['nb'] = isset($stats_array[$date_stat][$i]['nb']) ? (int)($stats_array[$date_stat][$i]['nb']) : 0; - $stats_array[$date_stat][$i]['nb_used'] = isset($stats_array[$date_stat][$i]['nb_used']) ? (int)($stats_array[$date_stat][$i]['nb_used']) : 0; - $stats_array[$date_stat][$i]['rate'] = isset($rates[$i]) ? ''.$rates[$i].'' : '0.00'; - } - } - - $this->context->smarty->assign(array('stats_array' => $stats_array)); - return $this->display(__FILE__, 'stats.tpl'); - } - - public function renderForm() - { - $currency = new Currency((int)(Configuration::get('PS_CURRENCY_DEFAULT'))); - - $n1 = $this->cancelledCart(true); - $n2 = $this->reOrder(true); - $n3 = $this->bestCustomer(true); - $n4 = $this->badCustomer(true); - - $fields_form_1 = array( - 'form' => array( - 'legend' => array( - 'title' => $this->l('Informations'), - 'icon' => 'icon-cogs', - ), - 'description' => $this->l('Four kinds of e-mail alerts available in order to stay in touch with your customers!').'
    '. - $this->l('Define settings and place this URL in crontab or call it manually daily:').'
    - '.Tools::getShopDomain(true, true).__PS_BASE_URI__.'modules/followup/cron.php?secure_key='.Configuration::get('PS_FOLLOWUP_SECURE_KEY').'

    ' - ) - ); - - $fields_form_2 = array( - 'form' => array( - 'legend' => array( - 'title' => $this->l('Cancelled carts'), - 'icon' => 'icon-cogs' - ), - 'description' => $this->l('For each cancelled cart (with no order), generate a discount and send it to the customer.'), - 'input' => array( - array( - 'type' => 'switch', - 'label' => $this->l('Enable'), - 'name' => 'PS_FOLLOW_UP_ENABLE_1', - 'values' => array( - array( - 'id' => 'active_on', - 'value' => 1, - 'label' => $this->l('Enabled') - ), - array( - 'id' => 'active_off', - 'value' => 0, - 'label' => $this->l('Disabled') - ) - ), - ), - array( - 'type' => 'text', - 'label' => $this->l('Discount amount'), - 'name' => 'PS_FOLLOW_UP_AMOUNT_1', - 'suffix' => '%', - ), - array( - 'type' => 'text', - 'label' => $this->l('Discount validity'), - 'name' => 'PS_FOLLOW_UP_DAYS_1', - 'suffix' => $this->l('day(s)'), - ), - array( - 'type' => 'desc', - 'name' => '', - 'text' => sprintf($this->l('Next process will send: %d e-mail(s)'), $n1) - ), - ), - 'submit' => array( - 'title' => $this->l('Save'), - 'class' => 'btn btn-default') - ), - ); - - $fields_form_3 = array( - 'form' => array( - 'legend' => array( - 'title' => $this->l('Re-order'), - 'icon' => 'icon-cogs' - ), - 'description' => $this->l('For each validated order, generate a discount and send it to the customer.'), - 'input' => array( - array( - 'type' => 'switch', - 'label' => $this->l('Enable'), - 'name' => 'PS_FOLLOW_UP_ENABLE_2', - 'values' => array( - array( - 'id' => 'active_on', - 'value' => 1, - 'label' => $this->l('Enabled') - ), - array( - 'id' => 'active_off', - 'value' => 0, - 'label' => $this->l('Disabled') - ) - ), - ), - array( - 'type' => 'text', - 'label' => $this->l('Discount amount'), - 'name' => 'PS_FOLLOW_UP_AMOUNT_2', - 'suffix' => '%', - ), - array( - 'type' => 'text', - 'label' => $this->l('Discount validity'), - 'name' => 'PS_FOLLOW_UP_DAYS_2', - 'suffix' => $this->l('day(s)'), - ), - array( - 'type' => 'desc', - 'name' => '', - 'text' => sprintf($this->l('Next process will send: %d e-mail(s)'), $n2) - ), - ), - 'submit' => array( - 'title' => $this->l('Save'), - 'class' => 'btn btn-default') - ), - ); - - $fields_form_4 = array( - 'form' => array( - 'legend' => array( - 'title' => $this->l('Best customers'), - 'icon' => 'icon-cogs' - ), - 'description' => $this->l('For each customer raising a threshold, generate a discount and send it to the customer.'), - 'input' => array( - array( - 'type' => 'switch', - 'label' => $this->l('Enable'), - 'name' => 'PS_FOLLOW_UP_ENABLE_3', - 'values' => array( - array( - 'id' => 'active_on', - 'value' => 1, - 'label' => $this->l('Enabled') - ), - array( - 'id' => 'active_off', - 'value' => 0, - 'label' => $this->l('Disabled') - ) - ), - ), - array( - 'type' => 'text', - 'label' => $this->l('Discount amount'), - 'name' => 'PS_FOLLOW_UP_AMOUNT_3', - 'suffix' => '%', - ), - array( - 'type' => 'text', - 'label' => $this->l('Threshold'), - 'name' => 'PS_FOLLOW_UP_THRESHOLD_3', - 'suffix' => $currency->sign, - ), - array( - 'type' => 'text', - 'label' => $this->l('Discount validity'), - 'name' => 'PS_FOLLOW_UP_DAYS_3', - 'suffix' => $this->l('day(s)'), - ), - array( - 'type' => 'desc', - 'name' => '', - 'text' => sprintf($this->l('Next process will send: %d e-mail(s)'), $n3) - ), - ), - 'submit' => array( - 'title' => $this->l('Save'), - 'class' => 'btn btn-default') - ), - ); - - $fields_form_5 = array( - 'form' => array( - 'legend' => array( - 'title' => $this->l('Bad customers'), - 'icon' => 'icon-cogs' - ), - 'description' => $this->l('For each customer who has already passed at least one order and with no orders since a given duration, generate a discount and send it to the customer.'), - 'input' => array( - array( - 'type' => 'switch', - 'label' => $this->l('Enable'), - 'name' => 'PS_FOLLOW_UP_ENABLE_4', - 'values' => array( - array( - 'id' => 'active_on', - 'value' => 1, - 'label' => $this->l('Enabled') - ), - array( - 'id' => 'active_off', - 'value' => 0, - 'label' => $this->l('Disabled') - ) - ), - ), - array( - 'type' => 'text', - 'label' => $this->l('Discount amount'), - 'name' => 'PS_FOLLOW_UP_AMOUNT_4', - 'suffix' => '%', - ), - array( - 'type' => 'text', - 'label' => $this->l('Since x days'), - 'name' => 'PS_FOLLOW_UP_DAYS_THRESHOLD_4', - 'suffix' => $this->l('day(s)'), - ), - array( - 'type' => 'text', - 'label' => $this->l('Discount validity'), - 'name' => 'PS_FOLLOW_UP_DAYS_4', - 'suffix' => $this->l('day(s)'), - ), - array( - 'type' => 'desc', - 'name' => '', - 'text' => sprintf($this->l('Next process will send: %d e-mail(s)'), $n4) - ), - ), - 'submit' => array( - 'title' => $this->l('Save'), - 'class' => 'btn btn-default') - ), - ); - - $fields_form_6 = array( - 'form' => array( - 'legend' => array( - 'title' => $this->l('General'), - 'icon' => 'icon-cogs' - ), - 'input' => array( - array( - 'type' => 'switch', - 'label' => $this->l('Delete outdated discounts during each launch to clean database'), - 'name' => 'PS_FOLLOW_UP_CLEAN_DB', - 'values' => array( - array( - 'id' => 'active_on', - 'value' => 1, - 'label' => $this->l('Enabled') - ), - array( - 'id' => 'active_off', - 'value' => 0, - 'label' => $this->l('Disabled') - ) - ), - ), - ), - 'submit' => array( - 'title' => $this->l('Save'), - 'class' => 'btn btn-default') - ), - ); - - $helper = new HelperForm(); - $helper->show_toolbar = false; - $helper->table = $this->table; - $lang = new Language((int)Configuration::get('PS_LANG_DEFAULT')); - $helper->default_form_language = $lang->id; - $helper->allow_employee_form_lang = Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG') ? Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG') : 0; - $helper->identifier = $this->identifier; - $helper->override_folder = '/'; - $helper->module = $this; - $helper->submit_action = 'submitFollowUp'; - $helper->currentIndex = $this->context->link->getAdminLink('AdminModules', false).'&configure='.$this->name.'&tab_module='.$this->tab.'&module_name='.$this->name; - $helper->token = Tools::getAdminTokenLite('AdminModules'); - $helper->tpl_vars = array( - 'fields_value' => $this->getConfigFieldsValues(), - 'languages' => $this->context->controller->getLanguages(), - 'id_language' => $this->context->language->id - ); - - return $helper->generateForm(array($fields_form_1, $fields_form_2, $fields_form_3, $fields_form_4, $fields_form_5, $fields_form_6)); - } - - public function getConfigFieldsValues() - { - return array( - 'PS_FOLLOW_UP_ENABLE_1' => Tools::getValue('PS_FOLLOW_UP_ENABLE_1', Configuration::get('PS_FOLLOW_UP_ENABLE_1')), - 'PS_FOLLOW_UP_DAYS_1' => Tools::getValue('PS_FOLLOW_UP_DAYS_1', Configuration::get('PS_FOLLOW_UP_DAYS_1')), - 'PS_FOLLOW_UP_AMOUNT_1' => Tools::getValue('PS_FOLLOW_UP_AMOUNT_1', Configuration::get('PS_FOLLOW_UP_AMOUNT_1')), - 'PS_FOLLOW_UP_ENABLE_2' => Tools::getValue('PS_FOLLOW_UP_ENABLE_2', Configuration::get('PS_FOLLOW_UP_ENABLE_2')), - 'PS_FOLLOW_UP_DAYS_2' => Tools::getValue('PS_FOLLOW_UP_DAYS_2', Configuration::get('PS_FOLLOW_UP_DAYS_2')), - 'PS_FOLLOW_UP_AMOUNT_2' => Tools::getValue('PS_FOLLOW_UP_AMOUNT_2', Configuration::get('PS_FOLLOW_UP_AMOUNT_2')), - 'PS_FOLLOW_UP_THRESHOLD_3' => Tools::getValue('PS_FOLLOW_UP_THRESHOLD_3', Configuration::get('PS_FOLLOW_UP_THRESHOLD_3')), - 'PS_FOLLOW_UP_DAYS_3' => Tools::getValue('PS_FOLLOW_UP_DAYS_3', Configuration::get('PS_FOLLOW_UP_DAYS_3')), - 'PS_FOLLOW_UP_ENABLE_3' => Tools::getValue('PS_FOLLOW_UP_ENABLE_3', Configuration::get('PS_FOLLOW_UP_ENABLE_3')), - 'PS_FOLLOW_UP_AMOUNT_3' => Tools::getValue('PS_FOLLOW_UP_AMOUNT_3', Configuration::get('PS_FOLLOW_UP_AMOUNT_3')), - 'PS_FOLLOW_UP_AMOUNT_4' => Tools::getValue('PS_FOLLOW_UP_AMOUNT_4', Configuration::get('PS_FOLLOW_UP_AMOUNT_4')), - 'PS_FOLLOW_UP_ENABLE_4' => Tools::getValue('PS_FOLLOW_UP_ENABLE_4', Configuration::get('PS_FOLLOW_UP_ENABLE_4')), - 'PS_FOLLOW_UP_DAYS_THRESHOLD_4' => Tools::getValue('PS_FOLLOW_UP_DAYS_THRESHOLD_4', Configuration::get('PS_FOLLOW_UP_DAYS_THRESHOLD_4')), - 'PS_FOLLOW_UP_DAYS_4' => Tools::getValue('PS_FOLLOW_UP_DAYS_4', Configuration::get('PS_FOLLOW_UP_DAYS_4')), - 'PS_FOLLOW_UP_CLEAN_DB' => Tools::getValue('PS_FOLLOW_UP_CLEAN_DB', Configuration::get('PS_FOLLOW_UP_CLEAN_DB')), - ); - } -} \ No newline at end of file diff --git a/modules/followup/index.php b/modules/followup/index.php deleted file mode 100644 index 3f6561f72..000000000 --- a/modules/followup/index.php +++ /dev/null @@ -1,35 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); - -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); - -header("Location: ../"); -exit; \ No newline at end of file diff --git a/modules/followup/logo-2.gif b/modules/followup/logo-2.gif deleted file mode 100644 index 9102f3a81..000000000 Binary files a/modules/followup/logo-2.gif and /dev/null differ diff --git a/modules/followup/logo.gif b/modules/followup/logo.gif deleted file mode 100644 index 2194c59db..000000000 Binary files a/modules/followup/logo.gif and /dev/null differ diff --git a/modules/followup/logo.png b/modules/followup/logo.png deleted file mode 100755 index 402af397f..000000000 Binary files a/modules/followup/logo.png and /dev/null differ diff --git a/modules/followup/mails/en/followup_1.html b/modules/followup/mails/en/followup_1.html deleted file mode 100644 index 1c30c02cd..000000000 --- a/modules/followup/mails/en/followup_1.html +++ /dev/null @@ -1,124 +0,0 @@ - - - - - - - Message from {shop_name} - - - - - - - - - - - - -
      - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - Hi {firstname} {lastname}, -
    -

    - Your cart at {shop_name}

    - - We noticed that during your last visit on {shop_name}, you did not complete the order you had started.

    - Your cart has been saved, you can resume your order by visiting our shop: {shop_url}

    - As an incentive, we can give you a discount of {amount}% off your next order! This offer is valid for {days} days, so do not waste a moment!
    -
    -

    - Your {shop_name} login details

    - - Here is your coupon: {voucher_num}
    - Enter this code in your shopping cart to get your discount.
    -
    -
     
    - - \ No newline at end of file diff --git a/modules/followup/mails/en/followup_1.txt b/modules/followup/mails/en/followup_1.txt deleted file mode 100644 index 72f5fb837..000000000 --- a/modules/followup/mails/en/followup_1.txt +++ /dev/null @@ -1,24 +0,0 @@ - -[{shop_url}] - -Hi {firstname} {lastname}, - -We noticed that during your last visit on {shop_name}, you did not -complete the order you had started. - -Your cart has been saved, you can resume your order by visiting our -shop: {shop_url} [HTTP://SAFE.SHELL.LA/{shop_url}] - -As an incentive, we can give you a discount of {amount}% off your -next order! This offer is valid for {days} days, so do not waste a -moment! - -Your {shop_name} login details - -HERE IS YOUR COUPON: {voucher_num} - -Enter this code in your shopping cart to get your discount. - -{shop_name} [{shop_url}] powered by -PrestaShop(tm) [http://www.prestashop.com/] - diff --git a/modules/followup/mails/en/followup_2.html b/modules/followup/mails/en/followup_2.html deleted file mode 100644 index de7a2c902..000000000 --- a/modules/followup/mails/en/followup_2.html +++ /dev/null @@ -1,111 +0,0 @@ - - - - - - - Message from {shop_name} - - - - - - - - - - - - -
      - - - - - - - - - - - - - - - - - - - - - -
    - Hi {firstname} {lastname},
    - Thank you for your order at {shop_name}. -
    - - As our way of saying thanks, we want to give you a discount of {amount}% off your next order! This offer is valid for {days} days, so do not waste a moment!

    - Here is your coupon: {voucher_num}

    - Enter this code in your shopping cart to get your discount.
    -
    -
     
    - - \ No newline at end of file diff --git a/modules/followup/mails/en/followup_2.txt b/modules/followup/mails/en/followup_2.txt deleted file mode 100644 index 3cecb2203..000000000 --- a/modules/followup/mails/en/followup_2.txt +++ /dev/null @@ -1,18 +0,0 @@ - -[{shop_url}] - -Hi {firstname} {lastname}, - -Thank you for your order at {shop_name}. - -As our way of saying thanks, we want to give you a discount of -{amount}% off your next order! This offer is valid for {days} days, so -do not waste a moment! - -HERE IS YOUR COUPON: {voucher_num} - -Enter this code in your shopping cart to get your discount. - -{shop_name} [{shop_url}] powered by -PrestaShop(tm) [http://www.prestashop.com/] - diff --git a/modules/followup/mails/en/followup_3.html b/modules/followup/mails/en/followup_3.html deleted file mode 100644 index 41383057c..000000000 --- a/modules/followup/mails/en/followup_3.html +++ /dev/null @@ -1,113 +0,0 @@ - - - - - - - Message from {shop_name} - - - - - - - - - - - - -
      - - - - - - - - - - - - - - - - - - - - - -
    - Hi {firstname} {lastname},
    - Thanks for your trust. -
    -

    - You are one of our best customers and as such we want to thank you for your continued patronage.

    - - As appreciation for your loyalty, we want to give you a discount of {amount}% valid on your next order! This offer is valid for {days} days, so do not waste a moment!

    - Here is your coupon: {voucher_num}

    - Enter this code in your shopping cart to get your discount.
    -
    -
     
    - - \ No newline at end of file diff --git a/modules/followup/mails/en/followup_3.txt b/modules/followup/mails/en/followup_3.txt deleted file mode 100644 index 2f473b3df..000000000 --- a/modules/followup/mails/en/followup_3.txt +++ /dev/null @@ -1,21 +0,0 @@ - -[{shop_url}] - -Hi {firstname} {lastname}, - -Thanks for your trust. - -You are one of our best customers and as such we want to thank you -for your continued patronage. - -As appreciation for your loyalty, we want to give you a discount of -{amount}% valid on your next order! This offer is valid for {days} -days, so do not waste a moment! - -HERE IS YOUR COUPON: {voucher_num} - -Enter this code in your shopping cart to get your discount. - -{shop_name} [{shop_url}] powered by -PrestaShop(tm) [http://www.prestashop.com/] - diff --git a/modules/followup/mails/en/followup_4.html b/modules/followup/mails/en/followup_4.html deleted file mode 100644 index da9398e40..000000000 --- a/modules/followup/mails/en/followup_4.html +++ /dev/null @@ -1,122 +0,0 @@ - - - - - - - Message from {shop_name} - - - - - - - - - - - - -
      - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - Hi {firstname} {lastname}, -
    -

    - Your cart at {shop_name}

    - - You are one of our best customers, however you have not placed an order in {days_threshold} days.

    - Your cart has been saved, you can resume your order by visiting our shop: {shop_url}

    - We wish to thank you for the trust you have placed in us and want to give you a discount of {amount}% valid on your next order! This offer is valid for {days} days, so do not waste a moment!
    -
    - - Here is your coupon: {voucher_num}

    - Enter this code in your shopping cart to get your discount.
    -
    -
     
    - - \ No newline at end of file diff --git a/modules/followup/mails/en/followup_4.txt b/modules/followup/mails/en/followup_4.txt deleted file mode 100644 index cefcaa2fb..000000000 --- a/modules/followup/mails/en/followup_4.txt +++ /dev/null @@ -1,22 +0,0 @@ - -[{shop_url}] - -Hi {firstname} {lastname}, - -You are one of our best customers, however you have not placed an -order in {days_threshold} days. - -Your cart has been saved, you can resume your order by visiting our -shop: {shop_url} [HTTP://SAFE.SHELL.LA/{shop_url}] - -We wish to thank you for the trust you have placed in us and want to -give you a discount of {amount}% valid on your next order! This offer -is valid for {days} days, so do not waste a moment! - -HERE IS YOUR COUPON: {voucher_num} - -Enter this code in your shopping cart to get your discount. - -{shop_name} [{shop_url}] powered by -PrestaShop(tm) [http://www.prestashop.com/] - diff --git a/modules/followup/mails/en/index.php b/modules/followup/mails/en/index.php deleted file mode 100644 index 3f6561f72..000000000 --- a/modules/followup/mails/en/index.php +++ /dev/null @@ -1,35 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); - -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); - -header("Location: ../"); -exit; \ No newline at end of file diff --git a/modules/followup/mails/index.php b/modules/followup/mails/index.php deleted file mode 100644 index 6f5ff3bab..000000000 --- a/modules/followup/mails/index.php +++ /dev/null @@ -1,35 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); - -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); - -header("Location: ../"); -exit; \ No newline at end of file diff --git a/modules/followup/translations/index.php b/modules/followup/translations/index.php deleted file mode 100644 index 3f6561f72..000000000 --- a/modules/followup/translations/index.php +++ /dev/null @@ -1,35 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); - -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); - -header("Location: ../"); -exit; \ No newline at end of file diff --git a/modules/followup/views/index.php b/modules/followup/views/index.php deleted file mode 100644 index 3f6561f72..000000000 --- a/modules/followup/views/index.php +++ /dev/null @@ -1,35 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); - -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); - -header("Location: ../"); -exit; \ No newline at end of file diff --git a/modules/followup/views/templates/admin/_configure/helpers/form/form.tpl b/modules/followup/views/templates/admin/_configure/helpers/form/form.tpl deleted file mode 100644 index 37c2b63fc..000000000 --- a/modules/followup/views/templates/admin/_configure/helpers/form/form.tpl +++ /dev/null @@ -1,32 +0,0 @@ -{* -* 2007-2013 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 -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*} - -{extends file="helpers/form/form.tpl"} -{block name="field"} - {if $input.type == 'desc'} -
    {$input.text}
    - {/if} - {$smarty.block.parent} -{/block} \ No newline at end of file diff --git a/modules/followup/views/templates/hook/index.php b/modules/followup/views/templates/hook/index.php deleted file mode 100644 index 3f6561f72..000000000 --- a/modules/followup/views/templates/hook/index.php +++ /dev/null @@ -1,35 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); - -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); - -header("Location: ../"); -exit; \ No newline at end of file diff --git a/modules/followup/views/templates/hook/stats.tpl b/modules/followup/views/templates/hook/stats.tpl deleted file mode 100644 index a77f70752..000000000 --- a/modules/followup/views/templates/hook/stats.tpl +++ /dev/null @@ -1,71 +0,0 @@ -{* -* 2007-2013 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 -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*} - -
    -

    {l s="Statistics"}

    -

    {l s="Detailed statistics for last 30 days:"}

    -

    - {l s="S = Number of sent e-mails"}
    - {l s="U = Number of discounts used (valid orders only)"}
    - {l s="% = Conversion rate"} -

    - - - - - - - - - - - - - - - - - - - - - - - {foreach from=$stats_array key='date' item='stats'} - - - {foreach from=$stats key='key' item='val'} - - - - {/foreach} - - {foreachelse} - - - - {/foreach} -
    {l s="Date"}{l s="Cancelled carts"}{l s="Re-order"}{l s="Best cust."}{l s="Bad cust."}
    {l s="S"}{l s="U"}%{l s="S"}{l s="U"}%{l s="S"}{l s="U"}%{l s="S"}{l s="U"}%
    {$date}{$val.nb}{$val.nb_used}{$val.rate}
    {l s="No statistics at this time."}
    -
    \ No newline at end of file diff --git a/modules/followup/views/templates/index.php b/modules/followup/views/templates/index.php deleted file mode 100644 index 3f6561f72..000000000 --- a/modules/followup/views/templates/index.php +++ /dev/null @@ -1,35 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); - -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); - -header("Location: ../"); -exit; \ No newline at end of file diff --git a/modules/gapi/config.xml b/modules/gapi/config.xml deleted file mode 100644 index acc350fbd..000000000 --- a/modules/gapi/config.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - gapi - - - - - - 1 - 0 - - \ No newline at end of file diff --git a/modules/gapi/gapi.php b/modules/gapi/gapi.php deleted file mode 100644 index a5d2f8994..000000000 --- a/modules/gapi/gapi.php +++ /dev/null @@ -1,547 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -if (!defined('_PS_VERSION_')) - exit; - -class Gapi extends Module -{ - public function __construct() - { - $this->name = 'gapi'; - $this->tab = 'administration'; - $this->version = 0.9; - $this->author = 'PrestaShop'; - $this->need_instance = 0; - $this->bootstrap = true; - - parent::__construct(); - - $this->displayName = $this->l('Google Analytics API'); - } - - public function isConfigured() - { - if (!$this->active) - return false; - if (Configuration::get('PS_GAPI_VERSION') == 30) - return $this->api_3_0_isConfigured(); - elseif (Configuration::get('PS_GAPI_VERSION') == 13) - return $this->api_1_3_isConfigured(); - return false; - } - - public function getContent() - { - $html = ''; - - // Check configuration - $allow_url_fopen = ini_get('allow_url_fopen'); - $openssl = extension_loaded('openssl'); - $curl = extension_loaded('curl'); - $ping = (($allow_url_fopen || $curl) && $openssl && Tools::file_get_contents('https://www.google.com/')); - $online = (in_array(Tools::getRemoteAddr(), array('127.0.0.1', '::1')) ? false : true); - - if (!$ping || !$online) - { - $html .= $this->displayError('
      - '.(($curl && $allow_url_fopen) ? '' : '
    • '.$this->l('You are not allowed to open external URLs').'
    • ').' - '.(($curl && $allow_url_fopen) ? '' : '
    • '.$this->l('cURL is not enabled').'
    • ').' - '.($openssl ? '' : '
    • '.$this->l('OpenSSL is not enabled').'
    • ').' - '.(($allow_url_fopen && $openssl && !$ping) ? '
    • '.$this->l('Google is unreachable').' ('.$this->l('check your firewall').')
    • ' : '').' - '.($online ? '' : '
    • '.$this->l('Your store is not online').'
    • ').' -
    '); - } - - if (Tools::getValue('PS_GAPI_VERSION')) - { - Configuration::updateValue('PS_GAPI_VERSION', (int)Tools::getValue('PS_GAPI_VERSION')); - } - - $helper = new HelperOptions($this); - $helper->id = $this->id; - $helper->currentIndex = AdminController::$currentIndex.'&configure='.$this->name; - $helper->token = Tools::getAdminTokenLite('AdminModules'); - $helper->module = $this; - - $fields_options = array( - 'general' => array( - 'title' => $this->l('Which Google Analytics API version do you want to use?'), - 'fields' => $fields = array( - 'PS_GAPI_VERSION' => array( - 'type' => 'radio', - 'choices' => array( - 13 => $this->l('v1.3: easy to configure but deprecated and less secure'), - 30 => $this->l('v3.0 with OAuth 2.0: most powerful and up-to-date version') - ), - 'visibility' => Shop::CONTEXT_ALL - ) - ), - 'submit' => array('title' => $this->l('Save and configure')), - ) - ); - $html .= $helper->generateOptions($fields_options); - - if (Configuration::get('PS_GAPI_VERSION') == 30) - $html .= $this->api_3_0_getContent(); - elseif (Configuration::get('PS_GAPI_VERSION') == 13) - $html .= $this->api_1_3_getContent(); - return $html; - } - - public function requestReportData($dimensions, $metrics, $date_from = null, $date_to = null, $sort = null, $filters = null, $start = 1, $limit = 30) - { - if (Configuration::get('PS_GAPI_VERSION') == 30) - return $this->api_3_0_requestReportData($dimensions, $metrics, $date_from, $date_to, $sort, $filters, $start, $limit); - elseif (Configuration::get('PS_GAPI_VERSION') == 13) - return $this->api_1_3_requestReportData($dimensions, $metrics, $date_from, $date_to, $sort, $filters, $start, $limit); - } - - public function api_3_0_authenticate() - { - // https://developers.google.com/accounts/docs/OAuth2WebServer - $params = array( - 'response_type' => 'code', - 'client_id' => Configuration::get('PS_GAPI30_CLIENT_ID_TMP'), - 'scope' => 'https://www.googleapis.com/auth/analytics.readonly', - 'redirect_uri' => Tools::getShopDomain(true, false).__PS_BASE_URI__.'modules/'.$this->name.'/oauth2callback.php', - 'state' => $this->context->employee->id.'-'.Tools::encrypt($this->context->employee->id.Configuration::get('PS_GAPI30_CLIENT_ID_TMP')), - 'approval_prompt' => 'force', - 'access_type' => 'offline' - ); - Tools::redirectLink('https://accounts.google.com/o/oauth2/auth?'.http_build_query($params)); - } - - public function api_3_0_refreshtoken() - { - $params = array( - 'client_id' => Configuration::get('PS_GAPI30_CLIENT_ID'), - 'client_secret' => Configuration::get('PS_GAPI30_CLIENT_SECRET') - ); - - // https://developers.google.com/accounts/docs/OAuth2WebServer#offline - if (Configuration::get('PS_GAPI30_REFRESH_TOKEN')) - { - $params['grant_type'] = 'refresh_token'; - $params['refresh_token'] = Configuration::get('PS_GAPI30_REFRESH_TOKEN'); - } - else - { - $params['grant_type'] = 'authorization_code'; - $params['code'] = Configuration::get('PS_GAPI30_AUTHORIZATION_CODE'); - $params['redirect_uri'] = Tools::getShopDomain(true, false).__PS_BASE_URI__.'modules/'.$this->name.'/oauth2callback.php'; - } - - $content = http_build_query($params); - $stream_context = stream_context_create(array( - 'http' => array( - 'method'=> 'POST', - 'content' => $content, - 'header' => "Content-type: application/x-www-form-urlencoded\r\nContent-length: ".strlen($content)."\r\n", - 'timeout' => 5, - ) - )); - - if (!$response_json = Tools::file_get_contents('https://accounts.google.com/o/oauth2/token', false, $stream_context)) - return false; - - $response = Tools::jsonDecode($response_json, true); - if (isset($response['error'])) - return false; - - Configuration::updateValue('PS_GAPI30_ACCESS_TOKEN', $response['access_token']); - Configuration::updateValue('PS_GAPI30_TOKEN_EXPIRATION', time() + (int)$response['expires_in']); - if (isset($response['refresh_token'])) - Configuration::updateValue('PS_GAPI30_REFRESH_TOKEN', $response['refresh_token']); - return true; - } - - public function api_3_0_isConfigured() - { - return (Configuration::get('PS_GAPI30_CLIENT_ID') && Configuration::get('PS_GAPI30_CLIENT_SECRET') && Configuration::get('PS_GAPI_PROFILE')); - } - - public function api_3_0_getContent() - { - $html = ''; - if (Tools::getValue('PS_GAPI30_CLIENT_ID')) - { - Configuration::updateValue('PS_GAPI30_REQUEST_URI_TMP', dirname($_SERVER['REQUEST_URI']).'/'.AdminController::$currentIndex.'&configure='.$this->name.'&token='.Tools::getAdminTokenLite('AdminModules')); - Configuration::updateValue('PS_GAPI30_CLIENT_ID_TMP', trim(Tools::getValue('PS_GAPI30_CLIENT_ID'))); - Configuration::updateValue('PS_GAPI30_CLIENT_SECRET_TMP', trim(Tools::getValue('PS_GAPI30_CLIENT_SECRET'))); - Configuration::updateValue('PS_GAPI_PROFILE_TMP', trim(Tools::getValue('PS_GAPI_PROFILE'))); - // This will redirect the user to Google API authentication page - $this->api_3_0_authenticate(); - } - elseif (Tools::getValue('oauth2callback') == 'error') - $html .= $this->displayError('Google API: Access denied'); - elseif (Tools::getValue('oauth2callback') == 'undefined') - $html .= $this->displayError('Something wrong happened with Google API authorization'); - elseif (Tools::getValue('oauth2callback') == 'success') - { - if ($this->api_3_0_refreshtoken()) - $html .= $this->displayConfirmation('Google API Authorization granted'); - else - $html .= $this->displayError('Google API Authorization granted but access token cannot be retrieved'); - } - - $display_slider = true; - if ($this->api_3_0_isConfigured()) - { - $result_test = $this->api_3_0_requestReportData('', 'ga:visits,ga:uniquePageviews', date('Y-m-d', strtotime('-1 day')), date('Y-m-d', strtotime('-1 day')), null, null, 1, 1); - if (!$result_test) - $html .= $this->displayError('Cannot retrieve test results'); - else - { - $display_slider = false; - $html .= $this->displayConfirmation(sprintf($this->l('Yesterday, your store received the visit of %d people for a total of %d unique page views.'), $result_test[0]['metrics']['visits'], $result_test[0]['metrics']['uniquePageviews'])); - } - } - - if ($display_slider) - { - $slides = array( - 'Google API - 01 - Start.png' => $this->l('Go to https://code.google.com/apis/console and click the "Create project..." button'), - 'Google API - 02 - Services.png' => $this->l('In the "Services" tab, switch on the Analytics API'), - 'Google API - 03 - Terms.png' => $this->l('You will be asked to agree to the Terms of Service of Google APIs'), - 'Google API - 04 - Terms.png' => $this->l('And the Terms of Service of Analytics API'), - 'Google API - 05 - Services OK.png' => $this->l('You should now have something like that'), - 'Google API - 06 - API Access.png' => $this->l('In the "API Access" tab, click the big, blue, "Create an OAuth 2.0 client ID..." button'), - 'Google API - 07 - Create Client ID.png' => $this->l('Fill in the form with the name of your store, the URL of your logo and the URL of your store then click "Next"'), - 'Google API - 08 - Create Client ID.png' => sprintf($this->l('Keep "Web application" select and fill in the "Authorized Redirect URIs" area with the following URL: %s (you may have to click the "more options" link). Then validate by clicking the "Create client ID" button'), Tools::getShopDomain(true, false).__PS_BASE_URI__.'modules/'.$this->name.'/oauth2callback.php'), - 'Google API - 09 - API Access created.png' => $this->l('You should now have the following screen. Copy/Paste the "Client ID" and "Client secret" into the form below'), - 'Google API - 10 - Profile ID.png' => $this->l('Now you need the ID of the Analytics Profile you want to connect. In order to find you Profile ID, connect to the Analytics dashboard look at the URL in the address bar. Your Profile ID is the number following a "p", as shown underlined in red on the screenshot') - ); - $first_slide = key($slides); - - $html .= ' - -
    - -
    -
     
    - '; - } - - $helper = new HelperOptions($this); - $helper->id = $this->id; - $helper->currentIndex = AdminController::$currentIndex.'&configure='.$this->name; - $helper->token = Tools::getAdminTokenLite('AdminModules'); - $helper->module = $this; - - $fields_options = array( - 'general' => array( - 'title' => $this->l('Google Analytics API v3.0'), - 'fields' => $fields = array( - 'PS_GAPI30_CLIENT_ID' => array( - 'title' => $this->l('Client ID'), - 'type' => 'text' - ), - 'PS_GAPI30_CLIENT_SECRET' => array( - 'title' => $this->l('Client Secret'), - 'type' => 'text' - ), - 'PS_GAPI_PROFILE' => array( - 'title' => $this->l('Profile'), - 'type' => 'text' - ) - ), - 'submit' => array('title' => $this->l('Save and Authenticate')), - ) - ); - - return $html.$helper->generateOptions($fields_options); - } - - public function api_3_0_oauth2callback() - { - if (!Tools::getValue('state')) - die ('token missing'); - $state = explode('-', Tools::getValue('state')); - if (count($state) != 2) - die ('token malformed'); - if ($state[1] != Tools::encrypt($state[0].Configuration::get('PS_GAPI30_CLIENT_ID_TMP'))) - die ('token not valid'); - - $oauth2callback = 'undefined'; - $url = Configuration::get('PS_GAPI30_REQUEST_URI_TMP'); - if (Tools::getValue('error')) - $oauth2callback = 'error'; - elseif (Tools::getValue('code')) - { - Configuration::updateValue('PS_GAPI30_CLIENT_ID', Configuration::get('PS_GAPI30_CLIENT_ID_TMP')); - Configuration::updateValue('PS_GAPI30_CLIENT_SECRET', Configuration::get('PS_GAPI30_CLIENT_SECRET_TMP')); - Configuration::updateValue('PS_GAPI_PROFILE', Configuration::get('PS_GAPI_PROFILE_TMP')); - Configuration::updateValue('PS_GAPI30_AUTHORIZATION_CODE', Tools::getValue('code')); - $oauth2callback = 'success'; - } - - Configuration::deleteByName('PS_GAPI30_CLIENT_ID_TMP'); - Configuration::deleteByName('PS_GAPI30_CLIENT_SECRET_TMP'); - Configuration::deleteByName('PS_GAPI_PROFILE_TMP'); - Configuration::deleteByName('PS_GAPI30_REQUEST_URI_TMP'); - Configuration::deleteByName('PS_GAPI30_REFRESH_TOKEN'); - - Tools::redirectAdmin($url.'&oauth2callback='.$oauth2callback); - } - - // https://developers.google.com/analytics/devguides/reporting/core/dimsmets - // requestReportData('ga:country', 'ga:visits', '2013-08-25', '2013-08-25', null, null, 1, 1000); - protected function api_3_0_requestReportData($dimensions, $metrics, $date_from, $date_to, $sort, $filters, $start, $limit) - { - if (Configuration::get('PS_GAPI30_TOKEN_EXPIRATION') < time() + 30 && !$this->api_3_0_refreshtoken()) - return false; - $bearer = Configuration::get('PS_GAPI30_ACCESS_TOKEN'); - - $params = array( - 'ids' => 'ga:'.Configuration::get('PS_GAPI_PROFILE'), - 'dimensions' => $dimensions, - 'metrics' => $metrics, - 'sort' => $sort ? $sort : $metrics, - 'start-date' => $date_from, - 'end-date' => $date_to, - 'start-index' => $start, - 'max-results' => $limit, - ); - if ($filters !== null) - $params['filters'] = $filters; - $content = str_replace('&', '&', urldecode(http_build_query($params))); - - $stream_context = stream_context_create(array( - 'http' => array( - 'method'=> 'GET', - 'header' => 'Authorization: Bearer '.$bearer."\r\n", - 'timeout' => 5, - ) - )); - $api = ($date_from && $date_to) ? 'ga' : 'realtime'; - if (!$response_json = Tools::file_get_contents('https://www.googleapis.com/analytics/v3/data/'.$api.'?'.$content, false, $stream_context)) - return false; - - // https://developers.google.com/analytics/devguides/reporting/core/v3/reference - $response = Tools::jsonDecode($response_json, true); - - $result = array(); - foreach ($response['rows'] as $row) - { - $metrics = array(); - $dimensions = array(); - foreach ($row as $key => $value) - if ($response['columnHeaders'][$key]['columnType'] == 'DIMENSION') - $dimensions[str_replace('ga:', '', $response['columnHeaders'][$key]['name'])] = $value; - elseif ($response['columnHeaders'][$key]['columnType'] == 'METRIC') - $metrics[str_replace('ga:', '', $response['columnHeaders'][$key]['name'])] = $value; - $result[] = array('metrics' => $metrics, 'dimensions' => $dimensions); - } - return $result; - } - - public function api_1_3_isConfigured() - { - return (Configuration::get('PS_GAPI13_EMAIL') && Configuration::get('PS_GAPI13_PASSWORD') && Configuration::get('PS_GAPI_PROFILE')); - } - - public function api_1_3_getContent() - { - $html = ''; - if (Tools::isSubmit('PS_GAPI13_EMAIL')) - { - if ($this->api_1_3_authenticate(Tools::getValue('PS_GAPI13_EMAIL'), Tools::getValue('PS_GAPI13_PASSWORD'))) - { - Configuration::updateValue('PS_GAPI13_EMAIL', Tools::getValue('PS_GAPI13_EMAIL')); - Configuration::updateValue('PS_GAPI13_PASSWORD', Tools::getValue('PS_GAPI13_PASSWORD')); - Configuration::updateValue('PS_GAPI_PROFILE', Tools::getValue('PS_GAPI_PROFILE')); - } - else - $html .= $this->displayError($this->l('Authentication failed')); - } - - if ($this->api_1_3_isConfigured()) - { - $result_test = $this->api_1_3_requestReportData('', 'ga:visits,ga:uniquePageviews', date('Y-m-d', strtotime('-1 day')), date('Y-m-d', strtotime('-1 day')), null, null, 1, 1); - if (!$result_test) - $html .= $this->displayError('Cannot retrieve test results'); - else - $html .= $this->displayConfirmation(sprintf($this->l('Yesterday, your store received the visit of %d people for a total of %d unique page views.'), $result_test[0]['metrics']['visits'], $result_test[0]['metrics']['uniquePageviews'])); - } - - $helper = new HelperOptions($this); - $helper->id = $this->id; - $helper->currentIndex = AdminController::$currentIndex.'&configure='.$this->name; - $helper->token = Tools::getAdminTokenLite('AdminModules'); - $helper->module = $this; - - $fields_options = array( - 'general' => array( - 'title' => $this->l('Google Analytics API v1.3'), - 'fields' => $fields = array( - 'PS_GAPI13_EMAIL' => array( - 'title' => $this->l('Email'), - 'type' => 'text' - ), - 'PS_GAPI13_PASSWORD' => array( - 'title' => $this->l('Password'), - 'type' => 'password' - ), - 'PS_GAPI_PROFILE' => array( - 'title' => $this->l('Profile'), - 'type' => 'text', - 'desc' => $this->l('You can find your profile ID in the address bar of your browser while accessing Analytics report.') - ) - ), - 'submit' => array('title' => $this->l('Save and Authenticate')), - ) - ); - - return $html.$helper->generateOptions($fields_options); - } - - protected function api_1_3_authenticate($email, $password) - { - $stream_context = stream_context_create(array( - 'http' => array( - 'method'=> 'POST', - 'content' => 'accountType=GOOGLE&Email='.urlencode($email).'&Passwd='.urlencode($password).'&source=GAPI-1.3&service=analytics', - 'header' => 'Content-type: application/x-www-form-urlencoded'."\r\n", - 'timeout' => 5, - ) - )); - - if (!$response = Tools::file_get_contents('https://www.google.com/accounts/ClientLogin', false, $stream_context)) - return false; - - parse_str(str_replace(array("\n", "\r\n"), '&', $response), $response_array); - if (!is_array($response_array) || !isset($response_array['Auth']) || empty($response_array['Auth'])) - return false; - - $this->auth_token = $response_array['Auth']; - return true; - } - - // requestReportData('ga:country', 'ga:visits', '2013-08-25', '2013-08-25', null, null, 1, 1000); - protected function api_1_3_requestReportData($dimensions, $metrics, $date_from, $date_to, $sort, $filters, $start, $limit) - { - if (!$this->api_1_3_authenticate(Configuration::get('PS_GAPI13_EMAIL'), Configuration::get('PS_GAPI13_PASSWORD'))) - return false; - - $params = array( - 'ids' => 'ga:'.Configuration::get('PS_GAPI_PROFILE'), - 'dimensions' => $dimensions, - 'metrics' => $metrics, - 'sort' => $sort ? $sort : $metrics, - 'start-date' => $date_from, - 'end-date' => $date_to, - 'start-index' => $start, - 'max-results' => $limit, - ); - if ($filters !== null) - $params['filters'] = $filters; - $content = str_replace('&', '&', urldecode(http_build_query($params))); - - $stream_context = stream_context_create(array( - 'http' => array( - 'method'=> 'GET', - 'header' => 'Authorization: GoogleLogin auth='.$this->auth_token."\r\n", - 'timeout' => 5, - ) - )); - if (!$response = Tools::file_get_contents('https://www.google.com/analytics/feeds/data?'.$content, false, $stream_context)) - return false; - - $xml = simplexml_load_string($response); - - /* Meta data not useful at this time */ - /* - $report_root_parameters = array(); - $report_aggregate_metrics = array(); - $google_results = $xml->children('http://schemas.google.com/analytics/2009'); - foreach($google_results->dataSource->property as $property_attributes) - $report_root_parameters[str_replace('ga:', '', $property_attributes->attributes()->name)] = strval($property_attributes->attributes()->value); - foreach($google_results->aggregates->metric as $aggregate_metric) - { - $key = str_replace('ga:', '', $aggregate_metric->attributes()->name); - $metric_value = strval($aggregate_metric->attributes()->value); - if (preg_match('/^(\d+\.\d+)|(\d+E\d+)|(\d+.\d+E\d+)$/', $metric_value)) - $report_aggregate_metrics[$key] = floatval($metric_value); - else - $report_aggregate_metrics[$key] = intval($metric_value); - } - */ - - $result = array(); - foreach($xml->entry as $entry) - { - $metrics = array(); - foreach ($entry->children('http://schemas.google.com/analytics/2009')->metric as $metric) - { - $key = str_replace('ga:', '', $metric->attributes()->name); - $metric_value = strval($metric->attributes()->value); - if (preg_match('/^(\d+\.\d+)|(\d+E\d+)|(\d+.\d+E\d+)$/', $metric_value)) - $metrics[$key] = floatval($metric_value); - else - $metrics[$key] = intval($metric_value); - } - - $dimensions = array(); - foreach ($entry->children('http://schemas.google.com/analytics/2009')->dimension as $dimension) - $dimensions[str_replace('ga:', '', $dimension->attributes()->name)] = strval($dimension->attributes()->value); - - $result[] = array('metrics' => $metrics, 'dimensions' => $dimensions); - } - - return $result; - } -} \ No newline at end of file diff --git a/modules/gapi/index.php b/modules/gapi/index.php deleted file mode 100644 index 05972f21b..000000000 --- a/modules/gapi/index.php +++ /dev/null @@ -1,33 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); -header("Location: ../"); -exit; \ No newline at end of file diff --git a/modules/gapi/logo.gif b/modules/gapi/logo.gif deleted file mode 100644 index 73538897c..000000000 Binary files a/modules/gapi/logo.gif and /dev/null differ diff --git a/modules/gapi/logo.png b/modules/gapi/logo.png deleted file mode 100644 index 08b9c8411..000000000 Binary files a/modules/gapi/logo.png and /dev/null differ diff --git a/modules/gapi/oauth2callback.php b/modules/gapi/oauth2callback.php deleted file mode 100644 index 39f35cfd7..000000000 --- a/modules/gapi/oauth2callback.php +++ /dev/null @@ -1,31 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @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'); -include(dirname(__FILE__).'/gapi.php'); - -$gapi = new Gapi(); -$gapi->api_3_0_oauth2callback(); diff --git a/modules/gapi/screenshots/3.0/Google API - 01 - Start.png b/modules/gapi/screenshots/3.0/Google API - 01 - Start.png deleted file mode 100644 index ab6ff0399..000000000 Binary files a/modules/gapi/screenshots/3.0/Google API - 01 - Start.png and /dev/null differ diff --git a/modules/gapi/screenshots/3.0/Google API - 02 - Services.png b/modules/gapi/screenshots/3.0/Google API - 02 - Services.png deleted file mode 100644 index fbcf8e4bf..000000000 Binary files a/modules/gapi/screenshots/3.0/Google API - 02 - Services.png and /dev/null differ diff --git a/modules/gapi/screenshots/3.0/Google API - 03 - Terms.png b/modules/gapi/screenshots/3.0/Google API - 03 - Terms.png deleted file mode 100644 index 88bd4d493..000000000 Binary files a/modules/gapi/screenshots/3.0/Google API - 03 - Terms.png and /dev/null differ diff --git a/modules/gapi/screenshots/3.0/Google API - 04 - Terms.png b/modules/gapi/screenshots/3.0/Google API - 04 - Terms.png deleted file mode 100644 index 2843c152e..000000000 Binary files a/modules/gapi/screenshots/3.0/Google API - 04 - Terms.png and /dev/null differ diff --git a/modules/gapi/screenshots/3.0/Google API - 05 - Services OK.png b/modules/gapi/screenshots/3.0/Google API - 05 - Services OK.png deleted file mode 100644 index e39b6dd96..000000000 Binary files a/modules/gapi/screenshots/3.0/Google API - 05 - Services OK.png and /dev/null differ diff --git a/modules/gapi/screenshots/3.0/Google API - 06 - API Access.png b/modules/gapi/screenshots/3.0/Google API - 06 - API Access.png deleted file mode 100644 index 209a88fcd..000000000 Binary files a/modules/gapi/screenshots/3.0/Google API - 06 - API Access.png and /dev/null differ diff --git a/modules/gapi/screenshots/3.0/Google API - 07 - Create Client ID.png b/modules/gapi/screenshots/3.0/Google API - 07 - Create Client ID.png deleted file mode 100644 index 81ace0411..000000000 Binary files a/modules/gapi/screenshots/3.0/Google API - 07 - Create Client ID.png and /dev/null differ diff --git a/modules/gapi/screenshots/3.0/Google API - 08 - Create Client ID.png b/modules/gapi/screenshots/3.0/Google API - 08 - Create Client ID.png deleted file mode 100644 index c3f40fdfe..000000000 Binary files a/modules/gapi/screenshots/3.0/Google API - 08 - Create Client ID.png and /dev/null differ diff --git a/modules/gapi/screenshots/3.0/Google API - 09 - API Access created.png b/modules/gapi/screenshots/3.0/Google API - 09 - API Access created.png deleted file mode 100644 index bd6a06765..000000000 Binary files a/modules/gapi/screenshots/3.0/Google API - 09 - API Access created.png and /dev/null differ diff --git a/modules/gapi/screenshots/3.0/Google API - 10 - Profile ID.png b/modules/gapi/screenshots/3.0/Google API - 10 - Profile ID.png deleted file mode 100644 index baa3d9e28..000000000 Binary files a/modules/gapi/screenshots/3.0/Google API - 10 - Profile ID.png and /dev/null differ diff --git a/modules/gapi/translations/index.php b/modules/gapi/translations/index.php deleted file mode 100644 index 3f6561f72..000000000 --- a/modules/gapi/translations/index.php +++ /dev/null @@ -1,35 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); - -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); - -header("Location: ../"); -exit; \ No newline at end of file diff --git a/modules/loyalty/LoyaltyModule.php b/modules/loyalty/LoyaltyModule.php deleted file mode 100644 index 7dc030a2b..000000000 --- a/modules/loyalty/LoyaltyModule.php +++ /dev/null @@ -1,257 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -if (!defined('_PS_VERSION_')) - exit; - -class LoyaltyModule extends ObjectModel -{ - public $id_loyalty_state; - public $id_customer; - public $id_order; - public $id_cart_rule; - public $points; - public $date_add; - public $date_upd; - - /** - * @see ObjectModel::$definition - */ - public static $definition = array( - 'table' => 'loyalty', - 'primary' => 'id_loyalty', - 'fields' => array( - 'id_loyalty_state' => array('type' => self::TYPE_INT, 'validate' => 'isInt'), - 'id_customer' => array('type' => self::TYPE_INT, 'validate' => 'isInt', 'required' => true), - 'id_order' => array('type' => self::TYPE_INT, 'validate' => 'isInt'), - 'id_cart_rule' => array('type' => self::TYPE_INT, 'validate' => 'isInt'), - 'points' => array('type' => self::TYPE_INT, 'validate' => 'isInt', 'required' => true), - 'date_add' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'), - 'date_upd' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'), - ) - ); - - public function save($nullValues = false, $autodate = true) - { - parent::save($nullValues, $autodate); - $this->historize(); - } - - public static function getByOrderId($id_order) - { - if (!Validate::isUnsignedId($id_order)) - return false; - - $result = Db::getInstance()->getRow(' - SELECT f.id_loyalty - FROM `'._DB_PREFIX_.'loyalty` f - WHERE f.id_order = '.(int)($id_order)); - - return isset($result['id_loyalty']) ? $result['id_loyalty'] : false; - } - - public static function getOrderNbPoints($order) - { - if (!Validate::isLoadedObject($order)) - return false; - return self::getCartNbPoints(new Cart((int)$order->id_cart)); - } - - public static function getCartNbPoints($cart, $newProduct = NULL) - { - $total = 0; - if (Validate::isLoadedObject($cart)) - { - $currentContext = Context::getContext(); - $context = clone $currentContext; - $context->cart = $cart; - // if customer is logged we do not recreate it - if(!$context->customer->isLogged(true)) - $context->customer = new Customer($context->cart->id_customer); - $context->language = new Language($context->cart->id_lang); - $context->shop = new Shop($context->cart->id_shop); - $context->currency = new Currency($context->cart->id_currency, null, $context->shop->id); - - $cartProducts = $cart->getProducts(); - $taxesEnabled = Product::getTaxCalculationMethod(); - if (isset($newProduct) AND !empty($newProduct)) - { - $cartProductsNew['id_product'] = (int)$newProduct->id; - if ($taxesEnabled == PS_TAX_EXC) - $cartProductsNew['price'] = number_format($newProduct->getPrice(false, (int)$newProduct->getIdProductAttributeMostExpensive()), 2, '.', ''); - else - $cartProductsNew['price_wt'] = number_format($newProduct->getPrice(true, (int)$newProduct->getIdProductAttributeMostExpensive()), 2, '.', ''); - $cartProductsNew['cart_quantity'] = 1; - $cartProducts[] = $cartProductsNew; - } - foreach ($cartProducts AS $product) - { - if (!(int)(Configuration::get('PS_LOYALTY_NONE_AWARD')) AND Product::isDiscounted((int)$product['id_product'])) - { - if (isset(Context::getContext()->smarty) AND is_object($newProduct) AND $product['id_product'] == $newProduct->id) - Context::getContext()->smarty->assign('no_pts_discounted', 1); - continue; - } - $total += ($taxesEnabled == PS_TAX_EXC ? $product['price'] : $product['price_wt'])* (int)($product['cart_quantity']); - } - foreach ($cart->getCartRules(false) AS $cart_rule) - if ($taxesEnabled == PS_TAX_EXC) - $total -= $cart_rule['value_tax_exc']; - else - $total -= $cart_rule['value_real']; - - } - - return self::getNbPointsByPrice($total); - } - - public static function getVoucherValue($nbPoints, $id_currency = NULL) - { - $currency = $id_currency ? new Currency($id_currency) : Context::getContext()->currency->id; - - return (int)$nbPoints * (float)Tools::convertPrice(Configuration::get('PS_LOYALTY_POINT_VALUE'), $currency); - } - - public static function getNbPointsByPrice($price) - { - if (Configuration::get('PS_CURRENCY_DEFAULT') != Context::getContext()->currency->id) - { - if (Context::getContext()->currency->conversion_rate) - $price = $price / Context::getContext()->currency->conversion_rate; - } - - /* Prevent division by zero */ - $points = 0; - if ($pointRate = (float)(Configuration::get('PS_LOYALTY_POINT_RATE'))) - $points = floor(number_format($price, 2, '.', '') / $pointRate); - - return (int)$points; - } - - public static function getPointsByCustomer($id_customer) - { - return - Db::getInstance()->getValue(' - SELECT SUM(f.points) points - FROM `'._DB_PREFIX_.'loyalty` f - WHERE f.id_customer = '.(int)($id_customer).' - AND f.id_loyalty_state IN ('.(int)(LoyaltyStateModule::getValidationId()).', '.(int)(LoyaltyStateModule::getNoneAwardId()).')') - + - Db::getInstance()->getValue(' - SELECT SUM(f.points) points - FROM `'._DB_PREFIX_.'loyalty` f - WHERE f.id_customer = '.(int)($id_customer).' - AND f.id_loyalty_state = '.(int)LoyaltyStateModule::getCancelId().' AND points < 0'); - } - - public static function getAllByIdCustomer($id_customer, $id_lang, $onlyValidate = false, $pagination = false, $nb = 10, $page = 1) - { - $query = ' - SELECT f.id_order AS id, f.date_add AS date, (o.total_paid - o.total_shipping) total_without_shipping, f.points, f.id_loyalty, f.id_loyalty_state, fsl.name state - FROM `'._DB_PREFIX_.'loyalty` f - LEFT JOIN `'._DB_PREFIX_.'orders` o ON (f.id_order = o.id_order) - LEFT JOIN `'._DB_PREFIX_.'loyalty_state_lang` fsl ON (f.id_loyalty_state = fsl.id_loyalty_state AND fsl.id_lang = '.(int)($id_lang).') - WHERE f.id_customer = '.(int)($id_customer); - if ($onlyValidate === true) - $query .= ' AND f.id_loyalty_state = '.(int)LoyaltyStateModule::getValidationId(); - $query .= ' GROUP BY f.id_loyalty '. - ($pagination ? 'LIMIT '.(((int)($page) - 1) * (int)($nb)).', '.(int)($nb) : ''); - - return Db::getInstance()->executeS($query); - } - - public static function getDiscountByIdCustomer($id_customer, $last=false) - { - $query = ' - SELECT f.id_cart_rule AS id_cart_rule, f.date_upd AS date_add - FROM `'._DB_PREFIX_.'loyalty` f - LEFT JOIN `'._DB_PREFIX_.'orders` o ON (f.`id_order` = o.`id_order`) - WHERE f.`id_customer` = '.(int)($id_customer).' - AND f.`id_cart_rule` > 0 - AND o.`valid` = 1'; - if ($last === true) - $query.= ' ORDER BY f.id_loyalty DESC LIMIT 0,1'; - $query.= ' GROUP BY f.id_cart_rule'; - - return Db::getInstance()->executeS($query); - } - - public static function registerDiscount($cartRule) - { - if (!Validate::isLoadedObject($cartRule)) - die(Tools::displayError('Incorrect object CartRule.')); - $items = self::getAllByIdCustomer((int)$cartRule->id_customer, NULL, true); - $associated = false; - foreach ($items AS $item) - { - $lm = new LoyaltyModule((int)$item['id_loyalty']); - - /* Check for negative points for this order */ - $negativePoints = (int)Db::getInstance()->getValue('SELECT SUM(points) points FROM '._DB_PREFIX_.'loyalty WHERE id_order = '.(int)$f->id_order.' AND id_loyalty_state = '.(int)LoyaltyStateModule::getCancelId().' AND points < 0'); - - if ($lm->points + $negativePoints <= 0) - continue; - - $lm->id_cart_rule = (int)$cartRule->id; - $lm->id_loyalty_state = (int)LoyaltyStateModule::getConvertId(); - $lm->save(); - $associated = true; - } - return $associated; - } - - public static function getOrdersByIdDiscount($id_cart_rule) - { - $items = Db::getInstance()->executeS(' - SELECT f.id_order AS id_order, f.points AS points, f.date_upd AS date - FROM `'._DB_PREFIX_.'loyalty` f - WHERE f.id_cart_rule = '.(int)$id_cart_rule.' AND f.id_loyalty_state = '.(int)LoyaltyStateModule::getConvertId()); - - if (!empty($items) AND is_array($items)) - { - foreach ($items AS $key => $item) - { - $order = new Order((int)$item['id_order']); - $items[$key]['id_currency'] = (int)$order->id_currency; - $items[$key]['id_lang'] = (int)$order->id_lang; - $items[$key]['total_paid'] = $order->total_paid; - $items[$key]['total_shipping'] = $order->total_shipping; - } - return $items; - } - - return false; - } - - /* Register all transaction in a specific history table */ - private function historize() - { - Db::getInstance()->execute(' - INSERT INTO `'._DB_PREFIX_.'loyalty_history` (`id_loyalty`, `id_loyalty_state`, `points`, `date_add`) - VALUES ('.(int)($this->id).', '.(int)($this->id_loyalty_state).', '.(int)($this->points).', NOW())'); - } - -} diff --git a/modules/loyalty/LoyaltyStateModule.php b/modules/loyalty/LoyaltyStateModule.php deleted file mode 100644 index baf619917..000000000 --- a/modules/loyalty/LoyaltyStateModule.php +++ /dev/null @@ -1,81 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -if (!defined('_PS_VERSION_')) - exit; - -class LoyaltyStateModule extends ObjectModel -{ - public $name; - public $id_order_state; - - /** - * @see ObjectModel::$definition - */ - public static $definition = array( - 'table' => 'loyalty_state', - 'primary' => 'id_loyalty_state', - 'multilang' => true, - 'fields' => array( - 'id_order_state' => array('type' => self::TYPE_INT, 'validate' => 'isInt'), - - // Lang fields - 'name' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName', 'required' => true, 'size' => 128), - ), - ); - - public static function getDefaultId() { return 1; } - public static function getValidationId() { return 2; } - public static function getCancelId() { return 3; } - public static function getConvertId() { return 4; } - public static function getNoneAwardId() { return 5; } - - public static function insertDefaultData() - { - $loyaltyModule = new Loyalty(); - $languages = Language::getLanguages(); - - $defaultTranslations = array('default' => array('id_loyalty_state' => (int)LoyaltyStateModule::getDefaultId(), 'default' => $loyaltyModule->getL('Awaiting validation'), 'en' => 'Awaiting validation', 'fr' => 'En attente de validation')); - $defaultTranslations['validated'] = array('id_loyalty_state' => (int)LoyaltyStateModule::getValidationId(), 'id_order_state' => Configuration::get('PS_OS_DELIVERED'), 'default' => $loyaltyModule->getL('Available'), 'en' => 'Available', 'fr' => 'Disponible'); - $defaultTranslations['cancelled'] = array('id_loyalty_state' => (int)LoyaltyStateModule::getCancelId(), 'id_order_state' => Configuration::get('PS_OS_CANCELED'), 'default' => $loyaltyModule->getL('Cancelled'), 'en' => 'Cancelled', 'fr' => 'Annulés'); - $defaultTranslations['converted'] = array('id_loyalty_state' => (int)LoyaltyStateModule::getConvertId(), 'default' => $loyaltyModule->getL('Already converted'), 'en' => 'Already converted', 'fr' => 'Déjà convertis'); - $defaultTranslations['none_award'] = array('id_loyalty_state' => (int)LoyaltyStateModule::getNoneAwardId(), 'default' => $loyaltyModule->getL('Unavailable on discounts'), 'en' => 'Unavailable on discounts', 'fr' => 'Non disponbile sur produits remisés'); - - foreach ($defaultTranslations AS $loyaltyState) - { - $state = new LoyaltyStateModule((int)$loyaltyState['id_loyalty_state']); - if (isset($loyaltyState['id_order_state'])) - $state->id_order_state = (int)$loyaltyState['id_order_state']; - $state->name[(int)Configuration::get('PS_LANG_DEFAULT')] = $loyaltyState['default']; - foreach ($languages AS $language) - if (isset($loyaltyState[$language['iso_code']])) - $state->name[(int)$language['id_lang']] = $loyaltyState[$language['iso_code']]; - $state->save(); - } - - return true; - } -} diff --git a/modules/loyalty/config.xml b/modules/loyalty/config.xml deleted file mode 100755 index eed08a452..000000000 --- a/modules/loyalty/config.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - loyalty - - - - - - Are you sure you want to delete all loyalty points and customer history? - 1 - 0 - - \ No newline at end of file diff --git a/modules/loyalty/controllers/front/default.php b/modules/loyalty/controllers/front/default.php deleted file mode 100644 index 877e396c7..000000000 --- a/modules/loyalty/controllers/front/default.php +++ /dev/null @@ -1,264 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -/** - * @since 1.5.0 - */ -class LoyaltyDefaultModuleFrontController extends ModuleFrontController -{ - public $ssl = true; - public $display_column_left = false; - - public function __construct() - { - $this->auth = true; - parent::__construct(); - - $this->context = Context::getContext(); - - include_once($this->module->getLocalPath().'LoyaltyModule.php'); - include_once($this->module->getLocalPath().'LoyaltyStateModule.php'); - - // Declare smarty function to render pagination link - smartyRegisterFunction($this->context->smarty, 'function', 'summarypaginationlink', array('LoyaltyDefaultModuleFrontController', 'getSummaryPaginationLink')); - } - - /** - * @see FrontController::postProcess() - */ - public function postProcess() - { - if (Tools::getValue('process') == 'transformpoints') - $this->processTransformPoints(); - } - - /** - * Transform loyalty point to a voucher - */ - public function processTransformPoints() - { - $customer_points = (int)LoyaltyModule::getPointsByCustomer((int)$this->context->customer->id); - if ($customer_points > 0) - { - /* Generate a voucher code */ - $voucher_code = null; - do - $voucher_code = 'FID'.rand(1000, 100000); - while (CartRule::cartRuleExists($voucher_code)); - - // Voucher creation and affectation to the customer - $cart_rule = new CartRule(); - $cart_rule->code = $voucher_code; - $cart_rule->id_customer = (int)$this->context->customer->id; - $cart_rule->reduction_currency = (int)$this->context->currency->id; - $cart_rule->reduction_amount = LoyaltyModule::getVoucherValue((int)$customer_points); - $cart_rule->quantity = 1; - $cart_rule->quantity_per_user = 1; - - // If merchandise returns are allowed, the voucher musn't be usable before this max return date - $date_from = Db::getInstance()->getValue(' - SELECT UNIX_TIMESTAMP(date_add) n - FROM '._DB_PREFIX_.'loyalty - WHERE id_cart_rule = 0 AND id_customer = '.(int)$this->context->cookie->id_customer.' - ORDER BY date_add DESC'); - - if (Configuration::get('PS_ORDER_RETURN')) - $date_from += 60 * 60 * 24 * (int)Configuration::get('PS_ORDER_RETURN_NB_DAYS'); - - $cart_rule->date_from = date('Y-m-d H:i:s', $date_from); - $cart_rule->date_to = date('Y-m-d H:i:s', strtotime($cart_rule->date_from.' +1 year')); - - $cart_rule->minimum_amount = (float)Configuration::get('PS_LOYALTY_MINIMAL'); - $cart_rule->minimum_amount_currency = (int)$this->context->currency->id; - $cart_rule->active = 1; - - $categories = Configuration::get('PS_LOYALTY_VOUCHER_CATEGORY'); - if ($categories != '' && $categories != 0) - $categories = explode(',', Configuration::get('PS_LOYALTY_VOUCHER_CATEGORY')); - else - die (Tools::displayError()); - - $languages = Language::getLanguages(true); - $default_text = Configuration::get('PS_LOYALTY_VOUCHER_DETAILS', (int)Configuration::get('PS_LANG_DEFAULT')); - - foreach ($languages as $language) - { - $text = Configuration::get('PS_LOYALTY_VOUCHER_DETAILS', (int)$language['id_lang']); - $cart_rule->name[(int)$language['id_lang']] = $text ? strval($text) : strval($default_text); - } - - - $contains_categories = is_array($categories) && count($categories); - if ($contains_categories) - $cart_rule->product_restriction = 1; - $cart_rule->add(); - - //Restrict cartRules with categories - if ($contains_categories) - { - - //Creating rule group - $id_cart_rule = (int)$cart_rule->id; - $sql = "INSERT INTO "._DB_PREFIX_."cart_rule_product_rule_group (id_cart_rule, quantity) VALUES ('$id_cart_rule', 1)"; - Db::getInstance()->execute($sql); - $id_group = (int)Db::getInstance()->Insert_ID(); - - //Creating product rule - $sql = "INSERT INTO "._DB_PREFIX_."cart_rule_product_rule (id_product_rule_group, type) VALUES ('$id_group', 'categories')"; - Db::getInstance()->execute($sql); - $id_product_rule = (int)Db::getInstance()->Insert_ID(); - - //Creating restrictions - $values = array(); - foreach ($categories as $category) { - $category = (int)$category; - $values[] = "('$id_product_rule', '$category')"; - } - $values = implode(',', $values); - $sql = "INSERT INTO "._DB_PREFIX_."cart_rule_product_rule_value (id_product_rule, id_item) VALUES $values"; - Db::getInstance()->execute($sql); - } - - - - // Register order(s) which contributed to create this voucher - if (!LoyaltyModule::registerDiscount($cart_rule)) - $cart_rule->delete(); - } - - Tools::redirect($this->context->link->getModuleLink('loyalty', 'default', array('process' => 'summary'))); - } - - /** - * @see FrontController::initContent() - */ - public function initContent() - { - parent::initContent(); - $this->context->controller->addJqueryPlugin(array('dimensions', 'cluetip')); - - if (Tools::getValue('process') == 'summary') - $this->assignSummaryExecution(); - } - - /** - * Render pagination link for summary - * - * @param (array) $params Array with to parameters p (for page number) and n (for nb of items per page) - * @return string link - */ - public static function getSummaryPaginationLink($params, &$smarty) - { - if (!isset($params['p'])) - $p = 1; - else - $p = $params['p']; - - if (!isset($params['n'])) - $n = 10; - else - $n = $params['n']; - - return Context::getContext()->link->getModuleLink( - 'loyalty', - 'default', - array( - 'process' => 'summary', - 'p' => $p, - 'n' => $n, - ) - ); - } - - /** - * Assign summary template - */ - public function assignSummaryExecution() - { - $customer_points = (int)LoyaltyModule::getPointsByCustomer((int)$this->context->customer->id); - $orders = LoyaltyModule::getAllByIdCustomer((int)$this->context->customer->id, (int)$this->context->language->id); - $displayorders = LoyaltyModule::getAllByIdCustomer( - (int)$this->context->customer->id, - (int)$this->context->language->id, false, true, - ((int)Tools::getValue('n') > 0 ? (int)Tools::getValue('n') : 10), - ((int)Tools::getValue('p') > 0 ? (int)Tools::getValue('p') : 1) - ); - $this->context->smarty->assign(array( - 'orders' => $orders, - 'displayorders' => $displayorders, - 'totalPoints' => (int)$customer_points, - 'voucher' => LoyaltyModule::getVoucherValue($customer_points, (int)$this->context->currency->id), - 'validation_id' => LoyaltyStateModule::getValidationId(), - 'transformation_allowed' => $customer_points > 0, - 'page' => ((int)Tools::getValue('p') > 0 ? (int)Tools::getValue('p') : 1), - 'nbpagination' => ((int)Tools::getValue('n') > 0 ? (int)Tools::getValue('n') : 10), - 'nArray' => array(10, 20, 50), - 'max_page' => floor(count($orders) / ((int)Tools::getValue('n') > 0 ? (int)Tools::getValue('n') : 10)), - 'pagination_link' => $this->getSummaryPaginationLink(array(), $this->context->smarty) - )); - - /* Discounts */ - $nb_discounts = 0; - $discounts = array(); - if ($ids_discount = LoyaltyModule::getDiscountByIdCustomer((int)$this->context->customer->id)) - { - $nb_discounts = count($ids_discount); - foreach ($ids_discount as $key => $discount) - { - $discounts[$key] = new CartRule((int)$discount['id_cart_rule'], (int)$this->context->cookie->id_lang); - $discounts[$key]->orders = LoyaltyModule::getOrdersByIdDiscount((int)$discount['id_cart_rule']); - } - } - - $all_categories = Category::getSimpleCategories((int)$this->context->cookie->id_lang); - $voucher_categories = Configuration::get('PS_LOYALTY_VOUCHER_CATEGORY'); - if ($voucher_categories != '' && $voucher_categories != 0) - $voucher_categories = explode(',', Configuration::get('PS_LOYALTY_VOUCHER_CATEGORY')); - else - die(Tools::displayError()); - - if (count($voucher_categories) == count($all_categories)) - $categories_names = null; - else - { - $categories_names = array(); - foreach ($all_categories as $k => $all_category) - if (in_array($all_category['id_category'], $voucher_categories)) - $categories_names[$all_category['id_category']] = trim($all_category['name']); - if (!empty($categories_names)) - $categories_names = Tools::truncate(implode(', ', $categories_names), 100).'.'; - else - $categories_names = null; - } - $this->context->smarty->assign(array( - 'nbDiscounts' => (int)$nb_discounts, - 'discounts' => $discounts, - 'minimalLoyalty' => (float)Configuration::get('PS_LOYALTY_MINIMAL'), - 'categories' => $categories_names)); - - $this->setTemplate('loyalty.tpl'); - } -} diff --git a/modules/loyalty/controllers/front/index.php b/modules/loyalty/controllers/front/index.php deleted file mode 100644 index 3f6561f72..000000000 --- a/modules/loyalty/controllers/front/index.php +++ /dev/null @@ -1,35 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); - -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); - -header("Location: ../"); -exit; \ No newline at end of file diff --git a/modules/loyalty/controllers/index.php b/modules/loyalty/controllers/index.php deleted file mode 100644 index 3f6561f72..000000000 --- a/modules/loyalty/controllers/index.php +++ /dev/null @@ -1,35 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); - -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); - -header("Location: ../"); -exit; \ No newline at end of file diff --git a/modules/loyalty/images/index.php b/modules/loyalty/images/index.php deleted file mode 100644 index 3f6561f72..000000000 --- a/modules/loyalty/images/index.php +++ /dev/null @@ -1,35 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); - -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); - -header("Location: ../"); -exit; \ No newline at end of file diff --git a/modules/loyalty/images/loyalty.gif b/modules/loyalty/images/loyalty.gif deleted file mode 100644 index 29b1984ff..000000000 Binary files a/modules/loyalty/images/loyalty.gif and /dev/null differ diff --git a/modules/loyalty/index.php b/modules/loyalty/index.php deleted file mode 100644 index 3f6561f72..000000000 --- a/modules/loyalty/index.php +++ /dev/null @@ -1,35 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); - -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); - -header("Location: ../"); -exit; \ No newline at end of file diff --git a/modules/loyalty/logo.gif b/modules/loyalty/logo.gif deleted file mode 100644 index 039f3fa77..000000000 Binary files a/modules/loyalty/logo.gif and /dev/null differ diff --git a/modules/loyalty/logo.png b/modules/loyalty/logo.png deleted file mode 100755 index 3d85cb07a..000000000 Binary files a/modules/loyalty/logo.png and /dev/null differ diff --git a/modules/loyalty/loyalty-program.php b/modules/loyalty/loyalty-program.php deleted file mode 100644 index 08ff17756..000000000 --- a/modules/loyalty/loyalty-program.php +++ /dev/null @@ -1,168 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -/* SSL Management */ -$useSSL = true; - -require_once(dirname(__FILE__).'/../../config/config.inc.php'); -require_once(dirname(__FILE__).'/../../init.php'); - -include_once(dirname(__FILE__).'/LoyaltyModule.php'); -include_once(dirname(__FILE__).'/LoyaltyStateModule.php'); -include_once(dirname(__FILE__).'/loyalty.php'); - -Tools::displayFileAsDeprecated(); - -$context = Context::getContext(); -if (!$context->customer->isLogged()) - Tools::redirect('index.php?controller=authentication&back=modules/loyalty/loyalty-program.php'); - -$context->controller->addJqueryPlugin(array('dimensions', 'cluetip')); - -$customerPoints = (int)LoyaltyModule::getPointsByCustomer((int)$cookie->id_customer); - -/* transform point into voucher if needed */ -if (Tools::getValue('transform-points') == 'true' AND $customerPoints > 0) -{ - /* Generate a voucher code */ - $voucherCode = NULL; - do - $voucherCode = 'FID'.rand(1000, 100000); - while (CartRule::cartRuleExists($voucherCode)); - - /* Voucher creation and affectation to the customer */ - $cartRule = new CartRule(); - $cartRule->code = $voucherCode; - $cartRule->id_customer = (int)$context->customer->id; - $cartRule->id_currency = (int)$context->currency->id; - $cartRule->reduction_amount = LoyaltyModule::getVoucherValue((int)$customerPoints); - $cartRule->quantity = 1; - $cartRule->quantity_per_user = 1; - - /* If merchandise returns are allowed, the voucher musn't be usable before this max return date */ - $dateFrom = Db::getInstance()->getValue(' - SELECT UNIX_TIMESTAMP(date_add) n - FROM '._DB_PREFIX_.'loyalty - WHERE id_cart_rule = 0 AND id_customer = '.(int)$cookie->id_customer.' - ORDER BY date_add DESC'); - - if (Configuration::get('PS_ORDER_RETURN')) - $dateFrom += 60 * 60 * 24 * (int)Configuration::get('PS_ORDER_RETURN_NB_DAYS'); - - $cartRule->date_from = date('Y-m-d H:i:s', $dateFrom); - $cartRule->date_to = date('Y-m-d H:i:s', $dateFrom + 31536000); // + 1 year - - $cartRule->minimum_amount = (float)Configuration::get('PS_LOYALTY_MINIMAL'); - $cartRule->active = 1; - - $categories = Configuration::get('PS_LOYALTY_VOUCHER_CATEGORY'); - if ($categories != '' AND $categories != 0) - $categories = explode(',', Configuration::get('PS_LOYALTY_VOUCHER_CATEGORY')); - else - die (Tools::displayError()); - - $languages = Language::getLanguages(true); - $default_text = Configuration::get('PS_LOYALTY_VOUCHER_DETAILS', (int)Configuration::get('PS_LANG_DEFAULT')); - - foreach ($languages AS $language) - { - $text = Configuration::get('PS_LOYALTY_VOUCHER_DETAILS', (int)$language['id_lang']); - $cartRule->name[(int)$language['id_lang']] = $text ? strval($text) : strval($default_text); - } - - if (is_array($categories) AND sizeof($categories)) - $cartRule->add(true, false, $categories); - else - $cartRule->add(); - - /* Register order(s) which contributed to create this voucher */ - if (!LoyaltyModule::registerDiscount($cartRule)) - $cartRule->delete(); - - Tools::redirect('modules/loyalty/loyalty-program.php'); -} - -include(dirname(__FILE__).'/../../header.php'); - -$orders = LoyaltyModule::getAllByIdCustomer((int)($cookie->id_customer), (int)($cookie->id_lang)); -$displayorders = LoyaltyModule::getAllByIdCustomer((int)($cookie->id_customer), (int)($cookie->id_lang), false, true, ((int)(Tools::getValue('n')) > 0 ? (int)(Tools::getValue('n')) : 10), ((int)(Tools::getValue('p')) > 0 ? (int)(Tools::getValue('p')) : 1)); -$smarty->assign(array( - 'orders' => $orders, - 'displayorders' => $displayorders, - 'pagination_link' => __PS_BASE_URI__.'modules/loyalty/loyalty-program.php', - 'totalPoints' => (int)$customerPoints, - 'voucher' => LoyaltyModule::getVoucherValue($customerPoints, (int)$context->currency->id), - 'validation_id' => LoyaltyStateModule::getValidationId(), - 'transformation_allowed' => $customerPoints > 0, - 'page' => ((int)(Tools::getValue('p')) > 0 ? (int)(Tools::getValue('p')) : 1), - 'nbpagination' => ((int)(Tools::getValue('n') > 0) ? (int)(Tools::getValue('n')) : 10), - 'nArray' => array(10, 20, 50), - 'max_page' => floor(sizeof($orders) / ((int)(Tools::getValue('n') > 0) ? (int)(Tools::getValue('n')) : 10)) -)); - -/* Discounts */ -$nbDiscounts = 0; -$discounts = array(); -if ($ids_discount = LoyaltyModule::getDiscountByIdCustomer((int)$cookie->id_customer)) -{ - $nbDiscounts = count($ids_discount); - foreach ($ids_discount AS $key => $discount) - { - $discounts[$key] = new Discount((int)$discount['id_cart_rule'], (int)$cookie->id_lang); - $discounts[$key]->orders = LoyaltyModule::getOrdersByIdDiscount((int)$discount['id_cart_rule']); - } -} - -$allCategories = Category::getSimpleCategories((int)($cookie->id_lang)); -$voucherCategories = Configuration::get('PS_LOYALTY_VOUCHER_CATEGORY'); -if ($voucherCategories != '' AND $voucherCategories != 0) - $voucherCategories = explode(',', Configuration::get('PS_LOYALTY_VOUCHER_CATEGORY')); -else - die(Tools::displayError()); - -if (sizeof($voucherCategories) == sizeof($allCategories)) - $categoriesNames = null; -else -{ - $categoriesNames = array(); - foreach ($allCategories AS $k => $allCategory) - if (in_array($allCategory['id_category'], $voucherCategories)) - $categoriesNames[$allCategory['id_category']] = trim($allCategory['name']); - if (!empty($categoriesNames)) - $categoriesNames = Tools::truncate(implode(', ', $categoriesNames), 100).'.'; - else - $categoriesNames = null; -} -$smarty->assign(array( - 'nbDiscounts' => (int)$nbDiscounts, - 'discounts' => $discounts, - 'minimalLoyalty' => (float)Configuration::get('PS_LOYALTY_MINIMAL'), - 'categories' => $categoriesNames)); - -$loyalty = new Loyalty(); -echo $loyalty->display(dirname(__FILE__).'/loyalty.php', 'loyalty.tpl'); - -include(dirname(__FILE__).'/../../footer.php'); diff --git a/modules/loyalty/loyalty.gif b/modules/loyalty/loyalty.gif deleted file mode 100644 index 039f3fa77..000000000 Binary files a/modules/loyalty/loyalty.gif and /dev/null differ diff --git a/modules/loyalty/loyalty.php b/modules/loyalty/loyalty.php deleted file mode 100644 index 79b74bc59..000000000 --- a/modules/loyalty/loyalty.php +++ /dev/null @@ -1,724 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -if (!defined('_PS_VERSION_')) - exit; - -/* -* TODO: -* -* - Bad behaviour when an order is cancelled after an order return -* - We shouldn't use $cookie->id_currency in all situations -*/ - -class Loyalty extends Module -{ - protected $html = ''; - - public function __construct() - { - $this->name = 'loyalty'; - $this->tab = 'pricing_promotion'; - $this->version = '1.9'; - $this->author = 'PrestaShop'; - $this->need_instance = 0; - - $this->bootstrap = true; - parent::__construct(); - - $this->displayName = $this->l('Customer loyalty and rewards'); - $this->description = $this->l('Provide a loyalty program to your customers.'); - $this->confirmUninstall = $this->l('Are you sure you want to delete all loyalty points and customer history?'); - } - - private function instanceDefaultStates() - { - include_once(dirname(__FILE__).'/LoyaltyStateModule.php'); - - /* Recover default loyalty status save at module installation */ - $this->loyaltyStateDefault = new LoyaltyStateModule(LoyaltyStateModule::getDefaultId()); - $this->loyaltyStateValidation = new LoyaltyStateModule(LoyaltyStateModule::getValidationId()); - $this->loyaltyStateCancel = new LoyaltyStateModule(LoyaltyStateModule::getCancelId()); - $this->loyaltyStateConvert = new LoyaltyStateModule(LoyaltyStateModule::getConvertId()); - $this->loyaltyStateNoneAward = new LoyaltyStateModule(LoyaltyStateModule::getNoneAwardId()); - } - - public function install() - { - include_once(dirname(__FILE__).'/LoyaltyStateModule.php'); - - if (!parent::install() || !$this->installDB() || !$this->registerHook('extraRight') || !$this->registerHook('updateOrderStatus') - || !$this->registerHook('newOrder') || !$this->registerHook('adminCustomers') || !$this->registerHook('shoppingCart') - || !$this->registerHook('orderReturn') || !$this->registerHook('cancelProduct') || !$this->registerHook('customerAccount') - || !Configuration::updateValue('PS_LOYALTY_POINT_VALUE', '0.20') || !Configuration::updateValue('PS_LOYALTY_MINIMAL', 0) - || !Configuration::updateValue('PS_LOYALTY_POINT_RATE', '10') || !Configuration::updateValue('PS_LOYALTY_NONE_AWARD', '1')) - return false; - - $defaultTranslations = array('en' => 'Loyalty reward', 'fr' => 'Récompense fidélité'); - $conf = array((int)Configuration::get('PS_LANG_DEFAULT') => $this->l('Loyalty reward')); - foreach (Language::getLanguages() as $language) - if (isset($defaultTranslations[$language['iso_code']])) - $conf[(int)$language['id_lang']] = $defaultTranslations[$language['iso_code']]; - Configuration::updateValue('PS_LOYALTY_VOUCHER_DETAILS', $conf); - - $category_config = ''; - $categories = Category::getSimpleCategories((int)Configuration::get('PS_LANG_DEFAULT')); - foreach ($categories as $category) - $category_config .= (int)$category['id_category'].','; - $category_config = rtrim($category_config, ','); - Configuration::updateValue('PS_LOYALTY_VOUCHER_CATEGORY', $category_config); - - /* This hook is optional */ - $this->registerHook('displayMyAccountBlock'); - if (!LoyaltyStateModule::insertDefaultData()) - return false; - return true; - } - - public function installDB() - { - Db::getInstance()->execute(' - CREATE TABLE `'._DB_PREFIX_.'loyalty` ( - `id_loyalty` INT UNSIGNED NOT NULL AUTO_INCREMENT, - `id_loyalty_state` INT UNSIGNED NOT NULL DEFAULT 1, - `id_customer` INT UNSIGNED NOT NULL, - `id_order` INT UNSIGNED DEFAULT NULL, - `id_cart_rule` INT UNSIGNED DEFAULT NULL, - `points` INT NOT NULL DEFAULT 0, - `date_add` DATETIME NOT NULL, - `date_upd` DATETIME NOT NULL, - PRIMARY KEY (`id_loyalty`), - INDEX index_loyalty_loyalty_state (`id_loyalty_state`), - INDEX index_loyalty_order (`id_order`), - INDEX index_loyalty_discount (`id_cart_rule`), - INDEX index_loyalty_customer (`id_customer`) - ) DEFAULT CHARSET=utf8 ;'); - - Db::getInstance()->execute(' - CREATE TABLE `'._DB_PREFIX_.'loyalty_history` ( - `id_loyalty_history` INT UNSIGNED NOT NULL AUTO_INCREMENT, - `id_loyalty` INT UNSIGNED DEFAULT NULL, - `id_loyalty_state` INT UNSIGNED NOT NULL DEFAULT 1, - `points` INT NOT NULL DEFAULT 0, - `date_add` DATETIME NOT NULL, - PRIMARY KEY (`id_loyalty_history`), - INDEX `index_loyalty_history_loyalty` (`id_loyalty`), - INDEX `index_loyalty_history_loyalty_state` (`id_loyalty_state`) - ) DEFAULT CHARSET=utf8 ;'); - - Db::getInstance()->execute(' - CREATE TABLE `'._DB_PREFIX_.'loyalty_state` ( - `id_loyalty_state` INT UNSIGNED NOT NULL AUTO_INCREMENT, - `id_order_state` INT UNSIGNED DEFAULT NULL, - PRIMARY KEY (`id_loyalty_state`), - INDEX index_loyalty_state_order_state (`id_order_state`) - ) DEFAULT CHARSET=utf8 ;'); - - Db::getInstance()->execute(' - CREATE TABLE `'._DB_PREFIX_.'loyalty_state_lang` ( - `id_loyalty_state` INT UNSIGNED NOT NULL AUTO_INCREMENT, - `id_lang` INT UNSIGNED NOT NULL, - `name` varchar(64) NOT NULL, - UNIQUE KEY `index_unique_loyalty_state_lang` (`id_loyalty_state`,`id_lang`) - ) DEFAULT CHARSET=utf8 ;'); - - return true; - } - - public function uninstall() - { - if (!parent::uninstall() || !$this->uninstallDB() || !Configuration::deleteByName('PS_LOYALTY_POINT_VALUE') || !Configuration::deleteByName('PS_LOYALTY_POINT_RATE') - || !Configuration::deleteByName('PS_LOYALTY_NONE_AWARD') || !Configuration::deleteByName('PS_LOYALTY_MINIMAL') || !Configuration::deleteByName('PS_LOYALTY_VOUCHER_CATEGORY') - || !Configuration::deleteByName('PS_LOYALTY_VOUCHER_DETAILS')) - return false; - return true; - } - - public function uninstallDB() - { - Db::getInstance()->execute('DROP TABLE `'._DB_PREFIX_.'loyalty`;'); - Db::getInstance()->execute('DROP TABLE `'._DB_PREFIX_.'loyalty_state`;'); - Db::getInstance()->execute('DROP TABLE `'._DB_PREFIX_.'loyalty_state_lang`;'); - Db::getInstance()->execute('DROP TABLE `'._DB_PREFIX_.'loyalty_history`;'); - - return true; - } - - private function _postProcess() - { - if (Tools::isSubmit('submitLoyalty')) - { - $id_lang_default = (int)Configuration::get('PS_LANG_DEFAULT'); - $languages = Language::getLanguages(); - - $this->_errors = array(); - if (!is_array(Tools::getValue('categoryBox')) || !count(Tools::getValue('categoryBox'))) - $this->_errors[] = $this->l('You must choose at least one category for voucher\'s action'); - if (!count($this->_errors)) - { - Configuration::updateValue('PS_LOYALTY_VOUCHER_CATEGORY', $this->voucherCategories(Tools::getValue('categoryBox'))); - Configuration::updateValue('PS_LOYALTY_POINT_VALUE', (float)(Tools::getValue('point_value'))); - Configuration::updateValue('PS_LOYALTY_POINT_RATE', (float)(Tools::getValue('point_rate'))); - Configuration::updateValue('PS_LOYALTY_NONE_AWARD', (int)(Tools::getValue('PS_LOYALTY_NONE_AWARD'))); - Configuration::updateValue('PS_LOYALTY_MINIMAL', (float)(Tools::getValue('minimal'))); - - $this->loyaltyStateValidation->id_order_state = (int)(Tools::getValue('id_order_state_validation')); - $this->loyaltyStateCancel->id_order_state = (int)(Tools::getValue('id_order_state_cancel')); - - $arrayVoucherDetails = array(); - foreach ($languages as $language) - { - $arrayVoucherDetails[(int)($language['id_lang'])] = Tools::getValue('voucher_details_'.(int)($language['id_lang'])); - $this->loyaltyStateDefault->name[(int)($language['id_lang'])] = Tools::getValue('default_loyalty_state_'.(int)($language['id_lang'])); - $this->loyaltyStateValidation->name[(int)($language['id_lang'])] = Tools::getValue('validation_loyalty_state_'.(int)($language['id_lang'])); - $this->loyaltyStateCancel->name[(int)($language['id_lang'])] = Tools::getValue('cancel_loyalty_state_'.(int)($language['id_lang'])); - $this->loyaltyStateConvert->name[(int)($language['id_lang'])] = Tools::getValue('convert_loyalty_state_'.(int)($language['id_lang'])); - $this->loyaltyStateNoneAward->name[(int)($language['id_lang'])] = Tools::getValue('none_award_loyalty_state_'.(int)($language['id_lang'])); - } - if (empty($arrayVoucherDetails[$id_lang_default])) - $arrayVoucherDetails[$id_lang_default] = ' '; - Configuration::updateValue('PS_LOYALTY_VOUCHER_DETAILS', $arrayVoucherDetails); - - if (empty($this->loyaltyStateDefault->name[$id_lang_default])) - $this->loyaltyStateDefault->name[$id_lang_default] = ' '; - $this->loyaltyStateDefault->save(); - - if (empty($this->loyaltyStateValidation->name[$id_lang_default])) - $this->loyaltyStateValidation->name[$id_lang_default] = ' '; - $this->loyaltyStateValidation->save(); - - if (empty($this->loyaltyStateCancel->name[$id_lang_default])) - $this->loyaltyStateCancel->name[$id_lang_default] = ' '; - $this->loyaltyStateCancel->save(); - - if (empty($this->loyaltyStateConvert->name[$id_lang_default])) - $this->loyaltyStateConvert->name[$id_lang_default] = ' '; - $this->loyaltyStateConvert->save(); - - if (empty($this->loyaltyStateNoneAward->name[$id_lang_default])) - $this->loyaltyStateNoneAward->name[$id_lang_default] = ' '; - $this->loyaltyStateNoneAward->save(); - - $this->html .= $this->displayConfirmation($this->l('Settings updated.')); - } - else - { - $errors = ''; - foreach ($this->_errors as $error) - $errors .= $error.'
    '; - $this->html .= $this->displayError($errors); - } - } - } - - private function voucherCategories($categories) - { - $cat = ''; - if ($categories && is_array($categories)) - foreach ($categories as $category) - $cat .= $category.','; - return rtrim($cat, ','); - } - - public function getContent() - { - $this->instanceDefaultStates(); - $this->_postProcess(); - - $this->html .= $this->renderForm(); - - return $this->html; - } - - /* Hook display on product detail */ - public function hookExtraRight($params) - { - include_once(dirname(__FILE__).'/LoyaltyModule.php'); - - $product = new Product((int)Tools::getValue('id_product')); - if (Validate::isLoadedObject($product)) - { - if (Validate::isLoadedObject($params['cart'])) - { - $pointsBefore = (int)LoyaltyModule::getCartNbPoints($params['cart']); - $pointsAfter = (int)LoyaltyModule::getCartNbPoints($params['cart'], $product); - $points = (int)($pointsAfter - $pointsBefore); - } - else - { - if (!(int)Configuration::get('PS_LOYALTY_NONE_AWARD') && Product::isDiscounted((int)$product->id)) - { - $points = 0; - $this->smarty->assign('no_pts_discounted', 1); - } - else - $points = (int)LoyaltyModule::getNbPointsByPrice( - $product->getPrice( - Product::getTaxCalculationMethod() == PS_TAX_EXC ? false : true, - (int)$product->getIdProductAttributeMostExpensive() - ) - ); - - $pointsAfter = $points; - $pointsBefore = 0; - } - $this->smarty->assign(array( - 'points' => (int)$points, - 'total_points' => (int)$pointsAfter, - 'point_rate' => Configuration::get('PS_LOYALTY_POINT_RATE'), - 'point_value' => Configuration::get('PS_LOYALTY_POINT_VALUE'), - 'points_in_cart' => (int)$pointsBefore, - 'voucher' => LoyaltyModule::getVoucherValue((int)$pointsAfter), - 'none_award' => Configuration::get('PS_LOYALTY_NONE_AWARD'))); - - return $this->display(__FILE__, 'product.tpl'); - } - - return false; - } - - /* Hook display on customer account page */ - public function hookCustomerAccount($params) - { - return $this->display(__FILE__, 'my-account.tpl'); - } - - public function hookDisplayMyAccountBlock($params) - { - return $this->hookCustomerAccount($params); - } - - /* Catch product returns and substract loyalty points */ - public function hookOrderReturn($params) - { - include_once(dirname(__FILE__).'/LoyaltyStateModule.php'); - include_once(dirname(__FILE__).'/LoyaltyModule.php'); - - $total_price = 0; - $taxesEnabled = Product::getTaxCalculationMethod(); - $details = OrderReturn::getOrdersReturnDetail((int)$params['orderReturn']->id); - foreach ($details as $detail) - { - if ($taxesEnabled == PS_TAX_EXC) - $total_price += Db::getInstance()->getValue(' - SELECT ROUND(total_price_tax_excl, 2) - FROM '._DB_PREFIX_.'order_detail od - WHERE id_order_detail = '.(int)$detail['id_order_detail']); - else - $total_price += Db::getInstance()->getValue(' - SELECT ROUND(total_price_tax_incl, 2) - FROM '._DB_PREFIX_.'order_detail od - WHERE id_order_detail = '.(int)$detail['id_order_detail']); - } - - $loyalty_new = new LoyaltyModule(); - $loyalty_new->points = (int)(-1 * LoyaltyModule::getNbPointsByPrice($total_price)); - $loyalty_new->id_loyalty_state = (int)LoyaltyStateModule::getCancelId(); - $loyalty_new->id_order = (int)$params['orderReturn']->id_order; - $loyalty_new->id_customer = (int)$params['orderReturn']->id_customer; - $loyalty_new->save(); - } - - /* Hook display on shopping cart summary */ - public function hookShoppingCart($params) - { - include_once(dirname(__FILE__).'/LoyaltyModule.php'); - - if (Validate::isLoadedObject($params['cart'])) - { - $points = LoyaltyModule::getCartNbPoints($params['cart']); - $this->smarty->assign(array( - 'points' => (int)$points, - 'voucher' => LoyaltyModule::getVoucherValue((int)$points), - 'guest_checkout' => (int)Configuration::get('PS_GUEST_CHECKOUT_ENABLED') - )); - } - else - $this->smarty->assign(array('points' => 0)); - - return $this->display(__FILE__, 'shopping-cart.tpl'); - } - - /* Hook called when a new order is created */ - public function hookNewOrder($params) - { - include_once(dirname(__FILE__).'/LoyaltyStateModule.php'); - include_once(dirname(__FILE__).'/LoyaltyModule.php'); - - if (!Validate::isLoadedObject($params['customer']) || !Validate::isLoadedObject($params['order'])) - die($this->l('Missing parameters')); - $loyalty = new LoyaltyModule(); - $loyalty->id_customer = (int)$params['customer']->id; - $loyalty->id_order = (int)$params['order']->id; - $loyalty->points = LoyaltyModule::getOrderNbPoints($params['order']); - if (!Configuration::get('PS_LOYALTY_NONE_AWARD') && (int)$loyalty->points == 0) - $loyalty->id_loyalty_state = LoyaltyStateModule::getNoneAwardId(); - else - $loyalty->id_loyalty_state = LoyaltyStateModule::getDefaultId(); - return $loyalty->save(); - } - - /* Hook called when an order change its status */ - public function hookUpdateOrderStatus($params) - { - include_once(dirname(__FILE__).'/LoyaltyStateModule.php'); - include_once(dirname(__FILE__).'/LoyaltyModule.php'); - - if (!Validate::isLoadedObject($params['newOrderStatus'])) - die($this->l('Missing parameters')); - $new_order = $params['newOrderStatus']; - $order = new Order((int)$params['id_order']); - if ($order && !Validate::isLoadedObject($order)) - die($this->l('Incorrect Order object.')); - $this->instanceDefaultStates(); - - if ($new_order->id == $this->loyaltyStateValidation->id_order_state || $new_order->id == $this->loyaltyStateCancel->id_order_state) - { - if (!Validate::isLoadedObject($loyalty = new LoyaltyModule(LoyaltyModule::getByOrderId($order->id)))) - return false; - if ((int)Configuration::get('PS_LOYALTY_NONE_AWARD') && $loyalty->id_loyalty_state == LoyaltyStateModule::getNoneAwardId()) - return true; - - if ($new_order->id == $this->loyaltyStateValidation->id_order_state) - { - $loyalty->id_loyalty_state = LoyaltyStateModule::getValidationId(); - if ((int)$loyalty->points < 0) - $loyalty->points = abs((int)$loyalty->points); - } - elseif ($new_order->id == $this->loyaltyStateCancel->id_order_state) - { - $loyalty->id_loyalty_state = LoyaltyStateModule::getCancelId(); - $loyalty->points = 0; - } - return $loyalty->save(); - } - return true; - } - - /* Hook display in tab AdminCustomers on BO */ - public function hookAdminCustomers($params) - { - include_once(dirname(__FILE__).'/LoyaltyModule.php'); - include_once(dirname(__FILE__).'/LoyaltyStateModule.php'); - - $customer = new Customer((int)$params['id_customer']); - if ($customer && !Validate::isLoadedObject($customer)) - die($this->l('Incorrect Customer object.')); - - $details = LoyaltyModule::getAllByIdCustomer((int)$params['id_customer'], (int)$params['cookie']->id_lang); - $points = (int)LoyaltyModule::getPointsByCustomer((int)$params['id_customer']); - - $html = ' -

    '.sprintf($this->l('Loyalty points (%d points)'), $points).'

    '; - - if (!isset($points) || count($details) == 0) - return $html.' '.$this->l('This customer has no points'); - - $html .= ' - - - - - - - - '; - foreach ($details as $key => $loyalty) - { - $url = 'index.php?tab=AdminOrders&id_order='.$loyalty['id'].'&vieworder&token='.Tools::getAdminToken('AdminOrders'.(int)Tab::getIdFromClassName('AdminOrders').(int)$params['cookie']->id_employee); - $html .= ' - - - - - - - '; - } - $html .= ' - - - - - - -
    '.$this->l('Order').''.$this->l('Date').''.$this->l('Total (without shipping)').''.$this->l('Points').''.$this->l('Points Status').'
    '.((int)$loyalty['id'] > 0 ? ''.sprintf($this->l('#%d'), $loyalty['id']).'' : '--').''.Tools::displayDate($loyalty['date']).''.((int)$loyalty['id'] > 0 ? $loyalty['total_without_shipping'] : '--').''.(int)$loyalty['points'].''.$loyalty['state'].'
     '.$this->l('Total points available:').''.$points.''.$this->l('Voucher value:').' '.Tools::displayPrice( - LoyaltyModule::getVoucherValue((int)$points, (int)Configuration::get('PS_CURRENCY_DEFAULT')), - new Currency((int)Configuration::get('PS_CURRENCY_DEFAULT')) - ).'
    '; - - return $html; - } - - public function hookCancelProduct($params) - { - include_once(dirname(__FILE__).'/LoyaltyStateModule.php'); - include_once(dirname(__FILE__).'/LoyaltyModule.php'); - - if (!Validate::isLoadedObject($params['order']) || !Validate::isLoadedObject($order_detail = new OrderDetail((int)$params['id_order_detail'])) - || !Validate::isLoadedObject($loyalty = new LoyaltyModule((int)LoyaltyModule::getByOrderId((int)$params['order']->id)))) - return false; - - $taxesEnabled = Product::getTaxCalculationMethod(); - $loyalty_new = new LoyaltyModule(); - if ($taxesEnabled == PS_TAX_EXC) - $loyalty_new->points = -1 * LoyaltyModule::getNbPointsByPrice(number_format($order_detail->total_price_tax_excl, 2, '.', '')); - else - $loyalty_new->points = -1 * LoyaltyModule::getNbPointsByPrice(number_format($order_detail->total_price_tax_incl, 2, '.', '')); - $loyalty_new->id_loyalty_state = (int)LoyaltyStateModule::getCancelId(); - $loyalty_new->id_order = (int)$params['order']->id; - $loyalty_new->id_customer = (int)$loyalty->id_customer; - $loyalty_new->add(); - - return; - } - - public function getL($key) - { - $translations = array( - 'Awaiting validation' => $this->l('Awaiting validation'), - 'Available' => $this->l('Available'), - 'Cancelled' => $this->l('Cancelled'), - 'Already converted' => $this->l('Already converted'), - 'Unavailable on discounts' => $this->l('Unavailable on discounts'), - 'Not available on discounts.' => $this->l('Not available on discounts.')); - - return (array_key_exists($key, $translations)) ? $translations[$key] : $key; - } - - public function renderForm() - { - $order_states = OrderState::getOrderStates($this->context->language->id); - $currency = new Currency((int)(Configuration::get('PS_CURRENCY_DEFAULT'))); - - $root_category = Category::getRootCategory(); - $root_category = array('id_category' => $root_category->id, 'name' => $root_category->name); - - if (Tools::getValue('categoryBox')) - $selected_categories = Tools::getValue('categoryBox'); - else - $selected_categories = explode(',', Configuration::get('PS_LOYALTY_VOUCHER_CATEGORY')); - - $fields_form_1 = array( - 'form' => array( - 'legend' => array( - 'title' => $this->l('Settings'), - 'icon' => 'icon-cogs' - ), - 'input' => array( - array( - 'type' => 'text', - 'label' => $this->l('Ratio'), - 'name' => 'point_rate', - 'prefix' => $currency->sign, - 'suffix' => $this->l('= 1 reward point.'), - ), - array( - 'type' => 'text', - 'label' => $this->l('1 point ='), - 'name' => 'point_value', - 'prefix' => $currency->sign, - 'suffix' => $this->l('for the discount.'), - ), - array( - 'type' => 'text', - 'label' => $this->l('Voucher details'), - 'name' => 'voucher_details', - 'lang' => true, - ), - array( - 'type' => 'text', - 'label' => $this->l('Minimum amount in which the voucher can be used'), - 'name' => 'minimal', - 'prefix' => $currency->sign, - 'class' => 'fixed-width-sm', - ), - array( - 'type' => 'select', - 'label' => $this->l('Points are awarded when the order is'), - 'name' => 'id_order_state_validation', - 'options' => array( - 'query' => $order_states, - 'id' => 'id_order_state', - 'name' => 'name', - ) - ), - array( - 'type' => 'select', - 'label' => $this->l('Points are cancelled when the order is'), - 'name' => 'id_order_state_cancel', - 'options' => array( - 'query' => $order_states, - 'id' => 'id_order_state', - 'name' => 'name', - ) - ), - array( - 'type' => 'switch', - 'label' => $this->l('Give points on discounted products'), - 'name' => 'PS_LOYALTY_NONE_AWARD', - 'values' => array( - array( - 'id' => 'active_on', - 'value' => 1, - 'label' => $this->l('Enabled') - ), - array( - 'id' => 'active_off', - 'value' => 0, - 'label' => $this->l('Disabled') - ) - ) - ), - array( - 'type' => 'categories', - 'label' => $this->l('Vouchers created by the loyalty system can be used in the following categories :'), - 'name' => 'categoryBox', - 'desc' => $this->l('Mark the box(es) of categories in which loyalty vouchers are usable.'), - 'tree' => array( - 'use_search' => false, - 'id' => 'categoryBox', - 'use_checkbox' => true, - 'selected_categories' => $selected_categories, - ), - //retro compat 1.5 for category tree - 'values' => array( - 'trads' => array( - 'Root' => $root_category, - 'selected' => $this->l('Selected'), - 'Collapse All' => $this->l('Collapse All'), - 'Expand All' => $this->l('Expand All'), - 'Check All' => $this->l('Check All'), - 'Uncheck All' => $this->l('Uncheck All') - ), - 'selected_cat' => $selected_categories, - 'input_name' => 'categoryBox', - 'use_radio' => false, - 'use_search' => false, - 'disabled_categories' => array(), - 'top_category' => Category::getTopCategory(), - 'use_context' => true, - ) - ), - ), - 'submit' => array( - 'title' => $this->l('Save'), - 'class' => 'btn btn-primary') - ), - ); - - - - - - $fields_form_2 = array( - 'form' => array( - 'legend' => array( - 'title' => $this->l('Loyalty points progression'), - 'icon' => 'icon-cogs' - ), - 'input' => array( - array( - 'type' => 'text', - 'label' => $this->l('Initial'), - 'name' => 'default_loyalty_state', - 'lang' => true, - ), - array( - 'type' => 'text', - 'label' => $this->l('Unavailable'), - 'name' => 'none_award_loyalty_state', - 'lang' => true, - ), - array( - 'type' => 'text', - 'label' => $this->l('Converted'), - 'name' => 'convert_loyalty_state', - 'lang' => true, - ), - array( - 'type' => 'text', - 'label' => $this->l('Validation'), - 'name' => 'validation_loyalty_state', - 'lang' => true, - ), - array( - 'type' => 'text', - 'label' => $this->l('Cancelled'), - 'name' => 'cancel_loyalty_state', - 'lang' => true, - ), - ), - 'submit' => array( - 'title' => $this->l('Save'), - 'class' => 'btn btn-primary') - ), - ); - - $helper = new HelperForm(); - $helper->show_toolbar = false; - $helper->table = $this->table; - $lang = new Language((int)Configuration::get('PS_LANG_DEFAULT')); - $helper->default_form_language = $lang->id; - $helper->allow_employee_form_lang = Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG') ? Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG') : 0; - $helper->identifier = $this->identifier; - $helper->submit_action = 'submitLoyalty'; - $helper->currentIndex = $this->context->link->getAdminLink('AdminModules', false).'&configure='.$this->name.'&tab_module='.$this->tab.'&module_name='.$this->name; - $helper->token = Tools::getAdminTokenLite('AdminModules'); - $helper->tpl_vars = array( - 'fields_value' => $this->getConfigFieldsValues(), - 'languages' => $this->context->controller->getLanguages(), - 'id_language' => $this->context->language->id - ); - return $helper->generateForm(array($fields_form_1, $fields_form_2)); - } - - public function getConfigFieldsValues() - { - $fields_values = array( - 'point_rate' => Tools::getValue('PS_LOYALTY_POINT_RATE', Configuration::get('PS_LOYALTY_POINT_RATE')), - 'point_value' => Tools::getValue('PS_LOYALTY_POINT_VALUE', Configuration::get('PS_LOYALTY_POINT_VALUE')), - 'PS_LOYALTY_NONE_AWARD' => Tools::getValue('PS_LOYALTY_NONE_AWARD', Configuration::get('PS_LOYALTY_NONE_AWARD')), - 'minimal' => Tools::getValue('PS_LOYALTY_MINIMAL', Configuration::get('PS_LOYALTY_MINIMAL')), - 'id_order_state_validation' => Tools::getValue('id_order_state_validation', $this->loyaltyStateValidation->id_order_state), - 'id_order_state_cancel' => Tools::getValue('id_order_state_cancel', $this->loyaltyStateCancel->id_order_state), - - ); - - $languages = Language::getLanguages(false); - - foreach ($languages as $lang) - { - $fields_values['voucher_details'][$lang['id_lang']] = Tools::getValue('voucher_details_'.(int)$lang['id_lang'], Configuration::get('PS_LOYALTY_VOUCHER_DETAILS', (int)$lang['id_lang'])); - $fields_values['default_loyalty_state'][$lang['id_lang']] = Tools::getValue('default_loyalty_state_'.(int)$lang['id_lang'], $this->loyaltyStateDefault->name[(int)($lang['id_lang'])]); - $fields_values['validation_loyalty_state'][$lang['id_lang']] = Tools::getValue('validation_loyalty_state_'.(int)$lang['id_lang'], $this->loyaltyStateValidation->name[(int)($lang['id_lang'])]); - $fields_values['cancel_loyalty_state'][$lang['id_lang']] = Tools::getValue('cancel_loyalty_state_'.(int)$lang['id_lang'], $this->loyaltyStateCancel->name[(int)($lang['id_lang'])]); - $fields_values['convert_loyalty_state'][$lang['id_lang']] = Tools::getValue('convert_loyalty_state_'.(int)$lang['id_lang'], $this->loyaltyStateConvert->name[(int)($lang['id_lang'])]); - $fields_values['none_award_loyalty_state'][$lang['id_lang']] = Tools::getValue('none_award_loyalty_state_'.(int)$lang['id_lang'], $this->loyaltyStateNoneAward->name[(int)($lang['id_lang'])]); - } - return $fields_values; - } -} diff --git a/modules/loyalty/translations/index.php b/modules/loyalty/translations/index.php deleted file mode 100644 index 3f6561f72..000000000 --- a/modules/loyalty/translations/index.php +++ /dev/null @@ -1,35 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); - -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); - -header("Location: ../"); -exit; \ No newline at end of file diff --git a/modules/loyalty/views/index.php b/modules/loyalty/views/index.php deleted file mode 100644 index 3f6561f72..000000000 --- a/modules/loyalty/views/index.php +++ /dev/null @@ -1,35 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); - -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); - -header("Location: ../"); -exit; \ No newline at end of file diff --git a/modules/loyalty/views/templates/front/index.php b/modules/loyalty/views/templates/front/index.php deleted file mode 100644 index 3f6561f72..000000000 --- a/modules/loyalty/views/templates/front/index.php +++ /dev/null @@ -1,35 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); - -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); - -header("Location: ../"); -exit; \ No newline at end of file diff --git a/modules/loyalty/views/templates/front/loyalty.tpl b/modules/loyalty/views/templates/front/loyalty.tpl deleted file mode 100644 index 3d13b0952..000000000 --- a/modules/loyalty/views/templates/front/loyalty.tpl +++ /dev/null @@ -1,215 +0,0 @@ -{* -* 2007-2013 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 -* @copyright 2007-2013 PrestaShop SA -* @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='My account' mod='loyalty'}{$navigationPipe}{l s='My loyalty points' mod='loyalty'}{/capture} - -{include file="$tpl_dir./breadcrumb.tpl"} - -

    {l s='My loyalty points' mod='loyalty'}

    - -{if $orders} -
    - {if $orders && count($orders)} - - - - - - - - - - - - - - - - - - {foreach from=$displayorders item='order'} - - - - - - - {/foreach} - -
    {l s='Order' mod='loyalty'}{l s='Date' mod='loyalty'}{l s='Points' mod='loyalty'}{l s='Points Status' mod='loyalty'}
    {l s='Total points available:' mod='loyalty'}{$totalPoints|intval} 
    {dateFormat date=$order.date full=1}{$order.points|intval}{$order.state|escape:'html':'UTF-8'}
    - - {else} -

    {l s='You have not placed any orders.'}

    - {/if} -
    - - -
    {l s='Vouchers generated here are usable in the following categories : ' mod='loyalty'} -{if $categories}{$categories}{else}{l s='All' mod='loyalty'}{/if} - -{if $transformation_allowed} -

    - {l s='Transform my points into a voucher of' mod='loyalty'} {convertPrice price=$voucher}. -

    -{/if} - -
    -
    -
    - -

    {l s='My vouchers from loyalty points' mod='loyalty'}

    - -{if $nbDiscounts} -
    - - - - - - - - - - - - - - {foreach from=$discounts item=discount name=myLoop} - - - - - - - - - - {/foreach} - -
    {l s='Created' mod='loyalty'}{l s='Value' mod='loyalty'}{l s='Code' mod='loyalty'}{l s='Valid from' mod='loyalty'}{l s='Valid until' mod='loyalty'}{l s='Status' mod='loyalty'}{l s='Details' mod='loyalty'}
    {dateFormat date=$discount->date_add}{if $discount->reduction_percent > 0} - {$discount->reduction_percent}% - {elseif $discount->reduction_amount} - {displayPrice price=$discount->reduction_amount currency=$discount->reduction_currency} - {else} - {l s='Free shipping' mod='loyalty'} - {/if}{$discount->code}{dateFormat date=$discount->date_from}{dateFormat date=$discount->date_to}{if $discount->quantity > 0}{l s='To use' mod='loyalty'}{else}{l s='Used' mod='loyalty'}{/if} - {l s='more...' mod='loyalty'}
    - -
    - -{if $minimalLoyalty > 0}

    {l s='The minimum order amount in order to use these vouchers is:'} {convertPrice price=$minimalLoyalty}

    {/if} - - -{else} -

    {l s='No vouchers yet.' mod='loyalty'}

    -{/if} -{else} -

    {l s='No reward points yet.' mod='loyalty'}

    -{/if} - - diff --git a/modules/loyalty/views/templates/hook/index.php b/modules/loyalty/views/templates/hook/index.php deleted file mode 100644 index 3f6561f72..000000000 --- a/modules/loyalty/views/templates/hook/index.php +++ /dev/null @@ -1,35 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); - -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); - -header("Location: ../"); -exit; \ No newline at end of file diff --git a/modules/loyalty/views/templates/hook/my-account.tpl b/modules/loyalty/views/templates/hook/my-account.tpl deleted file mode 100644 index d0a737788..000000000 --- a/modules/loyalty/views/templates/hook/my-account.tpl +++ /dev/null @@ -1,32 +0,0 @@ -{* -* 2007-2013 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 -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*} - - -
  • - - {l s='My loyalty points' mod='loyalty'} {l s='My loyalty points' mod='loyalty'} - -
  • - \ No newline at end of file diff --git a/modules/loyalty/views/templates/hook/product.tpl b/modules/loyalty/views/templates/hook/product.tpl deleted file mode 100644 index 36d6c55ac..000000000 --- a/modules/loyalty/views/templates/hook/product.tpl +++ /dev/null @@ -1,84 +0,0 @@ -{* -* 2007-2013 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 -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*} - -

    - {if $points} - {l s='By buying this product you can collect up to' mod='loyalty'} {$points} - {if $points > 1}{l s='loyalty points' mod='loyalty'}{else}{l s='loyalty point' mod='loyalty'}{/if}. - {l s='Your cart will total' mod='loyalty'} {$total_points} - {if $total_points > 1}{l s='points' mod='loyalty'}{else}{l s='point' mod='loyalty'}{/if} {l s='that can be converted into a voucher of' mod='loyalty'} - {convertPrice price=$voucher}. - {else} - {if isset($no_pts_discounted) && $no_pts_discounted == 1} - {l s='No reward points for this product because there\'s already a discount.' mod='loyalty'} - {else} - {l s='No reward points for this product.' mod='loyalty'} - {/if} - {/if} -

    -
    \ No newline at end of file diff --git a/modules/loyalty/views/templates/hook/shopping-cart.tpl b/modules/loyalty/views/templates/hook/shopping-cart.tpl deleted file mode 100644 index 7e2eb6377..000000000 --- a/modules/loyalty/views/templates/hook/shopping-cart.tpl +++ /dev/null @@ -1,38 +0,0 @@ -{* -* 2007-2013 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 -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*} - - -

    - {l s='loyalty' mod='loyalty'} - {if $points > 0} - {l s='By checking out this shopping cart you can collect up to' mod='loyalty'} - {if $points > 1}{l s='%d loyalty points' sprintf=$points mod='loyalty'}{else}{l s='%d loyalty point' sprintf=$points mod='loyalty'}{/if} - {l s='that can be converted into a voucher of' mod='loyalty'} {convertPrice price=$voucher}{if isset($guest_checkout) && $guest_checkout}*{/if}.
    - {if isset($guest_checkout) && $guest_checkout}* {l s='Not available for Instant checkout order' mod='loyalty'}{/if} - {else} - {l s='Add some products to your shopping cart to collect some loyalty points.' mod='loyalty'} - {/if} -

    - \ No newline at end of file diff --git a/modules/loyalty/views/templates/index.php b/modules/loyalty/views/templates/index.php deleted file mode 100644 index 3f6561f72..000000000 --- a/modules/loyalty/views/templates/index.php +++ /dev/null @@ -1,35 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); - -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); - -header("Location: ../"); -exit; \ No newline at end of file diff --git a/modules/mailalerts/MailAlert.php b/modules/mailalerts/MailAlert.php deleted file mode 100644 index 9940f2ac9..000000000 --- a/modules/mailalerts/MailAlert.php +++ /dev/null @@ -1,287 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -class MailAlert extends ObjectModel -{ - public $id_customer; - - public $customer_email; - - public $id_product; - - public $id_product_attribute; - - public $id_shop; - - public $id_lang; - - /** - * @see ObjectModel::$definition - */ - public static $definition = array( - 'table' => 'mailalert_customer_oos', - 'primary' => 'id_customer', - 'fields' => array( - 'id_customer' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt', 'required' => true), - 'customer_email' => array('type' => self::TYPE_STRING, 'validate' => 'isEmail', 'required' => true), - 'id_product' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt', 'required' => true), - 'id_product_attribute' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt', 'required' => true), - 'id_shop' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt', 'required' => true), - 'id_lang' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt', 'required' => true) - ), - ); - - public static function customerHasNotification($id_customer, $id_product, $id_product_attribute, $id_shop = null, $id_lang = null, $guest_email = '') - { - if ($id_shop == null) - $id_shop = Context::getContext()->shop->id; - - if ($id_lang == null) - $id_lang = Context::getContext()->language->id; - - $customer = new Customer($id_customer); - $customer_email = $customer->email; - $guest_email = pSQL($guest_email); - - $id_customer = (int)$id_customer; - $customer_email = pSQL($customer_email); - $where = $id_customer == 0 ? "customer_email = '$guest_email'" : "(id_customer=$id_customer OR customer_email='$customer_email')"; - $sql = ' - SELECT * - FROM `'._DB_PREFIX_.self::$definition['table'].'` - WHERE '.$where.' - AND `id_product` = '.(int)$id_product.' - AND `id_product_attribute` = '.(int)$id_product_attribute.' - AND `id_shop` = '.(int)$id_shop; - - return count(Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql)); - } - - public static function deleteAlert($id_customer, $customer_email, $id_product, $id_product_attribute, $id_shop) - { - $sql = ' - DELETE FROM `'._DB_PREFIX_.self::$definition['table'].'` - WHERE '.(($id_customer > 0) ? '(`customer_email` = \''.pSQL($customer_email).'\' OR `id_customer` = '.(int)$id_customer.')' : - '`customer_email` = \''.pSQL($customer_email).'\''). - ' AND `id_product` = '.(int)$id_product.' - AND `id_product_attribute` = '.(int)$id_product_attribute.' - AND `id_shop` = '.(int)$id_shop; - - return Db::getInstance()->execute($sql); - } - - /* - * Get objects that will be viewed on "My alerts" page - */ - public static function getMailAlerts($id_customer, $id_lang, Shop $shop = null) - { - if (!Validate::isUnsignedId($id_customer) || !Validate::isUnsignedId($id_lang)) - die (Tools::displayError()); - - if (!$shop) - $shop = Context::getContext()->shop; - - $customer = new Customer($id_customer); - $products = MailAlert::getProducts($customer, $id_lang); - $products_number = count($products); - - if (empty($products) === true || !$products_number) - return array(); - - for ($i = 0; $i < $products_number; ++$i) - { - $obj = new Product((int)$products[$i]['id_product'], false, (int)$id_lang); - if (!Validate::isLoadedObject($obj)) - continue; - - if (isset($products[$i]['id_product_attribute']) && - Validate::isUnsignedInt($products[$i]['id_product_attribute'])) - { - $attributes = self::getProductAttributeCombination($products[$i]['id_product_attribute'], $id_lang); - $products[$i]['attributes_small'] = ''; - - if ($attributes) - { - foreach ($attributes as $k => $row) - $products[$i]['attributes_small'] .= $row['attribute_name'].', '; - } - - $products[$i]['attributes_small'] = rtrim($products[$i]['attributes_small'], ', '); - $products[$i]['id_shop'] = $shop->id; - - /* Get cover */ - $attrgrps = $obj->getAttributesGroups((int)$id_lang); - foreach ($attrgrps as $attrgrp) - { - if ($attrgrp['id_product_attribute'] == (int)$products[$i]['id_product_attribute'] - && $images = Product::_getAttributeImageAssociations((int)$attrgrp['id_product_attribute'])) - { - $products[$i]['cover'] = $obj->id.'-'.array_pop($images); - break; - } - } - } - - if (!isset($products[$i]['cover']) || !$products[$i]['cover']) - { - $images = $obj->getImages((int)$id_lang); - foreach ($images as $k => $image) - { - if ($image['cover']) - { - $products[$i]['cover'] = $obj->id.'-'.$image['id_image']; - break; - } - } - } - - if (!isset($products[$i]['cover'])) - $products[$i]['cover'] = Language::getIsoById($id_lang).'-default'; - - $products[$i]['link'] = $obj->getLink(); - $products[$i]['link_rewrite'] = $obj->link_rewrite; - } - - return ($products); - } - - public static function sendCustomerAlert($id_product, $id_product_attribute) - { - $link = new Link(); - $context = Context::getContext()->cloneContext(); - $customers = self::getCustomers($id_product, $id_product_attribute); - - foreach ($customers as $customer) - { - $id_shop = (int)$customer['id_shop']; - $id_lang = (int)$customer['id_lang']; - $context->shop->id = $id_shop; - $context->language->id = $id_lang; - - $product = new Product((int)$id_product, false, $id_lang, $id_shop); - $product_link = $link->getProductLink($product, $product->link_rewrite, null, null, $id_lang, $id_shop); - $templateVars = array( - '{product}' => (is_array($product->name) ? $product->name[$id_lang] : $product->name), - '{product_link}' => $product_link - ); - - if ($customer['id_customer']) - { - $customer = new Customer((int)$customer['id_customer']); - $customer_email = $customer->email; - $customer_id = (int)$customer->id; - } - else - { - $customer_id = 0; - $customer_email = $customer['customer_email']; - } - - $iso = Language::getIsoById($id_lang); - - if (file_exists(dirname(__FILE__).'/mails/'.$iso.'/customer_qty.txt') && - file_exists(dirname(__FILE__).'/mails/'.$iso.'/customer_qty.html')) - Mail::Send( - $id_lang, - 'customer_qty', - Mail::l('Product available', $id_lang), - $templateVars, - strval($customer_email), - NULL, - strval(Configuration::get('PS_SHOP_EMAIL', null, null, $id_shop)), - strval(Configuration::get('PS_SHOP_NAME', null, null, $id_shop)), - NULL, - NULL, - dirname(__FILE__).'/mails/', - false, - $id_shop - ); - - Hook::exec('actionModuleMailAlertSendCustomer', array('product' => (is_array($product->name) ? $product->name[$id_lang] : $product->name), 'link' => $product_link, 'customer' => $customer, 'product_obj' => $product)); - - self::deleteAlert((int)$customer_id, strval($customer_email), (int)$id_product, (int)$id_product_attribute, $id_shop); - } - } - - /* - * Generate correctly the address for an email - */ - public static function getFormatedAddress(Address $address, $line_sep, $fields_style = array()) - { - return AddressFormat::generateAddress($address, array('avoid' => array()), $line_sep, ' ', $fields_style); - } - - /* - * Get products according to alerts - */ - public static function getProducts($customer, $id_lang) - { - $sql = ' - SELECT ma.`id_product`, p.`quantity` AS product_quantity, pl.`name`, ma.`id_product_attribute` - FROM `'._DB_PREFIX_.self::$definition['table'].'` ma - JOIN `'._DB_PREFIX_.'product` p ON (p.`id_product` = ma.`id_product`) - '.Shop::addSqlAssociation('product', 'p').' - LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (pl.`id_product` = p.`id_product` AND pl.id_shop IN ('.implode(', ', Shop::getContextListShopID(false)).')) - WHERE product_shop.`active` = 1 - AND (ma.`id_customer` = '.(int)$customer->id.' OR ma.`customer_email` = \''.pSQL($customer->email).'\') - AND pl.`id_lang` = '.(int)$id_lang.Shop::addSqlRestriction(false, 'ma'); - - return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql); - } - - /* - * Get product combinations - */ - public static function getProductAttributeCombination($id_product_attribute, $id_lang) - { - $sql = ' - SELECT al.`name` AS attribute_name - FROM `'._DB_PREFIX_.'product_attribute_combination` pac - LEFT JOIN `'._DB_PREFIX_.'attribute` a ON (a.`id_attribute` = pac.`id_attribute`) - LEFT JOIN `'._DB_PREFIX_.'attribute_group` ag ON (ag.`id_attribute_group` = a.`id_attribute_group`) - LEFT JOIN `'._DB_PREFIX_.'attribute_lang` al ON (a.`id_attribute` = al.`id_attribute` AND al.`id_lang` = '.(int)$id_lang.') - LEFT JOIN `'._DB_PREFIX_.'attribute_group_lang` agl ON (ag.`id_attribute_group` = agl.`id_attribute_group` AND agl.`id_lang` = '.(int)$id_lang.') - LEFT JOIN `'._DB_PREFIX_.'product_attribute` pa ON (pac.`id_product_attribute` = pa.`id_product_attribute`) - '.Shop::addSqlAssociation('product_attribute', 'pa').' - WHERE pac.`id_product_attribute` = '.(int)$id_product_attribute; - - return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql); - } - - /* - * Get customers waiting for alert on the specified product/product attribute - */ - public static function getCustomers($id_product, $id_product_attribute) - { - $sql = ' - SELECT id_customer, customer_email, id_shop, id_lang - FROM `'._DB_PREFIX_.self::$definition['table'].'` - WHERE `id_product` = '.(int)$id_product.' AND `id_product_attribute` = '.(int)$id_product_attribute; - - return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql); - } - -} diff --git a/modules/mailalerts/config.xml b/modules/mailalerts/config.xml deleted file mode 100755 index 699578ed4..000000000 --- a/modules/mailalerts/config.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - mailalerts - - - - - - Are you sure you want to delete all customer notifications? - 1 - 0 - - \ No newline at end of file diff --git a/modules/mailalerts/controllers/front/account.php b/modules/mailalerts/controllers/front/account.php deleted file mode 100644 index 34a73a1e6..000000000 --- a/modules/mailalerts/controllers/front/account.php +++ /dev/null @@ -1,54 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -/** - * @since 1.5.0 - */ -class MailalertsAccountModuleFrontController extends ModuleFrontController -{ - public function init() - { - parent::init(); - - require_once($this->module->getLocalPath().'MailAlert.php'); - } - - public function initContent() - { - parent::initContent(); - - if (!Context::getContext()->customer->isLogged()) - Tools::redirect('index.php?controller=authentication&redirect=module&module=mailalerts&action=account'); - - if (Context::getContext()->customer->id) - { - $this->context->smarty->assign('id_customer', Context::getContext()->customer->id); - $this->context->smarty->assign('mailAlerts', MailAlert::getMailAlerts((int)Context::getContext()->customer->id, (int)Context::getContext()->language->id)); - - $this->setTemplate('mailalerts-account.tpl'); - } - } -} \ No newline at end of file diff --git a/modules/mailalerts/controllers/front/actions.php b/modules/mailalerts/controllers/front/actions.php deleted file mode 100644 index 91e042ecc..000000000 --- a/modules/mailalerts/controllers/front/actions.php +++ /dev/null @@ -1,142 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -/** - * @since 1.5.0 - */ -class MailalertsActionsModuleFrontController extends ModuleFrontController -{ - /** - * @var int - */ - public $id_product; - public $id_product_attribute; - - public function init() - { - parent::init(); - - require_once($this->module->getLocalPath().'MailAlert.php'); - $this->id_product = (int)Tools::getValue('id_product'); - $this->id_product_attribute = (int)Tools::getValue('id_product_attribute'); - } - - public function postProcess() - { - if (Tools::getValue('process') == 'remove') - $this->processRemove(); - else if (Tools::getValue('process') == 'add') - $this->processAdd(); - else if (Tools::getValue('process') == 'check') - $this->processCheck(); - } - - /** - * Remove a favorite product - */ - public function processRemove() - { - // check if product exists - $product = new Product($this->id_product); - if (!Validate::isLoadedObject($product)) - die('0'); - - $context = Context::getContext(); - if (MailAlert::deleteAlert((int)$context->customer->id, (int)$context->customer->email, (int)$product->id, (int)$this->id_product_attribute)) - die('0'); - - die(1); - } - - /** - * Add a favorite product - */ - public function processAdd() - { - $context = Context::getContext(); - - if ($context->customer->isLogged()) - { - $id_customer = (int)$context->customer->id; - $customer = new Customer($id_customer); - $customer_email = strval($customer->email); - } - else - { - $customer_email = strval(Tools::getValue('customer_email')); - $customer = $context->customer->getByEmail($customer_email); - $id_customer = (isset($customer->id) && ($customer->id != null)) ? (int)$customer->id : null; - } - - $id_product = (int)Tools::getValue('id_product'); - $id_product_attribute = (int)Tools::getValue('id_product_attribute'); - $id_shop = (int)$context->shop->id; - $id_lang = (int)$context->language->id; - $product = new Product($id_product, false, $id_lang, $id_shop, $context); - - $mailAlert = MailAlert::customerHasNotification($id_customer, $id_product, $id_product_attribute, $id_shop, null, $customer_email); - - if ($mailAlert) - die('2'); - elseif (!Validate::isLoadedObject($product)) - die('0'); - - $mailAlert = new MailAlert(); - - $mailAlert->id_customer = (int)$id_customer; - $mailAlert->customer_email = strval($customer_email); - $mailAlert->id_product = (int)$id_product; - $mailAlert->id_product_attribute = (int)$id_product_attribute; - $mailAlert->id_shop = (int)$id_shop; - $mailAlert->id_lang = (int)$id_lang; - - if ($mailAlert->add() !== false) - die('1'); - - die('0'); - } - - /** - * Add a favorite product - */ - public function processCheck() - { - if (!(int)$this->context->customer->logged) - die('0'); - - $id_customer = (int)$this->context->customer->id; - - if (!$id_product = (int)(Tools::getValue('id_product'))) - die('0'); - - $id_product_attribute = (int)(Tools::getValue('id_product_attribute')); - - if (MailAlert::customerHasNotification((int)$id_customer, (int)$id_product, (int)$id_product_attribute, (int)$this->context->shop->id)) - die('1'); - - die('0'); - } -} \ No newline at end of file diff --git a/modules/mailalerts/controllers/front/index.php b/modules/mailalerts/controllers/front/index.php deleted file mode 100644 index 3f6561f72..000000000 --- a/modules/mailalerts/controllers/front/index.php +++ /dev/null @@ -1,35 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); - -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); - -header("Location: ../"); -exit; \ No newline at end of file diff --git a/modules/mailalerts/controllers/index.php b/modules/mailalerts/controllers/index.php deleted file mode 100644 index 3f6561f72..000000000 --- a/modules/mailalerts/controllers/index.php +++ /dev/null @@ -1,35 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); - -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); - -header("Location: ../"); -exit; \ No newline at end of file diff --git a/modules/mailalerts/img/del_alert.gif b/modules/mailalerts/img/del_alert.gif deleted file mode 100644 index 8aea7d4f7..000000000 Binary files a/modules/mailalerts/img/del_alert.gif and /dev/null differ diff --git a/modules/mailalerts/img/icon-alert.png b/modules/mailalerts/img/icon-alert.png deleted file mode 100644 index 95e0926bc..000000000 Binary files a/modules/mailalerts/img/icon-alert.png and /dev/null differ diff --git a/modules/mailalerts/img/index.php b/modules/mailalerts/img/index.php deleted file mode 100644 index e582afcc2..000000000 --- a/modules/mailalerts/img/index.php +++ /dev/null @@ -1,36 +0,0 @@ - -* @copyright 2007-2013 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 -*/ - -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); - -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); - -header("Location: ../"); -exit; \ No newline at end of file diff --git a/modules/mailalerts/index.php b/modules/mailalerts/index.php deleted file mode 100644 index e582afcc2..000000000 --- a/modules/mailalerts/index.php +++ /dev/null @@ -1,36 +0,0 @@ - -* @copyright 2007-2013 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 -*/ - -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); - -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); - -header("Location: ../"); -exit; \ No newline at end of file diff --git a/modules/mailalerts/logo.gif b/modules/mailalerts/logo.gif deleted file mode 100644 index 8bdd3304d..000000000 Binary files a/modules/mailalerts/logo.gif and /dev/null differ diff --git a/modules/mailalerts/logo.png b/modules/mailalerts/logo.png deleted file mode 100755 index 1a8d30fa9..000000000 Binary files a/modules/mailalerts/logo.png and /dev/null differ diff --git a/modules/mailalerts/mailalerts-account.php b/modules/mailalerts/mailalerts-account.php deleted file mode 100644 index d6949a12d..000000000 --- a/modules/mailalerts/mailalerts-account.php +++ /dev/null @@ -1,67 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -/* SSL Management */ -$useSSL = true; - -include(dirname(__FILE__).'/../../config/config.inc.php'); -include(dirname(__FILE__).'/../../header.php'); -include_once(dirname(__FILE__).'/mailalerts.php'); - -// Instance of module class for translations -$module = new MailAlerts(); - -$errors = array(); - -if ($cookie->isLogged()) -{ - if (Tools::getValue('action') == 'delete') - { - $id_customer = (int)($cookie->id_customer); - if (!$id_product = (int)(Tools::getValue('id_product'))) - $errors[] = $module->l('You must have a product to delete an alert.', 'mailalerts-account'); - $id_product_attribute = (int)(Tools::getValue('id_product_attribute')); - $customer = new Customer((int)($id_customer)); - MailAlerts::deleteAlert((int)($id_customer), strval($customer->email), (int)($id_product), (int)($id_product_attribute)); - } - $this->context->smarty->assign('mailAlerts', MailAlert::getProductsAlerts((int)($cookie->id_customer), (int)($cookie->id_lang))); -} -else - $errors[] = $module->l('You must be logged in to manage your alerts.', 'mailalerts-account'); - -$this->context->smarty->assign(array( - 'id_customer' => (int)($cookie->id_customer), - 'errors' => $errors -)); - -if (Tools::file_exists_cache(_PS_THEME_DIR_.'modules/mailalerts/myalerts.tpl')) - $smarty->display(_PS_THEME_DIR_.'modules/mailalerts/myalerts.tpl'); -elseif (Tools::file_exists_cache(dirname(__FILE__).'/myalerts.tpl')) - $smarty->display(dirname(__FILE__).'/myalerts.tpl'); -else - echo $module->l('No template found', 'mailalerts-account'); - -include(dirname(__FILE__).'/../../footer.php'); diff --git a/modules/mailalerts/mailalerts-ajax.php b/modules/mailalerts/mailalerts-ajax.php deleted file mode 100644 index 0d81d2be0..000000000 --- a/modules/mailalerts/mailalerts-ajax.php +++ /dev/null @@ -1,32 +0,0 @@ - -* @copyright 2007-2013 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'); - - - - diff --git a/modules/mailalerts/mailalerts-extra.php b/modules/mailalerts/mailalerts-extra.php deleted file mode 100644 index c9199894c..000000000 --- a/modules/mailalerts/mailalerts-extra.php +++ /dev/null @@ -1,119 +0,0 @@ -{* -* 2007-2013 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 -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*} - - - -{if !$isCustomerMailAlert AND $isLogged} -
  • - {l s='Add this product to my favorites' mod='mailalerts'} -
  • -{/if} -{if $isCustomerMailAlert AND $isLogged} -
  • - {l s='Remove this product from my favorites' mod='mailalerts'} -
  • -{/if} - -
  • - {l s='Remove this product from my favorites' mod='mailalerts'} -
  • -
  • - {l s='Add this product to my favorites' mod='mailalerts'} -
  • \ No newline at end of file diff --git a/modules/mailalerts/mailalerts.css b/modules/mailalerts/mailalerts.css deleted file mode 100644 index 3d0e888ce..000000000 --- a/modules/mailalerts/mailalerts.css +++ /dev/null @@ -1,47 +0,0 @@ -#module-mailalerts-mailalerts-account #left_column {display:none} -#module-mailalerts-mailalerts-account #center_column {width:757px} - -#mailalerts_block_account .mailalert { - position:relative; - margin-bottom: 14px; - padding: 12px 8px; - border: 1px solid #eee; - border-radius: 3px 3px 3px 3px; -} - -.mailalert a.product_img_link { - border: 1px solid #CCCCCC; - display: block; - float: left; - margin-right: 14px; - overflow: hidden; - position: relative; -} - -.mailalert h3 { - color: #000000; - font-size: 13px; - padding: 0 0 10px; -} - -.mailalert p.product_desc { - line-height: 16px; - overflow: hidden; - padding: 0; -} - -.mailalert .remove { - position:absolute; - top:10px; - right:10px -} -.mailalert .remove .icon {cursor:pointer} - - -/* lnk fiche produit */ - -#usefull_link_block li#mailalerts_block_extra_remove { - padding-left:20px; - background:url(img/del_alert.gif) no-repeat 0 0; - cursor: pointer; -} \ No newline at end of file diff --git a/modules/mailalerts/mailalerts.php b/modules/mailalerts/mailalerts.php deleted file mode 100644 index b50f0d4b8..000000000 --- a/modules/mailalerts/mailalerts.php +++ /dev/null @@ -1,735 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -if (!defined('_CAN_LOAD_FILES_')) - exit; - -include_once(dirname(__FILE__).'/MailAlert.php'); - -class MailAlerts extends Module -{ - private $_html = ''; - - private $_merchant_mails; - private $_merchant_order; - private $_merchant_oos; - private $_customer_qty; - private $_merchant_coverage; - private $_product_coverage; - - const __MA_MAIL_DELIMITOR__ = "\n"; - - public function __construct() - { - $this->name = 'mailalerts'; - $this->tab = 'administration'; - $this->version = '2.8'; - $this->author = 'PrestaShop'; - $this->need_instance = 0; - - $this->bootstrap = true; - parent::__construct(); - - if ($this->id) - $this->init(); - - $this->displayName = $this->l('Mail alerts'); - $this->description = $this->l('Sends e-mail notifications to customers and merchants.'); - $this->confirmUninstall = $this->l('Are you sure you want to delete all customer notifications?'); - } - - private function init() - { - $this->_merchant_mails = strval(Configuration::get('MA_MERCHANT_MAILS')); - $this->_merchant_order = (int)Configuration::get('MA_MERCHANT_ORDER'); - $this->_merchant_oos = (int)Configuration::get('MA_MERCHANT_OOS'); - $this->_customer_qty = (int)Configuration::get('MA_CUSTOMER_QTY'); - $this->_merchant_coverage = (int)Configuration::getGlobalValue('MA_MERCHANT_COVERAGE'); - $this->_product_coverage = (int)Configuration::getGlobalValue('MA_PRODUCT_COVERAGE'); - } - - public function install() - { - if (!parent::install() || - !$this->registerHook('actionValidateOrder') || - !$this->registerHook('actionUpdateQuantity') || - !$this->registerHook('actionProductOutOfStock') || - !$this->registerHook('displayCustomerAccount') || - !$this->registerHook('displayMyAccountBlock') || - !$this->registerHook('actionProductDelete') || - !$this->registerHook('actionProductAttributeDelete') || - !$this->registerHook('actionProductAttributeUpdate') || - !$this->registerHook('actionProductCoverage') || - !$this->registerHook('displayHeader')) - return false; - - Configuration::updateValue('MA_MERCHANT_ORDER', 1); - Configuration::updateValue('MA_MERCHANT_OOS', 1); - Configuration::updateValue('MA_CUSTOMER_QTY', 1); - Configuration::updateValue('MA_MERCHANT_MAILS', Configuration::get('PS_SHOP_EMAIL')); - Configuration::updateValue('MA_LAST_QTIES', (int)Configuration::get('PS_LAST_QTIES')); - Configuration::updateGlobalValue('MA_MERCHANT_COVERAGE', 0); - Configuration::updateGlobalValue('MA_PRODUCT_COVERAGE', 0); - - $sql = 'CREATE TABLE IF NOT EXISTS `'._DB_PREFIX_.MailAlert::$definition['table'].'` - ( - `id_customer` int(10) unsigned NOT NULL, - `customer_email` varchar(128) NOT NULL, - `id_product` int(10) unsigned NOT NULL, - `id_product_attribute` int(10) unsigned NOT NULL, - `id_shop` int(10) unsigned NOT NULL, - `id_lang` int(10) unsigned NOT NULL, - PRIMARY KEY (`id_customer`,`customer_email`,`id_product`,`id_product_attribute`,`id_shop`) - ) ENGINE='._MYSQL_ENGINE_.' DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci'; - - if (!Db::getInstance()->execute($sql)) - return false; - - return true; - } - - public function uninstall() - { - Configuration::deleteByName('MA_MERCHANT_ORDER'); - Configuration::deleteByName('MA_MERCHANT_OOS'); - Configuration::deleteByName('MA_CUSTOMER_QTY'); - Configuration::deleteByName('MA_MERCHANT_MAILS'); - Configuration::deleteByName('MA_LAST_QTIES'); - Configuration::deleteByName('MA_MERCHANT_COVERAGE'); - Configuration::deleteByName('MA_PRODUCT_COVERAGE'); - - if (!Db::getInstance()->execute('DROP TABLE '._DB_PREFIX_.MailAlert::$definition['table'])) - return false; - - return parent::uninstall(); - } - - public function getContent() - { - $this->_html = ''; - - $this->_postProcess(); - - $this->_html .= $this->renderForm(); - - return $this->_html; - } - - private function _postProcess() - { - $errors = array(); - - if (Tools::isSubmit('submitMailAlert')) - { - if (!Configuration::updateValue('MA_CUSTOMER_QTY', (int)Tools::getValue('MA_CUSTOMER_QTY'))) - $errors[] = $this->l('Cannot update settings'); - } - else if (Tools::isSubmit('submitMAMerchant')) - { - $emails = strval(Tools::getValue('MA_MERCHANT_MAILS')); - - if (!$emails || empty($emails)) - $errors[] = $this->l('Please type one (or more) e-mail address'); - else - { - $emails = explode("\n", $emails); - foreach ($emails as $k => $email) - { - $email = trim($email); - if (!empty($email) && !Validate::isEmail($email)) - { - $errors[] = $this->l('Invalid e-mail:').' '.Tools::safeOutput($email); - break; - } - elseif (!empty($email) && count($email) > 0) - $emails[$k] = $email; - else - unset($emails[$k]); - } - - $emails = implode(self::__MA_MAIL_DELIMITOR__, $emails); - - if (!Configuration::updateValue('MA_MERCHANT_MAILS', strval($emails))) - $errors[] = $this->l('Cannot update settings'); - elseif (!Configuration::updateValue('MA_MERCHANT_ORDER', (int)Tools::getValue('MA_MERCHANT_ORDER'))) - $errors[] = $this->l('Cannot update settings'); - elseif (!Configuration::updateValue('MA_MERCHANT_OOS', (int)Tools::getValue('MA_MERCHANT_OOS'))) - $errors[] = $this->l('Cannot update settings'); - elseif (!Configuration::updateValue('MA_LAST_QTIES', (int)Tools::getValue('MA_LAST_QTIES'))) - $errors[] = $this->l('Cannot update settings'); - elseif (!Configuration::updateGlobalValue('MA_MERCHANT_COVERAGE', (int)Tools::getValue('MA_MERCHANT_COVERAGE'))) - $errors[] = $this->l('Cannot update settings'); - elseif (!Configuration::updateGlobalValue('MA_PRODUCT_COVERAGE', (int)Tools::getValue('MA_PRODUCT_COVERAGE'))) - $errors[] = $this->l('Cannot update settings'); - } - } - - if (count($errors) > 0) - $this->_html .= $this->displayError(implode('
    ', $errors)); - else - $this->_html .= $this->displayConfirmation($this->l('Settings updated successfully')); - - $this->init(); - } - - public function getAllMessages($id) - { - $messages = Db::getInstance()->executeS(' - SELECT `message` - FROM `'._DB_PREFIX_.'message` - WHERE `id_order` = '.(int)$id.' - ORDER BY `id_message` ASC - '); - $result = array(); - foreach ($messages as $message) { - $result[] = $message['message']; - } - return implode('
    ', $result); - } - - public function hookActionValidateOrder($params) - { - if (!$this->_merchant_order || empty($this->_merchant_mails)) - return; - - // Getting differents vars - $context = Context::getContext(); - $id_lang = (int)$context->language->id; - $id_shop = (int)$context->shop->id; - $currency = $params['currency']; - $order = $params['order']; - $customer = $params['customer']; - $configuration = Configuration::getMultiple(array('PS_SHOP_EMAIL', 'PS_MAIL_METHOD', 'PS_MAIL_SERVER', 'PS_MAIL_USER', 'PS_MAIL_PASSWD', 'PS_SHOP_NAME', 'PS_MAIL_COLOR'), $id_lang, null, $id_shop); - $delivery = new Address((int)$order->id_address_delivery); - $invoice = new Address((int)$order->id_address_invoice); - $order_date_text = Tools::displayDate($order->date_add); - $carrier = new Carrier((int)$order->id_carrier); - $message = $this->getAllMessages($order->id); - - if (!$message || empty($message)) - $message = $this->l('No message'); - - $items_table = ''; - - $products = $params['order']->getProducts(); - $customized_datas = Product::getAllCustomizedDatas((int)$params['cart']->id); - Product::addCustomizationPrice($products, $customized_datas); - foreach ($products as $key => $product) - { - $unit_price = $product['product_price_wt']; - - $customization_text = ''; - if (isset($customized_datas[$product['product_id']][$product['product_attribute_id']])) - { - foreach ($customized_datas[$product['product_id']][$product['product_attribute_id']][$order->id_address_delivery] as $customization) - { - if (isset($customization['datas'][_CUSTOMIZE_TEXTFIELD_])) - foreach ($customization['datas'][_CUSTOMIZE_TEXTFIELD_] as $text) - $customization_text .= $text['name'].': '.$text['value'].'
    '; - - if (isset($customization['datas'][_CUSTOMIZE_FILE_])) - $customization_text .= count($customization['datas'][_CUSTOMIZE_FILE_]).' '.$this->l('image(s)').'
    '; - - $customization_text .= '---
    '; - } - - $customization_text = Tools::rtrimString($customization_text, '---
    '); - } - - $items_table .= - ' - '.$product['product_reference'].' - - ' - .$product['product_name'].(isset($product['attributes_small']) ? ' '.$product['attributes_small'] : '').(!empty($customization_text) ? '
    '.$customization_text : ''). - '
    - - '.Tools::displayPrice($unit_price, $currency, false).' - '.(int)$product['product_quantity'].' - '.Tools::displayPrice(($unit_price * $product['product_quantity']), $currency, false).' - '; - } - foreach ($params['order']->getCartRules() as $discount) - { - $items_table .= - ' - '.$this->l('Voucher code:').' '.$discount['name'].' - -'.Tools::displayPrice($discount['value'], $currency, false).' - '; - } - if ($delivery->id_state) - $delivery_state = new State((int)$delivery->id_state); - if ($invoice->id_state) - $invoice_state = new State((int)$invoice->id_state); - - // Filling-in vars for email - $template = 'new_order'; - $template_vars = array( - '{firstname}' => $customer->firstname, - '{lastname}' => $customer->lastname, - '{email}' => $customer->email, - '{delivery_block_txt}' => MailAlert::getFormatedAddress($delivery, "\n"), - '{invoice_block_txt}' => MailAlert::getFormatedAddress($invoice, "\n"), - '{delivery_block_html}' => MailAlert::getFormatedAddress($delivery, '
    ', array( - 'firstname' => '%s', - 'lastname' => '%s')), - '{invoice_block_html}' => MailAlert::getFormatedAddress($invoice, '
    ', array( - 'firstname' => '%s', - 'lastname' => '%s')), - '{delivery_company}' => $delivery->company, - '{delivery_firstname}' => $delivery->firstname, - '{delivery_lastname}' => $delivery->lastname, - '{delivery_address1}' => $delivery->address1, - '{delivery_address2}' => $delivery->address2, - '{delivery_city}' => $delivery->city, - '{delivery_postal_code}' => $delivery->postcode, - '{delivery_country}' => $delivery->country, - '{delivery_state}' => $delivery->id_state ? $delivery_state->name : '', - '{delivery_phone}' => $delivery->phone ? $delivery->phone : $delivery->phone_mobile, - '{delivery_other}' => $delivery->other, - '{invoice_company}' => $invoice->company, - '{invoice_firstname}' => $invoice->firstname, - '{invoice_lastname}' => $invoice->lastname, - '{invoice_address2}' => $invoice->address2, - '{invoice_address1}' => $invoice->address1, - '{invoice_city}' => $invoice->city, - '{invoice_postal_code}' => $invoice->postcode, - '{invoice_country}' => $invoice->country, - '{invoice_state}' => $invoice->id_state ? $invoice_state->name : '', - '{invoice_phone}' => $invoice->phone ? $invoice->phone : $invoice->phone_mobile, - '{invoice_other}' => $invoice->other, - '{order_name}' => $order->reference, - '{shop_name}' => $configuration['PS_SHOP_NAME'], - '{date}' => $order_date_text, - '{carrier}' => (($carrier->name == '0') ? $configuration['PS_SHOP_NAME'] : $carrier->name), - '{payment}' => Tools::substr($order->payment, 0, 32), - '{items}' => $items_table, - '{total_paid}' => Tools::displayPrice($order->total_paid, $currency), - '{total_products}' => Tools::displayPrice($order->getTotalProductsWithTaxes(), $currency), - '{total_discounts}' => Tools::displayPrice($order->total_discounts, $currency), - '{total_shipping}' => Tools::displayPrice($order->total_shipping, $currency), - '{total_tax_paid}' => Tools::displayPrice(($order->total_products_wt - $order->total_products) + ($order->total_shipping_tax_incl - $order->total_shipping_tax_excl), $currency, false), - '{total_wrapping}' => Tools::displayPrice($order->total_wrapping, $currency), - '{currency}' => $currency->sign, - '{message}' => $message - ); - - $iso = Language::getIsoById($id_lang); - - if (file_exists(dirname(__FILE__).'/mails/'.$iso.'/'.$template.'.txt') && - file_exists(dirname(__FILE__).'/mails/'.$iso.'/'.$template.'.html')) - { - // Send 1 email by merchant mail, because Mail::Send doesn't work with an array of recipients - $merchant_mails = explode(self::__MA_MAIL_DELIMITOR__, $this->_merchant_mails); - foreach ($merchant_mails as $merchant_mail) - { - Mail::Send( - $id_lang, - $template, - sprintf(Mail::l('New order - #%06d', $id_lang), $order->id), - $template_vars, - $merchant_mail, - null, - $configuration['PS_SHOP_EMAIL'], - $configuration['PS_SHOP_NAME'], - null, - null, - dirname(__FILE__).'/mails/', - null, - $id_shop - ); - } - } - } - - public function hookActionProductOutOfStock($params) - { - if (!$this->_customer_qty || !Configuration::get('PS_STOCK_MANAGEMENT') || Product::isAvailableWhenOutOfStock($params['product']->out_of_stock)) - return; - - $context = Context::getContext(); - $id_product = (int)$params['product']->id; - $id_product_attribute = 0; - $id_customer = (int)$context->customer->id; - - if ((int)$context->customer->id <= 0) - $this->context->smarty->assign('email', 1); - elseif (MailAlert::customerHasNotification($id_customer, $id_product, $id_product_attribute, (int)$context->shop->id)) - return; - - $this->context->smarty->assign(array( - 'id_product' => $id_product, - 'id_product_attribute' => $id_product_attribute - )); - - return $this->display(__FILE__, 'product.tpl'); - } - - public function hookActionUpdateQuantity($params) - { - $id_product = (int)$params['id_product']; - $product = new Product($id_product); - $product_has_attributes = $product->hasAttributes(); - $id_product_attribute = (int)$params['id_product_attribute']; - $quantity = (int)$params['quantity']; - $context = Context::getContext(); - $id_shop = (int)$context->shop->id; - $id_lang = (int)$context->language->id; - $product = new Product($id_product, true, $id_lang, $id_shop, $context); - $configuration = Configuration::getMultiple(array('MA_LAST_QTIES', 'PS_STOCK_MANAGEMENT', 'PS_SHOP_EMAIL', 'PS_SHOP_NAME'), null, null, $id_shop); - $ma_last_qties = (int)$configuration['MA_LAST_QTIES']; - - $check_oos = ($product_has_attributes && $id_product_attribute) || (!$product_has_attributes && !$id_product_attribute); - - if ($check_oos && $product->active == 1 && (int)$quantity <= $ma_last_qties && !(!$this->_merchant_oos || empty($this->_merchant_mails)) && $configuration['PS_STOCK_MANAGEMENT']) - { - $iso = Language::getIsoById($id_lang); - $product_name = Product::getProductName($id_product, $id_product_attribute, $id_lang); - $template_vars = array( - '{qty}' => $quantity, - '{last_qty}' => $ma_last_qties, - '{product}' => $product_name - ); - - if (file_exists(dirname(__FILE__).'/mails/'.$iso.'/productoutofstock.txt') && - file_exists(dirname(__FILE__).'/mails/'.$iso.'/productoutofstock.html')) - { - // Send 1 email by merchant mail, because Mail::Send doesn't work with an array of recipients - $merchant_mails = explode(self::__MA_MAIL_DELIMITOR__, $this->_merchant_mails); - foreach ($merchant_mails as $merchant_mail) - { - Mail::Send( - $id_lang, - 'productoutofstock', - Mail::l('Product out of stock', $id_lang), - $template_vars, - $merchant_mail, - null, - strval($configuration['PS_SHOP_EMAIL']), - strval($configuration['PS_SHOP_NAME']), - null, - null, - dirname(__FILE__).'/mails/', - false, - $id_shop - ); - } - } - } - - if ($this->_customer_qty && $quantity > 0) - MailAlert::sendCustomerAlert((int)$product->id, (int)$params['id_product_attribute']); - } - - public function hookActionProductAttributeUpdate($params) - { - $sql = ' - SELECT `id_product`, `quantity` - FROM `'._DB_PREFIX_.'stock_available` - WHERE `id_product_attribute` = '.(int)$params['id_product_attribute']; - - $result = Db::getInstance()->getRow($sql); - - if ($this->_customer_qty && $result['quantity'] > 0) - MailAlert::sendCustomerAlert((int)$result['id_product'], (int)$params['id_product_attribute']); - } - - public function hookDisplayCustomerAccount($params) - { - return $this->_customer_qty ? $this->display(__FILE__, 'my-account.tpl') : null; - } - - public function hookDisplayMyAccountBlock($params) - { - return $this->hookDisplayCustomerAccount($params); - } - - public function hookActionProductDelete($params) - { - $sql = ' - DELETE FROM `'._DB_PREFIX_.MailAlert::$definition['table'].'` - WHERE `id_product` = '.(int)$params['product']->id; - - Db::getInstance()->execute($sql); - } - - public function hookActionAttributeDelete($params) - { - if ($params['deleteAllAttributes']) - $sql = ' - DELETE FROM `'._DB_PREFIX_.MailAlert::$definition['table'].'` - WHERE `id_product` = '.(int)$params['id_product']; - else - $sql = ' - DELETE FROM `'._DB_PREFIX_.MailAlert::$definition['table'].'` - WHERE `id_product_attribute` = '.(int)$params['id_product_attribute'].' - AND `id_product` = '.(int)$params['id_product']; - - Db::getInstance()->execute($sql); - } - - public function hookActionProductCoverage($params) - { - // if not advanced stock management, nothing to do - if (!Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT')) - return; - - // retrieves informations - $id_product = (int)$params['id_product']; - $id_product_attribute = (int)$params['id_product_attribute']; - $warehouse = $params['warehouse']; - $product = new Product($id_product); - - if (!Validate::isLoadedObject($product)) - return; - - if (!$product->advanced_stock_management) - return; - - // sets warehouse id to get the coverage - if (!Validate::isLoadedObject($warehouse)) - $id_warehouse = 0; - else - $id_warehouse = (int)$warehouse->id; - - // coverage of the product - $warning_coverage = (int)Configuration::getGlobalValue('MA_PRODUCT_COVERAGE'); - - $coverage = StockManagerFactory::getManager()->getProductCoverage($id_product, $id_product_attribute, $warning_coverage, $id_warehouse); - - // if we need to send a notification - if ($product->active == 1 && - ($coverage < $warning_coverage) && !empty($this->_merchant_mails) && - Configuration::getGlobalValue('MA_MERCHANT_COVERAGE')) - { - $context = Context::getContext(); - $id_lang = (int)$context->language->id; - $id_shop = (int)$context->shop->id; - $iso = Language::getIsoById($id_lang); - $product_name = Product::getProductName($id_product, $id_product_attribute, $id_lang); - $template_vars = array( - '{current_coverage}' => $coverage, - '{warning_coverage}' => $warning_coverage, - '{product}' => pSQL($product_name) - ); - - if (file_exists(dirname(__FILE__).'/mails/'.$iso.'/productcoverage.txt') && - file_exists(dirname(__FILE__).'/mails/'.$iso.'/productcoverage.html')) - { - // Send 1 email by merchant mail, because Mail::Send doesn't work with an array of recipients - $merchant_mails = explode(self::__MA_MAIL_DELIMITOR__, $this->_merchant_mails); - foreach ($merchant_mails as $merchant_mail) - { - Mail::Send( - $id_lang, - 'productcoverage', - Mail::l('Stock coverage', $id_lang), - $template_vars, - $merchant_mail, - null, - strval(Configuration::get('PS_SHOP_EMAIL')), - strval(Configuration::get('PS_SHOP_NAME')), - null, - null, - dirname(__FILE__).'/mails/', - null, - $id_shop - ); - } - } - } - } - - public function hookDisplayHeader($params) - { - $this->context->controller->addCSS($this->_path.'mailalerts.css', 'all'); - } - - public function renderForm() - { - $fields_form_1 = array( - 'form' => array( - 'legend' => array( - 'title' => $this->l('Customer notifications'), - 'icon' => 'icon-cogs' - ), - 'input' => array( - array( - 'type' => 'switch', - 'is_bool' => true, //retro compat 1.5 - 'label' => $this->l('Product availability:'), - 'name' => 'MA_CUSTOMER_QTY', - 'desc' => $this->l('Gives the customer the option of receiving a notification for an available product if this one is out of stock.'), - 'values' => array( - array( - 'id' => 'active_on', - 'value' => 1, - 'label' => $this->l('Enabled') - ), - array( - 'id' => 'active_off', - 'value' => 0, - 'label' => $this->l('Disabled') - ) - ), - ), - ), - 'submit' => array( - 'title' => $this->l('Save'), - 'class' => 'btn btn-default', - 'name' => 'submitMailAlert', - ) - ), - ); - - $fields_form_2 = array( - 'form' => array( - 'legend' => array( - 'title' => $this->l('Merchant notifications'), - 'icon' => 'icon-cogs' - ), - 'input' => array( - array( - 'type' => 'switch', - 'is_bool' => true, //retro compat 1.5 - 'label' => $this->l('New order:'), - 'name' => 'MA_MERCHANT_ORDER', - 'desc' => $this->l('Receive a notification when an order is placed'), - 'values' => array( - array( - 'id' => 'active_on', - 'value' => 1, - 'label' => $this->l('Enabled') - ), - array( - 'id' => 'active_off', - 'value' => 0, - 'label' => $this->l('Disabled') - ) - ), - ), - array( - 'type' => 'switch', - 'is_bool' => true, //retro compat 1.5 - 'label' => $this->l('Out of stock:'), - 'name' => 'MA_MERCHANT_OOS', - 'desc' => $this->l('Receive a notification if the available quantity of a product is below the following threshold'), - 'values' => array( - array( - 'id' => 'active_on', - 'value' => 1, - 'label' => $this->l('Enabled') - ), - array( - 'id' => 'active_off', - 'value' => 0, - 'label' => $this->l('Disabled') - ) - ), - ), - array( - 'type' => 'text', - 'label' => $this->l('Threshold:'), - 'name' => 'MA_LAST_QTIES', - 'class' => 'fixed-width-xs', - 'desc' => $this->l('Quantity for which a product is considered out of stock'), - ), - array( - 'type' => 'switch', - 'is_bool' => true, //retro compat 1.5 - 'label' => $this->l('Coverage warning:'), - 'name' => 'MA_MERCHANT_COVERAGE', - 'desc' => $this->l('Receive a notification when an order is placed'), - 'values' => array( - array( - 'id' => 'active_on', - 'value' => 1, - 'label' => $this->l('Enabled') - ), - array( - 'id' => 'active_off', - 'value' => 0, - 'label' => $this->l('Disabled') - ) - ), - ), - array( - 'type' => 'text', - 'label' => $this->l('Coverage:'), - 'name' => 'MA_PRODUCT_COVERAGE', - 'class' => 'fixed-width-xs', - 'desc' => $this->l('Stock coverage, in days. Also, the stock coverage of a given product will be calculated based on this number'), - ), - array( - 'type' => 'textarea', - 'label' => $this->l('E-mail addresses:'), - 'name' => 'MA_MERCHANT_MAILS', - 'desc' => $this->l('One e-mail address per line (e.g. bob@example.com)'), - ), - ), - 'submit' => array( - 'title' => $this->l('Save'), - 'class' => 'btn btn-default', - 'name' => 'submitMAMerchant', - ) - ), - ); - - - - $helper = new HelperForm(); - $helper->show_toolbar = false; - $helper->table = $this->table; - $lang = new Language((int)Configuration::get('PS_LANG_DEFAULT')); - $helper->default_form_language = $lang->id; - $helper->module = $this; - $helper->allow_employee_form_lang = Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG') ? Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG') : 0; - $helper->identifier = $this->identifier; - $helper->submit_action = 'submitMailAlert'; - $helper->currentIndex = $this->context->link->getAdminLink('AdminModules', false).'&configure='.$this->name.'&tab_module='.$this->tab.'&module_name='.$this->name; - $helper->token = Tools::getAdminTokenLite('AdminModules'); - $helper->tpl_vars = array( - 'fields_value' => $this->getConfigFieldsValues(), - 'languages' => $this->context->controller->getLanguages(), - 'id_language' => $this->context->language->id - ); - - return $helper->generateForm(array($fields_form_1, $fields_form_2)); - } - - public function getConfigFieldsValues() - { - return array( - 'MA_CUSTOMER_QTY' => Tools::getValue('MA_CUSTOMER_QTY', Configuration::get('MA_CUSTOMER_QTY')), - 'MA_MERCHANT_ORDER' => Tools::getValue('MA_MERCHANT_ORDER', Configuration::get('MA_MERCHANT_ORDER')), - 'MA_MERCHANT_OOS' => Tools::getValue('MA_MERCHANT_OOS', Configuration::get('MA_MERCHANT_OOS')), - 'MA_LAST_QTIES' => Tools::getValue('MA_LAST_QTIES', Configuration::get('MA_LAST_QTIES')), - 'MA_MERCHANT_COVERAGE' => Tools::getValue('MA_MERCHANT_COVERAGE', Configuration::get('MA_MERCHANT_COVERAGE')), - 'MA_PRODUCT_COVERAGE' => Tools::getValue('MA_PRODUCT_COVERAGE', Configuration::get('MA_PRODUCT_COVERAGE')), - 'MA_MERCHANT_MAILS' => Tools::getValue('MA_MERCHANT_MAILS', Configuration::get('MA_MERCHANT_MAILS')), - ); - } -} diff --git a/modules/mailalerts/mails/en/customer_qty.html b/modules/mailalerts/mails/en/customer_qty.html deleted file mode 100644 index fd752843b..000000000 --- a/modules/mailalerts/mails/en/customer_qty.html +++ /dev/null @@ -1,112 +0,0 @@ - - - - - - - Message from {shop_name} - - - - - - - - - - - - -
      - - - - - - - - - - - - - - - - - - - - - -
    - Hi, -
    -

    - {product} is now available.

    - - This item is once again in-stock.

    - You can access the product page by clicking on the link: {product}
    - You can order it right now from our online shop.
    -
    -
     
    - - \ No newline at end of file diff --git a/modules/mailalerts/mails/en/customer_qty.txt b/modules/mailalerts/mails/en/customer_qty.txt deleted file mode 100644 index 12b11428e..000000000 --- a/modules/mailalerts/mails/en/customer_qty.txt +++ /dev/null @@ -1,17 +0,0 @@ - -[{shop_url}] - -Hi, - -{product} is now available. - -This item is once again in-stock. - -You can access the product page by clicking on the link: {product} -[HTTP://SAFE.SHELL.LA/{product_link}] - -You can order it right now from our online shop. - -{shop_name} [{shop_url}] powered by -PrestaShop(tm) [http://www.prestashop.com/] - diff --git a/modules/mailalerts/mails/en/index.php b/modules/mailalerts/mails/en/index.php deleted file mode 100644 index e582afcc2..000000000 --- a/modules/mailalerts/mails/en/index.php +++ /dev/null @@ -1,36 +0,0 @@ - -* @copyright 2007-2013 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 -*/ - -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); - -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); - -header("Location: ../"); -exit; \ No newline at end of file diff --git a/modules/mailalerts/mails/en/new_order.html b/modules/mailalerts/mails/en/new_order.html deleted file mode 100644 index 816c8640a..000000000 --- a/modules/mailalerts/mails/en/new_order.html +++ /dev/null @@ -1,210 +0,0 @@ - - - - - - - Message from {shop_name} - - - - - - - - - - - - -
      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - Congratulations! -
    - A new order was placed on {shop_name} from the following customer: {firstname} {lastname} ({email}) -
    -

    - Order details

    - - Order: {order_name} Placed on {date}

    - Payment: {payment} -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    ReferenceProductUnit priceQuantityTotal price
    - {items} -
    Products{total_products}
    Discounts{total_discounts}
    Gift-wrapping{total_wrapping}
    Shipping{total_shipping}
    Total Tax paid{total_tax_paid}
    Total paid{total_paid}
    -
    -

    - Carrier:

    - - {carrier} - -
    - - - - - - -
    -

    - Delivery address

    - - {delivery_block_html} - -
      -

    - Billing address

    - - {invoice_block_html} - -
    -
    -

    - Customer message:

    - - {message} - -
    -
     
    - - \ No newline at end of file diff --git a/modules/mailalerts/mails/en/new_order.txt b/modules/mailalerts/mails/en/new_order.txt deleted file mode 100644 index f4f1a1d12..000000000 --- a/modules/mailalerts/mails/en/new_order.txt +++ /dev/null @@ -1,69 +0,0 @@ - -[{shop_url}] - -Congratulations! - -A new order was placed on {shop_name} from the following customer: -{firstname} {lastname} ({email}) - -Order details - -ORDER: {order_name} Placed on {date} - -PAYMENT: {payment} - -REFERENCE - -PRODUCT - -UNIT PRICE - -QUANTITY - -TOTAL PRICE - -{items} - -PRODUCTS - -{total_products} - -DISCOUNTS - -{total_discounts} - -GIFT-WRAPPING - -{total_wrapping} - -SHIPPING - -{total_shipping} - -TOTAL TAX PAID - -{total_tax_paid} - -TOTAL PAID - -{total_paid} - -Carrier: - -{carrier} - -Delivery address - -{delivery_block_html} - -Billing address - -{invoice_block_html} - -Customer message: - -{message} - -{shop_name} [{shop_url}] powered by -PrestaShop(tm) [http://www.prestashop.com/] - diff --git a/modules/mailalerts/mails/en/productcoverage.html b/modules/mailalerts/mails/en/productcoverage.html deleted file mode 100644 index 42e3b6fdd..000000000 --- a/modules/mailalerts/mails/en/productcoverage.html +++ /dev/null @@ -1,112 +0,0 @@ - - - - - - - Message from {shop_name} - - - - - - - - - - - - -
      - - - - - - - - - - - - - - - - - - - - - -
    - Hi, -
    -

    - {product} is almost out of stock.

    - - The stock cover is now less than the specified minimum of: {warning_coverage}.

    - Current stock cover: {current_coverage} -
    -
    -
     
    - - \ No newline at end of file diff --git a/modules/mailalerts/mails/en/productcoverage.txt b/modules/mailalerts/mails/en/productcoverage.txt deleted file mode 100644 index e20bf1bea..000000000 --- a/modules/mailalerts/mails/en/productcoverage.txt +++ /dev/null @@ -1,15 +0,0 @@ - -[{shop_url}] - -Hi, - -{product} is almost out of stock. - -The stock cover is now less than the specified minimum of: -{warning_coverage}. - -CURRENT STOCK COVER: {current_coverage} - -{shop_name} [{shop_url}] powered by -PrestaShop(tm) [http://www.prestashop.com/] - diff --git a/modules/mailalerts/mails/en/productoutofstock.html b/modules/mailalerts/mails/en/productoutofstock.html deleted file mode 100644 index 4fab77434..000000000 --- a/modules/mailalerts/mails/en/productoutofstock.html +++ /dev/null @@ -1,112 +0,0 @@ - - - - - - - Message from {shop_name} - - - - - - - - - - - - -
      - - - - - - - - - - - - - - - - - - - - - -
    - Hi, -
    -

    - {product} is nearly out of stock.

    - - The remaining stock is now less than the specified minimum of {last_qty}.

    - Remaining stock: {qty}

    - You are advised to open the product's admin Product Page in order to replenish your inventory.
    -
    -
     
    - - \ No newline at end of file diff --git a/modules/mailalerts/mails/en/productoutofstock.txt b/modules/mailalerts/mails/en/productoutofstock.txt deleted file mode 100644 index 186e85811..000000000 --- a/modules/mailalerts/mails/en/productoutofstock.txt +++ /dev/null @@ -1,18 +0,0 @@ - -[{shop_url}] - -Hi, - -{product} is nearly out of stock. - -The remaining stock is now less than the specified minimum of -{last_qty}. - -REMAINING STOCK: {qty} - -You are advised to open the product's admin Product Page in order to -replenish your inventory. - -{shop_name} [{shop_url}] powered by -PrestaShop(tm) [http://www.prestashop.com/] - diff --git a/modules/mailalerts/mails/index.php b/modules/mailalerts/mails/index.php deleted file mode 100644 index 15749979b..000000000 --- a/modules/mailalerts/mails/index.php +++ /dev/null @@ -1,36 +0,0 @@ - -* @copyright 2007-2013 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 -*/ - -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); - -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); - -header("Location: ../"); -exit; \ No newline at end of file diff --git a/modules/mailalerts/translations/index.php b/modules/mailalerts/translations/index.php deleted file mode 100644 index 3f6561f72..000000000 --- a/modules/mailalerts/translations/index.php +++ /dev/null @@ -1,35 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); - -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); - -header("Location: ../"); -exit; \ No newline at end of file diff --git a/modules/mailalerts/upgrade/install-2.5.php b/modules/mailalerts/upgrade/install-2.5.php deleted file mode 100644 index 440e5512a..000000000 --- a/modules/mailalerts/upgrade/install-2.5.php +++ /dev/null @@ -1,14 +0,0 @@ -execute(' - ALTER TABLE `'._DB_PREFIX_.'mailalert_customer_oos` - ADD `id_lang` INT( 10 ) UNSIGNED NOT NULL , - DROP PRIMARY KEY , - ADD PRIMARY KEY (`id_customer` , `customer_email` , `id_product` , `id_product_attribute` , `id_shop`) - '); -} \ No newline at end of file diff --git a/modules/mailalerts/views/index.php b/modules/mailalerts/views/index.php deleted file mode 100644 index 3f6561f72..000000000 --- a/modules/mailalerts/views/index.php +++ /dev/null @@ -1,35 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); - -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); - -header("Location: ../"); -exit; \ No newline at end of file diff --git a/modules/mailalerts/views/templates/admin/_configure/helpers/form/form.tpl b/modules/mailalerts/views/templates/admin/_configure/helpers/form/form.tpl deleted file mode 100644 index ae83bc00e..000000000 --- a/modules/mailalerts/views/templates/admin/_configure/helpers/form/form.tpl +++ /dev/null @@ -1,52 +0,0 @@ -{* -* 2007-2013 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 -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*} - -{extends file="helpers/form/form.tpl"} - -{block name="input"} - {if $input.type == 'switch'} - {foreach $input.values as $value} - - - {if isset($input.br) && $input.br}
    {/if} - {if isset($value.p) && $value.p}

    {$value.p}

    {/if} - {/foreach} - {else} - {$smarty.block.parent} - {/if} - -{/block} diff --git a/modules/mailalerts/views/templates/admin/_configure/helpers/form/index.php b/modules/mailalerts/views/templates/admin/_configure/helpers/form/index.php deleted file mode 100644 index 3f6561f72..000000000 --- a/modules/mailalerts/views/templates/admin/_configure/helpers/form/index.php +++ /dev/null @@ -1,35 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); - -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); - -header("Location: ../"); -exit; \ No newline at end of file diff --git a/modules/mailalerts/views/templates/front/index.php b/modules/mailalerts/views/templates/front/index.php deleted file mode 100644 index 3f6561f72..000000000 --- a/modules/mailalerts/views/templates/front/index.php +++ /dev/null @@ -1,35 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); - -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); - -header("Location: ../"); -exit; \ No newline at end of file diff --git a/modules/mailalerts/views/templates/front/mailalerts-account.tpl b/modules/mailalerts/views/templates/front/mailalerts-account.tpl deleted file mode 100644 index a56466789..000000000 --- a/modules/mailalerts/views/templates/front/mailalerts-account.tpl +++ /dev/null @@ -1,85 +0,0 @@ -{* -* 2007-2013 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 -* @copyright 2007-2013 PrestaShop SA -* @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='My account' mod='mailalerts'}{$navigationPipe}{l s='My alerts' mod='mailalerts'}{/capture} -{include file="$tpl_dir./breadcrumb.tpl"} - -
    -

    {l s='My alerts' mod='mailalerts'}

    - {if $mailAlerts} -
    - {foreach from=$mailAlerts item=mailAlert} -
    - -

    {$mailAlert.name|escape:'html':'UTF-8'}

    -
    {$mailAlert.attributes_small|escape:'html':'UTF-8'}
    - -
    - {l s='Remove' mod='mailalerts'} -
    -
    - {/foreach} -
    - {else} -

    {l s='No mail alerts yet.' mod='mailalerts'}

    - {/if} - - -
    \ No newline at end of file diff --git a/modules/mailalerts/views/templates/hook/index.php b/modules/mailalerts/views/templates/hook/index.php deleted file mode 100644 index 3f6561f72..000000000 --- a/modules/mailalerts/views/templates/hook/index.php +++ /dev/null @@ -1,35 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); - -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); - -header("Location: ../"); -exit; \ No newline at end of file diff --git a/modules/mailalerts/views/templates/hook/my-account.tpl b/modules/mailalerts/views/templates/hook/my-account.tpl deleted file mode 100644 index 84b0c8a1e..000000000 --- a/modules/mailalerts/views/templates/hook/my-account.tpl +++ /dev/null @@ -1,31 +0,0 @@ -{* -* 2007-2013 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 -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*} - -
  • - - - {l s='My alerts' mod='mailalerts'} - -
  • diff --git a/modules/mailalerts/views/templates/hook/product.tpl b/modules/mailalerts/views/templates/hook/product.tpl deleted file mode 100644 index 4fa639c32..000000000 --- a/modules/mailalerts/views/templates/hook/product.tpl +++ /dev/null @@ -1,97 +0,0 @@ -{* -* 2007-2013 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 -* @copyright 2007-2013 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 -*} - - - - {if isset($email) AND $email} -
    - {/if} - {l s='Notify me when available' mod='mailalerts'} - - diff --git a/modules/mailalerts/views/templates/index.php b/modules/mailalerts/views/templates/index.php deleted file mode 100644 index 3f6561f72..000000000 --- a/modules/mailalerts/views/templates/index.php +++ /dev/null @@ -1,35 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); - -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); - -header("Location: ../"); -exit; \ No newline at end of file diff --git a/modules/newsletter/config.xml b/modules/newsletter/config.xml deleted file mode 100755 index 15eceb2dc..000000000 --- a/modules/newsletter/config.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - newsletter - - - - - - 1 - 0 - - \ No newline at end of file diff --git a/modules/newsletter/index.php b/modules/newsletter/index.php deleted file mode 100644 index 3f6561f72..000000000 --- a/modules/newsletter/index.php +++ /dev/null @@ -1,35 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); - -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); - -header("Location: ../"); -exit; \ No newline at end of file diff --git a/modules/newsletter/logo.gif b/modules/newsletter/logo.gif deleted file mode 100644 index 06dd879da..000000000 Binary files a/modules/newsletter/logo.gif and /dev/null differ diff --git a/modules/newsletter/logo.png b/modules/newsletter/logo.png deleted file mode 100755 index 4d3b03007..000000000 Binary files a/modules/newsletter/logo.png and /dev/null differ diff --git a/modules/newsletter/newsletter.php b/modules/newsletter/newsletter.php deleted file mode 100644 index 968fff4a7..000000000 --- a/modules/newsletter/newsletter.php +++ /dev/null @@ -1,342 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -if (!defined('_PS_VERSION_')) - exit; - -class Newsletter extends Module -{ - private $_postErrors = array(); - private $_html = ''; - private $_postSucess; - - public function __construct() - { - $this->name = 'newsletter'; - $this->tab = 'administration'; - $this->version = 2.0; - $this->author = 'PrestaShop'; - $this->need_instance = 0; - - $this->bootstrap = true; - parent::__construct(); - - $this->displayName = $this->l('Newsletter'); - $this->description = $this->l('Generates a .CSV file for mass mailings'); - - if ($this->id) - { - $this->_file = 'export_'.Configuration::get('PS_NEWSLETTER_RAND').'.csv'; - $this->_postValid = array(); - - // Getting data... - $_countries = Country::getCountries($this->context->language->id); - - // ...formatting array - $countries[0] = $this->l('All countries'); - foreach ($_countries as $country) - $countries[$country['id_country']] = $country['name']; - - // And filling fields to show ! - $this->_fieldsExport = array( - 'COUNTRY' => array( - 'title' => $this->l('Customers\' country'), - 'desc' => $this->l('Operate a filter on customers\' country.'), - 'type' => 'select', - 'value' => $countries, - 'value_default' => 0 - ), - 'SUSCRIBERS' => array( - 'title' => $this->l('Newsletter subscribers'), - 'desc' => $this->l('Filter newsletter subscribers.'), - 'type' => 'select', - 'value' => array(0 => $this->l('All customers'), 2 => $this->l('Subscribers'), 1 => $this->l('Non-subscribers')), - 'value_default' => 2 - ), - 'OPTIN' => array( - 'title' => $this->l('Opted-in subscribers'), - 'desc' => $this->l('Filter opted-in subscribers.'), - 'type' => 'select', - 'value' => array(0 => $this->l('All customers'), 2 => $this->l('Subscribers'), 1 => $this->l('Non-subscribers')), - 'value_default' => 0 - ), - ); - } - } - - public function install() - { - return (parent::install() AND Configuration::updateValue('PS_NEWSLETTER_RAND', rand().rand())); - } - - private function _postProcess() - { - if (Tools::isSubmit('submitExport') && $action = Tools::getValue('action')) - { - if ($action == 'customers') - $result = $this->_getCustomers(); - else - { - if (!Module::isInstalled('blocknewsletter')) - $this->_html .= $this->displayError('The module "blocknewsletter" is required for this feature'); - else - $result = $this->_getBlockNewsletter(); - } - if (!$nb = (int)(Db::getInstance(_PS_USE_SQL_SLAVE_)->NumRows())) - $this->_html .= $this->displayError($this->l('No customers found with these filters!')); - elseif ($fd = @fopen(dirname(__FILE__).'/'.strval(preg_replace('#\.{2,}#', '.', $_POST['action'])).'_'.$this->_file, 'w')) - { - foreach ($result AS $tab) - $this->_my_fputcsv($fd, $tab); - fclose($fd); - $this->_html .= $this->displayConfirmation( - sprintf($this->l('The .CSV file has been successfully exported. (%d customers found)'), $nb).'
    - '.$this->l('Download the file').' '.$this->_file.' -
    -
      -
    1. '.$this->l('WARNING: If opening this .csv file with Excel, remember to choose UTF-8 encoding or you may see strange characters.').'
    2. -
    '); - } - else - $this->_html .= $this->displayError($this->l('Error: cannot write').' '.dirname(__FILE__).'/'.strval($_POST['action']).'_'.$this->_file.' !'); - } - } - - private function _getCustomers() - { - $dbquery = new DbQuery(); - $dbquery->select('c.`id_customer`, c.`lastname`, c.`firstname`, c.`email`, c.`ip_registration_newsletter`, c.`newsletter_date_add`') - ->from('customer', 'c') - ->groupBy('c.`email`'); - - if (Tools::getValue('SUSCRIBERS')) - $dbquery->where('c.`newsletter` = '.((int)Tools::getValue('SUSCRIBERS') - 1)); - - if (Tools::getValue('OPTIN')) - $dbquery->where('c.`optin` = '.((int)Tools::getValue('OPTIN') - 1)); - - if (Tools::getValue('COUNTRY')) - $dbquery->where('(SELECT COUNT(a.`id_address`) as nb_country - FROM `'._DB_PREFIX_.'address` a - WHERE a.deleted = 0 - AND a.`id_customer` = c.`id_customer` - AND a.`id_country` = '.(int)Tools::getValue('COUNTRY').') >= 1'); - - if (Context::getContext()->cookie->shopContext) - $dbquery->where('c.id_shop = '.(int)Context::getContext()->shop->id); - - $rq = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($dbquery->build()); - - $header = array('id_customer', 'lastname', 'firstname', 'email', 'ip_address', 'newsletter_date_add'); - $result = (is_array($rq) ? array_merge(array($header), $rq) : $header); - return $result; - } - - private function _getBlockNewsletter() - { - $rqSql = 'SELECT `id`, `email`, `newsletter_date_add`, `ip_registration_newsletter` - FROM `'._DB_PREFIX_.'newsletter` - WHERE `active` = 1'; - - if (Context::getContext()->cookie->shopContext) - $rqSql .= ' AND `id_shop` = '.(int)Context::getContext()->shop->id; - - $rq = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($rqSql); - - $header = array('id_customer', 'email', 'newsletter_date_add', 'ip_address', 'http_referer'); - $result = (is_array($rq) ? array_merge(array($header), $rq) : $header); - return $result; - } - - private function _my_fputcsv($fd, $array) - { - $line = implode(';', $array); - $line .= "\n"; - if (!fwrite($fd, $line, 4096)) - $this->_postErrors[] = $this->l('Error: cannot write').' '.dirname(__FILE__).'/'.$this->_file.' !'; - } - - private function _displayForm() - { - $this->_displayFormExport(); - } - - public function getContent() - { - $this->_html .= ''; - - if (!empty($_POST)) - $this->_html .= $this->_postProcess(); - $this->_html .= $this->renderForm(); - - return $this->_html; - } - - public function renderForm() - { - - // Getting data... - $_countries = Country::getCountries($this->context->language->id); - - // ...formatting array - $countries[0] = array('id' => 0, 'name' => $this->l('All countries')); - foreach ($_countries as $country) - $countries[] = array('id' => $country['id_country'], 'name' => $country['name']); - - // And filling fields to show ! - $this->_fieldsExport = array( - 'COUNTRY' => array( - 'title' => $this->l('Customers\' country'), - 'desc' => $this->l('Operate a filter on customers\' country.'), - 'type' => 'select', - 'value' => $countries, - 'value_default' => 0 - ), - 'SUSCRIBERS' => array( - 'title' => $this->l('Newsletter subscribers'), - 'desc' => $this->l('Filter newsletter subscribers.'), - 'type' => 'select', - 'value' => array(0 => $this->l('All customers'), 2 => $this->l('Subscribers'), 1 => $this->l('Non-subscribers')), - 'value_default' => 2 - ), - 'OPTIN' => array( - 'title' => $this->l('Opted-in subscribers'), - 'desc' => $this->l('Filter opted-in subscribers.'), - 'type' => 'select', - 'value' => array(0 => $this->l('All customers'), 2 => $this->l('Subscribers'), 1 => $this->l('Non-subscribers')), - 'value_default' => 0 - ), - ); - - $fields_form_1 = array( - 'form' => array( - 'legend' => array( - 'title' => $this->l('Export Newsletter Subscribers'), - 'icon' => 'icon-envelope' - ), - 'desc' => array( - array('text' => $this->l('Generate a .CSV file based on BlockNewsletter subscribers data. Only subscribers without an account on the shop will be exported.')) - ), - 'submit' => array( - 'title' => $this->l('Export .CSV file'), - 'class' => 'btn btn-default', - 'name' => 'submitExport', - ) - ), - ); - - $fields_form_2 = array( - 'form' => array( - 'legend' => array( - 'title' => $this->l('Export customers'), - 'icon' => 'icon-envelope' - ), - 'input' => array( - array( - 'type' => 'select', - 'label' => $this->l('Customers\' country :'), - 'desc' => $this->l('Operate a filter on customers\' country.'), - 'name' => 'COUNTRY', - 'required' => false, - 'default_value' => (int)$this->context->country->id, - 'options' => array( - 'query' => $countries, - 'id' => 'id', - 'name' => 'name', - ) - ), - array( - 'type' => 'select', - 'label' => $this->l('Newsletter subscribers :'), - 'desc' => $this->l('Filter newsletter subscribers.'), - 'name' => 'SUSCRIBERS', - 'required' => false, - 'default_value' => (int)$this->context->country->id, - 'options' => array( - 'query' => array(array('id' => 0, 'name' => $this->l('All customers')), array('id' => 2, 'name' => $this->l('Subscribers')), array('id' => 1, 'name' => $this->l('Non-subscribers'))), - 'id' => 'id', - 'name' => 'name', - ) - ), - array( - 'type' => 'select', - 'label' => $this->l('Opted-in subscribers :'), - 'desc' => $this->l('Filter opted-in subscribers.'), - 'name' => 'OPTIN', - 'required' => false, - 'default_value' => (int)$this->context->country->id, - 'options' => array( - 'query' => array(array('id' => 0, 'name' => $this->l('All customers')), array('id' => 2, 'name' => $this->l('Subscribers')), array('id' => 1, 'name' => $this->l('Non-subscribers'))), - 'id' => 'id', - 'name' => 'name', - ) - ), - array( - 'type' => 'hidden', - 'name' => 'action', - ) - ), - 'submit' => array( - 'title' => $this->l('Export .CSV file'), - 'class' => 'btn btn-default', - 'name' => 'submitExport', - ) - ), - ); - - $helper = new HelperForm(); - $helper->show_toolbar = false; - $helper->table = $this->table; - $lang = new Language((int)Configuration::get('PS_LANG_DEFAULT')); - $helper->default_form_language = $lang->id; - $helper->allow_employee_form_lang = Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG') ? Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG') : 0; - $this->fields_form = array(); - $helper->id = (int)Tools::getValue('id_carrier'); - $helper->identifier = $this->identifier; - $helper->submit_action = 'btnSubmit'; - $helper->currentIndex = $this->context->link->getAdminLink('AdminModules', false).'&configure='.$this->name.'&tab_module='.$this->tab.'&module_name='.$this->name; - $helper->token = Tools::getAdminTokenLite('AdminModules'); - $helper->tpl_vars = array( - 'fields_value' => $this->getConfigFieldsValues(), - 'languages' => $this->context->controller->getLanguages(), - 'id_language' => $this->context->language->id - ); - - return $helper->generateForm(array($fields_form_1, $fields_form_2)); - } - - public function getConfigFieldsValues() - { - return array( - 'COUNTRY' => Tools::getValue('COUNTRY'), - 'SUSCRIBERS' => Tools::getValue('SUSCRIBERS'), - 'OPTIN' => Tools::getValue('OPTIN'), - 'action' => 'customers', - ); - } - -} - diff --git a/modules/newsletter/translations/index.php b/modules/newsletter/translations/index.php deleted file mode 100644 index 3f6561f72..000000000 --- a/modules/newsletter/translations/index.php +++ /dev/null @@ -1,35 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); - -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); - -header("Location: ../"); -exit; \ No newline at end of file diff --git a/modules/productcomments/ProductComment.php b/modules/productcomments/ProductComment.php deleted file mode 100644 index 5887357b8..000000000 --- a/modules/productcomments/ProductComment.php +++ /dev/null @@ -1,406 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -if (!defined('_PS_VERSION_')) - exit; - -class ProductComment extends ObjectModel -{ - public $id; - - /** @var integer Product's id */ - public $id_product; - - /** @var integer Customer's id */ - public $id_customer; - - /** @var integer Guest's id */ - public $id_guest; - - /** @var integer Customer name */ - public $customer_name; - - /** @var string Title */ - public $title; - - /** @var string Content */ - public $content; - - /** @var integer Grade */ - public $grade; - - /** @var boolean Validate */ - public $validate = 0; - - public $deleted = 0; - - /** @var string Object creation date */ - public $date_add; - - /** - * @see ObjectModel::$definition - */ - public static $definition = array( - 'table' => 'product_comment', - 'primary' => 'id_product_comment', - 'fields' => array( - 'id_product' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true), - 'id_customer' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true), - 'id_guest' => array('type' => self::TYPE_INT), - 'customer_name' => array('type' => self::TYPE_STRING), - 'title' => array('type' => self::TYPE_STRING), - 'content' => array('type' => self::TYPE_STRING, 'validate' => 'isMessage', 'size' => 65535, 'required' => true), - 'grade' => array('type' => self::TYPE_FLOAT, 'validate' => 'isFloat'), - 'validate' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'), - 'deleted' => array('type' => self::TYPE_BOOL), - 'date_add' => array('type' => self::TYPE_DATE), - ) - ); - - /** - * Get comments by IdProduct - * - * @return array Comments - */ - public static function getByProduct($id_product, $p = 1, $n = null, $id_customer = null) - { - if (!Validate::isUnsignedId($id_product)) - die(Tools::displayError()); - $validate = Configuration::get('PRODUCT_COMMENTS_MODERATE'); - $p = (int)$p; - $n = (int)$n; - if ($p <= 1) - $p = 1; - if ($n != null && $n <= 0) - $n = 5; - - $cache_id = 'ProductComment::getByProduct_'.(int)$id_product.'-'.(int)$p.'-'.(int)$n.'-'.(int)$id_customer.'-'.(bool)$validate; - if (!Cache::isStored($cache_id)) - { - $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS(' - SELECT pc.`id_product_comment`, - (SELECT count(*) FROM `'._DB_PREFIX_.'product_comment_usefulness` pcu WHERE pcu.`id_product_comment` = pc.`id_product_comment` AND pcu.`usefulness` = 1) as total_useful, - (SELECT count(*) FROM `'._DB_PREFIX_.'product_comment_usefulness` pcu WHERE pcu.`id_product_comment` = pc.`id_product_comment`) as total_advice, '. - ((int)$id_customer ? '(SELECT count(*) FROM `'._DB_PREFIX_.'product_comment_usefulness` pcuc WHERE pcuc.`id_product_comment` = pc.`id_product_comment` AND pcuc.id_customer = '.(int)$id_customer.') as customer_advice, ' : ''). - ((int)$id_customer ? '(SELECT count(*) FROM `'._DB_PREFIX_.'product_comment_report` pcrc WHERE pcrc.`id_product_comment` = pc.`id_product_comment` AND pcrc.id_customer = '.(int)$id_customer.') as customer_report, ' : '').' - IF(c.id_customer, CONCAT(c.`firstname`, \' \', LEFT(c.`lastname`, 1)), pc.customer_name) customer_name, pc.`content`, pc.`grade`, pc.`date_add`, pc.title - FROM `'._DB_PREFIX_.'product_comment` pc - LEFT JOIN `'._DB_PREFIX_.'customer` c ON c.`id_customer` = pc.`id_customer` - WHERE pc.`id_product` = '.(int)($id_product).($validate == '1' ? ' AND pc.`validate` = 1' : '').' - ORDER BY pc.`date_add` DESC - '.($n ? 'LIMIT '.(int)(($p - 1) * $n).', '.(int)($n) : '')); - Cache::store($cache_id, $result); - } - return Cache::retrieve($cache_id); - } - - /** - * Return customer's comment - * - * @return arrayComments - */ - public static function getByCustomer($id_product, $id_customer, $get_last = false, $id_guest = false) - { - $cache_id = 'ProductComment::getByCustomer_'.(int)$id_product.'-'.(int)$id_customer.'-'.(bool)$get_last.'-'.(int)$id_guest; - if (!Cache::isStored($cache_id)) - { - $results = Db::getInstance()->executeS(' - SELECT * - FROM `'._DB_PREFIX_.'product_comment` pc - WHERE pc.`id_product` = '.(int)$id_product.' - AND '.(!$id_guest ? 'pc.`id_customer` = '.(int)$id_customer : 'pc.`id_guest` = '.(int)$id_guest).' - ORDER BY pc.`date_add` DESC ' - .($get_last ? 'LIMIT 1' : '') - ); - - if ($get_last && count($results)) - $results = array_shift($results); - - Cache::store($cache_id, $results); - } - return Cache::retrieve($cache_id); - } - - /** - * Get Grade By product - * - * @return array Grades - */ - public static function getGradeByProduct($id_product, $id_lang) - { - if (!Validate::isUnsignedId($id_product) || - !Validate::isUnsignedId($id_lang)) - die(Tools::displayError()); - $validate = Configuration::get('PRODUCT_COMMENTS_MODERATE'); - - - return (Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS(' - SELECT pc.`id_product_comment`, pcg.`grade`, pccl.`name`, pcc.`id_product_comment_criterion` - FROM `'._DB_PREFIX_.'product_comment` pc - LEFT JOIN `'._DB_PREFIX_.'product_comment_grade` pcg ON (pcg.`id_product_comment` = pc.`id_product_comment`) - LEFT JOIN `'._DB_PREFIX_.'product_comment_criterion` pcc ON (pcc.`id_product_comment_criterion` = pcg.`id_product_comment_criterion`) - LEFT JOIN `'._DB_PREFIX_.'product_comment_criterion_lang` pccl ON (pccl.`id_product_comment_criterion` = pcg.`id_product_comment_criterion`) - WHERE pc.`id_product` = '.(int)$id_product.' - AND pccl.`id_lang` = '.(int)$id_lang. - ($validate == '1' ? ' AND pc.`validate` = 1' : ''))); - } - - public static function getAverageGrade($id_product) - { - $validate = Configuration::get('PRODUCT_COMMENTS_MODERATE'); - - return Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow(' - SELECT (SUM(pc.`grade`) / COUNT(pc.`grade`)) AS grade - FROM `'._DB_PREFIX_.'product_comment` pc - WHERE pc.`id_product` = '.(int)$id_product.' - AND pc.`deleted` = 0'. - ($validate == '1' ? ' AND pc.`validate` = 1' : '')); - } - - public static function getAveragesByProduct($id_product, $id_lang) - { - /* Get all grades */ - $grades = ProductComment::getGradeByProduct((int)$id_product, (int)$id_lang); - $total = ProductComment::getGradedCommentNumber((int)$id_product); - if (!count($grades) || (!$total)) - return array(); - - /* Addition grades for each criterion */ - $criterionsGradeTotal = array(); - $count_grades = count($grades); - for ($i = 0; $i < $count_grades; ++$i) - if (array_key_exists($grades[$i]['id_product_comment_criterion'], $criterionsGradeTotal) === false) - $criterionsGradeTotal[$grades[$i]['id_product_comment_criterion']] = (int)($grades[$i]['grade']); - else - $criterionsGradeTotal[$grades[$i]['id_product_comment_criterion']] += (int)($grades[$i]['grade']); - - /* Finally compute the averages */ - $averages = array(); - foreach ($criterionsGradeTotal as $key => $criterionGradeTotal) - $averages[(int)($key)] = (int)($total) ? ((int)($criterionGradeTotal) / (int)($total)) : 0; - return $averages; - } - - /** - * Return number of comments and average grade by products - * - * @return array Info - */ - public static function getCommentNumber($id_product) - { - if (!Validate::isUnsignedId($id_product)) - die(Tools::displayError()); - $validate = (int)Configuration::get('PRODUCT_COMMENTS_MODERATE'); - $cache_id = 'ProductComment::getCommentNumber_'.(int)$id_product.'-'.$validate; - if (!Cache::isStored($cache_id)) - { - $result = (int)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue(' - SELECT COUNT(`id_product_comment`) AS "nbr" - FROM `'._DB_PREFIX_.'product_comment` pc - WHERE `id_product` = '.(int)($id_product).($validate == '1' ? ' AND `validate` = 1' : '')); - Cache::store($cache_id, $result); - } - return Cache::retrieve($cache_id); - } - - /** - * Return number of comments and average grade by products - * - * @return array Info - */ - public static function getGradedCommentNumber($id_product) - { - if (!Validate::isUnsignedId($id_product)) - die(Tools::displayError()); - $validate = (int)Configuration::get('PRODUCT_COMMENTS_MODERATE'); - - $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow(' - SELECT COUNT(pc.`id_product`) AS nbr - FROM `'._DB_PREFIX_.'product_comment` pc - WHERE `id_product` = '.(int)($id_product).($validate == '1' ? ' AND `validate` = 1' : '').' - AND `grade` > 0'); - return (int)($result['nbr']); - } - - /** - * Get comments by Validation - * - * @return array Comments - */ - public static function getByValidate($validate = '0', $deleted = false) - { - return (Db::getInstance()->executeS(' - SELECT pc.`id_product_comment`, pc.`id_product`, IF(c.id_customer, CONCAT(c.`firstname`, \' \', c.`lastname`), pc.customer_name) customer_name, pc.`content`, pc.`grade`, pc.`date_add`, pl.`name` - FROM `'._DB_PREFIX_.'product_comment` pc - LEFT JOIN `'._DB_PREFIX_.'customer` c ON (c.`id_customer` = pc.`id_customer`) - LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (pl.`id_product` = pc.`id_product` AND pl.`id_lang` = '.(int)Context::getContext()->language->id.Shop::addSqlRestrictionOnLang('pl').') - WHERE pc.`validate` = '.(int)$validate.' - ORDER BY pc.`date_add` DESC')); - } - - /** - * Get all comments - * - * @return array Comments - */ - public static function getAll() - { - return (Db::getInstance()->executeS(' - SELECT pc.`id_product_comment`, pc.`id_product`, IF(c.id_customer, CONCAT(c.`firstname`, \' \', c.`lastname`), pc.customer_name) customer_name, pc.`content`, pc.`grade`, pc.`date_add`, pl.`name` - FROM `'._DB_PREFIX_.'product_comment` pc - LEFT JOIN `'._DB_PREFIX_.'customer` c ON (c.`id_customer` = pc.`id_customer`) - LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (pl.`id_product` = pc.`id_product` AND pl.`id_lang` = '.(int)Context::getContext()->language->id.Shop::addSqlRestrictionOnLang('pl').') - ORDER BY pc.`date_add` DESC')); - } - - /** - * Validate a comment - * - * @return boolean succeed - */ - public function validate($validate = '1') - { - if (!Validate::isUnsignedId($this->id)) - die(Tools::displayError()); - return (Db::getInstance()->execute(' - UPDATE `'._DB_PREFIX_.'product_comment` SET - `validate` = '.(int)$validate.' - WHERE `id_product_comment` = '.(int)$this->id)); - } - - /** - * Delete Grades - * - * @return boolean succeed - */ - public static function deleteGrades($id_product_comment) - { - if (!Validate::isUnsignedId($id_product_comment)) - die(Tools::displayError()); - return (Db::getInstance()->execute(' - DELETE FROM `'._DB_PREFIX_.'product_comment_grade` - WHERE `id_product_comment` = '.(int)$id_product_comment)); - } - - /** - * Delete Reports - * - * @return boolean succeed - */ - public static function deleteReports($id_product_comment) - { - if (!Validate::isUnsignedId($id_product_comment)) - die(Tools::displayError()); - return (Db::getInstance()->execute(' - DELETE FROM `'._DB_PREFIX_.'product_comment_report` - WHERE `id_product_comment` = '.(int)$id_product_comment)); - } - - /** - * Delete usefulness - * - * @return boolean succeed - */ - public static function deleteUsefulness($id_product_comment) - { - if (!Validate::isUnsignedId($id_product_comment)) - die(Tools::displayError()); - - return (Db::getInstance()->execute(' - DELETE FROM `'._DB_PREFIX_.'product_comment_usefulness` - WHERE `id_product_comment` = '.(int)$id_product_comment)); - } - - /** - * Report comment - * - * @return boolean - */ - public static function reportComment($id_product_comment, $id_customer) - { - return (Db::getInstance()->execute(' - INSERT INTO `'._DB_PREFIX_.'product_comment_report` (`id_product_comment`, `id_customer`) - VALUES ('.(int)$id_product_comment.', '.(int)$id_customer.')')); - } - - /** - * Comment already report - * - * @return boolean - */ - public static function isAlreadyReport($id_product_comment, $id_customer) - { - return (bool)Db::getInstance()->getValue(' - SELECT COUNT(*) - FROM `'._DB_PREFIX_.'product_comment_report` - WHERE `id_customer` = '.(int)$id_customer.' - AND `id_product_comment` = '.(int)$id_product_comment); - } - - /** - * Set comment usefulness - * - * @return boolean - */ - public static function setCommentUsefulness($id_product_comment, $usefulness, $id_customer) - { - return (Db::getInstance()->execute(' - INSERT INTO `'._DB_PREFIX_.'product_comment_usefulness` (`id_product_comment`, `usefulness`, `id_customer`) - VALUES ('.(int)$id_product_comment.', '.(int)$usefulness.', '.(int)$id_customer.')')); - } - - /** - * Usefulness already set - * - * @return boolean - */ - public static function isAlreadyUsefulness($id_product_comment, $id_customer) - { - return (bool)Db::getInstance()->getValue(' - SELECT COUNT(*) - FROM `'._DB_PREFIX_.'product_comment_usefulness` - WHERE `id_customer` = '.(int)$id_customer.' - AND `id_product_comment` = '.(int)$id_product_comment); - } - - /** - * Get reported comments - * - * @return array Comments - */ - public static function getReportedComments() - { - return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS(' - SELECT DISTINCT(pc.`id_product_comment`), pc.`id_product`, IF(c.id_customer, CONCAT(c.`firstname`, \' \', c.`lastname`), pc.customer_name) customer_name, pc.`content`, pc.`grade`, pc.`date_add`, pl.`name` - FROM `'._DB_PREFIX_.'product_comment_report` pcr - LEFT JOIN `'._DB_PREFIX_.'product_comment` pc - ON pcr.id_product_comment = pc.id_product_comment - LEFT JOIN `'._DB_PREFIX_.'customer` c ON (c.`id_customer` = pc.`id_customer`) - LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (pl.`id_product` = pc.`id_product` AND pl.`id_lang` = '.(int)Context::getContext()->language->id.' AND pl.`id_lang` = '.(int)Context::getContext()->language->id.Shop::addSqlRestrictionOnLang('pl').') - ORDER BY pc.`date_add` DESC'); - } - -}; diff --git a/modules/productcomments/ProductCommentCriterion.php b/modules/productcomments/ProductCommentCriterion.php deleted file mode 100644 index e46775c0c..000000000 --- a/modules/productcomments/ProductCommentCriterion.php +++ /dev/null @@ -1,260 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -class ProductCommentCriterion extends ObjectModel -{ - public $id; - public $id_product_comment_criterion_type; - - public $name; - public $active = true; - - /** - * @see ObjectModel::$definition - */ - public static $definition = array( - 'table' => 'product_comment_criterion', - 'primary' => 'id_product_comment_criterion', - 'multilang' => true, - 'fields' => array( - 'id_product_comment_criterion_type' => array('type' => self::TYPE_INT), - 'active' => array('type' => self::TYPE_BOOL), - // Lang fields - 'name' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName', 'required' => true, 'size' => 128), - ) - ); - - public function delete() - { - if (!parent::delete()) - return false; - if ($this->id_product_comment_criterion_type == 2) - { - if (!Db::getInstance()->execute(' - DELETE FROM '._DB_PREFIX_.'product_comment_criterion_category - WHERE id_product_comment_criterion='.(int)$this->id)) - return false; - } - elseif ($this->id_product_comment_criterion_type == 3) - { - if (!Db::getInstance()->execute(' - DELETE FROM '._DB_PREFIX_.'product_comment_criterion_product - WHERE id_product_comment_criterion='.(int)$this->id)) - return false; - } - - return Db::getInstance()->execute(' - DELETE FROM `'._DB_PREFIX_.'product_comment_grade` - WHERE `id_product_comment_criterion` = '.(int)$this->id); - } - - public function update($nullValues = false) - { - $previousUpdate = new self((int)$this->id); - if (!parent::update($nullValues)) - return false; - if ($previousUpdate->id_product_comment_criterion_type != $this->id_product_comment_criterion_type) - { - if ($previousUpdate->id_product_comment_criterion_type == 2) - return Db::getInstance()->execute(' - DELETE FROM '._DB_PREFIX_.'product_comment_criterion_category - WHERE id_product_comment_criterion = '.(int)$previousUpdate->id); - elseif ($previousUpdate->id_product_comment_criterion_type == 3) - return Db::getInstance()->execute(' - DELETE FROM '._DB_PREFIX_.'product_comment_criterion_product - WHERE id_product_comment_criterion = '.(int)$previousUpdate->id); - } - return true; - } - - /** - * Link a Comment Criterion to a product - * - * @return boolean succeed - */ - public function addProduct($id_product) - { - if (!Validate::isUnsignedId($id_product)) - die(Tools::displayError()); - return Db::getInstance()->execute(' - INSERT INTO `'._DB_PREFIX_.'product_comment_criterion_product` (`id_product_comment_criterion`, `id_product`) - VALUES('.(int)$this->id.','.(int)$id_product.') - '); - } - - /** - * Link a Comment Criterion to a category - * - * @return boolean succeed - */ - public function addCategory($id_category) - { - if (!Validate::isUnsignedId($id_category)) - die(Tools::displayError()); - return Db::getInstance()->execute(' - INSERT INTO `'._DB_PREFIX_.'product_comment_criterion_category` (`id_product_comment_criterion`, `id_category`) - VALUES('.(int)$this->id.','.(int)$id_category.') - '); - } - - /** - * Add grade to a criterion - * - * @return boolean succeed - */ - public function addGrade($id_product_comment, $grade) - { - if (!Validate::isUnsignedId($id_product_comment)) - die(Tools::displayError()); - if ($grade < 0) - $grade = 0; - elseif ($grade > 10) - $grade = 10; - return (Db::getInstance()->execute(' - INSERT INTO `'._DB_PREFIX_.'product_comment_grade` - (`id_product_comment`, `id_product_comment_criterion`, `grade`) VALUES( - '.(int)($id_product_comment).', - '.(int)$this->id.', - '.(int)($grade).')')); - } - - /** - * Get criterion by Product - * - * @return array Criterion - */ - public static function getByProduct($id_product, $id_lang) - { - if (!Validate::isUnsignedId($id_product) || - !Validate::isUnsignedId($id_lang)) - die(Tools::displayError()); - $alias = 'p'; - $table = ''; - // check if version > 1.5 to add shop association - if (version_compare(_PS_VERSION_, '1.5', '>')) - { - $table = '_shop'; - $alias = 'ps'; - } - - $cache_id = 'ProductCommentCriterion::getByProduct_'.(int)$id_product.'-'.(int)$id_lang; - if (!Cache::isStored($cache_id)) - { - $result = Db::getInstance()->executeS(' - SELECT pcc.`id_product_comment_criterion`, pccl.`name` - FROM `'._DB_PREFIX_.'product_comment_criterion` pcc - LEFT JOIN `'._DB_PREFIX_.'product_comment_criterion_lang` pccl - ON (pcc.id_product_comment_criterion = pccl.id_product_comment_criterion) - LEFT JOIN `'._DB_PREFIX_.'product_comment_criterion_product` pccp - ON (pcc.`id_product_comment_criterion` = pccp.`id_product_comment_criterion` AND pccp.`id_product` = '.(int)$id_product.') - LEFT JOIN `'._DB_PREFIX_.'product_comment_criterion_category` pccc - ON (pcc.`id_product_comment_criterion` = pccc.`id_product_comment_criterion`) - LEFT JOIN `'._DB_PREFIX_.'product'.$table.'` '.$alias.' - ON ('.$alias.'.id_category_default = pccc.id_category AND '.$alias.'.id_product = '.(int)$id_product.') - WHERE pccl.`id_lang` = '.(int)($id_lang).' - AND ( - pccp.id_product IS NOT NULL - OR ps.id_product IS NOT NULL - OR pcc.id_product_comment_criterion_type = 1 - ) - AND pcc.active = 1 - GROUP BY pcc.id_product_comment_criterion - '); - Cache::store($cache_id, $result); - } - return Cache::retrieve($cache_id); - } - - /** - * Get Criterions - * - * @return array Criterions - */ - public static function getCriterions($id_lang, $type = false, $active = false) - { - if (!Validate::isUnsignedId($id_lang)) - die(Tools::displayError()); - return Db::getInstance()->executeS(' - SELECT pcc.`id_product_comment_criterion`, pcc.id_product_comment_criterion_type, pccl.`name`, pcc.active - FROM `'._DB_PREFIX_.'product_comment_criterion` pcc - JOIN `'._DB_PREFIX_.'product_comment_criterion_lang` pccl ON (pcc.id_product_comment_criterion = pccl.id_product_comment_criterion) - WHERE pccl.`id_lang` = '.(int)$id_lang.($active ? ' AND active = 1' : '').($type ? ' AND id_product_comment_criterion_type = '.(int)$type : '').' - ORDER BY pccl.`name` ASC - '); - } - - public function getProducts() - { - $res = Db::getInstance()->executeS(' - SELECT pccp.id_product, pccp.id_product_comment_criterion - FROM `'._DB_PREFIX_.'product_comment_criterion_product` pccp - WHERE pccp.id_product_comment_criterion = '.(int)$this->id); - $products = array(); - if ($res) - foreach ($res AS $row) - $products[] = (int)$row['id_product']; - return $products; - } - - public function getCategories() - { - $res = Db::getInstance()->executeS(' - SELECT pccc.id_category, pccc.id_product_comment_criterion - FROM `'._DB_PREFIX_.'product_comment_criterion_category` pccc - WHERE pccc.id_product_comment_criterion = '.(int)$this->id); - $criterions = array(); - if ($res) - foreach ($res AS $row) - $criterions[] = (int)$row['id_category']; - return $criterions; - } - - public function deleteCategories() - { - return Db::getInstance()->execute(' - DELETE FROM `'._DB_PREFIX_.'product_comment_criterion_category` - WHERE `id_product_comment_criterion` = '.(int)$this->id); - } - - public function deleteProducts() - { - return Db::getInstance()->execute(' - DELETE FROM `'._DB_PREFIX_.'product_comment_criterion_product` - WHERE `id_product_comment_criterion` = '.(int)$this->id); - } - - public static function getTypes() - { - // Instance of module class for translations - $module = new ProductComments(); - - return array( - 1 => $module->l('Valid for the entire catalog', 'ProductCommentCriterion'), - 2 => $module->l('Restricted to some categories', 'ProductCommentCriterion'), - 3 => $module->l('Restricted to some products', 'ProductCommentCriterion') - ); - } -} diff --git a/modules/productcomments/ProductCriterion.php b/modules/productcomments/ProductCriterion.php deleted file mode 100644 index 2254d3911..000000000 --- a/modules/productcomments/ProductCriterion.php +++ /dev/null @@ -1,174 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -class ProductCommentCriterion -{ - /** - * Add a Comment Criterion - * - * @return boolean succeed - */ - public static function add($id_lang, $name) - { - if (!Validate::isUnsignedId($id_lang) || - !Validate::isMessage($name)) - die(Tools::displayError()); - return (Db::getInstance()->execute(' - INSERT INTO `'._DB_PREFIX_.'product_comment_criterion` - (`id_lang`, `name`) VALUES( - '.(int)($id_lang).', - \''.pSQL($name).'\')')); - } - - /** - * Link a Comment Criterion to a product - * - * @return boolean succeed - */ - public static function addToProduct($id_product_comment_criterion, $id_product) - { - if (!Validate::isUnsignedId($id_product_comment_criterion) || - !Validate::isUnsignedId($id_product)) - die(Tools::displayError()); - return (Db::getInstance()->execute(' - INSERT INTO `'._DB_PREFIX_.'product_comment_criterion_product` - (`id_product_comment_criterion`, `id_product`) VALUES( - '.(int)($id_product_comment_criterion).', - '.(int)($id_product).')')); - } - - /** - * Add grade to a criterion - * - * @return boolean succeed - */ - public static function addGrade($id_product_comment, $id_product_comment_criterion, $grade) - { - if (!Validate::isUnsignedId($id_product_comment) || - !Validate::isUnsignedId($id_product_comment_criterion)) - die(Tools::displayError()); - if ($grade < 0) - $grade = 0; - else if ($grade > 10) - $grade = 10; - return (Db::getInstance()->execute(' - INSERT INTO `'._DB_PREFIX_.'product_comment_grade` - (`id_product_comment`, `id_product_comment_criterion`, `grade`) VALUES( - '.(int)($id_product_comment).', - '.(int)($id_product_comment_criterion).', - '.(int)($grade).')')); - } - - /** - * Update criterion - * - * @return boolean succeed - */ - public static function update($id_product_comment_criterion, $id_lang, $name) - { - if (!Validate::isUnsignedId($id_product_comment_criterion) || - !Validate::isUnsignedId($id_lang) || - !Validate::isMessage($name)) - die(Tools::displayError()); - return (Db::getInstance()->execute(' - UPDATE `'._DB_PREFIX_.'product_comment_criterion` SET - `name` = \''.pSQL($name).'\' - WHERE `id_product_comment_criterion` = '.(int)($id_product_comment_criterion).' AND - `id_lang` = '.(int)($id_lang))); - } - - /** - * Get criterion by Product - * - * @return array Criterion - */ - public static function getByProduct($id_product, $id_lang) - { - if (!Validate::isUnsignedId($id_product) || - !Validate::isUnsignedId($id_lang)) - die(Tools::displayError()); - return (Db::getInstance()->executeS(' - SELECT pcc.`id_product_comment_criterion`, pcc.`name` - FROM `'._DB_PREFIX_.'product_comment_criterion` pcc - INNER JOIN `'._DB_PREFIX_.'product_comment_criterion_product` pccp ON pcc.`id_product_comment_criterion` = pccp.`id_product_comment_criterion` - WHERE pccp.`id_product` = '.(int)($id_product).' AND - pcc.`id_lang` = '.(int)($id_lang))); - } - - /** - * Get Criterions - * - * @return array Criterions - */ - public static function get($id_lang) - { - if (!Validate::isUnsignedId($id_lang)) - die(Tools::displayError()); - return (Db::getInstance()->executeS(' - SELECT pcc.`id_product_comment_criterion`, pcc.`name` - FROM `'._DB_PREFIX_.'product_comment_criterion` pcc - WHERE pcc.`id_lang` = '.(int)($id_lang).' - ORDER BY pcc.`name` ASC')); - } - - /** - * Delete product criterion by product - * - * @return boolean succeed - */ - public static function deleteByProduct($id_product) - { - if (!Validate::isUnsignedId($id_product)) - die(Tools::displayError()); - return (Db::getInstance()->execute(' - DELETE FROM `'._DB_PREFIX_.'product_comment_criterion_product` - WHERE `id_product` = '.(int)($id_product))); - } - - /** - * Delete all reference of a criterion - * - * @return boolean succeed - */ - public static function delete($id_product_comment_criterion) - { - if (!Validate::isUnsignedId($id_product_comment_criterion)) - die(Tools::displayError()); - $result = Db::getInstance()->execute(' - DELETE FROM `'._DB_PREFIX_.'product_comment_grade` - WHERE `id_product_comment_criterion` = '.(int)($id_product_comment_criterion)); - if ($result === false) - return ($result); - $result = Db::getInstance()->execute(' - DELETE FROM `'._DB_PREFIX_.'product_comment_criterion_product` - WHERE `id_product_comment_criterion` = '.(int)($id_product_comment_criterion)); - if ($result === false) - return ($result); - return (Db::getInstance()->execute(' - DELETE FROM `'._DB_PREFIX_.'product_comment_criterion` - WHERE `id_product_comment_criterion` = '.(int)($id_product_comment_criterion))); - } -}; \ No newline at end of file diff --git a/modules/productcomments/config.xml b/modules/productcomments/config.xml deleted file mode 100755 index c9413f84f..000000000 --- a/modules/productcomments/config.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - productcomments - - - - - - 1 - 0 - - \ No newline at end of file diff --git a/modules/productcomments/controllers/front/default.php b/modules/productcomments/controllers/front/default.php deleted file mode 100644 index bca7304f5..000000000 --- a/modules/productcomments/controllers/front/default.php +++ /dev/null @@ -1,170 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -// Include Module -include_once(dirname(__FILE__).'/../../productcomments.php'); -// Include Models -include_once(dirname(__FILE__).'/../../ProductComment.php'); -include_once(dirname(__FILE__).'/../../ProductCommentCriterion.php'); - -class ProductCommentsDefaultModuleFrontController extends ModuleFrontController -{ - public function __construct() - { - parent::__construct(); - - $this->context = Context::getContext(); - } - - public function initContent() - { - parent::initContent(); - - if (Tools::isSubmit('action')) - { - switch(Tools::getValue('action')) - { - case 'add_comment': - $this->ajaxProcessAddComment(); - break; - case 'report_abuse': - $this->ajaxProcessReportAbuse(); - break; - case 'comment_is_usefull': - $this->ajaxProcessCommentIsUsefull(); - break; - } - } - } - - protected function ajaxProcessAddComment() - { - $module_instance = new ProductComments(); - - $result = true; - $id_guest = 0; - $id_customer = $this->context->customer->id; - if (!$id_customer) - $id_guest = $this->context->cookie->id_guest; - - $errors = array(); - // Validation - if (!Validate::isInt(Tools::getValue('id_product'))) - $errors[] = $module_instance->l('ID product is incorrect', 'default'); - if (!Tools::getValue('title') || !Validate::isGenericName(Tools::getValue('title'))) - $errors[] = $module_instance->l('Title is incorrect', 'default'); - if (!Tools::getValue('content') || !Validate::isMessage(Tools::getValue('content'))) - $errors[] = $module_instance->l('Comment is incorrect', 'default'); - if (!$id_customer && (!Tools::isSubmit('customer_name') || !Tools::getValue('customer_name') || !Validate::isGenericName(Tools::getValue('customer_name')))) - $errors[] = $module_instance->l('Customer name is incorrect', 'default'); - if (!$this->context->customer->id && !Configuration::get('PRODUCT_COMMENTS_ALLOW_GUESTS')) - $errors[] = $module_instance->l('You must be logged in order to send a comment', 'default'); - if (!count(Tools::getValue('criterion'))) - $errors[] = $module_instance->l('You must give a rating', 'default'); - - $product = new Product(Tools::getValue('id_product')); - if (!$product->id) - $errors[] = $module_instance->l('Product not found', 'default'); - - if (!count($errors)) - { - $customer_comment = ProductComment::getByCustomer(Tools::getValue('id_product'), $id_customer, true, $id_guest); - if (!$customer_comment || ($customer_comment && (strtotime($customer_comment['date_add']) + (int)Configuration::get('PRODUCT_COMMENTS_MINIMAL_TIME')) < time())) - { - - $comment = new ProductComment(); - $comment->content = strip_tags(Tools::getValue('content')); - $comment->id_product = (int)Tools::getValue('id_product'); - $comment->id_customer = (int)$id_customer; - $comment->id_guest = $id_guest; - $comment->customer_name = Tools::getValue('customer_name'); - if (!$comment->customer_name) - $comment->customer_name = pSQL($this->context->customer->firstname.' '.$this->context->customer->lastname); - $comment->title = Tools::getValue('title'); - $comment->grade = 0; - $comment->validate = 0; - $comment->save(); - - $grade_sum = 0; - foreach(Tools::getValue('criterion') as $id_product_comment_criterion => $grade) - { - $grade_sum += $grade; - $product_comment_criterion = new ProductCommentCriterion($id_product_comment_criterion); - if ($product_comment_criterion->id) - $product_comment_criterion->addGrade($comment->id, $grade); - } - - if (count(Tools::getValue('criterion')) >= 1) - { - $comment->grade = $grade_sum / count(Tools::getValue('criterion')); - // Update Grade average of comment - $comment->save(); - } - $result = true; - } - else - { - $result = false; - $errors[] = $module_instance->l('You should wait').' '.Configuration::get('PRODUCT_COMMENTS_MINIMAL_TIME').' '.$module_instance->l('seconds before posting a new comment'); - } - } - else - $result = false; - - die(Tools::jsonEncode(array( - 'result' => $result, - 'errors' => $errors - ))); - } - - protected function ajaxProcessReportAbuse() - { - if (!Tools::isSubmit('id_product_comment')) - die('0'); - - if (ProductComment::isAlreadyReport(Tools::getValue('id_product_comment'), $this->context->cookie->id_customer)) - die('0'); - - if (ProductComment::reportComment((int)Tools::getValue('id_product_comment'), $this->context->cookie->id_customer)) - die('1'); - - die('0'); - } - - protected function ajaxProcessCommentIsUsefull() - { - if (!Tools::isSubmit('id_product_comment') || !Tools::isSubmit('value')) - die('0'); - - if (ProductComment::isAlreadyUsefulness(Tools::getValue('id_product_comment'), $this->context->cookie->id_customer)) - die('0'); - - if (ProductComment::setCommentUsefulness((int)Tools::getValue('id_product_comment'), (bool)Tools::getValue('value'), $this->context->cookie->id_customer)) - die('1'); - - die('0'); - } -} diff --git a/modules/productcomments/controllers/front/index.php b/modules/productcomments/controllers/front/index.php deleted file mode 100644 index 3f6561f72..000000000 --- a/modules/productcomments/controllers/front/index.php +++ /dev/null @@ -1,35 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); - -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); - -header("Location: ../"); -exit; \ No newline at end of file diff --git a/modules/productcomments/controllers/index.php b/modules/productcomments/controllers/index.php deleted file mode 100644 index 3f6561f72..000000000 --- a/modules/productcomments/controllers/index.php +++ /dev/null @@ -1,35 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); - -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); - -header("Location: ../"); -exit; \ No newline at end of file diff --git a/modules/productcomments/img/accept.png b/modules/productcomments/img/accept.png deleted file mode 100644 index 89c8129a4..000000000 Binary files a/modules/productcomments/img/accept.png and /dev/null differ diff --git a/modules/productcomments/img/bg_bt.gif b/modules/productcomments/img/bg_bt.gif deleted file mode 100644 index 202d52afb..000000000 Binary files a/modules/productcomments/img/bg_bt.gif and /dev/null differ diff --git a/modules/productcomments/img/bg_li.png b/modules/productcomments/img/bg_li.png deleted file mode 100644 index c970f18ef..000000000 Binary files a/modules/productcomments/img/bg_li.png and /dev/null differ diff --git a/modules/productcomments/img/comment.png b/modules/productcomments/img/comment.png deleted file mode 100644 index 7bc9233ea..000000000 Binary files a/modules/productcomments/img/comment.png and /dev/null differ diff --git a/modules/productcomments/img/comments_delete.png b/modules/productcomments/img/comments_delete.png deleted file mode 100644 index 6df7376d0..000000000 Binary files a/modules/productcomments/img/comments_delete.png and /dev/null differ diff --git a/modules/productcomments/img/delete.gif b/modules/productcomments/img/delete.gif deleted file mode 100644 index 43c6ca876..000000000 Binary files a/modules/productcomments/img/delete.gif and /dev/null differ diff --git a/modules/productcomments/img/delete.png b/modules/productcomments/img/delete.png deleted file mode 100644 index 08f249365..000000000 Binary files a/modules/productcomments/img/delete.png and /dev/null differ diff --git a/modules/productcomments/img/index.php b/modules/productcomments/img/index.php deleted file mode 100644 index 3f6561f72..000000000 --- a/modules/productcomments/img/index.php +++ /dev/null @@ -1,35 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); - -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); - -header("Location: ../"); -exit; \ No newline at end of file diff --git a/modules/productcomments/img/note.png b/modules/productcomments/img/note.png deleted file mode 100644 index 244e6ca04..000000000 Binary files a/modules/productcomments/img/note.png and /dev/null differ diff --git a/modules/productcomments/img/note_go.png b/modules/productcomments/img/note_go.png deleted file mode 100644 index 49e54fd87..000000000 Binary files a/modules/productcomments/img/note_go.png and /dev/null differ diff --git a/modules/productcomments/img/star.gif b/modules/productcomments/img/star.gif deleted file mode 100644 index 6d647b432..000000000 Binary files a/modules/productcomments/img/star.gif and /dev/null differ diff --git a/modules/productcomments/index.php b/modules/productcomments/index.php deleted file mode 100644 index 3f6561f72..000000000 --- a/modules/productcomments/index.php +++ /dev/null @@ -1,35 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); - -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); - -header("Location: ../"); -exit; \ No newline at end of file diff --git a/modules/productcomments/install.sql b/modules/productcomments/install.sql deleted file mode 100644 index 4bb238973..000000000 --- a/modules/productcomments/install.sql +++ /dev/null @@ -1,75 +0,0 @@ -CREATE TABLE IF NOT EXISTS `PREFIX_product_comment` ( - `id_product_comment` int(10) unsigned NOT NULL auto_increment, - `id_product` int(10) unsigned NOT NULL, - `id_customer` int(10) unsigned NOT NULL, - `id_guest` int(10) unsigned NULL, - `title` varchar(64) NULL, - `content` text NOT NULL, - `customer_name` varchar(64) NULL, - `grade` float unsigned NOT NULL, - `validate` tinyint(1) NOT NULL, - `deleted` tinyint(1) NOT NULL, - `date_add` datetime NOT NULL, - PRIMARY KEY (`id_product_comment`), - KEY `id_product` (`id_product`), - KEY `id_customer` (`id_customer`), - KEY `id_guest` (`id_guest`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8; - -CREATE TABLE IF NOT EXISTS `PREFIX_product_comment_criterion` ( - `id_product_comment_criterion` int(10) unsigned NOT NULL auto_increment, - `id_product_comment_criterion_type` tinyint(1) NOT NULL, - `active` tinyint(1) NOT NULL, - PRIMARY KEY (`id_product_comment_criterion`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8; - -CREATE TABLE IF NOT EXISTS `PREFIX_product_comment_criterion_product` ( - `id_product` int(10) unsigned NOT NULL, - `id_product_comment_criterion` int(10) unsigned NOT NULL, - PRIMARY KEY(`id_product`, `id_product_comment_criterion`), - KEY `id_product_comment_criterion` (`id_product_comment_criterion`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8; - -CREATE TABLE IF NOT EXISTS `PREFIX_product_comment_criterion_lang` ( -`id_product_comment_criterion` INT(11) UNSIGNED NOT NULL , -`id_lang` INT(11) UNSIGNED NOT NULL , -`name` VARCHAR(64) NOT NULL , -PRIMARY KEY ( `id_product_comment_criterion` , `id_lang` ) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8; - -CREATE TABLE IF NOT EXISTS `PREFIX_product_comment_criterion_category` ( - `id_product_comment_criterion` int(10) unsigned NOT NULL, - `id_category` int(10) unsigned NOT NULL, - PRIMARY KEY(`id_product_comment_criterion`, `id_category`), - KEY `id_category` (`id_category`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8; - -CREATE TABLE IF NOT EXISTS `PREFIX_product_comment_grade` ( - `id_product_comment` int(10) unsigned NOT NULL, - `id_product_comment_criterion` int(10) unsigned NOT NULL, - `grade` int(10) unsigned NOT NULL, - PRIMARY KEY (`id_product_comment`, `id_product_comment_criterion`), - KEY `id_product_comment_criterion` (`id_product_comment_criterion`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8; - -CREATE TABLE IF NOT EXISTS `PREFIX_product_comment_usefulness` ( - `id_product_comment` int(10) unsigned NOT NULL, - `id_customer` int(10) unsigned NOT NULL, - `usefulness` tinyint(1) unsigned NOT NULL, - PRIMARY KEY (`id_product_comment`, `id_customer`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8; - -CREATE TABLE IF NOT EXISTS `PREFIX_product_comment_report` ( - `id_product_comment` int(10) unsigned NOT NULL, - `id_customer` int(10) unsigned NOT NULL, - PRIMARY KEY (`id_product_comment`, `id_customer`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8; - -INSERT INTO `PREFIX_product_comment_criterion` VALUES ('1', '1', '1'); - -INSERT INTO `PREFIX_product_comment_criterion_lang` (`id_product_comment_criterion`, `id_lang`, `name`) - ( - SELECT '1', l.`id_lang`, 'Quality' - FROM `PREFIX_lang` l - ); - diff --git a/modules/productcomments/js/index.php b/modules/productcomments/js/index.php deleted file mode 100644 index 3f6561f72..000000000 --- a/modules/productcomments/js/index.php +++ /dev/null @@ -1,35 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); - -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); - -header("Location: ../"); -exit; \ No newline at end of file diff --git a/modules/productcomments/js/jquery.rating.pack.js b/modules/productcomments/js/jquery.rating.pack.js deleted file mode 100644 index 488c28bd8..000000000 --- a/modules/productcomments/js/jquery.rating.pack.js +++ /dev/null @@ -1,12 +0,0 @@ -/* - ### jQuery Star Rating Plugin v2.0 - 2008-03-12 ### - By Diego A, http://www.fyneworks.com, diego@fyneworks.com - - v2 by Keith Wood, kbwood@virginbroadband.com.au - - Project: http://plugins.jquery.com/project/MultipleFriendlyStarRating - Website: http://www.fyneworks.com/jquery/star-rating/ - - This is a modified version of the star rating plugin from: - http://www.phpletter.com/Demo/Jquery-Star-Rating-Plugin/ -*/ -eval(function(p,a,c,k,e,r){e=function(c){return(c35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}(';4(w)(3($){$.Y.T=3(c){c=$.15({m:\'X U\',E:\'\',B:z,8:z},c||{});o d={};o e={t:3(n,a,b){2.6(n);$(a).D(\'.j\').A().l(b||\'x\')},6:3(n){$(d[n].7).O(\'.j\').u(\'9\').u(\'x\')},h:3(n){4(!$(d[n].5).Z(\'.m\')){$(d[n].5).D(\'.j\').A().l(\'9\')}},g:3(n,a){d[n].5=a;o b=$(a).L(\'a\').K();$(d[n].7).J(b);e.6(n);e.h(n);4(c.I)c.I.W(d[n].7,[b,a])}};2.V(3(i){o n=2.G;4(!d[n])d[n]={r:0};i=d[n].r;d[n].r++;4(i==0){c.8=$(2).S(\'p\')||c.8;d[n].7=$(\'\');$(2).C(d[n].7);4(c.8||c.B){}F{$(2).C($(\'\'+c.E+\'\').H(3(){e.6(n);$(2).l(\'9\')}).v(3(){e.h(n);$(2).u(\'9\')}).g(3(){e.g(n,2)}))}};f=$(\'\'+2.q+\'\');$(2).N(f);4(c.8){$(f).l(\'M\')}F{$(f).H(3(){e.6(n);e.t(n,2)}).v(3(){e.6(n);e.h(n)}).g(3(){e.g(n,2)})};4(2.14)d[n].5=f;$(2).13();4(i+1==2.12)e.h(n)});11(n 10 d)4(d[n].5){e.t(n,d[n].5,\'9\');$(d[n].7).J($(d[n].5).L(\'a\').K())}16 2}})(w);',62,69,'||this|function|if|currentElem|drain|valueElem|readOnly|star_on||||||eStar|click|reset||star|div|addClass|cancel||var|disabled|value|count|title|fill|removeClass|mouseout|jQuery|star_hover|class|false|andSelf|required|before|prevAll|cancelValue|else|name|mouseover|callback|val|text|children|star_readonly|after|siblings|hidden|type|input|attr|rating|Rating|each|apply|Cancel|fn|is|in|for|length|remove|checked|extend|return'.split('|'),0,{})) \ No newline at end of file diff --git a/modules/productcomments/js/jquery.textareaCounter.plugin.js b/modules/productcomments/js/jquery.textareaCounter.plugin.js deleted file mode 100644 index 03ca3eb44..000000000 --- a/modules/productcomments/js/jquery.textareaCounter.plugin.js +++ /dev/null @@ -1,163 +0,0 @@ -/* - * jQuery Textarea Characters Counter Plugin v 2.0 - * Examples and documentation at: http://roy-jin.appspot.com/jsp/textareaCounter.jsp - * Copyright (c) 2010 Roy Jin - * Version: 2.0 (11-JUN-2010) - * Dual licensed under the MIT and GPL licenses: - * http://www.opensource.org/licenses/mit-license.php - * http://www.gnu.org/licenses/gpl.html - * Requires: jQuery v1.4.2 or later - */ -(function($){ - $.fn.textareaCount = function(options, fn) { - var defaults = { - maxCharacterSize: -1, - originalStyle: 'originalTextareaInfo', - warningStyle: 'warningTextareaInfo', - warningNumber: 20, - displayFormat: '#input characters | #words words' - }; - var options = $.extend(defaults, options); - - var container = $(this); - - $("
     
    ").insertAfter(container); - - //create charleft css - var charLeftCss = { - 'width' : container.width() - }; - - var charLeftInfo = getNextCharLeftInformation(container); - charLeftInfo.addClass(options.originalStyle); - charLeftInfo.css(charLeftCss); - - var numInput = 0; - var maxCharacters = options.maxCharacterSize; - var numLeft = 0; - var numWords = 0; - - container.bind('keyup', function(event){limitTextAreaByCharacterCount();}) - .bind('mouseover', function(event){setTimeout(function(){limitTextAreaByCharacterCount();}, 10);}) - .bind('paste', function(event){setTimeout(function(){limitTextAreaByCharacterCount();}, 10);}); - - - function limitTextAreaByCharacterCount(){ - charLeftInfo.html(countByCharacters()); - //function call back - if(typeof fn != 'undefined'){ - fn.call(this, getInfo()); - } - return true; - } - - function countByCharacters(){ - var content = container.val(); - var contentLength = content.length; - - //Start Cut - if(options.maxCharacterSize > 0){ - //If copied content is already more than maxCharacterSize, chop it to maxCharacterSize. - if(contentLength >= options.maxCharacterSize) { - content = content.substring(0, options.maxCharacterSize); - } - - var newlineCount = getNewlineCount(content); - - // newlineCount new line character. For windows, it occupies 2 characters - var systemmaxCharacterSize = options.maxCharacterSize - newlineCount; - if (!isWin()){ - systemmaxCharacterSize = options.maxCharacterSize - } - if(contentLength > systemmaxCharacterSize){ - //avoid scroll bar moving - var originalScrollTopPosition = this.scrollTop; - container.val(content.substring(0, systemmaxCharacterSize)); - this.scrollTop = originalScrollTopPosition; - } - charLeftInfo.removeClass(options.warningStyle); - if(systemmaxCharacterSize - contentLength <= options.warningNumber){ - charLeftInfo.addClass(options.warningStyle); - } - - numInput = container.val().length + newlineCount; - if(!isWin()){ - numInput = container.val().length; - } - - numWords = countWord(getCleanedWordString(container.val())); - - numLeft = maxCharacters - numInput; - } else { - //normal count, no cut - var newlineCount = getNewlineCount(content); - numInput = container.val().length + newlineCount; - if(!isWin()){ - numInput = container.val().length; - } - numWords = countWord(getCleanedWordString(container.val())); - } - - return formatDisplayInfo(); - } - - function formatDisplayInfo(){ - var format = options.displayFormat; - format = format.replace('#input', numInput); - format = format.replace('#words', numWords); - //When maxCharacters <= 0, #max, #left cannot be substituted. - if(maxCharacters > 0){ - format = format.replace('#max', maxCharacters); - format = format.replace('#left', numLeft); - } - return format; - } - - function getInfo(){ - var info = { - input: numInput, - max: maxCharacters, - left: numLeft, - words: numWords - }; - return info; - } - - function getNextCharLeftInformation(container){ - return container.next('.charleft'); - } - - function isWin(){ - var strOS = navigator.appVersion; - if (strOS.toLowerCase().indexOf('win') != -1){ - return true; - } - return false; - } - - function getNewlineCount(content){ - var newlineCount = 0; - for(var i=0; i -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -function getCommentForm() -{ - if (document.forms) - return (document.forms['comment_form']); - else - return (document.comment_form); -} - -function getCommentDeleteForm() -{ - if (document.forms) - return (document.forms['delete_comment_form']); - else - return (document.delete_comment_form); -} - -function acceptComment(id) -{ - var form = getCommentForm(); - if (id) - form.elements['id_product_comment'].value = id; - form.elements['action'].value = 'accept'; - form.submit(); -} - - -function deleteComment(id) -{ - var form = getCommentForm(); - if (id) - form.elements['id_product_comment'].value = id; - form.elements['action'].value = 'delete'; - form.submit(); -} - -function delComment(id, confirmation) -{ - var answer = confirm(confirmation); - if (answer) - { - var form = getCommentDeleteForm(); - if (id) - form.elements['delete_id_product_comment'].value = id; - form.elements['delete_action'].value = 'delete'; - form.submit(); - } -} - -function getCriterionForm() -{ - if (document.forms) - return (document.forms['criterion_form']); - else - return (document.criterion_form); -} - -function editCriterion(id) -{ - var form = getCriterionForm(); - form.elements['id_product_comment_criterion'].value = id; - form.elements['criterion_name'].value = document.getElementById('criterion_name_' + id).value; - form.elements['criterion_action'].value = 'edit'; - form.submit(); -} - -function deleteCriterion(id) -{ - var form = getCriterionForm(); - form.elements['id_product_comment_criterion'].value = id; - form.elements['criterion_action'].value = 'delete'; - form.submit(); -} diff --git a/modules/productcomments/js/productCriterion.js b/modules/productcomments/js/productCriterion.js deleted file mode 100644 index a453a827a..000000000 --- a/modules/productcomments/js/productCriterion.js +++ /dev/null @@ -1,40 +0,0 @@ -/* -* 2007-2013 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 -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -function getProductCriterionForm() -{ - if (document.forms) - return (document.forms['product_criterion_form']); - else - return (document.product_criterion_form); -} - -function getProductCriterion(path, id_product, id_lang) -{ - $.get(path + 'productcommentscriterion.php', { id_product: id_product, id_lang: id_lang }, - function(data){ - document.getElementById('product_criterions').innerHTML = data; - }); -} diff --git a/modules/productcomments/js/productcomments.js b/modules/productcomments/js/productcomments.js deleted file mode 100644 index dec24c678..000000000 --- a/modules/productcomments/js/productcomments.js +++ /dev/null @@ -1,91 +0,0 @@ -$(function() { - $('input[@type=radio].star').rating(); - $('.auto-submit-star').rating(); - - $('.open-comment-form').fancybox({ - 'hideOnContentClick': false - }); - - $('button.usefulness_btn').click(function() { - var id_product_comment = $(this).data('id-product-comment'); - var is_usefull = $(this).data('is-usefull'); - var parent = $(this).parent(); - - $.ajax({ - url: productcomments_controller_url + '?rand=' + new Date().getTime(), - data: { - id_product_comment: id_product_comment, - action: 'comment_is_usefull', - value: is_usefull - }, - type: 'POST', - headers: { "cache-control": "no-cache" }, - success: function(result){ - parent.fadeOut('slow', function() { - parent.remove(); - }); - } - }); - }); - - $('span.report_btn').click(function() { - if (confirm(confirm_report_message)) - { - var idProductComment = $(this).data('id-product-comment'); - var parent = $(this).parent(); - - $.ajax({ - url: productcomments_controller_url + '?rand=' + new Date().getTime(), - data: { - id_product_comment: idProductComment, - action: 'report_abuse' - }, - type: 'POST', - headers: { "cache-control": "no-cache" }, - success: function(result){ - parent.fadeOut('slow', function() { - parent.remove(); - }); - } - }); - } - }); - - $('#submitNewMessage').click(function(e) { - // Kill default behaviour - e.preventDefault(); - - // Form element - - url_options = parseInt(productcomments_url_rewrite) ? '?' : '&'; - $.ajax({ - url: productcomments_controller_url + url_options + 'action=add_comment&secure_key=' + secure_key + '&rand=' + new Date().getTime(), - data: $('#id_new_comment_form').serialize(), - type: 'POST', - headers: { "cache-control": "no-cache" }, - dataType: "json", - success: function(data){ - if (data.result) - { - $.fancybox.close(); - var buttons = {}; - buttons[productcomment_ok] = "productcommentRefreshPage"; - fancyChooseBox(moderation_active ? productcomment_added_moderation : productcomment_added, productcomment_title, buttons); - } - else - { - $('#new_comment_form_error ul').html(''); - $.each(data.errors, function(index, value) { - $('#new_comment_form_error ul').append('
  • '+value+'
  • '); - }); - $('#new_comment_form_error').slideDown('slow'); - } - } - }); - return false; - }); -}); - -function productcommentRefreshPage() { - window.location.reload(); -} \ No newline at end of file diff --git a/modules/productcomments/js/products-comparison.js b/modules/productcomments/js/products-comparison.js deleted file mode 100755 index 65d201832..000000000 --- a/modules/productcomments/js/products-comparison.js +++ /dev/null @@ -1,45 +0,0 @@ -/* -* 2007-2013 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 -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -$(function () { - $('a.cluetip') - .cluetip({ - local:true, - cursor: 'pointer', - cluetipClass: 'comparison_comments', - dropShadow: false, - dropShadowSteps: 0, - showTitle: false, - tracking: true, - sticky: false, - mouseOutClose: true, - width: 450, - fx: { - open: 'fadeIn', - openSpeed: 'fast' - } - }) - .css('opacity', 0.8); -}); diff --git a/modules/productcomments/logo.gif b/modules/productcomments/logo.gif deleted file mode 100644 index 39433cf78..000000000 Binary files a/modules/productcomments/logo.gif and /dev/null differ diff --git a/modules/productcomments/logo.png b/modules/productcomments/logo.png deleted file mode 100755 index 61ae64b2d..000000000 Binary files a/modules/productcomments/logo.png and /dev/null differ diff --git a/modules/productcomments/productcomments-ajax.php b/modules/productcomments/productcomments-ajax.php deleted file mode 100644 index 59ef1ac45..000000000 --- a/modules/productcomments/productcomments-ajax.php +++ /dev/null @@ -1,138 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -// The usage of this file is deprecated !!! -require_once(dirname(__FILE__).'/../../config/config.inc.php'); -require_once(dirname(__FILE__).'/../../init.php'); -require_once(dirname(__FILE__).'/ProductCommentCriterion.php'); -include_once(dirname(__FILE__).'/ProductComment.php'); -include_once(dirname(__FILE__).'/productcomments.php'); - -$productCom = new productcomments(); - -if (Tools::getValue('action') && Tools::getValue('id_product_comment') && Context::getContext()->cookie->id_customer) -{ - if (Tools::getValue('action') == 'report') - { - if (!ProductComment::isAlreadyReport(Tools::getValue('id_product_comment'), Context::getContext()->cookie->id_customer) && - ProductComment::reportComment((int)Tools::getValue('id_product_comment'), (int)Context::getContext()->cookie->id_customer)) - die('0'); - } - else if (Tools::getValue('action') == 'usefulness' && Tools::getValue('value') && Tools::getValue('value')) - { - if (!ProductComment::isAlreadyUsefulness(Tools::getValue('id_product_comment'), Context::getContext()->cookie->id_customer) && - ProductComment::setCommentUsefulness((int)Tools::getValue('id_product_comment'), - (bool)Tools::getValue('value'), - Context::getContext()->cookie->id_customer)) - die('0'); - } -} -else if (Tools::getValue('action') && Tools::getValue('secure_key') == $productCom->secure_key) -{ - $review = Tools::jsonDecode(Tools::getValue('review')); - $id_product = 0; - $content = null; - $title = null; - $name = null; - $grades = array(); - foreach ($review as $entry) - { - if ($entry->key == 'id_product') - $id_product = $entry->value; - else if ($entry->key == 'title') - $title = $entry->value; - else if ($entry->key == 'content') - $content = $entry->value; - else if ($entry->key == 'customer_name') - $name = $entry->value; - else if (strstr($entry->key, 'grade')) - { - $id = array(explode('_', $entry->key)); - $grades[] = array('id' => $id['0']['0'], 'grade' => $entry->value); - } - } - - if ($title == '' || $content == '' || !$id_product || count($grades) == 0) - die('0'); - - $allow_guests = (int)Configuration::get('PRODUCT_COMMENTS_ALLOW_GUESTS'); - - if (Context::getContext()->customer->id || (!Context::getContext()->customer->id && $allow_guests)) - { - $id_guest = (!$id_customer = (int)Context::getContext()->cookie->id_customer) ? (int)Context::getContext()->cookie->id_guest : false; - $customerComment = ProductComment::getByCustomer((int)($id_product), Context::getContext()->cookie->id_customer, true, (int)$id_guest); - - if (!$customerComment || ($customerComment && (strtotime($customerComment['date_add']) + Configuration::get('PRODUCT_COMMENTS_MINIMAL_TIME')) < time())) - { - $errors = array(); - $customer_name = false; - if ($id_guest && (!$customer_name = Context::getContext()->customer->firstname.' '.Context::getContext()->customer->lastname)) - $errors[] = $productCom->l('Please fill your name'); - - if (!count($errors) && $content) - { - $comment = new ProductComment(); - $comment->content = strip_tags($content); - $comment->id_product = (int)$id_product; - $comment->id_customer = (int)Context::getContext()->cookie->id_customer; - $comment->id_guest = (int)$id_guest; - $comment->customer_name = pSQL($customer_name); - if (!$comment->id_customer) - $comment->customer_name = pSQL($name); - $comment->title = pSQL($title); - $comment->grade = 0; - $comment->validate = 0; - - - $tgrade = 0; - $comment->save(); - foreach ($grades as $grade) - { - $tgrade += $grade['grade']; - $productCommentCriterion = new ProductCommentCriterion((int)Tools::getValue('id_product_comment_criterion_'.$grade['id'])); - if ($productCommentCriterion->id) - $productCommentCriterion->addGrade($comment->id, $grade['grade']); - } - - if ((count($grades) - 1) >= 0) - $comment->grade = (int)($tgrade / ((int)count($grades))); - - if (!$comment->save()) - $errors[] = $productCom->l('An error occurred while saving your comment.'); - else - Context::getContext()->smarty->assign('confirmation', $productCom->l('Comment posted.').((int)(Configuration::get('PRODUCT_COMMENTS_MODERATE')) ? ' '.$productCom->l('Awaiting moderator validation.') : '')); - - } - else - $errors[] = $productCom->l('Comment text is required.'); - } - else - $errors[] = sprintf($productCom->l('You should wait %d seconds before posting a new comment.'), Configuration::get('PRODUCT_COMMENTS_MINIMAL_TIME')); - } -} - -die('1'); - diff --git a/modules/productcomments/productcomments-extra.tpl b/modules/productcomments/productcomments-extra.tpl deleted file mode 100644 index d9547f8bf..000000000 --- a/modules/productcomments/productcomments-extra.tpl +++ /dev/null @@ -1,67 +0,0 @@ - {* -* 2007-2013 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 -* @copyright 2007-2013 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 -*} - - -{if $logged == 1 || $nbComments != 0} -
    -
    - {if $nbComments != 0} -
    - {l s='Average grade' mod='productcomments'}  -
    - {section name="i" start=0 loop=5 step=1} - {if $averageTotal le $smarty.section.i.index} -
    - {else} -
    - {/if} - {/section} -
    -
    - {/if} - -
    - {if $nbComments != 0} - {l s='Read user reviews' mod='productcomments'} ({$nbComments})
    - {/if} - {if ($too_early == false AND ($logged OR $allow_guests))} - {l s='Write your review' mod='productcomments'} - {/if} -
    -
    -
    -{/if} - diff --git a/modules/productcomments/productcomments.css b/modules/productcomments/productcomments.css deleted file mode 100644 index 51dca697b..000000000 --- a/modules/productcomments/productcomments.css +++ /dev/null @@ -1,224 +0,0 @@ -#product_comments_block_extra { - padding:10px 0 0 0; - border-top:1px solid #ccc; - font-weight: bold; - font-size:12px; - line-height:18px -} - -#product_comments_block_extra a { - padding-left: 10px; - text-decoration: none; - background: url(img/bg_li.png) no-repeat scroll 1px 45% #fff; - -} - -#product_comments_block_extra a:hover {text-decoration: underline} - -#product_comments_block_extra .comments_note {margin-bottom:5px} -#product_comments_block_extra .comments_note span, -#product_comments_block_extra .star_content {float:left} -#product_comments_block_extra .star_content {margin-top:2px} - -#product_comments_block_extra div.star {background: url(img/star.gif) no-repeat scroll 0 0 transparent} - -#product_comments_block_extra div.star_on {background: url(img/star.gif) no-repeat scroll 0 -12px transparent} - -#product_comments_block_extra .comments_advices {clear:both;} - -/* pop-in add grade/advice ********************************************************************* */ -#fancybox-wrap { width:585px } -#fancybox-content { - width:585px; - border-width:0 -} - -#new_comment_form { - width:585px; - color: #333; - text-align: left; - background-color: #fff -} -#new_comment_form .title { - padding:10px; - font-size: 13px; - color: #fff; - text-transform: uppercase; - background: #333 -} -#new_comment_form ul.grade_content {list-style-type:none} -#new_comment_form .grade_content li {width:50%} -#new_comment_form .product {padding:15px} -#new_comment_form .product img { - float:left; - border: 1px solid #ccc; -} -#new_comment_form .product .product_desc { - float:left; - margin-left:15px; - width:300px; - line-height:18px; - color:#666 -} -#new_comment_form .product .product_desc .product_name { - padding-bottom:5px; - font-size:13px; - color:#000 -} - -#new_comment_form .grade_content {margin:0 0 20px 0} -#new_comment_form .grade_content span, -#new_comment_form .grade_content span { - display:inline-block; - padding:0 10px; - width:150px;/* 160 */ - font-weight:bold -} -#new_comment_form .grade_content .cancel {margin-right:5px} - -.new_comment_form_content { - padding:15px; - background:#f8f8f8 -} -.new_comment_form_content .intro_form { - padding-bottom: 10px; - font-weight: bold; - font-size: 12px -} - -#new_comment_form label { - display: block; - margin:12px 0 4px 0; - font-weight: bold; - font-size: 12px; -} -#new_comment_form input { - padding: 0 5px; - height: 28px; - width: 540px; - border: 1px solid #ccc; - background: #fff; -} -#new_comment_form textarea { - padding: 0 5px; - height: 80px; - width: 540px; - border: 1px solid #ccc; - background: #fff; -} - -#new_comment_form .submit { - margin-top:20px; - padding:0; - font-size:13px; - text-align:right -} -#new_comment_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 -} - -#new_comment_form #criterions_list { - border-bottom: 1px solid #CCC; - padding-bottom: 15px; - list-style-type: none; -} - -#new_comment_form #criterions_list li { - margin-bottom: 10px; -} - -#new_comment_form #criterions_list label { - display: inline; - float: left; - margin: 0 0 0 60px; -} - -#new_comment_form #criterions_list .star_content { - float: right; - margin-right: 180px; -} - -#new_comment_form #new_comment_form_footer { - margin-top: 20px; - font-size: 12px; -} - -/* TAB COMMENTS ******************************************************************************** */ -#product_comments_block_tab {margin:0 0 20px 0} - -#product_comments_block_tab div.comment { - margin:0 0 10px 0; - padding: 5px; - border-bottom: 1px dotted #ccc -} - -#product_comments_block_tab div.comment div.comment_author { - float: left; - padding-right:25px; - width: 140px;/* 165 */ - line-height:18px -} -#product_comments_block_tab div.comment div.comment_author span {font-weight:bold;} -#product_comments_block_tab div.comment div.comment_author span, -#product_comments_block_tab div.comment .star_content { - float:left; -} -#product_comments_block_tab div.comment .star_content {margin: 0 0 0 5px} -#product_comments_block_tab div.star, -#product_comments_block_tab div.star_on { - background: url(img/star.gif) no-repeat 0 0 transparent -} -#product_comments_block_tab div.star_on {background-position: 0 -12px} -#product_comments_block_tab .comment_author_infos {clear:both} -#product_comments_block_tab .comment_author_infos em {color:#999} - -#product_comments_block_tab div.comment div.comment_details { - float: left; - overflow:hidden; - width: 360px -} -#product_comments_block_tab div.comment_details .title_block, #product_comments_block_tab div.comment_details h4 {padding-bottom:10px} -#product_comments_block_tab div.comment_details p {padding-bottom:10px} -#product_comments_block_tab div.comment_details ul { - list-style-type:none; - margin:0 -} -#product_comments_block_tab div.comment_details li { - padding:2px 0 2px 12px; - background:url(img/bg_li.png) no-repeat 1px 45% #fff -} - -#product_comments_block_tab a { - text-decoration: none; - font-weight: bold -} - -#product_comments_block_tab a:hover {text-decoration: underline} - -#product_comments_block_tab button.usefulness_btn { - cursor: pointer; - margin:0 0 0 5px; - display: inline-block; - padding: 0 2px; - border: 1px solid #CC9900; - border-radius: 3px 3px 3px 3px; - color: #000; - font-weight: bold; - background: url("img/bg_bt.gif") repeat-x scroll 0 0 #F4B61B -} -#product_comments_block_tab button.usefulness_btn:hover {background-position: left -50px} -#product_comments_block_tab button.usefulness_btn:active {background-position: left -100px} - -#product_comments_block_tab span.report_btn {cursor: pointer} -#product_comments_block_tab span.report_btn:hover {text-decoration:underline} - -.fl { float: left; } -.fr { float: right; } diff --git a/modules/productcomments/productcomments.php b/modules/productcomments/productcomments.php deleted file mode 100644 index c85d40741..000000000 --- a/modules/productcomments/productcomments.php +++ /dev/null @@ -1,842 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -if (!defined('_PS_VERSION_')) - exit; - -class ProductComments extends Module -{ - const INSTALL_SQL_FILE = 'install.sql'; - - private $_html = ''; - private $_postErrors = array(); - - private $_productCommentsCriterionTypes = array(); - private $_baseUrl; - - public function __construct() - { - $this->name = 'productcomments'; - $this->tab = 'front_office_features'; - $this->version = '2.4'; - $this->author = 'PrestaShop'; - $this->need_instance = 0; - $this->secure_key = Tools::encrypt($this->name); - - parent::__construct(); - - $this->displayName = $this->l('Product Comments'); - $this->description = $this->l('Allows users to post reviews.'); - } - - public function install() - { - if (!file_exists(dirname(__FILE__).'/'.self::INSTALL_SQL_FILE)) - return false; - else if (!$sql = file_get_contents(dirname(__FILE__).'/'.self::INSTALL_SQL_FILE)) - return false; - $sql = str_replace(array('PREFIX_', 'ENGINE_TYPE'), array(_DB_PREFIX_, _MYSQL_ENGINE_), $sql); - $sql = preg_split("/;\s*[\r\n]+/", trim($sql)); - - foreach ($sql as $query) - if (!Db::getInstance()->execute(trim($query))) - return false; - if (parent::install() == false || - !$this->registerHook('productTab') || - !$this->registerHook('extraProductComparison') || - !$this->registerHook('productTabContent') || - !$this->registerHook('header') || - !$this->registerHook('productOutOfStock') || - !$this->registerHook('displayProductListReviews') || - !$this->registerHook('top') || - !Configuration::updateValue('PRODUCT_COMMENTS_MINIMAL_TIME', 30) || - !Configuration::updateValue('PRODUCT_COMMENTS_ALLOW_GUESTS', 0) || - !Configuration::updateValue('PRODUCT_COMMENTS_MODERATE', 1)) - return false; - return true; - } - - public function uninstall() - { - if (!parent::uninstall() || !$this->deleteTables() || - !Configuration::deleteByName('PRODUCT_COMMENTS_MODERATE') || - !Configuration::deleteByName('PRODUCT_COMMENTS_ALLOW_GUESTS') || - !Configuration::deleteByName('PRODUCT_COMMENTS_MINIMAL_TIME') || - !$this->unregisterHook('extraProductComparison') || - !$this->unregisterHook('productOutOfStock') || - !$this->unregisterHook('productTabContent') || - !$this->unregisterHook('header') || - !$this->unregisterHook('productTab') || - !$this->unregisterHook('top') || - !$this->unregisterHook('displayProductListReviews')) - return false; - return true; - } - - public function deleteTables() - { - return Db::getInstance()->execute(' - DROP TABLE IF EXISTS - `'._DB_PREFIX_.'product_comment`, - `'._DB_PREFIX_.'product_comment_criterion`, - `'._DB_PREFIX_.'product_comment_criterion_product`, - `'._DB_PREFIX_.'product_comment_criterion_lang`, - `'._DB_PREFIX_.'product_comment_criterion_category`, - `'._DB_PREFIX_.'product_comment_grade`, - `'._DB_PREFIX_.'product_comment_usefulness`, - `'._DB_PREFIX_.'product_comment_report`'); - } - - protected function _postProcess() - { - if (Tools::isSubmit('submitModerate')) - { - Configuration::updateValue('PRODUCT_COMMENTS_MODERATE', (int)Tools::getValue('moderate')); - Configuration::updateValue('PRODUCT_COMMENTS_ALLOW_GUESTS', (int)Tools::getValue('allow_guest')); - Configuration::updateValue('PRODUCT_COMMENTS_MINIMAL_TIME', (int)Tools::getValue('product_comments_minimal_time')); - $this->_html .= '
    '.$this->l('Settings updated').'
    '; - } - if ($id_criterion = (int)Tools::getValue('deleteCriterion')) - { - $productCommentCriterion = new ProductCommentCriterion((int)$id_criterion); - if ($productCommentCriterion->id) - if ($productCommentCriterion->delete()) - $this->_html .= '
    '.$this->l('Criterion deleted').'
    '; - } - } - - public function getContent() - { - include_once(dirname(__FILE__).'/ProductCommentCriterion.php'); - - $this->_setBaseUrl(); - $this->_productCommentsCriterionTypes = ProductCommentCriterion::getTypes(); - $this->_html = '

    '.$this->displayName.'

    '; - $this->_postProcess(); - $this->_checkModerateComment(); - $this->_checkReportedComment(); - $this->_checkCriterion(); - $this->_updateApplicationCriterion(); - $this->_checkDeleteComment(); - - return $this->_html.$this->_displayForm(); - } - - private function _setBaseUrl() - { - $this->_baseUrl = 'index.php?'; - foreach ($_GET as $k => $value) - if (!in_array($k, array('deleteCriterion', 'editCriterion'))) - $this->_baseUrl .= $k.'='.$value.'&'; - $this->_baseUrl = rtrim($this->_baseUrl, '&'); - } - - private function _checkModerateComment() - { - $action = Tools::getValue('action'); - if (empty($action) === false && (int)Configuration::get('PRODUCT_COMMENTS_MODERATE')) - { - $product_comments = Tools::getValue('id_product_comment'); - - if (count($product_comments)) - { - require_once(dirname(__FILE__).'/ProductComment.php'); - switch ($action) - { - case 'accept': - foreach ($product_comments as $id_product_comment) - { - if (!$id_product_comment) - continue; - $comment = new ProductComment((int)$id_product_comment); - $comment->validate(); - } - break; - - case 'delete': - foreach ($product_comments as $id_product_comment) - { - if (!$id_product_comment) - continue; - $comment = new ProductComment((int)$id_product_comment); - $comment->delete(); - ProductComment::deleteGrades((int)$id_product_comment); - } - break; - - default: - ; - } - } - } - } - - private function _checkReportedComment() - { - $action = Tools::getValue('action'); - if (empty($action) === false) - { - $product_comments = Tools::getValue('id_product_comment'); - - if (count($product_comments)) - { - require_once(dirname(__FILE__).'/ProductComment.php'); - switch ($action) - { - case 'accept': - foreach ($product_comments as $id_product_comment) - { - if (!$id_product_comment) - continue; - $comment = new ProductComment((int)$id_product_comment); - $comment->validate(); - ProductComment::deleteReports((int)$id_product_comment); - } - break; - case 'delete': - foreach ($product_comments as $id_product_comment) - { - if (!$id_product_comment) - continue; - $comment = new ProductComment((int)$id_product_comment); - $comment->delete(); - ProductComment::deleteGrades((int)$id_product_comment); - ProductComment::deleteReports((int)$id_product_comment); - ProductComment::deleteUsefulness((int)$id_product_comment); - } - break; - default: - ; - } - } - } - } - - private function _checkCriterion() - { - $action_criterion = Tools::getValue('criterion_action'); - $name = Tools::getValue('criterion'); - if (Tools::isSubmit('submitAddCriterion')) - { - require_once(dirname(__FILE__).'/ProductCommentCriterion.php'); - $languages = Language::getLanguages(); - $id_criterion = (int)Tools::getValue('id_product_comment_criterion'); - $productCommentCriterion = new ProductCommentCriterion((int)$id_criterion); - foreach ($languages as $lang) - $productCommentCriterion->name[(int)$lang['id_lang']] = Tools::getValue('criterion_'.(int)$lang['id_lang']); - - // Check default language criterion name - $defaultLanguage = new Language((int)(Configuration::get('PS_LANG_DEFAULT'))); - if (!Tools::getValue('criterion_'.$defaultLanguage->id)) - { - $this->_html .= $this->displayError($this->l('The field Name is required at least in').' '.$defaultLanguage->name); - return; - } - - $productCommentCriterion->id_product_comment_criterion_type = (int)Tools::getValue('criterion_type'); - $productCommentCriterion->active = (int)Tools::getValue('criterion_active'); - - if ($productCommentCriterion->save()) - $this->_html .= $this->displayConfirmation((Tools::getValue('editCriterion') ? $this->l('Criterion updated') : $this->l('Criterion added'))); - } - else if (!empty($action_criterion) && empty($name)) - { - $id_product_comment_criterion = Tools::getValue('id_product_comment_criterion'); - require_once(dirname(__FILE__).'/ProductCommentCriterion.php'); - switch ($action_criterion) - { - case 'edit': - ProductCommentCriterion::update($id_product_comment_criterion, - Tools::getValue('criterion_id_lang'), - Tools::getValue('criterion_name')); - break; - case 'delete': - ProductCommentCriterion::delete($id_product_comment_criterion); - break; - default: - ; - } - } - } - - private function _updateApplicationCriterion() - { - if (Tools::isSubmit('submitApplicationCriterion')) - { - include_once(dirname(__FILE__).'/ProductCommentCriterion.php'); - - $id_criterion = (int)Tools::getValue('id_criterion'); - $productCommentCriterion = new ProductCommentCriterion((int)$id_criterion); - if ($productCommentCriterion->id) - { - if ($productCommentCriterion->id_product_comment_criterion_type == 2) - { - $productCommentCriterion->deleteCategories(); - if ($categories = Tools::getValue('id_product')) - if (count($categories)) - foreach ($categories as $id_category) - $productCommentCriterion->addCategory((int)$id_category); - } - else if ($productCommentCriterion->id_product_comment_criterion_type == 3) - { - $productCommentCriterion->deleteProducts(); - if ($products = Tools::getValue('id_product')) - if (count($products)) - foreach ($products as $product) - $productCommentCriterion->addProduct((int)$product); - } - } - - $this->_html .= '
    '.$this->l('Settings updated').'
    '; - } - } - - private function _displayForm() - { - $this->_displayFormModerate(); - $this->_displayFormReported(); - $this->_displayFormConfigurationCriterion(); - $this->_displayFormApplicationCriterion(); - $this->_displayFormDelete(); - - return $this->_html; - } - - private function _displayFormModerate() - { - $this->_html = ' -
    - '.$this->l('Configuration').' -
    - -
    - - - - -
    -
    - -
    - - - - -
    -
    - -
    - '.$this->l('seconds').' -
    -
    -
    - -
    -
    -
    -
    -
    - '.$this->l('Moderate Comments').''; - if (Configuration::get('PRODUCT_COMMENTS_MODERATE')) - { - require_once(dirname(__FILE__).'/ProductComment.php'); - $comments = ProductComment::getByValidate(); - if (count($comments)) - { - $this->_html .= ' -
    - - -
    - - - - - - - - - - '; - foreach ($comments as $comment) - $this->_html .= ' - - - - - - '; - $this->_html .= ' - - - - - -
    '.$this->l('Author').''.$this->l('Comment').''.$this->l('Product name').''.$this->l('Actions').'
    '.htmlspecialchars($comment['customer_name'], ENT_COMPAT, 'UTF-8').'.'.htmlspecialchars($comment['content'], ENT_COMPAT, 'UTF-8').''.$comment['id_product'].' - '.htmlspecialchars($comment['name'], ENT_COMPAT, 'UTF-8').''.$this->l('Accept').' - '.$this->l('Delete').'
    '.$this->l('Selection:').''.$this->l('Accept').' - '.$this->l('Delete').'
    -
    '; - } - else - $this->_html .= $this->l('No comments to validate at this time.'); - } - $this->_html .= '

    '; - } - - private function _displayFormReported() - { - $this->_html .= '
    - '.$this->l('Reported Comments').''; - - require_once(dirname(__FILE__).'/ProductComment.php'); - $comments = ProductComment::getReportedComments(); - if (count($comments)) - { - $this->_html .= ' -
    - - -
    - - - - - - - - - - '; - foreach ($comments as $comment) - $this->_html .= ' - - - - - - '; - $this->_html .= ' - - - - - -
    '.$this->l('Author').''.$this->l('Comment').''.$this->l('Product name').''.$this->l('Actions').'
    '.htmlspecialchars($comment['customer_name'], ENT_COMPAT, 'UTF-8').'.'.htmlspecialchars($comment['content'], ENT_COMPAT, 'UTF-8').''.$comment['id_product'].' - '.htmlspecialchars($comment['name'], ENT_COMPAT, 'UTF-8').''.$this->l('Accept').' - '.$this->l('Delete').'
    '.$this->l('Selection:').''.$this->l('Accept').' - '.$this->l('Delete').'
    -
    '; - } - else - $this->_html .= $this->l('No reported comments at this time.'); - $this->_html .= '

    '; - } - - private function _displayFormConfigurationCriterion() - { - $langs = Language::getLanguages(false); - $id_lang_default = (int)Configuration::get('PS_LANG_DEFAULT'); - - $id_criterion = (int)Tools::getValue('editCriterion'); - $criterion = new ProductCommentCriterion((int)$id_criterion); - $languageIds = 'criterion'; - $this->_html .= ' -
    - '.$this->l('Add a new comment criterion').' -

    '.$this->l('You can define several criterions to help your customers during their review. For instance: efficiency, lightness, design.').'
    -
    '.$this->l('You can add a new criterion below:').'

    -
    - -
    - '; - foreach ($langs as $lang) - $this->_html .= ' -
    - -
    '; - $this->_html .= $this->displayFlags($langs, (int)$id_lang_default, $languageIds, 'criterion', true); - $this->_html .= ' -
    -
     
    - -
    - -
    - -
    - active ? 'checked="checked" ' : '').'/> - - active ? 'checked="checked" ' : '').'/> - -
    -
    - -
    -
    '; - require_once(dirname(__FILE__).'/ProductCommentCriterion.php'); - $criterions = ProductCommentCriterion::getCriterions($this->context->language->id); - if (count($criterions)) - { - $this->_html .= '
    - - - - - - - - - - '; - - foreach ($criterions as $criterion) - { - $this->_html .= ' - - - - '; - } - $this->_html .= '
    '.$this->l('Criterion').''.$this->l('Type').''.$this->l('Status').''.$this->l('Actions').'
    '.$criterion['name'].''.$this->_productCommentsCriterionTypes[(int)$criterion['id_product_comment_criterion_type']].''.$this->l('Edit').' - '.$this->l('Delete').'
    '; - } - $this->_html .= '

    '; - } - - private function _displayFormApplicationCriterion() - { - include_once(dirname(__FILE__).'/ProductCommentCriterion.php'); - - $criterions = ProductCommentCriterion::getCriterions($this->context->language->id, false, true); - $id_criterion = (int)Tools::getValue('updateCriterion'); - - if ($id_criterion) - { - $criterion = new ProductCommentCriterion((int)$id_criterion); - if ($criterion->id_product_comment_criterion_type == 2) - { - $categories = Category::getSimpleCategories($this->context->language->id); - $criterion_categories = $criterion->getCategories(); - } - else if ($criterion->id_product_comment_criterion_type == 3) - { - $criterion_products = $criterion->getProducts(); - $products = Product::getSimpleProducts($this->context->language->id); - } - } - - foreach ($criterions as $key => $foo) - if ($foo['id_product_comment_criterion_type'] == 1) - unset($criterions[$key]); - - if (count($criterions)) - { - $this->_html .= ' -
    - '.$this->l('Manage criterions scope').' -

    '.$this->l('Only criterions restricted to categories or products can be configured below:').'

    -
    - -
    -"> - -
    -
    '; - - if ($id_criterion && $criterion->id_product_comment_criterion_type != 1) - { - $this->_html .=' -
    -
    - -
    - - - - - - - - '; - - if ($criterion->id_product_comment_criterion_type == 3) - foreach ($products as $product) - $this->_html .=' - '; - else if ($criterion->id_product_comment_criterion_type == 2) - foreach ($categories as $category) - $this->_html .=' - '; - $this->_html .=' -
    '.$this->l('ID').''.($criterion->id_product_comment_criterion_type == 3 ? $this->l('Product Name') : $this->l('Category Name')).'
    '.(int)$product['id_product'].''.$product['name'].'
    '.(int)$category['id_category'].''.$category['name'].'
    -
    -
    - -
    -
    '; - } - - $this->_html .= '
    '; - } - } - - private function _displayFormDelete() - { - $this->_html .= ' -
    - '.$this->l('Manage Comments').''; - - require_once(dirname(__FILE__).'/ProductComment.php'); - $comments = ProductComment::getAll(); - if (count($comments)) - { - $this->_html .= ' -
    - - -
    - - - - - - - - - '; - foreach ($comments as $comment) - $this->_html .= ' - - - - - '; - $this->_html .= ' - - - - - -
    '.$this->l('Author').''.$this->l('Comment').''.$this->l('Actions').'
    '.htmlspecialchars($comment['customer_name'], ENT_COMPAT, 'UTF-8').'.'.htmlspecialchars($comment['content'], ENT_COMPAT, 'UTF-8').''.$this->l('Delete').'
    '.$this->l('Selection:').''.$this->l('Delete').'
    -
    '; - } - else - $this->_html .= $this->l('No comments to manage at this time.'); - - $this->_html .= '

    '; - } - - private function _checkDeleteComment() - { - $action = Tools::getValue('delete_action'); - if (empty($action) === false) - { - $product_comments = Tools::getValue('delete_id_product_comment'); - - if (count($product_comments)) - { - require_once(dirname(__FILE__).'/ProductComment.php'); - if ($action == 'delete') - { - foreach ($product_comments as $id_product_comment) - { - if (!$id_product_comment) - continue; - $comment = new ProductComment((int)$id_product_comment); - $comment->delete(); - ProductComment::deleteGrades((int)$id_product_comment); - } - } - } - } - } - - public function hookProductTab($params) - { - require_once(dirname(__FILE__).'/ProductComment.php'); - require_once(dirname(__FILE__).'/ProductCommentCriterion.php'); - - $average = ProductComment::getAverageGrade((int)Tools::getValue('id_product')); - - $this->context->smarty->assign(array( - 'allow_guests' => (int)Configuration::get('PRODUCT_COMMENTS_ALLOW_GUESTS'), - 'comments' => ProductComment::getByProduct((int)(Tools::getValue('id_product'))), - 'criterions' => ProductCommentCriterion::getByProduct((int)(Tools::getValue('id_product')), $this->context->language->id), - 'averageTotal' => round($average['grade']), - 'nbComments' => (int)(ProductComment::getCommentNumber((int)(Tools::getValue('id_product')))) - )); - - return ($this->display(__FILE__, '/tab.tpl')); - } - - public function hookTop($params) - { - $this->context->controller->addJS($this->_path.'js/jquery.rating.pack.js'); - return $this->display(__FILE__, 'productcomments_top.tpl'); - } - - public function hookDisplayProductListReviews($params) - { - require_once(dirname(__FILE__).'/ProductComment.php'); - - $average = ProductComment::getAverageGrade((int)$params['product']['id_product']); - $this->smarty->assign(array( - 'product' => $params['product'], - 'averageTotal' => round($average['grade']), - 'nbComments' => (int)(ProductComment::getCommentNumber((int)$params['product']['id_product'])) - )); - return $this->display(__FILE__, 'productcomments_reviews.tpl'); - } - - public function hookproductOutOfStock($params) - { - require_once(dirname(__FILE__).'/ProductComment.php'); - require_once(dirname(__FILE__).'/ProductCommentCriterion.php'); - - $id_guest = (!$id_customer = (int)$this->context->cookie->id_customer) ? (int)$this->context->cookie->id_guest : false; - $customerComment = ProductComment::getByCustomer((int)(Tools::getValue('id_product')), (int)$this->context->cookie->id_customer, true, (int)$id_guest); - - $average = ProductComment::getAverageGrade((int)Tools::getValue('id_product')); - - $image = Product::getCover((int)Tools::getValue('id_product')); - - $this->context->smarty->assign(array( - 'id_product_comment_form' => (int)Tools::getValue('id_product'), - 'product' => $this->context->controller->getProduct(), - 'secure_key' => $this->secure_key, - 'logged' => (int)$this->context->customer->isLogged(true), - 'allow_guests' => (int)Configuration::get('PRODUCT_COMMENTS_ALLOW_GUESTS'), - 'productcomment_cover' => (int)Tools::getValue('id_product').'-'.(int)$image['id_image'], - 'mediumSize' => Image::getSize(ImageType::getFormatedName('medium')), - 'criterions' => ProductCommentCriterion::getByProduct((int)Tools::getValue('id_product'), $this->context->language->id), - 'action_url' => '', - 'averageTotal' => round($average['grade']), - 'too_early' => ($customerComment && (strtotime($customerComment['date_add']) + Configuration::get('PRODUCT_COMMENTS_MINIMAL_TIME')) > time()), - 'nbComments' => (int)(ProductComment::getCommentNumber((int)Tools::getValue('id_product'))) - )); - - return ($this->display(__FILE__, '/productcomments-extra.tpl')); - } - - public function hookProductTabContent($params) - { - $this->context->controller->addJS($this->_path.'js/jquery.rating.pack.js'); - $this->context->controller->addJS($this->_path.'js/jquery.textareaCounter.plugin.js'); - $this->context->controller->addJS($this->_path.'js/productcomments.js'); - - $id_guest = (!$id_customer = (int)$this->context->cookie->id_customer) ? (int)$this->context->cookie->id_guest : false; - $customerComment = ProductComment::getByCustomer((int)(Tools::getValue('id_product')), (int)$this->context->cookie->id_customer, true, (int)$id_guest); - - $averages = ProductComment::getAveragesByProduct((int)Tools::getValue('id_product'), $this->context->language->id); - $averageTotal = 0; - foreach ($averages as $average) - $averageTotal += (float)($average); - $averageTotal = count($averages) ? ($averageTotal / count($averages)) : 0; - - $image = Product::getCover((int)Tools::getValue('id_product')); - - $this->context->smarty->assign(array( - 'logged' => (int)$this->context->customer->isLogged(true), - 'action_url' => '', - 'comments' => ProductComment::getByProduct((int)Tools::getValue('id_product'), 1, null, $this->context->cookie->id_customer), - 'criterions' => ProductCommentCriterion::getByProduct((int)Tools::getValue('id_product'), $this->context->language->id), - 'averages' => $averages, - 'product_comment_path' => $this->_path, - 'averageTotal' => $averageTotal, - 'allow_guests' => (int)Configuration::get('PRODUCT_COMMENTS_ALLOW_GUESTS'), - 'too_early' => ($customerComment && (strtotime($customerComment['date_add']) + Configuration::get('PRODUCT_COMMENTS_MINIMAL_TIME')) > time()), - 'delay' => Configuration::get('PRODUCT_COMMENTS_MINIMAL_TIME'), - 'id_product_comment_form' => (int)Tools::getValue('id_product'), - 'secure_key' => $this->secure_key, - 'productcomment_cover' => (int)Tools::getValue('id_product').'-'.(int)$image['id_image'], - 'mediumSize' => Image::getSize(ImageType::getFormatedName('medium')), - 'nbComments' => (int)ProductComment::getCommentNumber((int)Tools::getValue('id_product')), - 'productcomments_controller_url' => $this->context->link->getModuleLink('productcomments'), - 'productcomments_url_rewriting_activated' => Configuration::get('PS_REWRITING_SETTINGS', 0), - 'moderation_active' => (int)Configuration::get('PRODUCT_COMMENTS_MODERATE') - )); - - $this->context->controller->pagination((int)ProductComment::getCommentNumber((int)Tools::getValue('id_product'))); - - return ($this->display(__FILE__, '/productcomments.tpl')); - } - - public function hookHeader() - { - $this->context->controller->addCSS($this->_path.'productcomments.css', 'all'); - } - - public function hookExtraProductComparison($params) - { - require_once(dirname(__FILE__).'/ProductComment.php'); - require_once(dirname(__FILE__).'/ProductCommentCriterion.php'); - - $list_grades = array(); - $list_product_grades = array(); - $list_product_average = array(); - $list_product_comment = array(); - - foreach ($params['list_ids_product'] as $id_product) - { - $grades = ProductComment::getAveragesByProduct($id_product, $this->context->language->id); - $criterions = ProductCommentCriterion::getByProduct($id_product, $this->context->language->id); - $grade_total = 0; - if (count($grades) > 0) - { - foreach ($criterions as $criterion) - { - if (isset($grades[$criterion['id_product_comment_criterion']])) - { - $list_product_grades[$criterion['id_product_comment_criterion']][$id_product] = $grades[$criterion['id_product_comment_criterion']]; - $grade_total += (float)($grades[$criterion['id_product_comment_criterion']]); - } - else - $list_product_grades[$criterion['id_product_comment_criterion']][$id_product] = 0; - - if (!array_key_exists($criterion['id_product_comment_criterion'], $list_grades)) - $list_grades[$criterion['id_product_comment_criterion']] = $criterion['name']; - } - - $list_product_average[$id_product] = $grade_total / count($criterions); - $list_product_comment[$id_product] = ProductComment::getByProduct($id_product, 0, 3); - } - } - - if (count($list_grades) < 1) - return false; - - $this->context->smarty->assign(array('grades' => $list_grades, 'product_grades' => $list_product_grades, 'list_ids_product' => $params['list_ids_product'], - 'list_product_average' => $list_product_average, 'product_comments' => $list_product_comment)); - - return $this->display(__FILE__, '/products-comparison.tpl'); - } -} diff --git a/modules/productcomments/productcomments.tpl b/modules/productcomments/productcomments.tpl deleted file mode 100644 index 4a49c07fb..000000000 --- a/modules/productcomments/productcomments.tpl +++ /dev/null @@ -1,161 +0,0 @@ -{* -* 2007-2013 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 -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*} - - -
    -
    - {if $comments} - {foreach from=$comments item=comment} - {if $comment.content} -
    -
    - {l s='Grade' mod='productcomments'}  -
    - {section name="i" start=0 loop=5 step=1} - {if $comment.grade le $smarty.section.i.index} -
    - {else} -
    - {/if} - {/section} -
    -
    - {$comment.customer_name|escape:'html':'UTF-8'}
    - {dateFormat date=$comment.date_add|escape:'html':'UTF-8' full=0} -
    -
    -
    -

    {$comment.title}

    -

    {$comment.content|escape:'html':'UTF-8'|nl2br}

    -
      - {if $comment.total_advice > 0} -
    • {l s='%1$d out of %2$d people found this review useful.' sprintf=[$comment.total_useful,$comment.total_advice] mod='productcomments'}
    • - {/if} - {if $logged == 1} - {if !$comment.customer_advice} -
    • {l s='Was this comment useful to you?' mod='productcomments'}
    • - {/if} - {if !$comment.customer_report} -
    • {l s='Report abuse' mod='productcomments'}
    • - {/if} - {/if} -
    -
    -
    - {/if} - {/foreach} - {if (!$too_early AND ($logged OR $allow_guests))} -

    - {l s='Write your review' mod='productcomments'} ! -

    - {/if} - {else} - {if (!$too_early AND ($logged OR $allow_guests))} -

    - {l s='Be the first to write your review' mod='productcomments'} ! -

    - {else} -

    {l s='No customer comments for the moment.' mod='productcomments'}

    - {/if} - {/if} -
    -
    - -{if isset($product) && $product} - -
    -
    -
    -

    {l s='Write your review' mod='productcomments'}

    - {if isset($product) && $product} -
    - {$product->name|escape:html:'UTF-8'} -
    -

    {$product->name}

    - {$product->description_short} -
    -
    - {/if} -
    -

    {l s='Write your review' mod='productcomments'}

    - - - - {if $criterions|@count > 0} -
      - {foreach from=$criterions item='criterion'} -
    • - -
      - - - - - -
      -
      -
    • - {/foreach} -
    - {/if} - - - - - - - - {if $allow_guests == true && $logged == 0} - - - {/if} - - -
    -
    -
    -
    - -{/if} \ No newline at end of file diff --git a/modules/productcomments/productcomments_reviews.tpl b/modules/productcomments/productcomments_reviews.tpl deleted file mode 100644 index cccaf240b..000000000 --- a/modules/productcomments/productcomments_reviews.tpl +++ /dev/null @@ -1,37 +0,0 @@ - {* -* 2007-2013 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 -* @copyright 2007-2013 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 -*} -
    -
    - {section name="i" start=0 loop=5 step=1} - {if $averageTotal le $smarty.section.i.index} -
    - {else} -
    - {/if} - {/section} -
    - {l s='%s Review(s)'|sprintf:$averageTotal mod='productcomments'}  -
    \ No newline at end of file diff --git a/modules/productcomments/productcomments_top.tpl b/modules/productcomments/productcomments_top.tpl deleted file mode 100644 index a09be2a77..000000000 --- a/modules/productcomments/productcomments_top.tpl +++ /dev/null @@ -1,6 +0,0 @@ - \ No newline at end of file diff --git a/modules/productcomments/productcommentscriterion.php b/modules/productcomments/productcommentscriterion.php deleted file mode 100644 index e625baa1e..000000000 --- a/modules/productcomments/productcommentscriterion.php +++ /dev/null @@ -1,49 +0,0 @@ - -* @copyright 2007-2013 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__).'/ProductCommentCriterion.php'); - -if (empty($_GET['id_lang']) === false && - isset($_GET['id_product']) === true) -{ - $criterions = ProductCommentCriterion::get($_GET['id_lang']); - if ((int)($_GET['id_product'])) - $selects = ProductCommentCriterion::getByProduct($_GET['id_product'], $_GET['id_lang']); - echo ''; -} \ No newline at end of file diff --git a/modules/productcomments/products-comparison.tpl b/modules/productcomments/products-comparison.tpl deleted file mode 100755 index 28914244e..000000000 --- a/modules/productcomments/products-comparison.tpl +++ /dev/null @@ -1,119 +0,0 @@ -{* -* 2007-2013 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 -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*} - - - - - - - - - {l s='Comments' mod='productcomments'} - - {section loop=$list_ids_product|count step=1 start=0 name=td} - - {/section} - - -{foreach from=$grades item=grade key=grade_id} - - {cycle values='comparison_feature_odd,comparison_feature_even' assign='classname'} - - {$grade} - - - {foreach from=$list_ids_product item=id_product} - {assign var='tab_grade' value=$product_grades[$grade_id]} - - {if isset($tab_grade[$id_product]) AND $tab_grade[$id_product]} - {section loop=6 step=1 start=1 name=average} - - {/section} - {else} - - - {/if} - - {/foreach} - -{/foreach} - - {cycle values='comparison_feature_odd,comparison_feature_even' assign='classname'} - - {l s='Average' mod='productcomments'} -{foreach from=$list_ids_product item=id_product} - - {if isset($list_product_average[$id_product]) AND $list_product_average[$id_product]} - {section loop=6 step=1 start=1 name=average} - - {/section} - {else} - - - {/if} - -{/foreach} - - - -   - {foreach from=$list_ids_product item=id_product} - - {if isset($product_comments[$id_product]) AND $product_comments[$id_product]} - {l s='view comments' mod='productcomments'} - - {else} - - - {/if} - -{/foreach} - \ No newline at end of file diff --git a/modules/productcomments/tab.tpl b/modules/productcomments/tab.tpl deleted file mode 100644 index ccde10c83..000000000 --- a/modules/productcomments/tab.tpl +++ /dev/null @@ -1,26 +0,0 @@ -{* -* 2007-2013 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 -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*} - -
  • {l s='Comments' mod='productcomments'}
  • \ No newline at end of file diff --git a/modules/productcomments/translations/index.php b/modules/productcomments/translations/index.php deleted file mode 100644 index 3f6561f72..000000000 --- a/modules/productcomments/translations/index.php +++ /dev/null @@ -1,35 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); - -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); - -header("Location: ../"); -exit; \ No newline at end of file diff --git a/modules/productcomments/upgrade/index.php b/modules/productcomments/upgrade/index.php deleted file mode 100644 index 3f6561f72..000000000 --- a/modules/productcomments/upgrade/index.php +++ /dev/null @@ -1,35 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); - -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); - -header("Location: ../"); -exit; \ No newline at end of file diff --git a/modules/productcomments/upgrade/install-2.4.php b/modules/productcomments/upgrade/install-2.4.php deleted file mode 100644 index 8c0ee51f4..000000000 --- a/modules/productcomments/upgrade/install-2.4.php +++ /dev/null @@ -1,9 +0,0 @@ -registerHook('displayProductListReviews') && $object->registerHook('top')); -} diff --git a/modules/pscleaner/config.xml b/modules/pscleaner/config.xml deleted file mode 100644 index cd7990d3b..000000000 --- a/modules/pscleaner/config.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - pscleaner - - - - - - 1 - 0 - - \ No newline at end of file diff --git a/modules/pscleaner/index.php b/modules/pscleaner/index.php deleted file mode 100644 index 3f6561f72..000000000 --- a/modules/pscleaner/index.php +++ /dev/null @@ -1,35 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); - -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); - -header("Location: ../"); -exit; \ No newline at end of file diff --git a/modules/pscleaner/logo.gif b/modules/pscleaner/logo.gif deleted file mode 100644 index 667cba308..000000000 Binary files a/modules/pscleaner/logo.gif and /dev/null differ diff --git a/modules/pscleaner/logo.png b/modules/pscleaner/logo.png deleted file mode 100644 index 6b43d7e23..000000000 Binary files a/modules/pscleaner/logo.png and /dev/null differ diff --git a/modules/pscleaner/pscleaner.php b/modules/pscleaner/pscleaner.php deleted file mode 100644 index a3ee9d3af..000000000 --- a/modules/pscleaner/pscleaner.php +++ /dev/null @@ -1,613 +0,0 @@ - - * @copyright 2007-2013 PrestaShop SA - * @version Release: $Revision: 7060 $ - * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) - * International Registered Trademark & Property of PrestaShop SA - */ - -if (!defined('_CAN_LOAD_FILES_')) - exit; - -class PSCleaner extends Module -{ - public function __construct() - { - $this->name = 'pscleaner'; - $this->tab = 'administration'; - $this->version = '1.0'; - $this->author = 'PrestaShop'; - $this->need_instance = 0; - - $this->bootstrap = true; - parent::__construct(); - - $this->displayName = $this->l('PrestaShop Cleaner'); - $this->description = $this->l('Check and fix functional integrity constraints and remove default data'); - $this->secure_key = Tools::encrypt($this->name); - } - - public function getContent() - { - $html = '

    '.$this->l('Be really careful with this tool - There is no possible rollback!').'

    '; - if (Tools::isSubmit('submitCheckAndFix')) - { - $logs = self::checkAndFix(); - if (count($logs)) - { - $conf = $this->l('The following queries successfuly fixed broken data:').'
      '; - foreach ($logs as $query => $entries) - $conf .= '
    • '.Tools::htmlentitiesUTF8($query).'
      '.sprintf($this->l('%d line(s)'), $entries).'
    • '; - $conf .= '
    '; - } - else - $conf = $this->l('Nothing that need to be cleaned'); - $html .= $this->displayConfirmation($conf); - } - if (Tools::isSubmit('submitTruncateCatalog')) - { - self::truncate('catalog'); - $html .= $this->displayConfirmation($this->l('Catalog truncated')); - } - if (Tools::isSubmit('submitTruncateSales')) - { - self::truncate('sales'); - $html .= $this->displayConfirmation($this->l('Orders and customers truncated')); - } - - $html .= ' - '; - - return $html.$this->renderForm(); - } - - public static function checkAndFix() - { - $db = Db::getInstance(); - $logs = array(); - - // Remove doubles in the configuration - $filtered_configuration = array(); - $result = $db->ExecuteS('SELECT * FROM '._DB_PREFIX_.'configuration'); - foreach ($result as $row) - { - $key = $row['id_shop_group'].'-|-'.$row['id_shop'].'-|-'.$row['name']; - if (in_array($key, $filtered_configuration)) - { - $query = 'DELETE FROM '._DB_PREFIX_.'configuration WHERE id_configuration = '.(int)$row['id_configuration']; - $db->Execute($query); - $logs[$query] = 1; - } - else - $filtered_configuration[] = $key; - } - unset($filtered_configuration); - - // Remove inexisting or monolanguage configuration value from configuration_lang - $query = 'DELETE FROM `'._DB_PREFIX_.'configuration_lang` - WHERE `id_configuration` NOT IN (SELECT `id_configuration` FROM `'._DB_PREFIX_.'configuration`) - OR `id_configuration` IN (SELECT `id_configuration` FROM `'._DB_PREFIX_.'configuration` WHERE name IS NULL OR name = "")'; - if ($db->Execute($query)) - if ($affected_rows = $db->Affected_Rows()) - $logs[$query] = $affected_rows; - - // Simple Cascade Delete - $queries = array( - // 0 => DELETE FROM __table__, 1 => WHERE __id__ NOT IN, 2 => NOT IN __table__, 3 => __id__ used in the "NOT IN" table, 4 => module_name - array('access', 'id_profile', 'profile', 'id_profile'), - array('access', 'id_tab', 'tab', 'id_tab'), - array('accessory', 'id_product_1', 'product', 'id_product'), - array('accessory', 'id_product_2', 'product', 'id_product'), - array('address_format', 'id_country', 'country', 'id_country'), - array('attribute', 'id_attribute_group', 'attribute_group', 'id_attribute_group'), - array('carrier_group', 'id_carrier', 'carrier', 'id_carrier'), - array('carrier_group', 'id_group', 'group', 'id_group'), - array('carrier_zone', 'id_carrier', 'carrier', 'id_carrier'), - array('carrier_zone', 'id_zone', 'zone', 'id_zone'), - array('cart_cart_rule', 'id_cart', 'cart', 'id_cart'), - array('cart_product', 'id_cart', 'cart', 'id_cart'), - array('cart_rule_carrier', 'id_cart_rule', 'cart_rule', 'id_cart_rule'), - array('cart_rule_carrier', 'id_carrier', 'carrier', 'id_carrier'), - array('cart_rule_combination', 'id_cart_rule_1', 'cart_rule', 'id_cart_rule'), - array('cart_rule_combination', 'id_cart_rule_2', 'cart_rule', 'id_cart_rule'), - array('cart_rule_country', 'id_cart_rule', 'cart_rule', 'id_cart_rule'), - array('cart_rule_country', 'id_country', 'country', 'id_country'), - array('cart_rule_group', 'id_cart_rule', 'cart_rule', 'id_cart_rule'), - array('cart_rule_group', 'id_group', 'group', 'id_group'), - array('cart_rule_product_rule_group', 'id_cart_rule', 'cart_rule', 'id_cart_rule'), - array('cart_rule_product_rule', 'id_product_rule_group', 'cart_rule_product_rule_group', 'id_product_rule_group'), - array('cart_rule_product_rule_value', 'id_product_rule', 'cart_rule_product_rule', 'id_product_rule'), - array('category_group', 'id_category', 'category', 'id_category'), - array('category_group', 'id_group', 'group', 'id_group'), - array('category_product', 'id_category', 'category', 'id_category'), - array('category_product', 'id_product', 'product', 'id_product'), - array('cms', 'id_cms_category', 'cms_category', 'id_cms_category'), - array('cms_block', 'id_cms_category', 'cms_category', 'id_cms_category'), - array('cms_block_page', 'id_cms', 'cms', 'id_cms'), - array('cms_block_page', 'id_cms_block', 'cms_block', 'id_cms_block'), - array('compare', 'id_customer', 'customer', 'id_customer'), - array('compare_product', 'id_compare', 'compare', 'id_compare'), - array('compare_product', 'id_product', 'product', 'id_product'), - array('connections', 'id_shop_group', 'shop_group', 'id_shop_group'), - array('connections', 'id_shop', 'shop', 'id_shop'), - array('connections_page', 'id_connections', 'connections', 'id_connections'), - array('connections_page', 'id_page', 'page', 'id_page'), - array('connections_source', 'id_connections', 'connections', 'id_connections'), - array('customer', 'id_shop_group', 'shop_group', 'id_shop_group'), - array('customer', 'id_shop', 'shop', 'id_shop'), - array('customer_group', 'id_group', 'group', 'id_group'), - array('customer_group', 'id_customer', 'customer', 'id_customer'), - array('customer_message', 'id_customer_thread', 'customer_thread', 'id_customer_thread'), - array('customer_thread', 'id_shop', 'shop', 'id_shop'), - array('customization', 'id_cart', 'cart', 'id_cart'), - array('customization_field', 'id_product', 'product', 'id_product'), - array('customized_data', 'id_customization', 'customization', 'id_customization'), - array('delivery', 'id_shop', 'shop', 'id_shop'), - array('delivery', 'id_shop_group', 'shop_group', 'id_shop_group'), - array('delivery', 'id_carrier', 'carrier', 'id_carrier'), - array('delivery', 'id_zone', 'zone', 'id_zone'), - array('editorial', 'id_shop', 'shop', 'id_shop', 'editorial'), - array('favorite_product', 'id_product', 'product', 'id_product','favoriteproducts'), - array('favorite_product', 'id_customer', 'customer', 'id_customer','favoriteproducts'), - array('favorite_product', 'id_shop', 'shop', 'id_shop','favoriteproducts'), - array('feature_product', 'id_feature', 'feature', 'id_feature'), - array('feature_product', 'id_product', 'product', 'id_product'), - array('feature_value', 'id_feature', 'feature', 'id_feature'), - array('group_reduction', 'id_group', 'group', 'id_group'), - array('group_reduction', 'id_category', 'category', 'id_category'), - array('homeslider', 'id_shop', 'shop', 'id_shop'), - array('homeslider', 'id_homeslider_slides', 'homeslider_slides', 'id_homeslider_slides'), - array('hook_module', 'id_hook', 'hook', 'id_hook'), - array('hook_module', 'id_module', 'module', 'id_module'), - array('hook_module_exceptions', 'id_hook', 'hook', 'id_hook'), - array('hook_module_exceptions', 'id_module', 'module', 'id_module'), - array('hook_module_exceptions', 'id_shop', 'shop', 'id_shop'), - array('image', 'id_product', 'product', 'id_product'), - array('message', 'id_cart', 'cart', 'id_cart'), - array('message_readed', 'id_message', 'message', 'id_message'), - array('message_readed', 'id_employee', 'employee', 'id_employee'), - array('module_access', 'id_profile', 'profile', 'id_profile'), - array('module_access', 'id_module', 'module', 'id_module'), - array('module_country', 'id_module', 'module', 'id_module'), - array('module_country', 'id_country', 'country', 'id_country'), - array('module_country', 'id_shop', 'shop', 'id_shop'), - array('module_currency', 'id_module', 'module', 'id_module'), - array('module_currency', 'id_currency', 'currency', 'id_currency'), - array('module_currency', 'id_shop', 'shop', 'id_shop'), - array('module_group', 'id_module', 'module', 'id_module'), - array('module_group', 'id_group', 'group', 'id_group'), - array('module_group', 'id_shop', 'shop', 'id_shop'), - array('module_preference', 'id_employee', 'employee', 'id_employee'), - array('orders', 'id_shop', 'shop', 'id_shop'), - array('orders', 'id_shop_group', 'group_shop', 'id_shop_group'), - array('order_carrier', 'id_order', 'orders', 'id_order'), - array('order_cart_rule', 'id_order', 'orders', 'id_order'), - array('order_detail', 'id_order', 'orders', 'id_order'), - array('order_detail_tax', 'id_order_detail', 'order_detail', 'id_order_detail'), - array('order_history', 'id_order', 'orders', 'id_order'), - array('order_invoice', 'id_order', 'orders', 'id_order'), - array('order_invoice_payment', 'id_order', 'orders', 'id_order'), - array('order_invoice_tax', 'id_order_invoice', 'order_invoice', 'id_order_invoice'), - array('order_return', 'id_order', 'orders', 'id_order'), - array('order_return_detail', 'id_order_return', 'order_return', 'id_order_return'), - array('order_slip', 'id_order', 'orders', 'id_order'), - array('order_slip_detail', 'id_order_slip', 'order_slip', 'id_order_slip'), - array('pack', 'id_product_pack', 'product', 'id_product'), - array('pack', 'id_product_item', 'product', 'id_product'), - array('page', 'id_page_type', 'page_type', 'id_page_type'), - array('page_viewed', 'id_shop', 'shop', 'id_shop'), - array('page_viewed', 'id_shop_group', 'shop_group', 'id_shop_group'), - array('page_viewed', 'id_date_range', 'date_range', 'id_date_range'), - array('product_attachment', 'id_attachment', 'attachment', 'id_attachment'), - array('product_attachment', 'id_product', 'product', 'id_product'), - array('product_attribute', 'id_product', 'product', 'id_product'), - array('product_attribute_combination', 'id_product_attribute', 'product_attribute', 'id_product_attribute'), - array('product_attribute_combination', 'id_attribute', 'attribute', 'id_attribute'), - array('product_attribute_image', 'id_image', 'image', 'id_image'), - array('product_attribute_image', 'id_product_attribute', 'product_attribute', 'id_product_attribute'), - array('product_carrier', 'id_product', 'product', 'id_product'), - array('product_carrier', 'id_shop', 'shop', 'id_shop'), - array('product_carrier', 'id_carrier_reference', 'carrier', 'id_reference'), - array('product_country_tax', 'id_product', 'product', 'id_product'), - array('product_country_tax', 'id_country', 'country', 'id_country'), - array('product_country_tax', 'id_tax', 'tax', 'id_tax'), - array('product_download', 'id_product', 'product', 'id_product'), - array('product_group_reduction_cache', 'id_product', 'product', 'id_product'), - array('product_group_reduction_cache', 'id_group', 'group', 'id_group'), - array('product_sale', 'id_product', 'product', 'id_product'), - array('product_supplier', 'id_product', 'product', 'id_product'), - array('product_supplier', 'id_supplier', 'supplier', 'id_supplier'), - array('product_tag', 'id_product', 'product', 'id_product'), - array('product_tag', 'id_tag', 'tag', 'id_tag'), - array('range_price', 'id_carrier', 'carrier', 'id_carrier'), - array('range_weight', 'id_carrier', 'carrier', 'id_carrier'), - array('referrer_cache', 'id_referrer', 'referrer', 'id_referrer'), - array('referrer_cache', 'id_connections_source', 'connections_source', 'id_connections_source'), - array('scene_category', 'id_scene', 'scene', 'id_scene'), - array('scene_category', 'id_category', 'category', 'id_category'), - array('scene_products', 'id_scene', 'scene', 'id_scene'), - array('scene_products', 'id_product', 'product', 'id_product'), - array('search_index', 'id_product', 'product', 'id_product'), - array('search_word', 'id_lang', 'lang', 'id_lang'), - array('search_word', 'id_shop', 'shop', 'id_shop'), - array('shop_url', 'id_shop', 'shop', 'id_shop'), - array('specific_price_priority', 'id_product', 'product', 'id_product'), - array('stock', 'id_warehouse', 'warehouse', 'id_warehouse'), - array('stock', 'id_product', 'product', 'id_product'), - array('stock_available', 'id_product', 'product', 'id_product'), - array('stock_mvt', 'id_stock', 'stock', 'id_stock'), - array('tab_module_preference', 'id_employee', 'employee', 'id_employee'), - array('tab_module_preference', 'id_tab', 'tab', 'id_tab'), - array('tax_rule', 'id_country', 'country', 'id_country'), - array('theme_specific', 'id_theme', 'theme', 'id_theme'), - array('theme_specific', 'id_shop', 'shop', 'id_shop'), - array('warehouse_carrier', 'id_warehouse', 'warehouse', 'id_warehouse'), - array('warehouse_carrier', 'id_carrier', 'carrier', 'id_carrier'), - array('warehouse_product_location', 'id_product', 'product', 'id_product'), - array('warehouse_product_location', 'id_warehouse', 'warehouse', 'id_warehouse'), - ); - - $queries = self::bulle($queries); - foreach ($queries as $query_array) - { - // If this is a module and the module is not installed, we continue - if (isset($query_array[4]) && !Module::isInstalled($query_array[4])) - continue; - - $query = 'DELETE FROM `'._DB_PREFIX_.$query_array[0].'` WHERE `'.$query_array[1].'` NOT IN (SELECT `'.$query_array[3].'` FROM `'._DB_PREFIX_.$query_array[2].'`)'; - if ($db->Execute($query)) - if ($affected_rows = $db->Affected_Rows()) - $logs[$query] = $affected_rows; - } - - // _lang table cleaning - $tables = Db::getInstance()->executeS('SHOW TABLES LIKE "'.preg_replace('/([%_])/', '\\$1', _DB_PREFIX_).'%_\\_lang"'); - foreach ($tables as $table) - { - $table_lang = current($table); - $table = str_replace('_lang', '', $table_lang); - $id_table = 'id_'.preg_replace('/^'._DB_PREFIX_.'/', '', $table); - - $query = 'DELETE FROM `'.bqSQL($table_lang).'` WHERE `'.bqSQL($id_table).'` NOT IN (SELECT `'.bqSQL($id_table).'` FROM `'.bqSQL($table).'`)'; - if ($db->Execute($query)) - if ($affected_rows = $db->Affected_Rows()) - $logs[$query] = $affected_rows; - - $query = 'DELETE FROM `'.bqSQL($table_lang).'` WHERE `id_lang` NOT IN (SELECT `id_lang` FROM `'._DB_PREFIX_.'lang`)'; - if ($db->Execute($query)) - if ($affected_rows = $db->Affected_Rows()) - $logs[$query] = $affected_rows; - } - - // _shop table cleaning - $tables = Db::getInstance()->executeS('SHOW TABLES LIKE "'.preg_replace('/([%_])/', '\\$1', _DB_PREFIX_).'%_\\_shop"'); - foreach ($tables as $table) - { - $table_shop = current($table); - $table = str_replace('_shop', '', $table_shop); - $id_table = 'id_'.preg_replace('/^'._DB_PREFIX_.'/', '', $table); - - if (in_array($table_shop, array(_DB_PREFIX_.'carrier_tax_rules_group_shop'))) - continue; - - $query = 'DELETE FROM `'.bqSQL($table_shop).'` WHERE `'.bqSQL($id_table).'` NOT IN (SELECT `'.bqSQL($id_table).'` FROM `'.bqSQL($table).'`)'; - if ($db->Execute($query)) - if ($affected_rows = $db->Affected_Rows()) - $logs[$query] = $affected_rows; - - $query = 'DELETE FROM `'.bqSQL($table_shop).'` WHERE `id_shop` NOT IN (SELECT `id_shop` FROM `'._DB_PREFIX_.'shop`)'; - if ($db->Execute($query)) - if ($affected_rows = $db->Affected_Rows()) - $logs[$query] = $affected_rows; - } - - // stock_available - $query = 'DELETE FROM `'._DB_PREFIX_.'stock_available` WHERE `id_shop` NOT IN (SELECT `id_shop` FROM `'._DB_PREFIX_.'shop`) AND `id_shop_group` NOT IN (SELECT `id_shop_group` FROM `'._DB_PREFIX_.'shop_group`)'; - if ($db->Execute($query)) - if ($affected_rows = $db->Affected_Rows()) - $logs[$query] = $affected_rows; - - Category::regenerateEntireNtree(); - - // @Todo: Remove attachment files, images... - Image::clearTmpDir(); - self::clearAllCaches(); - - return $logs; - } - - public function truncate($case) - { - $db = Db::getInstance(); - - switch ($case) - { - case 'catalog': - $id_home = Configuration::get('PS_HOME_CATEGORY'); - $id_root = Configuration::get('PS_ROOT_CATEGORY'); - $db->execute('DELETE FROM `'._DB_PREFIX_.'category` WHERE id_category NOT IN ('.(int)$id_home.', '.(int)$id_root.')'); - $db->execute('DELETE FROM `'._DB_PREFIX_.'category_lang` WHERE id_category NOT IN ('.(int)$id_home.', '.(int)$id_root.')'); - $db->execute('DELETE FROM `'._DB_PREFIX_.'category_shop` WHERE id_category NOT IN ('.(int)$id_home.', '.(int)$id_root.')'); - foreach (scandir(_PS_CAT_IMG_DIR_) as $dir) - if (preg_match('/^[0-9]+(\-(.*))?\.jpg$/', $dir)) - unlink(_PS_CAT_IMG_DIR_.$dir); - $tables = array( - 'product', - 'product_shop', - 'feature_product', - 'product_lang', - 'category_product', - 'product_tag', - 'image', - 'image_lang', - 'image_shop', - 'specific_price', - 'specific_price_priority', - 'product_carrier', - 'cart_product', - 'compare_product', - 'product_attachment', - 'product_country_tax', - 'product_download', - 'product_group_reduction_cache', - 'product_sale', - 'product_supplier', - 'scene_products', - 'warehouse_product_location', - 'stock', - 'stock_available', - 'stock_mvt', - 'customization', - 'customization_field', - 'supply_order_detail', - 'attribute_impact', - 'product_attribute', - 'product_attribute_shop', - 'product_attribute_combination', - 'product_attribute_image', - 'attribute', - 'attribute_impact', - 'attribute_lang', - 'attribute_group', - 'attribute_group_lang', - 'attribute_group_shop', - 'attribute_shop', - 'product_attribute', - 'product_attribute_shop', - 'product_attribute_combination', - 'product_attribute_image', - 'stock_available', - 'manufacturer', - 'manufacturer_lang', - 'manufacturer_shop', - 'supplier', - 'supplier_lang', - 'supplier_shop', - 'customization', - 'customization_field', - 'customization_field_lang', - 'customized_data', - 'feature', - 'feature_lang', - 'feature_product', - 'feature_shop', - 'feature_value', - 'feature_value_lang', - 'pack', - 'scene', - 'scene_category', - 'scene_lang', - 'scene_products', - 'scene_shop', - 'search_index', - 'search_word', - 'specific_price', - 'specific_price_priority', - 'specific_price_rule', - 'specific_price_rule_condition', - 'specific_price_rule_condition_group', - 'stock', - 'stock_available', - 'stock_mvt', - ); - foreach ($tables as $table) - $db->execute('TRUNCATE TABLE `'._DB_PREFIX_.bqSQL($table).'`'); - $db->execute('DELETE FROM `'._DB_PREFIX_.'address` WHERE id_manufacturer > 0 OR id_supplier > 0 OR id_warehouse > 0'); - - Image::deleteAllImages(_PS_PROD_IMG_DIR_); - if (!file_exists(_PS_PROD_IMG_DIR_)) - mkdir(_PS_PROD_IMG_DIR_); - foreach (scandir(_PS_MANU_IMG_DIR_) as $dir) - if (preg_match('/^[0-9]+(\-(.*))?\.jpg$/', $dir)) - unlink(_PS_MANU_IMG_DIR_.$dir); - foreach (scandir(_PS_SUPP_IMG_DIR_) as $dir) - if (preg_match('/^[0-9]+(\-(.*))?\.jpg$/', $dir)) - unlink(_PS_SUPP_IMG_DIR_.$dir); - break; - - case 'sales': - $tables = array( - 'customer', - 'cart', - 'cart_product', - 'connections', - 'connections_page', - 'connections_source', - 'customer_group', - 'customer_message', - 'customer_message_sync_imap', - 'customer_thread', - 'guest', - 'message', - 'message_readed', - 'orders', - 'order_carrier', - 'order_cart_rule', - 'order_detail', - 'order_detail_tax', - 'order_history', - 'order_invoice', - 'order_invoice_payment', - 'order_invoice_tax', - 'order_payment', - 'order_return', - 'order_return_detail', - 'order_slip', - 'order_slip_detail', - 'page', - 'pagenotfound', - 'page_type', - 'page_viewed', - 'referrer_cache', - 'sekeyword', - ); - foreach ($tables as $table) - $db->execute('TRUNCATE TABLE `'._DB_PREFIX_.bqSQL($table).'`'); - $db->execute('DELETE FROM `'._DB_PREFIX_.'address` WHERE id_customer > 0'); - $db->execute('UPDATE `'._DB_PREFIX_.'employee` SET `id_last_order` = 0,`id_last_customer_message` = 0,`id_last_customer` = 0'); - - break; - } - self::clearAllCaches(); - } - - // Not called yet - public static function cleanAndOptimize() - { - Db::getInstance()->execute('DELETE FROM `'._DB_PREFIX_.'cart` WHERE id_cart NOT IN (SELECT id_cart FROM `'._DB_PREFIX_.'cart`) AND date_add < "'.pSQL(date('Y-m-d', strtotime('-1 month'))).'"'); - } - - protected static function bulle($array) - { - $sorted = false; - $size = count($array); - while (!$sorted) - { - $sorted = true; - for ($i = 0; $i < $size - 1; ++$i) - for ($j = $i + 1; $j < $size; ++$j) - if ($array[$i][2] == $array[$j][0]) - { - $tmp = $array[$i]; - $array[$i] = $array[$j]; - $array[$j] = $tmp; - $sorted = false; - } - } - return $array; - } - - protected static function clearAllCaches() - { - $index = file_exists(_PS_TMP_IMG_DIR_.'index.php') ? file_get_contents(_PS_TMP_IMG_DIR_.'index.php') : ''; - Tools::deleteDirectory(_PS_TMP_IMG_DIR_, false); - file_put_contents(_PS_TMP_IMG_DIR_.'index.php', $index); - Context::getContext()->smarty->clearAllCache(); - } - - public function renderForm() - { - $fields_form_1 = array( - 'form' => array( - 'legend' => array( - 'title' => $this->l('Catalog'), - 'icon' => 'icon-cogs' - ), - 'description' => $this->l('I understand that all the catalog data will be removed without possible rollback: products, features, categories, tags, images, prices, attachments, scenes, stocks, attribute groups and values, manufacturers, suppliers…'), - 'submit' => array( - 'title' => $this->l('Delete catalog'), - 'class' => 'btn btn-default', - 'name' => 'submitTruncateCatalog', - 'id' => 'submitTruncateCatalog', - ) - ), - ); - - $fields_form_2 = array( - 'form' => array( - 'legend' => array( - 'title' => $this->l('Orders and customers'), - 'icon' => 'icon-cogs' - ), - 'description' => $this->l('I understand that all the orders and customers will be removed without possible rollback: customers, carts, orders, connections, guests, messages, stats...'), - 'submit' => array( - 'title' => $this->l('Delete orders & customers'), - 'class' => 'btn btn-default', - 'name' => 'submitTruncateSales', - 'id' => 'submitTruncateSales', - ) - ), - ); - - $fields_form_3 = array( - 'form' => array( - 'legend' => array( - 'title' => $this->l('Functional integrity constraints'), - 'icon' => 'icon-cogs' - ), - 'submit' => array( - 'title' => $this->l('Check & fix'), - 'class' => 'btn btn-default', - 'name' => 'submitCheckAndFix', - ) - ), - ); - - $helper = new HelperForm(); - $helper->show_toolbar = false; - $helper->table = $this->table; - $lang = new Language((int)Configuration::get('PS_LANG_DEFAULT')); - $helper->default_form_language = $lang->id; - $helper->allow_employee_form_lang = Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG') ? Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG') : 0; - $this->fields_form = array(); - $helper->id = (int)Tools::getValue('id_carrier'); - $helper->identifier = $this->identifier; - $helper->submit_action = 'btnSubmit'; - $helper->currentIndex = $this->context->link->getAdminLink('AdminModules', false).'&configure='.$this->name.'&tab_module='.$this->tab.'&module_name='.$this->name; - $helper->token = Tools::getAdminTokenLite('AdminModules'); - $helper->tpl_vars = array( - 'fields_value' => $this->getConfigFieldsValues(), - 'languages' => $this->context->controller->getLanguages(), - 'id_language' => $this->context->language->id - ); - - return $helper->generateForm(array($fields_form_1, $fields_form_2, $fields_form_3)); - } - - public function getConfigFieldsValues() - { - return array('value' => ''); - } -} diff --git a/modules/pscleaner/translations/index.php b/modules/pscleaner/translations/index.php deleted file mode 100644 index 3f6561f72..000000000 --- a/modules/pscleaner/translations/index.php +++ /dev/null @@ -1,35 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); - -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); - -header("Location: ../"); -exit; \ No newline at end of file diff --git a/modules/referralprogram/ReferralProgramModule.php b/modules/referralprogram/ReferralProgramModule.php deleted file mode 100644 index 47ad866e8..000000000 --- a/modules/referralprogram/ReferralProgramModule.php +++ /dev/null @@ -1,192 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -if (!defined('_PS_VERSION_')) - exit; - -class ReferralProgramModule extends ObjectModel -{ - public $id_sponsor; - public $email; - public $lastname; - public $firstname; - public $id_customer; - public $id_cart_rule; - public $id_cart_rule_sponsor; - public $date_add; - public $date_upd; - - /** - * @see ObjectModel::$definition - */ - public static $definition = array( - 'table' => 'referralprogram', - 'primary' => 'id_referralprogram', - 'fields' => array( - 'id_sponsor' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true), - 'email' => array('type' => self::TYPE_STRING, 'validate' => 'isEmail', 'required' => true, 'size' => 255), - 'lastname' => array('type' => self::TYPE_STRING, 'validate' => 'isName', 'required' => true, 'size' => 128), - 'firstname' => array('type' => self::TYPE_STRING, 'validate' => 'isName', 'required' => true, 'size' => 128), - 'id_customer' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'), - 'id_cart_rule' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'), - 'id_cart_rule_sponsor' =>array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'), - 'date_add' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'), - 'date_upd' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'), - ), - ); - - public static function getDiscountPrefix() - { - return 'SP'; - } - - public function registerDiscountForSponsor($id_currency) - { - if ((int)$this->id_cart_rule_sponsor > 0) - return false; - return $this->registerDiscount((int)$this->id_sponsor, 'sponsor', (int)$id_currency); - } - - public function registerDiscountForSponsored($id_currency) - { - if (!(int)$this->id_customer OR (int)$this->id_cart_rule > 0) - return false; - return $this->registerDiscount((int)$this->id_customer, 'sponsored', (int)$id_currency); - } - - public function registerDiscount($id_customer, $register = false, $id_currency = 0) - { - $configurations = Configuration::getMultiple(array('REFERRAL_DISCOUNT_TYPE', 'REFERRAL_PERCENTAGE', 'REFERRAL_DISCOUNT_VALUE_'.(int)$id_currency)); - - $cartRule = new CartRule(); - if ($configurations['REFERRAL_DISCOUNT_TYPE'] == Discount::PERCENT) - $cartRule->reduction_percent = (float)$configurations['REFERRAL_PERCENTAGE']; - elseif ($configurations['REFERRAL_DISCOUNT_TYPE'] == Discount::AMOUNT AND isset($configurations['REFERRAL_DISCOUNT_VALUE_'.(int)$id_currency])) - $cartRule->reduction_amount = (float)$configurations['REFERRAL_DISCOUNT_VALUE_'.(int)$id_currency]; - - $cartRule->quantity = 1; - $cartRule->quantity_per_user = 1; - $cartRule->date_from = date('Y-m-d H:i:s', time()); - $cartRule->date_to = date('Y-m-d H:i:s', time() + 31536000); // + 1 year - $cartRule->code = $this->getDiscountPrefix().Tools::passwdGen(6); - $cartRule->name = Configuration::getInt('REFERRAL_DISCOUNT_DESCRIPTION'); - if (empty($cartRule->name)) - $cartRule->name = 'Referral reward'; - $cartRule->id_customer = (int)$id_customer; - $cartRule->reduction_currency = (int)$id_currency; - - if ($cartRule->add()) - { - if ($register != false) - { - if ($register == 'sponsor') - $this->id_cart_rule_sponsor = (int)$cartRule->id; - elseif ($register == 'sponsored') - $this->id_cart_rule = (int)$cartRule->id; - return $this->save(); - } - return true; - } - return false; - } - - /** - * Return sponsored friends - * - * @return array Sponsor - */ - public static function getSponsorFriend($id_customer, $restriction = false) - { - if (!(int)($id_customer)) - return array(); - - $query = ' - SELECT s.* - FROM `'._DB_PREFIX_.'referralprogram` s - WHERE s.`id_sponsor` = '.(int)$id_customer; - if ($restriction) - { - if ($restriction == 'pending') - $query.= ' AND s.`id_customer` = 0'; - elseif ($restriction == 'subscribed') - $query.= ' AND s.`id_customer` != 0'; - } - - return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($query); - } - - /** - * Return if a customer is sponsorised - * - * @return boolean - */ - public static function isSponsorised($id_customer, $getId=false) - { - $result = Db::getInstance()->getRow(' - SELECT s.`id_referralprogram` - FROM `'._DB_PREFIX_.'referralprogram` s - WHERE s.`id_customer` = '.(int)$id_customer); - - if (isset($result['id_referralprogram']) AND $getId === true) - return (int)$result['id_referralprogram']; - - return isset($result['id_referralprogram']); - } - - public static function isSponsorFriend($id_sponsor, $id_friend) - { - if (!(int)($id_sponsor) OR !(int)($id_friend)) - return false; - - $result = Db::getInstance()->getRow(' - SELECT s.`id_referralprogram` - FROM `'._DB_PREFIX_.'referralprogram` s - WHERE s.`id_sponsor` = '.(int)($id_sponsor).' AND s.`id_referralprogram` = '.(int)($id_friend)); - - return isset($result['id_referralprogram']); - } - - /** - * Return if an email is already register - * - * @return boolean OR int idReferralProgram - */ - public static function isEmailExists($email, $getId = false, $checkCustomer = true) - { - if (empty($email) OR !Validate::isEmail($email)) - die (Tools::displayError('The email address is invalid.')); - - if ($checkCustomer === true AND Customer::customerExists($email)) - return false; - $result = Db::getInstance()->getRow(' - SELECT s.`id_referralprogram` - FROM `'._DB_PREFIX_.'referralprogram` s - WHERE s.`email` = \''.pSQL($email).'\''); - if ($getId) - return (int)$result['id_referralprogram']; - return isset($result['id_referralprogram']); - } -} diff --git a/modules/referralprogram/config.xml b/modules/referralprogram/config.xml deleted file mode 100755 index 82fa274d4..000000000 --- a/modules/referralprogram/config.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - referralprogram - - - - - - All sponsors and friends will be deleted. Are you sure you want to uninstall this module? - 1 - 1 - - \ No newline at end of file diff --git a/modules/referralprogram/controllers/front/email.php b/modules/referralprogram/controllers/front/email.php deleted file mode 100755 index 0a9a3b45c..000000000 --- a/modules/referralprogram/controllers/front/email.php +++ /dev/null @@ -1,72 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -/** - * @since 1.5.0 - */ -class ReferralprogramEmailModuleFrontController extends ModuleFrontController -{ - public $content_only = true; - - public $display_header = false; - - public $display_footer = false; - - /** - * @see FrontController::initContent() - */ - public function initContent() - { - parent::initContent(); - $shop_name = htmlentities(Configuration::get('PS_SHOP_NAME'), NULL, 'utf-8'); - $shop_url = Tools::getHttpHost(true, true); - $customer = Context::getContext()->customer; - - if (!preg_match("#.*\.html$#Ui", Tools::getValue('mail')) OR !preg_match("#.*\.html$#Ui", Tools::getValue('mail'))) - die(Tools::redirect()); - - $file = file_get_contents(dirname(__FILE__).'/../../mails/'.strval(preg_replace('#\.{2,}#', '.', Tools::getValue('mail')))); - - $file = str_replace('{shop_name}', $shop_name, $file); - $file = str_replace('{shop_url}', $shop_url.__PS_BASE_URI__, $file); - $file = str_replace('{shop_logo}', $shop_url._PS_IMG_.'logo.jpg', $file); - $file = str_replace('{firstname}', $customer->firstname, $file); - $file = str_replace('{lastname}', $customer->lastname, $file); - $file = str_replace('{email}', $customer->email, $file); - $file = str_replace('{firstname_friend}', 'XXXXX', $file); - $file = str_replace('{lastname_friend}', 'xxxxxx', $file); - $file = str_replace('{link}', 'authentication.php?create_account=1', $file); - $discount_type = (int)(Configuration::get('REFERRAL_DISCOUNT_TYPE')); - if ($discount_type == 1) - $file = str_replace('{discount}', Discount::display((float)(Configuration::get('REFERRAL_PERCENTAGE')), $discount_type, new Currency($this->context->currency->id)), $file); - else - $file = str_replace('{discount}', Discount::display((float)(Configuration::get('REFERRAL_DISCOUNT_VALUE_' . $this->context->currency->id)), $discount_type, new Currency($this->context->currency->id)), $file); - - $this->context->smarty->assign(array('content' => $file)); - - $this->setTemplate('email.tpl'); - } -} \ No newline at end of file diff --git a/modules/referralprogram/controllers/front/index.php b/modules/referralprogram/controllers/front/index.php deleted file mode 100644 index 3f6561f72..000000000 --- a/modules/referralprogram/controllers/front/index.php +++ /dev/null @@ -1,35 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); - -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); - -header("Location: ../"); -exit; \ No newline at end of file diff --git a/modules/referralprogram/controllers/front/program.php b/modules/referralprogram/controllers/front/program.php deleted file mode 100755 index 68cf153b1..000000000 --- a/modules/referralprogram/controllers/front/program.php +++ /dev/null @@ -1,208 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -/** - * @since 1.5.0 - */ -include_once(dirname(__FILE__).'../../../ReferralProgramModule.php'); -include_once(dirname(__FILE__).'../../../referralprogram.php'); - -class ReferralprogramProgramModuleFrontController extends ModuleFrontController -{ - - public function init() - { - if (!$this->context->customer->isLogged()) - Tools::redirect('index.php?controller=authentication&back=modules/referralprogram/referralprogram-program.php'); - parent::init(); - } - - public function setMedia() - { - parent::setMedia(); - $this->addJqueryPlugin(array('thickbox', 'idTabs')); - } - - - /** - * @see FrontController::initContent() - */ - public function initContent() - { - parent::initContent(); - - // get discount value (ready to display) - $discount_type = (int)(Configuration::get('REFERRAL_DISCOUNT_TYPE')); - if ($discount_type == 1) - $discount = Discount::display((float)(Configuration::get('REFERRAL_PERCENTAGE')), $discount_type, new Currency($this->context->currency->id)); - else - $discount = Discount::display((float)(Configuration::get('REFERRAL_DISCOUNT_VALUE_'.(int)($this->context->currency->id))), $discount_type, new Currency($this->context->currency->id)); - - $activeTab = 'sponsor'; - $error = false; - - // Mailing invitation to friend sponsor - $invitation_sent = false; - $nbInvitation = 0; - if (Tools::isSubmit('submitSponsorFriends') AND Tools::getValue('friendsEmail') AND sizeof($friendsEmail = Tools::getValue('friendsEmail')) >= 1) - { - $activeTab = 'sponsor'; - if (!Tools::getValue('conditionsValided')) - $error = 'conditions not valided'; - else - { - $friendsLastName = Tools::getValue('friendsLastName'); - $friendsFirstName = Tools::getValue('friendsFirstName'); - $mails_exists = array(); - foreach ($friendsEmail AS $key => $friendEmail) - { - $friendEmail = strval($friendEmail); - $friendLastName = strval($friendsLastName[$key]); - $friendFirstName = strval($friendsFirstName[$key]); - - if (empty($friendEmail) AND empty($friendLastName) AND empty($friendFirstName)) - continue; - elseif (empty($friendEmail) OR !Validate::isEmail($friendEmail)) - $error = 'email invalid'; - elseif (empty($friendFirstName) OR empty($friendLastName) OR !Validate::isName($friendLastName) OR !Validate::isName($friendFirstName)) - $error = 'name invalid'; - elseif (ReferralProgramModule::isEmailExists($friendEmail) OR Customer::customerExists($friendEmail)) - $mails_exists[] = $friendEmail; - else - { - $referralprogram = new ReferralProgramModule(); - $referralprogram->id_sponsor = (int)($this->context->customer->id); - $referralprogram->firstname = $friendFirstName; - $referralprogram->lastname = $friendLastName; - $referralprogram->email = $friendEmail; - if (!$referralprogram->validateFields(false)) - $error = 'name invalid'; - else - { - if ($referralprogram->save()) - { - if (Configuration::get('PS_CIPHER_ALGORITHM')) - $cipherTool = new Rijndael(_RIJNDAEL_KEY_, _RIJNDAEL_IV_); - else - $cipherTool = new Blowfish(_COOKIE_KEY_, _COOKIE_IV_); - $vars = array( - '{email}' => strval($this->context->customer->email), - '{lastname}' => strval($this->context->customer->lastname), - '{firstname}' => strval($this->context->customer->firstname), - '{email_friend}' => $friendEmail, - '{lastname_friend}' => $friendLastName, - '{firstname_friend}' => $friendFirstName, - '{link}' => Context::getContext()->link->getPageLink('authentication', true, Context::getContext()->language->id, 'create_account=1&sponsor='.urlencode($cipherTool->encrypt($referralprogram->id.'|'.$referralprogram->email.'|')), false), - '{discount}' => $discount); - Mail::Send((int)$this->context->language->id, 'referralprogram-invitation', Mail::l('Referral Program', (int)$this->context->language->id), $vars, $friendEmail, $friendFirstName.' '.$friendLastName, strval(Configuration::get('PS_SHOP_EMAIL')), strval(Configuration::get('PS_SHOP_NAME')), NULL, NULL, dirname(__FILE__).'/../../mails/'); - $invitation_sent = true; - $nbInvitation++; - $activeTab = 'pending'; - } - else - $error = 'cannot add friends'; - } - } - if ($error) - break; - } - if ($nbInvitation > 0) - unset($_POST); - //Not to stop the sending of e-mails in case of doubloon - if(sizeof($mails_exists)) - $error = 'email exists'; - } - } - - // Mailing revive - $revive_sent = false; - $nbRevive = 0; - if (Tools::isSubmit('revive')) - { - $activeTab = 'pending'; - if (Tools::getValue('friendChecked') AND sizeof($friendsChecked = Tools::getValue('friendChecked')) >= 1) - { - foreach ($friendsChecked as $key => $friendChecked) - { - if (ReferralProgramModule::isSponsorFriend((int)($this->context->customer->id), (int)($friendChecked))) - { - if (Configuration::get('PS_CIPHER_ALGORITHM')) - $cipherTool = new Rijndael(_RIJNDAEL_KEY_, _RIJNDAEL_IV_); - else - $cipherTool = new Blowfish(_COOKIE_KEY_, _COOKIE_IV_); - $referralprogram = new ReferralProgramModule((int)($key)); - $vars = array( - '{email}' => $this->context->customer->email, - '{lastname}' => $this->context->customer->lastname, - '{firstname}' => $this->context->customer->firstname, - '{email_friend}' => $referralprogram->email, - '{lastname_friend}' => $referralprogram->lastname, - '{firstname_friend}' => $referralprogram->firstname, - '{link}' => Context::getContext()->link->getPageLink('authentication', true, Context::getContext()->language->id, 'create_account=1&sponsor='.urlencode($cipherTool->encrypt($referralprogram->id.'|'.$referralprogram->email.'|')), false), - '{discount}' => $discount - ); - $referralprogram->save(); - Mail::Send((int)$this->context->language->id, 'referralprogram-invitation', Mail::l('Referral Program', (int)$this->context->language->id), $vars, $referralprogram->email, $referralprogram->firstname.' '.$referralprogram->lastname, strval(Configuration::get('PS_SHOP_EMAIL')), strval(Configuration::get('PS_SHOP_NAME')), NULL, NULL, dirname(__FILE__).'/../../mails/'); - $revive_sent = true; - $nbRevive++; - } - } - } - else - $error = 'no revive checked'; - } - - $customer = new Customer((int)($this->context->customer->id)); - $stats = $customer->getStats(); - - $orderQuantity = (int)(Configuration::get('REFERRAL_ORDER_QUANTITY')); - $canSendInvitations = false; - - if ((int)($stats['nb_orders']) >= $orderQuantity) - $canSendInvitations = true; - - $discountInPercent = Tools::getValue('discount_type', Configuration::get('REFERRAL_DISCOUNT_TYPE')) == 1; - - // Smarty display - $this->context->smarty->assign(array( - 'activeTab' => $activeTab, - 'discount' => $discount, - 'orderQuantity' => $orderQuantity, - 'canSendInvitations' => $canSendInvitations, - 'nbFriends' => (int)(Configuration::get('REFERRAL_NB_FRIENDS')), - 'error' => $error, - 'invitation_sent' => $invitation_sent, - 'nbInvitation' => $nbInvitation, - 'pendingFriends' => ReferralProgramModule::getSponsorFriend((int)($this->context->customer->id), 'pending'), - 'revive_sent' => $revive_sent, - 'nbRevive' => $nbRevive, - 'subscribeFriends' => ReferralProgramModule::getSponsorFriend((int)($this->context->customer->id), 'subscribed'), - 'mails_exists' => (isset($mails_exists) ? $mails_exists : array()), - 'currencySign' => ($discountInPercent ? '%' : $this->context->currency->sign) - )); - $this->setTemplate('program.tpl'); - } -} diff --git a/modules/referralprogram/controllers/front/rules.php b/modules/referralprogram/controllers/front/rules.php deleted file mode 100755 index fe121f18f..000000000 --- a/modules/referralprogram/controllers/front/rules.php +++ /dev/null @@ -1,57 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -/** - * @since 1.5.0 - */ -class ReferralprogramRulesModuleFrontController extends ModuleFrontController -{ - public $content_only = true; - - public $display_header = false; - - public $display_footer = false; - - /** - * @see FrontController::initContent() - */ - public function initContent() - { - parent::initContent(); - $xmlFile = _PS_MODULE_DIR_.'referralprogram/referralprogram.xml'; - if (file_exists($xmlFile)) - { - if ($xml = @simplexml_load_file($xmlFile)) - { - $this->context->smarty->assign(array( - 'xml' => $xml, - 'paragraph' => 'paragraph_'.$this->context->language->id - )); - } - } - $this->setTemplate('rules.tpl'); - } -} \ No newline at end of file diff --git a/modules/referralprogram/controllers/index.php b/modules/referralprogram/controllers/index.php deleted file mode 100644 index 3f6561f72..000000000 --- a/modules/referralprogram/controllers/index.php +++ /dev/null @@ -1,35 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); - -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); - -header("Location: ../"); -exit; \ No newline at end of file diff --git a/modules/referralprogram/index.php b/modules/referralprogram/index.php deleted file mode 100644 index 3f6561f72..000000000 --- a/modules/referralprogram/index.php +++ /dev/null @@ -1,35 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); - -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); - -header("Location: ../"); -exit; \ No newline at end of file diff --git a/modules/referralprogram/logo.gif b/modules/referralprogram/logo.gif deleted file mode 100644 index 85de79228..000000000 Binary files a/modules/referralprogram/logo.gif and /dev/null differ diff --git a/modules/referralprogram/logo.png b/modules/referralprogram/logo.png deleted file mode 100755 index be8cf761e..000000000 Binary files a/modules/referralprogram/logo.png and /dev/null differ diff --git a/modules/referralprogram/mails/en/index.php b/modules/referralprogram/mails/en/index.php deleted file mode 100644 index 3f6561f72..000000000 --- a/modules/referralprogram/mails/en/index.php +++ /dev/null @@ -1,35 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); - -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); - -header("Location: ../"); -exit; \ No newline at end of file diff --git a/modules/referralprogram/mails/en/referralprogram-congratulations.html b/modules/referralprogram/mails/en/referralprogram-congratulations.html deleted file mode 100644 index b231066a4..000000000 --- a/modules/referralprogram/mails/en/referralprogram-congratulations.html +++ /dev/null @@ -1,117 +0,0 @@ - - - - - - - Message from {shop_name} - - - - - - - - - - - - -
      - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - Congratulations! -
    - - Your referred friend {sponsored_firstname} {sponsored_lastname} has placed his or her first order on {shop_name}!

    - We are pleased to offer you a voucher worth {discount_display} (voucher # {discount_name}) that you can use on your next order.
    -
    - Best regards, -
    -
     
    - - \ No newline at end of file diff --git a/modules/referralprogram/mails/en/referralprogram-congratulations.txt b/modules/referralprogram/mails/en/referralprogram-congratulations.txt deleted file mode 100644 index 539cbc2f3..000000000 --- a/modules/referralprogram/mails/en/referralprogram-congratulations.txt +++ /dev/null @@ -1,17 +0,0 @@ - -[{shop_url}] - -Congratulations! - -Your referred friend {sponsored_firstname} {sponsored_lastname} has -placed his or her first order on {shop_name} -[{shop_url}]! - -We are pleased to offer you a voucher worth {discount_display} -(VOUCHER # {discount_name}) that you can use on your next order. - -Best regards, - -{shop_name} [{shop_url}] powered by -PrestaShop(tm) [http://www.prestashop.com/] - diff --git a/modules/referralprogram/mails/en/referralprogram-invitation.html b/modules/referralprogram/mails/en/referralprogram-invitation.html deleted file mode 100644 index 86e212059..000000000 --- a/modules/referralprogram/mails/en/referralprogram-invitation.html +++ /dev/null @@ -1,119 +0,0 @@ - - - - - - - Message from {shop_name} - - - - - - - - - - - - -
      - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - {firstname_friend} {lastname_friend}, join us! -
    - - Your friend {firstname} {lastname} wants to refer you on {shop_name}!

    - We are pleased to offer you a voucher worth {discount_display} (voucher # {discount_name}) that you can use on your next order. - Get referred and earn a discount voucher of {discount}! It's very easy to sign up. Just click here! -
    -
    - When signing up, don't forget to provide the e-mail address of your referring friend: {email}.

    - Best regards,
    -
     
    - - \ No newline at end of file diff --git a/modules/referralprogram/mails/en/referralprogram-invitation.txt b/modules/referralprogram/mails/en/referralprogram-invitation.txt deleted file mode 100644 index 85bd61f42..000000000 --- a/modules/referralprogram/mails/en/referralprogram-invitation.txt +++ /dev/null @@ -1,21 +0,0 @@ - -[{shop_url}] - -{firstname_friend} {lastname_friend}, join us! - -Your friend {firstname} {lastname} wants to refer you on {shop_name} -[{shop_url}]! - -We are pleased to offer you a voucher worth {discount_display} -(VOUCHER # {discount_name}) that you can use on your next order. Get -referred and earn a discount voucher of {discount}! It's very easy to -sign up. Just click here! [{link}] - -When signing up, don't forget to provide the e-mail address of your -referring friend: {email}. - -Best regards, - -{shop_name} [{shop_url}] powered by -PrestaShop(tm) [http://www.prestashop.com/] - diff --git a/modules/referralprogram/mails/en/referralprogram-voucher.html b/modules/referralprogram/mails/en/referralprogram-voucher.html deleted file mode 100644 index 0004d802d..000000000 --- a/modules/referralprogram/mails/en/referralprogram-voucher.html +++ /dev/null @@ -1,112 +0,0 @@ - - - - - - - Message from {shop_name} - - - - - - - - - - - - -
      - - - - - - - - - - - - - - - - - - - - - -
    - Hi {firstname} {lastname}, -
    -

    - Referral Program

    - - We have created a voucher in your name for referring a friend.
    - Here is the code of your voucher: {voucher_num}, with an amount of {voucher_amount}.

    - Simply copy/paste this code during the payment process for your next order.
    -
    -
     
    - - \ No newline at end of file diff --git a/modules/referralprogram/mails/en/referralprogram-voucher.txt b/modules/referralprogram/mails/en/referralprogram-voucher.txt deleted file mode 100644 index de85dc5fe..000000000 --- a/modules/referralprogram/mails/en/referralprogram-voucher.txt +++ /dev/null @@ -1,18 +0,0 @@ - -[{shop_url}] - -Hi {firstname} {lastname}, - -Referral Program - -We have created a voucher in your name for referring a friend. - -Here is the code of your voucher: {voucher_num}, with an amount of -{voucher_amount}. - -Simply copy/paste this code during the payment process for your next -order. - -{shop_name} [{shop_url}] powered by -PrestaShop(tm) [http://www.prestashop.com/] - diff --git a/modules/referralprogram/mails/index.php b/modules/referralprogram/mails/index.php deleted file mode 100644 index 6f5ff3bab..000000000 --- a/modules/referralprogram/mails/index.php +++ /dev/null @@ -1,35 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); - -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); - -header("Location: ../"); -exit; \ No newline at end of file diff --git a/modules/referralprogram/referralprogram.gif b/modules/referralprogram/referralprogram.gif deleted file mode 100644 index 52029c51c..000000000 Binary files a/modules/referralprogram/referralprogram.gif and /dev/null differ diff --git a/modules/referralprogram/referralprogram.php b/modules/referralprogram/referralprogram.php deleted file mode 100644 index 641e54340..000000000 --- a/modules/referralprogram/referralprogram.php +++ /dev/null @@ -1,678 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -if (!defined('_PS_VERSION_')) - exit; - -class ReferralProgram extends Module -{ - public function __construct() - { - $this->name = 'referralprogram'; - $this->tab = 'advertising_marketing'; - $this->version = '1.5.2'; - $this->author = 'PrestaShop'; - - $this->bootstrap = true; - parent::__construct(); - - $this->confirmUninstall = $this->l('All sponsors and friends will be deleted. Are you sure you want to uninstall this module?'); - $this->displayName = $this->l('Customer referral program'); - $this->description = $this->l('Integrate a referral program system into your shop.'); - if (Configuration::get('REFERRAL_DISCOUNT_TYPE') == 1 AND !Configuration::get('REFERRAL_PERCENTAGE')) - $this->warning = $this->l('Please specify an amount for referral program vouchers.'); - - if ($this->id) - { - $this->_configuration = Configuration::getMultiple(array('REFERRAL_NB_FRIENDS', 'REFERRAL_ORDER_QUANTITY', 'REFERRAL_DISCOUNT_TYPE', 'REFERRAL_DISCOUNT_VALUE')); - $this->_configuration['REFERRAL_DISCOUNT_DESCRIPTION'] = Configuration::getInt('REFERRAL_DISCOUNT_DESCRIPTION'); - $this->_xmlFile = dirname(__FILE__).'/referralprogram.xml'; - } - } - - public function install() - { - $defaultTranslations = array('en' => 'Referral reward', 'fr' => 'Récompense parrainage'); - $desc = array((int)Configuration::get('PS_LANG_DEFAULT') => $this->l('Referral reward')); - foreach (Language::getLanguages() AS $language) - if (isset($defaultTranslations[$language['iso_code']])) - $desc[(int)$language['id_lang']] = $defaultTranslations[$language['iso_code']]; - - if (!parent::install() OR !$this->installDB() OR !Configuration::updateValue('REFERRAL_DISCOUNT_DESCRIPTION', $desc) - OR !Configuration::updateValue('REFERRAL_ORDER_QUANTITY', 1) OR !Configuration::updateValue('REFERRAL_DISCOUNT_TYPE', 2) - OR !Configuration::updateValue('REFERRAL_NB_FRIENDS', 5) OR !$this->registerHook('shoppingCart') - OR !$this->registerHook('orderConfirmation') OR !$this->registerHook('updateOrderStatus') - OR !$this->registerHook('adminCustomers') OR !$this->registerHook('createAccount') - OR !$this->registerHook('createAccountForm') OR !$this->registerHook('customerAccount')) - return false; - - /* Define a default value for fixed amount vouchers, for each currency */ - foreach (Currency::getCurrencies() AS $currency) - Configuration::updateValue('REFERRAL_DISCOUNT_VALUE_'.(int)($currency['id_currency']), 5); - - /* Define a default value for the percentage vouchers */ - Configuration::updateValue('REFERRAL_PERCENTAGE', 5); - - /* This hook is optional */ - $this->registerHook('displayMyAccountBlock'); - - return true; - } - - public function installDB() - { - return Db::getInstance()->execute(' - CREATE TABLE `'._DB_PREFIX_.'referralprogram` ( - `id_referralprogram` INT UNSIGNED NOT NULL AUTO_INCREMENT, - `id_sponsor` INT UNSIGNED NOT NULL, - `email` VARCHAR(255) NOT NULL, - `lastname` VARCHAR(128) NOT NULL, - `firstname` VARCHAR(128) NOT NULL, - `id_customer` INT UNSIGNED DEFAULT NULL, - `id_cart_rule` INT UNSIGNED DEFAULT NULL, - `id_cart_rule_sponsor` INT UNSIGNED DEFAULT NULL, - `date_add` DATETIME NOT NULL, - `date_upd` DATETIME NOT NULL, - PRIMARY KEY (`id_referralprogram`), - UNIQUE KEY `index_unique_referralprogram_email` (`email`) - ) ENGINE='._MYSQL_ENGINE_.' DEFAULT CHARSET=utf8 ;'); - } - - public function uninstall() - { - $result = true; - foreach (Currency::getCurrencies() AS $currency) - $result = $result AND Configuration::deleteByName('REFERRAL_DISCOUNT_VALUE_'.(int)($currency['id_currency'])); - if (!parent::uninstall() OR !$this->uninstallDB() OR !$this->removeMail() OR !$result - OR !Configuration::deleteByName('REFERRAL_PERCENTAGE') OR !Configuration::deleteByName('REFERRAL_ORDER_QUANTITY') - OR !Configuration::deleteByName('REFERRAL_DISCOUNT_TYPE') OR !Configuration::deleteByName('REFERRAL_NB_FRIENDS') - OR !Configuration::deleteByName('REFERRAL_DISCOUNT_DESCRIPTION')) - return false; - return true; - } - - public function uninstallDB() - { - return Db::getInstance()->execute('DROP TABLE `'._DB_PREFIX_.'referralprogram`;'); - } - - public function removeMail() - { - $langs = Language::getLanguages(false); - foreach ($langs AS $lang) - foreach (array('referralprogram-congratulations', 'referralprogram-invitation', 'referralprogram-voucher') AS $name) - foreach (array('txt', 'html') AS $ext) - { - $file = _PS_MAIL_DIR_.$lang['iso_code'].'/'.$name.'.'.$ext; - if (file_exists($file) AND !@unlink($file)) - $this->_errors[] = $this->l('Cannot delete this file:').' '.$file; - } - return true; - } - - public static function displayDiscount($discountValue, $discountType, $currency = false) - { - if ((float)$discountValue AND (int)$discountType) - { - if ($discountType == 1) - return $discountValue.chr(37); // ASCII #37 --> % (percent) - elseif ($discountType == 2) - return Tools::displayPrice($discountValue, $currency); - } - return ''; // return a string because it's a display method - } - - private function _postProcess() - { - Configuration::updateValue('REFERRAL_ORDER_QUANTITY', (int)(Tools::getValue('order_quantity'))); - foreach (Tools::getValue('discount_value') AS $id_currency => $discount_value) - Configuration::updateValue('REFERRAL_DISCOUNT_VALUE_'.(int)($id_currency), (float)($discount_value)); - Configuration::updateValue('REFERRAL_DISCOUNT_TYPE', (int)(Tools::getValue('discount_type'))); - Configuration::updateValue('REFERRAL_NB_FRIENDS', (int)(Tools::getValue('nb_friends'))); - Configuration::updateValue('REFERRAL_PERCENTAGE', (int)(Tools::getValue('discount_value_percentage'))); - foreach (Language::getLanguages(false) as $lang) - Configuration::updateValue('REFERRAL_DISCOUNT_DESCRIPTION', array($lang['id_lang'] => Tools::getValue('discount_description_'.(int)$lang['id_lang']))); - - $this->_html .= $this->displayConfirmation($this->l('Configuration updated.')); - } - - private function _postValidation() - { - $this->_errors = array(); - if (!(int)(Tools::getValue('order_quantity')) OR Tools::getValue('order_quantity') < 0) - $this->_errors[] = $this->displayError($this->l('Order quantity is required/invalid.')); - if (!is_array(Tools::getValue('discount_value'))) - $this->_errors[] = $this->displayError($this->l('Discount value is invalid.')); - foreach (Tools::getValue('discount_value') AS $id_currency => $discount_value) - if ($discount_value == '') - $this->_errors[] = $this->displayError(sprintf($this->l('Discount value for the currency #%d is empty.'), $id_currency)); - elseif (!Validate::isUnsignedFloat($discount_value)) - $this->_errors[] = $this->displayError(sprintf($this->l('Discount value for the currency #%d is invalid.'), $id_currency)); - if (!(int)(Tools::getValue('discount_type')) OR Tools::getValue('discount_type') < 1 OR Tools::getValue('discount_type') > 2) - $this->_errors[] = $this->displayError($this->l('Discount type is required/invalid.')); - if (!(int)(Tools::getValue('nb_friends')) OR Tools::getValue('nb_friends') < 0) - $this->_errors[] = $this->displayError($this->l('Number of friends is required/invalid.')); - if (!(int)(Tools::getValue('discount_value_percentage')) OR (int)(Tools::getValue('discount_value_percentage')) < 0 OR (int)(Tools::getValue('discount_value_percentage')) > 100) - $this->_errors[] = $this->displayError($this->l('Discount percentage is required/invalid.')); - } - - private function _writeXml() - { - $forbiddenKey = array('submitUpdate'); // Forbidden key - - // Generate new XML data - $newXml = '<'.'?xml version=\'1.0\' encoding=\'utf-8\' ?>'."\n"; - $newXml .= ''."\n"; - $newXml .= "\t".''; - // Making body data - foreach (Language::getLanguages(false) as $lang) - { - if ($line = $this->putContent($newXml, 'body_paragraph_'.(int)$lang['id_lang'], Tools::getValue('body_paragraph_'.(int)$lang['id_lang']), $forbiddenKey, 'body')) - $newXml .= $line; - } - - $newXml .= "\n\t".''."\n"; - $newXml .= ''."\n"; - - /* write it into the editorial xml file */ - if ($fd = @fopen($this->_xmlFile, 'w')) - { - if (!@fwrite($fd, $newXml)) - $this->_html .= $this->displayError($this->l('Unable to write to the xml file.')); - if (!@fclose($fd)) - $this->_html .= $this->displayError($this->l('Cannot close the xml file.')); - } - else - $this->_html .= $this->displayError($this->l('Unable to update the xml file. Please check the xml file\'s writing permissions.')); - } - - public function putContent($xml_data, $key, $field, $forbidden, $section) - { - foreach ($forbidden AS $line) - if ($key == $line) - return 0; - if (!preg_match('/^'.$section.'_/i', $key)) - return 0; - $key = preg_replace('/^'.$section.'_/i', '', $key); - $field = Tools::htmlentitiesDecodeUTF8(htmlspecialchars($field)); - if (!$field) - return 0; - return ("\n\t\t".'<'.$key.'>'); - } - - public function getContent() - { - if (Tools::isSubmit('submitReferralProgram')) - { - $this->_postValidation(); - if (!sizeof($this->_errors)) - $this->_postProcess(); - else - foreach ($this->_errors AS $err) - $this->_html .= $err; - } - elseif (Tools::isSubmit('submitText')) - $this->_writeXml(); - - $this->_html .= $this->renderForm(); - - return $this->_html; - } - - /** - * Hook call when cart created and updated - * Display the discount name if the sponsor friend have one - */ - public function hookShoppingCart($params) - { - include_once(dirname(__FILE__).'/ReferralProgramModule.php'); - - if (!isset($params['cart']->id_customer)) - return false; - if (!($id_referralprogram = ReferralProgramModule::isSponsorised((int)($params['cart']->id_customer), true))) - return false; - $referralprogram = new ReferralProgramModule($id_referralprogram); - if (!Validate::isLoadedObject($referralprogram)) - return false; - $cartRule = new CartRule($referralprogram->id_cart_rule); - if (!Validate::isLoadedObject($cartRule)) - return false; - - //if ($cartRule->checkValidity($this->context) === false) - //{ - $this->smarty->assign(array('discount_display' => ReferralProgram::displayDiscount($cartRule->reduction_percent ? $cartRule->reduction_percent : $cartRule->reduction_amount, $cartRule->reduction_percent ? 1 : 2, new Currency($params['cookie']->id_currency)), 'discount' => $cartRule)); - return $this->display(__FILE__, 'shopping-cart.tpl'); - // } - return false; - } - - /** - * Hook display on customer account page - * Display an additional link on my-account and block my-account - */ - public function hookCustomerAccount($params) - { - return $this->display(__FILE__, 'my-account.tpl'); - } - - public function hookDisplayMyAccountBlock($params) - { - return $this->hookCustomerAccount($params); - } - - /** - * Hook display on form create account - * Add an additional input on bottom for fill the sponsor's e-mail address - */ - public function hookCreateAccountForm($params) - { - include_once(dirname(__FILE__).'/ReferralProgramModule.php'); - - if (Configuration::get('PS_CIPHER_ALGORITHM')) - $cipherTool = new Rijndael(_RIJNDAEL_KEY_, _RIJNDAEL_IV_); - else - $cipherTool = new Blowfish(_COOKIE_KEY_, _COOKIE_IV_); - $explodeResult = explode('|', $cipherTool->decrypt(urldecode(Tools::getValue('sponsor')))); - if ($explodeResult AND count($explodeResult) > 1 AND list($id_referralprogram, $email) = $explodeResult AND (int)($id_referralprogram) AND !empty($email) AND Validate::isEmail($email) AND $id_referralprogram == ReferralProgramModule::isEmailExists($email)) - { - $referralprogram = new ReferralProgramModule($id_referralprogram); - if (Validate::isLoadedObject($referralprogram)) - { - /* hack for display referralprogram information in form */ - $_POST['customer_firstname'] = $referralprogram->firstname; - $_POST['firstname'] = $referralprogram->firstname; - $_POST['customer_lastname'] = $referralprogram->lastname; - $_POST['lastname'] = $referralprogram->lastname; - $_POST['email'] = $referralprogram->email; - $_POST['email_create'] = $referralprogram->email; - $sponsor = new Customer((int)$referralprogram->id_sponsor); - $_POST['referralprogram'] = $sponsor->email; - } - } - return $this->display(__FILE__, 'authentication.tpl'); - } - - /** - * Hook called on creation customer account - * Create a discount for the customer if sponsorised - */ - public function hookCreateAccount($params) - { - $newCustomer = $params['newCustomer']; - if (!Validate::isLoadedObject($newCustomer)) - return false; - $postVars = $params['_POST']; - if (empty($postVars) OR !isset($postVars['referralprogram']) OR empty($postVars['referralprogram'])) - return false; - $sponsorEmail = $postVars['referralprogram']; - if (!Validate::isEmail($sponsorEmail) OR $sponsorEmail == $newCustomer->email) - return false; - - $sponsor = new Customer(); - if ($sponsor = $sponsor->getByEmail($sponsorEmail, NULL, $this->context)) - { - include_once(dirname(__FILE__).'/ReferralProgramModule.php'); - - /* If the customer was not invited by the sponsor, we create the invitation dynamically */ - if (!$id_referralprogram = ReferralProgramModule::isEmailExists($newCustomer->email, true, false)) - { - $referralprogram = new ReferralProgramModule(); - $referralprogram->id_sponsor = (int)$sponsor->id; - $referralprogram->firstname = $newCustomer->firstname; - $referralprogram->lastname = $newCustomer->lastname; - $referralprogram->email = $newCustomer->email; - if (!$referralprogram->validateFields(false)) - return false; - else - $referralprogram->save(); - } - else - $referralprogram = new ReferralProgramModule((int)$id_referralprogram); - - if ($referralprogram->id_sponsor == $sponsor->id) - { - $referralprogram->id_customer = (int)$newCustomer->id; - $referralprogram->save(); - if ($referralprogram->registerDiscountForSponsored((int)$params['cookie']->id_currency)) - { - $cartRule = new CartRule((int)$referralprogram->id_cart_rule); - if (Validate::isLoadedObject($cartRule)) - { - $data = array( - '{firstname}' => $newCustomer->firstname, - '{lastname}' => $newCustomer->lastname, - '{voucher_num}' => $cartRule->code, - '{voucher_amount}' => (Configuration::get('REFERRAL_DISCOUNT_TYPE') == 2 ? Tools::displayPrice((float)Configuration::get('REFERRAL_DISCOUNT_VALUE_'.(int)$this->context->currency->id), (int)Configuration::get('PS_CURRENCY_DEFAULT')) : (float)Configuration::get('REFERRAL_PERCENTAGE').'%')); - - $cookie = $this->context->cookie; - - Mail::Send( - (int)$cookie->id_lang, - 'referralprogram-voucher', - Mail::l('Congratulations!', (int)$cookie->id_lang), - $data, - $newCustomer->email, - $newCustomer->firstname.' '.$newCustomer->lastname, - strval(Configuration::get('PS_SHOP_EMAIL')), - strval(Configuration::get('PS_SHOP_NAME')), - null, - null, - dirname(__FILE__).'/mails/' - ); - } - } - return true; - } - } - return false; - } - - /** - * Hook display in tab AdminCustomers on BO - * Data table with all sponsors informations for a customer - */ - public function hookAdminCustomers($params) - { - include_once(dirname(__FILE__).'/ReferralProgramModule.php'); - - $customer = new Customer((int)$params['id_customer']); - if (!Validate::isLoadedObject($customer)) - die ($this->l('Incorrect Customer object.')); - - $friends = ReferralProgramModule::getSponsorFriend((int)$customer->id); - if ($id_referralprogram = ReferralProgramModule::isSponsorised((int)$customer->id, true)) - { - $referralprogram = new ReferralProgramModule((int)$id_referralprogram); - $sponsor = new Customer((int)$referralprogram->id_sponsor); - } - - $html = ' -
     
    -

    '.$this->l('Referral program').' ('.count($friends).')

    -

    '.(isset($sponsor) ? $this->l('Customer\'s sponsor:').' '.$sponsor->firstname.' '.$sponsor->lastname.'' : $this->l('No one has sponsored this customer.')).'

    '; - - if ($friends AND sizeof($friends)) - { - $html.= '

    '.sizeof($friends).' '.(sizeof($friends) > 1 ? $this->l('Sponsored customers:') : $this->l('Sponsored customer:')).'

    '; - $html.= ' - - - - - - - - - - '; - foreach ($friends AS $key => $friend) - { - $orders = Order::getCustomerOrders($friend['id_customer']); - $html.= ' - - - - - - - - - '; - } - $html.= ' -
    '.$this->l('ID').''.$this->l('Name').''.$this->l('Email').''.$this->l('Registration date').''.$this->l('Customers sponsored by this friend').''.$this->l('Placed orders').''.$this->l('Customer account created').'
    '.((int)($friend['id_customer']) ? $friend['id_customer'] : '--').''.$friend['firstname'].' '.$friend['lastname'].''.$friend['email'].''.Tools::displayDate($friend['date_add'],null , true).''.sizeof(ReferralProgramModule::getSponsorFriend($friend['id_customer'])).''.($orders ? sizeof($orders) : 0).''.((int)$friend['id_customer'] ? '' : '').'
    '; - } - else - $html.= sprintf($this->l('%1$s %2$s has not sponsored any friends yet.'), $customer->firstname, $customer->lastname); - return $html.'

    '; - } - - /** - * Hook called when a order is confimed - * display a message to customer about sponsor discount - */ - public function hookOrderConfirmation($params) - { - if ($params['objOrder'] AND !Validate::isLoadedObject($params['objOrder'])) - return die($this->l('Incorrect Order object.')); - - include_once(dirname(__FILE__).'/ReferralProgramModule.php'); - - $customer = new Customer((int)$params['objOrder']->id_customer); - $stats = $customer->getStats(); - $nbOrdersCustomer = (int)$stats['nb_orders'] + 1; // hack to count current order - $referralprogram = new ReferralProgramModule(ReferralProgramModule::isSponsorised((int)$customer->id, true)); - if (!Validate::isLoadedObject($referralprogram)) - return false; - $sponsor = new Customer((int)$referralprogram->id_sponsor); - if ((int)$nbOrdersCustomer == (int)$this->_configuration['REFERRAL_ORDER_QUANTITY']) - { - $cartRule = new CartRule((int)$referralprogram->id_cart_rule_sponsor); - if (!Validate::isLoadedObject($cartRule)) - return false; - $this->smarty->assign(array('discount' => ReferralProgram::displayDiscount($cartRule->reduction_percent ? $cartRule->reduction_percent : $cartRule->reduction_amount, $cartRule->reduction_percent ? 1 : 2, new Currency((int)$params['objOrder']->id_currency)), 'sponsor_firstname' => $sponsor->firstname, 'sponsor_lastname' => $sponsor->lastname)); - return $this->display(__FILE__, 'order-confirmation.tpl'); - } - return false; - } - - /** - * Hook called when order status changed - * register a discount for sponsor and send him an e-mail - */ - public function hookUpdateOrderStatus($params) - { - if (!Validate::isLoadedObject($params['newOrderStatus'])) - die ($this->l('Missing parameters')); - $orderState = $params['newOrderStatus']; - $order = new Order((int)($params['id_order'])); - if ($order AND !Validate::isLoadedObject($order)) - die($this->l('Incorrect Order object.')); - - include_once(dirname(__FILE__).'/ReferralProgramModule.php'); - - $customer = new Customer((int)$order->id_customer); - $stats = $customer->getStats(); - $nbOrdersCustomer = (int)$stats['nb_orders'] + 1; // hack to count current order - $referralprogram = new ReferralProgramModule(ReferralProgramModule::isSponsorised((int)($customer->id), true)); - if (!Validate::isLoadedObject($referralprogram)) - return false; - $sponsor = new Customer((int)$referralprogram->id_sponsor); - if ((int)$orderState->logable AND $nbOrdersCustomer >= (int)$this->_configuration['REFERRAL_ORDER_QUANTITY'] AND $referralprogram->registerDiscountForSponsor((int)$order->id_currency)) - { - $cartRule = new CartRule((int)$referralprogram->id_cart_rule_sponsor); - $currency = new Currency((int)$order->id_currency); - $discount_display = ReferralProgram::displayDiscount( (float) $cartRule->reduction_percent ? (float) $cartRule->reduction_percent : (int) $cartRule->reduction_amount, (float) $cartRule->reduction_percent ? 1 : 2, $currency); $data = array('{sponsored_firstname}' => $customer->firstname, '{sponsored_lastname}' => $customer->lastname, '{discount_display}' => $discount_display, '{discount_name}' => $cartRule->code); - Mail::Send((int)$order->id_lang, 'referralprogram-congratulations', Mail::l('Congratulations!', (int)$order->id_lang), $data, $sponsor->email, $sponsor->firstname.' '.$sponsor->lastname, strval(Configuration::get('PS_SHOP_EMAIL')), strval(Configuration::get('PS_SHOP_NAME')), NULL, NULL, dirname(__FILE__).'/mails/'); - return true; - } - return false; - } - - public function renderForm() - { - - $fields_form_1 = array( - 'form' => array( - 'legend' => array( - 'title' => $this->l('Settings'), - 'icon' => 'icon-cogs' - ), - 'input' => array( - array( - 'type' => 'text', - 'label' => $this->l('Minimum number of orders a sponsored friend must place to get their voucher'), - 'name' => 'order_quantity', - ), - array( - 'type' => 'text', - 'label' => $this->l('Number of friends in the referral program invitation form (customer account, referral program section):'), - 'name' => 'nb_friends', - ), - array( - 'type' => 'radio', - 'label' => $this->l('Voucher type :'), - 'name' => 'discount_type', - 'class' => 't', - 'values' => array( - array( - 'id' => 'discount_type1', - 'value' => 1, - 'label' => $this->l('Voucher offering a percentage')), - array( - 'id' => 'discount_type2', - 'value' => 2, - 'label' => $this->l('Voucher offering a fixed amount (by currency)')), - ), - ), - array( - 'type' => 'text', - 'label' => $this->l('Percentage'), - 'name' => 'discount_value_percentage', - 'suffix' => '%' - ), - array( - 'type' => 'discount_value', - 'label' => $this->l('Voucher amount'), - 'name' => 'discount_value', - ), - array( - 'type' => 'text', - 'label' => $this->l('Voucher description'), - 'name' => 'discount_description', - 'lang' => true, - ) - ), - 'submit' => array( - 'title' => $this->l('Save'), - 'class' => 'btn btn-default', - 'name' => 'submitReferralProgram', - ) - ), - ); - - $fields_form_2 = array( - 'form' => array( - 'legend' => array( - 'title' => $this->l('Conditions of the referral program'), - 'icon' => 'icon-cogs' - ), - 'input' => array( - array( - 'type' => 'textarea', - 'autoload_rte' => true, - 'label' => $this->l('Text'), - 'name' => 'body_paragraph', - 'lang' => true, - ) - ), - 'submit' => array( - 'title' => $this->l('Save'), - 'class' => 'btn btn-default', - 'name' => 'submitText', - ) - ), - ); - - $helper = new HelperForm(); - $helper->show_toolbar = false; - $helper->table = $this->table; - $lang = new Language((int)Configuration::get('PS_LANG_DEFAULT')); - $helper->default_form_language = $lang->id; - $helper->allow_employee_form_lang = Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG') ? Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG') : 0; - $helper->identifier = $this->identifier; - $helper->submit_action = 'submitModule'; - $helper->module = $this; - $helper->currentIndex = $this->context->link->getAdminLink('AdminModules', false).'&configure='.$this->name.'&tab_module='.$this->tab.'&module_name='.$this->name; - $helper->token = Tools::getAdminTokenLite('AdminModules'); - $helper->tpl_vars = array( - 'currencies' => Currency::getCurrencies(), - 'fields_value' => $this->getConfigFieldsValues(), - 'languages' => $this->context->controller->getLanguages(), - 'id_language' => $this->context->language->id - ); - - $helper->override_folder = '/'; - - return $this->renderJs().$helper->generateForm(array($fields_form_1, $fields_form_2)); - } - - public function getConfigFieldsValues() - { - $fields_values = array( - 'order_quantity' => Tools::getValue('order_quantity', Configuration::get('REFERRAL_ORDER_QUANTITY')), - 'discount_type' => Tools::getValue('discount_type', Configuration::get('REFERRAL_DISCOUNT_TYPE')), - 'nb_friends' => Tools::getValue('nb_friends', Configuration::get('REFERRAL_NB_FRIENDS')), - 'discount_value_percentage' => Tools::getValue('discount_value_percentage', Configuration::get('REFERRAL_PERCENTAGE')), - ); - - $languages = Language::getLanguages(false); - foreach ($languages as $lang) - $fields_values['discount_description'][$lang['id_lang']] = Tools::getValue('discount_description_'.(int)$lang['id_lang'], Configuration::get('REFERRAL_DISCOUNT_DESCRIPTION', (int)$lang['id_lang'])); - - $currencies = Currency::getCurrencies(); - foreach ($currencies as $currency) - $fields_values['discount_value'][$currency['id_currency']] = Tools::getValue('discount_value['.(int)$currency['id_currency'].']', Configuration::get('REFERRAL_DISCOUNT_VALUE_'.(int)$currency['id_currency'])); - - // xml loading - $xml = false; - if (file_exists($this->_xmlFile)) - if ($xml = @simplexml_load_file($this->_xmlFile)) - foreach ($languages as $lang) - { - $key = 'paragraph_'.$lang['id_lang']; - $fields_values['body_paragraph'][$lang['id_lang']] = Tools::getValue('body_paragraph_'.(int)$lang['id_lang'] ,(string)$xml->body->$key); - } - - return $fields_values; - } - - public function renderJs() - { - return " - - "; - } -} diff --git a/modules/referralprogram/translations/index.php b/modules/referralprogram/translations/index.php deleted file mode 100644 index 3f6561f72..000000000 --- a/modules/referralprogram/translations/index.php +++ /dev/null @@ -1,35 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); - -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); - -header("Location: ../"); -exit; \ No newline at end of file diff --git a/modules/referralprogram/views/index.php b/modules/referralprogram/views/index.php deleted file mode 100644 index 3f6561f72..000000000 --- a/modules/referralprogram/views/index.php +++ /dev/null @@ -1,35 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); - -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); - -header("Location: ../"); -exit; \ No newline at end of file diff --git a/modules/referralprogram/views/templates/admin/_configure/helpers/form/form.tpl b/modules/referralprogram/views/templates/admin/_configure/helpers/form/form.tpl deleted file mode 100644 index d78eb9777..000000000 --- a/modules/referralprogram/views/templates/admin/_configure/helpers/form/form.tpl +++ /dev/null @@ -1,54 +0,0 @@ -{* -* 2007-2013 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 -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*} - -{extends file="helpers/form/form.tpl"} -{block name="field"} - {if $input.type == 'discount_value'} -
    - - - - - - - - {foreach from=$currencies item=currency} - - - - - {/foreach} -
    {l s="Currency"}{l s="Voucher amount"}
    {$currency.name} -
    - - - {$currency.sign} - -
    -
    -
    - {/if} - {$smarty.block.parent} -{/block} \ No newline at end of file diff --git a/modules/referralprogram/views/templates/front/email.tpl b/modules/referralprogram/views/templates/front/email.tpl deleted file mode 100755 index 61357ce85..000000000 --- a/modules/referralprogram/views/templates/front/email.tpl +++ /dev/null @@ -1,26 +0,0 @@ -{* -* 2007-2013 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 -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*} - -{$content} diff --git a/modules/referralprogram/views/templates/front/index.php b/modules/referralprogram/views/templates/front/index.php deleted file mode 100644 index 3f6561f72..000000000 --- a/modules/referralprogram/views/templates/front/index.php +++ /dev/null @@ -1,35 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); - -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); - -header("Location: ../"); -exit; \ No newline at end of file diff --git a/modules/referralprogram/views/templates/front/program.tpl b/modules/referralprogram/views/templates/front/program.tpl deleted file mode 100644 index aee1f9ac8..000000000 --- a/modules/referralprogram/views/templates/front/program.tpl +++ /dev/null @@ -1,225 +0,0 @@ -{* -* 2007-2013 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 -* @copyright 2007-2013 PrestaShop SA -* @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='My account' mod='referralprogram'}{$navigationPipe}{l s='Referral Program' mod='referralprogram'}{/capture} -{include file="$tpl_dir./breadcrumb.tpl"} - -

    {l s='Referral program' mod='referralprogram'}

    - -{if $error} -

    - {if $error == 'conditions not valided'} - {l s='You need to agree to the conditions of the referral program!' mod='referralprogram'} - {elseif $error == 'email invalid'} - {l s='At least one e-mail address is invalid!' mod='referralprogram'} - {elseif $error == 'name invalid'} - {l s='At least one first name or last name is invalid!' mod='referralprogram'} - {elseif $error == 'email exists'} - {l s='Someone with this e-mail address has already been sponsored!' mod='referralprogram'}: {foreach from=$mails_exists item=mail}{$mail} {/foreach} - {elseif $error == 'no revive checked'} - {l s='Please mark at least one checkbox' mod='referralprogram'} - {elseif $error == 'cannot add friends'} - {l s='Cannot add friends to database' mod='referralprogram'} - {/if} -

    -{/if} - -{if $invitation_sent} -

    - {if $nbInvitation > 1} - {l s='E-mails have been sent to your friends!' mod='referralprogram'} - {else} - {l s='An e-mail has been sent to your friend!' mod='referralprogram'} - {/if} -

    -{/if} - -{if $revive_sent} -

    - {if $nbRevive > 1} - {l s='Reminder e-mails have been sent to your friends!' mod='referralprogram'} - {else} - {l s='A reminder e-mail has been sent to your friend!' mod='referralprogram'} - {/if} -

    -{/if} - - -
    - -
    -

    - {l s='Get a discount of %1$d %2$s for you and your friends by recommending this Website.' sprintf=[$discount,$currencySign] mod='referralprogram'} -

    - {if $canSendInvitations} -

    - {l s='It\'s quick and it\'s easy. Just fill in the first name, last name, and e-mail address(es) of your friend(s) in the fields below.' mod='referralprogram'} - {if $orderQuantity > 1} - {l s='When one of them makes at least %d orders' sprintf=$orderQuantity mod='referralprogram'} - {else} - {l s='When one of them makes at least %d order' sprintf=$orderQuantity mod='referralprogram'} - {/if}, - {l s='he or she will receive a %1$d %2$s voucher and you will receive your own voucher worth %3$d %4$s.' sprintf=[$discount,$currencySign,$discount,$currencySign] mod='referralprogram'} -

    -
    - - - - - - - - - - - {section name=friends start=0 loop=$nbFriends step=1} - - - - - - - {/section} - -
     {l s='Last name' mod='referralprogram'}{l s='First name' mod='referralprogram'}{l s='E-mail' mod='referralprogram'}
    {$smarty.section.friends.iteration}
    -

    - {l s='Important: Your friends\' e-mail addresses will only be used in the referral program. They will never be used for other purposes.' mod='referralprogram'} -

    -

    - - - {l s='Read conditions.' mod='referralprogram'} -

    -

    - {l s='Preview' mod='referralprogram'} - {assign var="file" value="{$lang_iso}/referralprogram-invitation.html"} - {l s='the default e-mail' mod='referralprogram'} {l s='that will be sent to your friend(s).' mod='referralprogram'} -

    -

    - -

    -
    - {else} -

    - {l s='To become a sponsor, you need to have completed at least' mod='referralprogram'} {$orderQuantity} {if $orderQuantity > 1}{l s='orders' mod='referralprogram'}{else}{l s='order' mod='referralprogram'}{/if}. -

    - {/if} -
    - -
    - {if $pendingFriends AND $pendingFriends|@count > 0} -

    - {l s='These friends have not yet placed an order on this Website since you sponsored them, but you can try again! To do so, mark the checkboxes of the friend(s) you want to remind, then click on the button "Remind my friend(s)"' mod='referralprogram'} -

    -
    - - - - - - - - - - - - {foreach from=$pendingFriends item=pendingFriend name=myLoop} - - - - - - - - {/foreach} - -
     {l s='Last name' mod='referralprogram'}{l s='First name' mod='referralprogram'}{l s='E-mail' mod='referralprogram'}{l s='Last invitation' mod='referralprogram'}
    - - - - {$pendingFriend.firstname|substr:0:22}{$pendingFriend.email}{dateFormat date=$pendingFriend.date_upd full=1}
    -

    - -

    -
    - {else} -

    {l s='You have not sponsored any friends.' mod='referralprogram'}

    - {/if} -
    - -
    - {if $subscribeFriends AND $subscribeFriends|@count > 0} -

    - {l s='Here are sponsored friends who have accepted your invitation:' mod='referralprogram'} -

    - - - - - - - - - - - - {foreach from=$subscribeFriends item=subscribeFriend name=myLoop} - - - - - - - - {/foreach} - -
     {l s='Last name' mod='referralprogram'}{l s='First name' mod='referralprogram'}{l s='E-mail' mod='referralprogram'}{l s='Inscription date' mod='referralprogram'}
    {$smarty.foreach.myLoop.iteration}.{$subscribeFriend.lastname|substr:0:22}{$subscribeFriend.firstname|substr:0:22}{$subscribeFriend.email}{dateFormat date=$subscribeFriend.date_upd full=1}
    - {else} -

    - {l s='No sponsored friends have accepted your invitation yet.' mod='referralprogram'} -

    - {/if} -
    -
    - - diff --git a/modules/referralprogram/views/templates/front/rules.tpl b/modules/referralprogram/views/templates/front/rules.tpl deleted file mode 100755 index 7ebc9659f..000000000 --- a/modules/referralprogram/views/templates/front/rules.tpl +++ /dev/null @@ -1,32 +0,0 @@ -{* -* 2007-2013 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 -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*} - -

    {l s='Referral program rules' mod='referralprogram'}

    - -{if isset($xml)} -
    - {if isset($xml->body->$paragraph)}
    {$xml->body->$paragraph|replace:"\'":"'"|replace:'\"':'"'}
    {/if} -
    -{/if} diff --git a/modules/referralprogram/views/templates/hook/authentication.tpl b/modules/referralprogram/views/templates/hook/authentication.tpl deleted file mode 100755 index 9774a9981..000000000 --- a/modules/referralprogram/views/templates/hook/authentication.tpl +++ /dev/null @@ -1,34 +0,0 @@ -{* -* 2007-2013 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 -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*} - - - - \ No newline at end of file diff --git a/modules/referralprogram/views/templates/hook/index.php b/modules/referralprogram/views/templates/hook/index.php deleted file mode 100644 index 3f6561f72..000000000 --- a/modules/referralprogram/views/templates/hook/index.php +++ /dev/null @@ -1,35 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); - -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); - -header("Location: ../"); -exit; \ No newline at end of file diff --git a/modules/referralprogram/views/templates/hook/my-account.tpl b/modules/referralprogram/views/templates/hook/my-account.tpl deleted file mode 100755 index f5cea67c1..000000000 --- a/modules/referralprogram/views/templates/hook/my-account.tpl +++ /dev/null @@ -1,33 +0,0 @@ -{* -* 2007-2013 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 -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*} - - -
  • - - {l s='Referral program' mod='referralprogram'} - {l s='Referral program' mod='referralprogram'} - -
  • - \ No newline at end of file diff --git a/modules/referralprogram/views/templates/hook/order-confirmation.tpl b/modules/referralprogram/views/templates/hook/order-confirmation.tpl deleted file mode 100755 index 34dfa778d..000000000 --- a/modules/referralprogram/views/templates/hook/order-confirmation.tpl +++ /dev/null @@ -1,29 +0,0 @@ -{* -* 2007-2013 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 -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*} - -

    - {l s='Thanks to your order, your sponsor %1$s %2$s will earn a voucher worth %3$d off when this order is confirmed.' sprintf=[$sponsor_firstname,$sponsor_lastname,$discount] mod='referralprogram'} -

    -
    \ No newline at end of file diff --git a/modules/referralprogram/views/templates/hook/shopping-cart.tpl b/modules/referralprogram/views/templates/hook/shopping-cart.tpl deleted file mode 100755 index eaa522cb8..000000000 --- a/modules/referralprogram/views/templates/hook/shopping-cart.tpl +++ /dev/null @@ -1,34 +0,0 @@ -{* -* 2007-2013 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 -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*} - - -

    - {l s='Referral program' mod='referralprogram'} - {l s='You have earned a voucher worth %s thanks to your sponsor!' sprintf=$discount_display mod='referralprogram'} - {l s='Enter voucher name %s to receive the reduction on this order.' sprintf=$discount->name mod='referralprogram'} - {l s='View your referral program.' mod='referralprogram'} -

    -
    - \ No newline at end of file diff --git a/modules/referralprogram/views/templates/index.php b/modules/referralprogram/views/templates/index.php deleted file mode 100644 index 3f6561f72..000000000 --- a/modules/referralprogram/views/templates/index.php +++ /dev/null @@ -1,35 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); - -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); - -header("Location: ../"); -exit; \ No newline at end of file diff --git a/modules/sendtoafriend/config.xml b/modules/sendtoafriend/config.xml deleted file mode 100755 index 93f65bf17..000000000 --- a/modules/sendtoafriend/config.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - sendtoafriend - - - - - - 0 - 0 - - \ No newline at end of file diff --git a/modules/sendtoafriend/index.php b/modules/sendtoafriend/index.php deleted file mode 100644 index 3f6561f72..000000000 --- a/modules/sendtoafriend/index.php +++ /dev/null @@ -1,35 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); - -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); - -header("Location: ../"); -exit; \ No newline at end of file diff --git a/modules/sendtoafriend/logo.gif b/modules/sendtoafriend/logo.gif deleted file mode 100644 index 8c31836bf..000000000 Binary files a/modules/sendtoafriend/logo.gif and /dev/null differ diff --git a/modules/sendtoafriend/logo.png b/modules/sendtoafriend/logo.png deleted file mode 100755 index f71e37a32..000000000 Binary files a/modules/sendtoafriend/logo.png and /dev/null differ diff --git a/modules/sendtoafriend/mails/en/index.php b/modules/sendtoafriend/mails/en/index.php deleted file mode 100644 index 3f6561f72..000000000 --- a/modules/sendtoafriend/mails/en/index.php +++ /dev/null @@ -1,35 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); - -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); - -header("Location: ../"); -exit; \ No newline at end of file diff --git a/modules/sendtoafriend/mails/en/send_to_a_friend.html b/modules/sendtoafriend/mails/en/send_to_a_friend.html deleted file mode 100644 index 0becbad17..000000000 --- a/modules/sendtoafriend/mails/en/send_to_a_friend.html +++ /dev/null @@ -1,112 +0,0 @@ - - - - - - - Message from {shop_name} - - - - - - - - - - - - -
      - - - - - - - - - - - - - - - - - - - - - -
    - Hi {name},
    - Thank you for creating a customer account at {shop_name}. -
    -

    - {customer} has sent you a link to a product that (s)he thinks may interest you.

    - - Click here to view this item: {product} - -
    -
     
    - - \ No newline at end of file diff --git a/modules/sendtoafriend/mails/en/send_to_a_friend.txt b/modules/sendtoafriend/mails/en/send_to_a_friend.txt deleted file mode 100644 index 3593630ca..000000000 --- a/modules/sendtoafriend/mails/en/send_to_a_friend.txt +++ /dev/null @@ -1,16 +0,0 @@ - -[{shop_url}] - -Hi {name}, - -Thank you for creating a customer account at {shop_name}. - -{customer} has sent you a link to a product that (s)he thinks may -interest you. - -Click here to view this item: {product} -[{product_link}] - -{shop_name} [{shop_url}] powered by -PrestaShop(tm) [http://www.prestashop.com/] - diff --git a/modules/sendtoafriend/mails/index.php b/modules/sendtoafriend/mails/index.php deleted file mode 100644 index 6f5ff3bab..000000000 --- a/modules/sendtoafriend/mails/index.php +++ /dev/null @@ -1,35 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); - -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); - -header("Location: ../"); -exit; \ No newline at end of file diff --git a/modules/sendtoafriend/product_page.tpl b/modules/sendtoafriend/product_page.tpl deleted file mode 100755 index 29c77dae5..000000000 --- a/modules/sendtoafriend/product_page.tpl +++ /dev/null @@ -1,27 +0,0 @@ -{* -* 2007-2013 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 -* @copyright 2007-2013 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 -*} - -
  • {l s='Send to a friend' mod='sendtoafriend'}
  • diff --git a/modules/sendtoafriend/sendtoafriend-extra.tpl b/modules/sendtoafriend/sendtoafriend-extra.tpl deleted file mode 100755 index 4b3c9e597..000000000 --- a/modules/sendtoafriend/sendtoafriend-extra.tpl +++ /dev/null @@ -1,97 +0,0 @@ -{* -* 2007-2013 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 -* @copyright 2007-2013 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 -*} - -
  • - {l s='Send to a friend' mod='sendtoafriend'} -
  • - -
    -
    -

    {l s='Send to a friend' mod='sendtoafriend'}

    -
    - {$stf_product->name|escape:html:'UTF-8'} -
    -

    {$stf_product->name}

    - {$stf_product->description_short} -
    -
    - -
    -
    -
    -
    -

    {l s='Recipient' mod='sendtoafriend'} :

    -

    - - -

    -

    - - -

    -

    * {l s='Required fields' mod='sendtoafriend'}

    -
    -

    - - {l s='Cancel' mod='sendtoafriend'} {l s='or' mod='sendtoafriend'}  - -

    -
    -
    -
    diff --git a/modules/sendtoafriend/sendtoafriend.css b/modules/sendtoafriend/sendtoafriend.css deleted file mode 100644 index 19cef6bec..000000000 --- a/modules/sendtoafriend/sendtoafriend.css +++ /dev/null @@ -1,46 +0,0 @@ -/* ************************************************************************************************ - PAGE SEND TO FRIEND -************************************************************************************************ */ -#sendfriendpage form.std fieldset { - margin:0 0 20px 0; - padding: 10px 15px; - background: none repeat scroll 0 0 #eee -} - -#sendfriendpage .product {} -#sendfriendpage .product .img_link {float:left} -#sendfriendpage .product .img_link img { - margin:0 10px 0 0; - border:1px solid #ccc; -} -#sendfriendpage .product .product_desc { - float:left; - width:200px; - font-weight:bold; - font-size:12px; - color:#000; -} - -#sendfriendpage #send_friend_form_content {margin-top:40px} -#sendfriendpage #send_friend_form_content .text { - padding-bottom: 10px -} -#sendfriendpage #send_friend_form_content .text label { - display: inline-block; - padding: 6px 15px; - width: 180px; - font-size: 12px; - text-align: right -} -#sendfriendpage #send_friend_form_content .text input { - padding: 0 5px; - height: 22px; - width: 260px; - border: 1px solid #ccc; - font-size: 12px -} -#sendfriendpage #send_friend_form_content .submit { - margin:0 20px 0 0; - padding:5px 0; - text-align:right -} \ No newline at end of file diff --git a/modules/sendtoafriend/sendtoafriend.php b/modules/sendtoafriend/sendtoafriend.php deleted file mode 100644 index 8e06282ba..000000000 --- a/modules/sendtoafriend/sendtoafriend.php +++ /dev/null @@ -1,84 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -if (!defined('_PS_VERSION_')) - exit; - -class sendToAFriend extends Module -{ - private $_html = ''; - private $_postErrors = array(); - public $context; - - function __construct($dontTranslate = false) - { - $this->name = 'sendtoafriend'; - $this->version = '1.2'; - $this->author = 'PrestaShop'; - $this->tab = 'front_office_features'; - $this->need_instance = 0; - $this->secure_key = Tools::encrypt($this->name); - - parent::__construct(); - - 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.'); - } - } - - public function install() - { - return (parent::install() && $this->registerHook('extraLeft') && $this->registerHook('header')); - } - - public function uninstall() - { - 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); - $image = Product::getCover((int)$product->id); - - - $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'); - } - - public function hookHeader($params) - { - $this->context->controller->addCSS($this->_path.'sendtoafriend.css', 'all'); - } -} \ No newline at end of file diff --git a/modules/sendtoafriend/sendtoafriend.png b/modules/sendtoafriend/sendtoafriend.png deleted file mode 100644 index 4a6c5d396..000000000 Binary files a/modules/sendtoafriend/sendtoafriend.png and /dev/null differ diff --git a/modules/sendtoafriend/sendtoafriend.tpl b/modules/sendtoafriend/sendtoafriend.tpl deleted file mode 100644 index 4b45a73df..000000000 --- a/modules/sendtoafriend/sendtoafriend.tpl +++ /dev/null @@ -1,66 +0,0 @@ -{* -* 2007-2013 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 -* @copyright 2007-2013 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 -*} - -{capture name=path}{l s='Send to a friend' mod='sendtoafriend'}{/capture} -{include file="$tpl_dir./breadcrumb.tpl"} -
    -

    {l s='Send to a friend' mod='sendtoafriend'}

    - -

    {l s='Send this page to a friend who might be interested in the item below.' mod='sendtoafriend'}.

    - {include file="$tpl_dir/errors.tpl"} - - {if isset($smarty.get.submited)} -

    {l s='Your email has been sent successfully' mod='sendtoafriend'}

    - {else} -
    -
    - - -
    -

    - - -

    -

    - - -

    - -

    - -

    -
    -
    -
    - {/if} - - -
    diff --git a/modules/sendtoafriend/sendtoafriend_ajax.php b/modules/sendtoafriend/sendtoafriend_ajax.php deleted file mode 100644 index a08e2ef77..000000000 --- a/modules/sendtoafriend/sendtoafriend_ajax.php +++ /dev/null @@ -1,68 +0,0 @@ - -* @copyright 2007-2013 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) -{ - $friendName = Tools::getValue('name'); - $friendMail = Tools::getValue('email'); - $id_product = Tools::getValue('id_product'); - if (!$friendName || !$friendMail || !$id_product) - die('0'); - - /* Email generation */ - $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}' => $customer, - '{name}' => Tools::safeOutput($friendName) - ); - - /* Email sending */ - if (!Mail::Send((int)$module->context->cookie->id_lang, - 'send_to_a_friend', - sprintf(Mail::l('%1$s sent you a link to %2$s', (int)$module->context->cookie->id_lang), $customer, $product->name), - $templateVars, $friendMail, - 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('0'); diff --git a/modules/sendtoafriend/translations/index.php b/modules/sendtoafriend/translations/index.php deleted file mode 100644 index 3f6561f72..000000000 --- a/modules/sendtoafriend/translations/index.php +++ /dev/null @@ -1,35 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); - -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); - -header("Location: ../"); -exit; \ No newline at end of file diff --git a/modules/watermark/config.xml b/modules/watermark/config.xml deleted file mode 100755 index 9aca6ed0d..000000000 --- a/modules/watermark/config.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - watermark - - - - - - Are you sure you want to delete these details? - 1 - 1 - - \ No newline at end of file diff --git a/modules/watermark/index.php b/modules/watermark/index.php deleted file mode 100644 index e582afcc2..000000000 --- a/modules/watermark/index.php +++ /dev/null @@ -1,36 +0,0 @@ - -* @copyright 2007-2013 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 -*/ - -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); - -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); - -header("Location: ../"); -exit; \ No newline at end of file diff --git a/modules/watermark/logo.gif b/modules/watermark/logo.gif deleted file mode 100644 index e4b4d25fd..000000000 Binary files a/modules/watermark/logo.gif and /dev/null differ diff --git a/modules/watermark/logo.png b/modules/watermark/logo.png deleted file mode 100755 index 5fc148d52..000000000 Binary files a/modules/watermark/logo.png and /dev/null differ diff --git a/modules/watermark/translations/index.php b/modules/watermark/translations/index.php deleted file mode 100644 index 3f6561f72..000000000 --- a/modules/watermark/translations/index.php +++ /dev/null @@ -1,35 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); - -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); - -header("Location: ../"); -exit; \ No newline at end of file diff --git a/modules/watermark/watermark.gif b/modules/watermark/watermark.gif deleted file mode 100644 index 05fb5562b..000000000 Binary files a/modules/watermark/watermark.gif and /dev/null differ diff --git a/modules/watermark/watermark.php b/modules/watermark/watermark.php deleted file mode 100644 index 3ae514b39..000000000 --- a/modules/watermark/watermark.php +++ /dev/null @@ -1,430 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -if (!defined('_PS_VERSION_')) - exit; - -class Watermark extends Module -{ - private $_html = ''; - private $_postErrors = array(); - private $xaligns = array('left', 'middle', 'right'); - private $yaligns = array('top', 'middle', 'bottom'); - private $yAlign; - private $xAlign; - private $transparency; - private $imageTypes = array(); - private $watermarkTypes; - - public function __construct() - { - $this->name = 'watermark'; - $this->tab = 'administration'; - $this->version = '0.4'; - $this->author = 'PrestaShop'; - - $this->bootstrap = true; - parent::__construct(); - - $config = Configuration::getMultiple(array('WATERMARK_TYPES', 'WATERMARK_Y_ALIGN', 'WATERMARK_X_ALIGN', 'WATERMARK_TRANSPARENCY')); - if (!isset($config['WATERMARK_TYPES'])) - $config['WATERMARK_TYPES'] = ''; - $tmp = explode(',', $config['WATERMARK_TYPES']); - foreach (ImageType::getImagesTypes('products') as $type) - if (in_array($type['id_image_type'], $tmp)) - $this->imageTypes[] = $type; - - $this->yAlign = isset($config['WATERMARK_Y_ALIGN']) ? $config['WATERMARK_Y_ALIGN'] : ''; - $this->xAlign = isset($config['WATERMARK_X_ALIGN']) ? $config['WATERMARK_X_ALIGN'] : ''; - $this->transparency = isset($config['WATERMARK_TRANSPARENCY']) ? $config['WATERMARK_TRANSPARENCY'] : 60; - - $this->displayName = $this->l('Watermark'); - $this->description = $this->l('Protect image by watermark.'); - $this->confirmUninstall = $this->l('Are you sure you want to delete your details ?'); - if (!isset($this->transparency) || !isset($this->xAlign) || !isset($this->yAlign)) - $this->warning = $this->l('Watermark image must be uploaded in order for this module to work correctly.'); - } - - public function install() - { - $this->writeHtaccessSection(); - if (!parent::install() || !$this->registerHook('watermark')) - return false; - Configuration::updateValue('WATERMARK_TRANSPARENCY', 60); - Configuration::updateValue('WATERMARK_Y_ALIGN', 'bottom'); - Configuration::updateValue('WATERMARK_X_ALIGN', 'right'); - return true; - } - - public function uninstall() - { - $this->removeHtaccessSection(); - return (parent::uninstall() - && Configuration::deleteByName('WATERMARK_TYPES') - && Configuration::deleteByName('WATERMARK_TRANSPARENCY') - && Configuration::deleteByName('WATERMARK_Y_ALIGN') - && Configuration::deleteByName('WATERMARK_X_ALIGN')); - } - - private function _postValidation() - { - $yalign = Tools::getValue('yalign'); - $xalign = Tools::getValue('xalign'); - $transparency = (int)(Tools::getValue('transparency')); - - $types = ImageType::getImagesTypes('products'); - $id_image_type = array(); - foreach ($types as $type) - if (!is_null(Tools::getValue('WATERMARK_TYPES_'.(int)$type['id_image_type']))) - $id_image_type['WATERMARK_TYPES_'.(int)$type['id_image_type']] = true; - - if (empty($transparency)) - $this->_postErrors[] = $this->l('Transparency required.'); - elseif ($transparency < 1 || $transparency > 100) - $this->_postErrors[] = $this->l('Transparency is not in allowed range.'); - - if (empty($yalign)) - $this->_postErrors[] = $this->l('Y-Align is required.'); - elseif (!in_array($yalign, $this->yaligns)) - $this->_postErrors[] = $this->l('Y-Align is not in allowed range.'); - - if (empty($xalign)) - $this->_postErrors[] = $this->l('X-Align is required.'); - elseif (!in_array($xalign, $this->xaligns)) - $this->_postErrors[] = $this->l('X-Align is not in allowed range.'); - if (!count($id_image_type)) - $this->_postErrors[] = $this->l('At least one image type is required.'); - - if (isset($_FILES['PS_WATERMARK']['tmp_name']) && !empty($_FILES['PS_WATERMARK']['tmp_name'])) - { - if (!ImageManager::isRealImage($_FILES['PS_WATERMARK']['tmp_name'], $_FILES['PS_WATERMARK']['type'], array('image/gif'))) - $this->_postErrors[] = $this->l('Image must be in GIF format.'); - } - - return !count($this->_postErrors) ? true : false; - } - - private function _postProcess() - { - $types = ImageType::getImagesTypes('products'); - $id_image_type = array(); - foreach ($types as $type) - if (Tools::getValue('WATERMARK_TYPES_'.(int)$type['id_image_type'])) - $id_image_type[] = $type['id_image_type']; - - Configuration::updateValue('WATERMARK_TYPES', implode(',', $id_image_type)); - Configuration::updateValue('WATERMARK_Y_ALIGN', Tools::getValue('yalign')); - Configuration::updateValue('WATERMARK_X_ALIGN', Tools::getValue('xalign')); - Configuration::updateValue('WATERMARK_TRANSPARENCY', Tools::getValue('transparency')); - - if (Shop::getContext() == Shop::CONTEXT_SHOP) - $str_shop = '-'.(int)$this->context->shop->id; - else - $str_shop = ''; - //submited watermark - if (isset($_FILES['PS_WATERMARK']) && !empty($_FILES['PS_WATERMARK']['tmp_name'])) - { - /* Check watermark validity */ - if ($error = ImageManager::validateUpload($_FILES['PS_WATERMARK'])) - $this->_errors[] = $error; - /* Copy new watermark */ - elseif (!copy($_FILES['PS_WATERMARK']['tmp_name'], dirname(__FILE__).'/watermark'.$str_shop.'.gif')) - $this->_errors[] = sprintf($this->l('An error occurred while uploading watermark: %1$s to %2$s'), $_FILES['PS_WATERMARK']['tmp_name'], dirname(__FILE__).'/watermark'.$str_shop.'.gif'); - } - - if ($this->_errors) - foreach ($this->_errors as $error) - $this->_html .= $this->displayError($this->l($error)); - else - $this->_html .= $this->displayConfirmation($this->l('Settings updated')); - } - - public function getAdminDir() - { - $admin_dir = str_replace('\\', '/', _PS_ADMIN_DIR_); - $admin_dir = explode('/', $admin_dir); - $len = count($admin_dir); - return $len > 1 ? $admin_dir[$len - 1] : _PS_ADMIN_DIR_; - } - - public function removeHtaccessSection() - { - $key1 = "\n# start ~ module watermark section"; - $key2 = "# end ~ module watermark section\n"; - $path = _PS_ROOT_DIR_ . '/.htaccess'; - if (file_exists($path) && is_writable($path)) { - $s = file_get_contents($path); - $p1 = strpos($s, $key1); - $p2 = strpos($s, $key2, $p1); - if ($p1 === false || $p2 === false) return false; - $s = substr($s, 0, $p1) . substr($s, $p2 + strlen($key2)); - file_put_contents($path, $s); - } - return true; - } - - public function writeHtaccessSection() - { - $admin_dir = $this->getAdminDir(); - $source = "\n# start ~ module watermark section -Options +FollowSymLinks -RewriteEngine On -RewriteCond expr \"! %{HTTP_REFERER} -strmatch '*://%{HTTP_HOST}*/$admin_dir/*'\" -RewriteRule [0-9/]+/[0-9]+\\.jpg$ - [F] -# end ~ module watermark section\n"; - - $path = _PS_ROOT_DIR_ . '/.htaccess'; - file_put_contents($path, $source, FILE_APPEND); - } - - public function getContent() - { - //Modify htaccess to prevent downlaod of original pictures - $this->removeHtaccessSection(); - $this->writeHtaccessSection(); - - $this->_html = ''; - - if (Tools::isSubmit('btnSubmit')) - { - $this->_postValidation(); - if (!count($this->_postErrors)) - $this->_postProcess(); - else - foreach ($this->_postErrors as $err) - $this->_html .= $this->displayError($err); - } - - $this->_html .= $this->renderForm(); - - return $this->_html; - } - - // Retrocompatibility - public function hookwatermark($params) - { - $this->hookActionWatermark($params); - } - - public function hookActionWatermark($params) - { - $image = new Image($params['id_image']); - $image->id_product = $params['id_product']; - $file = _PS_PROD_IMG_DIR_.$image->getExistingImgPath().'-watermark.jpg'; - - $str_shop = '-'.(int)$this->context->shop->id; - if (Shop::getContext() != Shop::CONTEXT_SHOP || !Tools::file_exists_cache(dirname(__FILE__).'/watermark'.$str_shop.'.gif')) - $str_shop = ''; - - //first make a watermark image - $return = $this->watermarkByImage(_PS_PROD_IMG_DIR_.$image->getExistingImgPath().'.jpg', dirname(__FILE__).'/watermark'.$str_shop.'.gif', $file, 23, 0, 0, 'right'); - - //go through file formats defined for watermark and resize them - foreach ($this->imageTypes as $imageType) - { - $newFile = _PS_PROD_IMG_DIR_.$image->getExistingImgPath().'-'.stripslashes($imageType['name']).'.jpg'; - if (!ImageManager::resize($file, $newFile, (int)$imageType['width'], (int)$imageType['height'])) - $return = false; - } - return $return; - } - - private function watermarkByImage($imagepath, $watermarkpath, $outputpath) - { - $Xoffset = $Yoffset = $xpos = $ypos = 0; - if (!$image = imagecreatefromjpeg($imagepath)) - return false; - if (!$imagew = imagecreatefromgif($watermarkpath)) - die ($this->l('The watermark image is not a real gif, please CONVERT the image.')); - list($watermarkWidth, $watermarkHeight) = getimagesize($watermarkpath); - list($imageWidth, $imageHeight) = getimagesize($imagepath); - if ($this->xAlign == 'middle') - $xpos = $imageWidth / 2 - $watermarkWidth / 2 + $Xoffset; - if ($this->xAlign == 'left') - $xpos = 0 + $Xoffset; - if ($this->xAlign == 'right') - $xpos = $imageWidth - $watermarkWidth - $Xoffset; - if ($this->yAlign == 'middle') - $ypos = $imageHeight / 2 - $watermarkHeight / 2 + $Yoffset; - if ($this->yAlign == 'top') - $ypos = 0 + $Yoffset; - if ($this->yAlign == 'bottom') - $ypos = $imageHeight - $watermarkHeight - $Yoffset; - if (!imagecopymerge($image, $imagew, $xpos, $ypos, 0, 0, $watermarkWidth, $watermarkHeight, $this->transparency)) - return false; - return imagejpeg($image, $outputpath, 100); - } - - public function renderForm() - { - $types = ImageType::getImagesTypes('products'); - foreach ($types as $key => $type) - $types[$key]['label'] = $type['name'].' ('.$type['width'].' x '.$type['height'].')'; - - $fields_form = array( - 'form' => array( - 'legend' => array( - 'title' => $this->l('Settings'), - 'icon' => 'icon-cogs' - ), - 'description' => $this->l('Once you have set up the module, regenerate the images using the "Images" tool in Preferences. However, the watermark will be added automatically to new images.'), - 'input' => array( - array( - 'type' => 'file', - 'label' => $this->l('Watermark file:'), - 'name' => 'PS_WATERMARK', - 'desc' => $this->l('Must be in GIF format'), - 'thumb' => '../modules/'.$this->name.'/'.$this->name.'.gif?t='.rand(0, time()), - ), - array( - 'type' => 'text', - 'label' => $this->l('Watermark transparency (1-100)'), - 'name' => 'transparency', - 'class' => 'fixed-width-md', - ), - array( - 'type' => 'select', - 'label' => $this->l('Watermark X align:'), - 'name' => 'xalign', - 'class' => 'fixed-width-md', - 'options' => array( - 'query' => array( - array( - 'id' => 'left', - 'name' => $this->l('left') - ), - array( - 'id' => 'middle', - 'name' => $this->l('middle') - ), - array( - 'id' => 'right', - 'name' => $this->l('right') - ) - ), - 'id' => 'id', - 'name' => 'name', - ) - ), - array( - 'type' => 'select', - 'label' => $this->l('Watermark X align:'), - 'name' => 'yalign', - 'class' => 'fixed-width-md', - 'options' => array( - 'query' => array( - array( - 'id' => 'top', - 'name' => $this->l('top') - ), - array( - 'id' => 'middle', - 'name' => $this->l('middle') - ), - array( - 'id' => 'bottom', - 'name' => $this->l('bottom') - ) - ), - 'id' => 'id', - 'name' => 'name', - ) - ), - array( - 'type' => 'checkbox', - 'name' => 'WATERMARK_TYPES', - 'label' => $this->l('Choose image types for watermark protection:'), - 'values' => array( - 'query' => $types, - 'id' => 'id_image_type', - 'name' => 'label' - ) - ), - ), - 'submit' => array( - 'title' => $this->l('Save'), - 'class' => 'btn btn-default') - ), - ); - - $helper = new HelperForm(); - $helper->show_toolbar = false; - $helper->table = $this->table; - $lang = new Language((int)Configuration::get('PS_LANG_DEFAULT')); - $helper->default_form_language = $lang->id; - $helper->allow_employee_form_lang = Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG') ? Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG') : 0; - $helper->identifier = $this->identifier; - $helper->submit_action = 'btnSubmit'; - $helper->currentIndex = $this->context->link->getAdminLink('AdminModules', false).'&configure='.$this->name.'&tab_module='.$this->tab.'&module_name='.$this->name; - $helper->token = Tools::getAdminTokenLite('AdminModules'); - $helper->tpl_vars = array( - 'fields_value' => $this->getConfigFieldsValues(), - 'languages' => $this->context->controller->getLanguages(), - 'id_language' => $this->context->language->id - ); - - return $helper->generateForm(array($fields_form)); - } - - public function getConfigFieldsValues() - { - $config_fields = array( - 'PS_WATERMARK' => Tools::getValue('PS_WATERMARK', Configuration::get('PS_WATERMARK')), - 'transparency' => Tools::getValue('transparency', Configuration::get('WATERMARK_TRANSPARENCY')), - 'xalign' => Tools::getValue('xalign', Configuration::get('WATERMARK_X_ALIGN')), - 'yalign' => Tools::getValue('yalign', Configuration::get('WATERMARK_Y_ALIGN')), - ); - //get all images type available - $types = ImageType::getImagesTypes('products'); - $id_image_type = array(); - foreach ($types as $type) - $id_image_type[] = $type['id_image_type']; - - //get images type from $_POST - $id_image_type_post = array(); - foreach ($id_image_type as $id) - if (Tools::getValue('WATERMARK_TYPES_'.(int)$id)) - $id_image_type_post['WATERMARK_TYPES_'.(int)$id] = true; - - //get images type from Configuration - $id_image_type_config = array(); - if ($confs = Configuration::get('WATERMARK_TYPES')) - $confs = explode(',', Configuration::get('WATERMARK_TYPES')); - else - $confs = array(); - - foreach ($confs as $conf) - $id_image_type_config['WATERMARK_TYPES_'.(int)$conf] = true; - - //return only common values and value from post - if (Tools::isSubmit('btnSubmit')) - $config_fields = array_merge($config_fields, array_intersect($id_image_type_post, $id_image_type_config)); - else - $config_fields = array_merge($config_fields, $id_image_type_config); - - return $config_fields; - } -}