// Context part 26
This commit is contained in:
@@ -68,12 +68,12 @@ class WishList extends ObjectModel
|
||||
|
||||
public function delete()
|
||||
{
|
||||
global $cookie;
|
||||
$context = Context::getContext();
|
||||
|
||||
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($cookie->id_wishlist))
|
||||
unset($cookie->id_wishlist);
|
||||
if (isset($context->cookie->id_wishlist))
|
||||
unset($context->cookie->id_wishlist);
|
||||
|
||||
return (parent::delete());
|
||||
}
|
||||
@@ -102,13 +102,13 @@ class WishList extends ObjectModel
|
||||
|
||||
public static function isExistsByNameForUser($name)
|
||||
{
|
||||
global $cookie;
|
||||
|
||||
$context = Context::getContext();
|
||||
|
||||
return Db::getInstance()->getValue('
|
||||
SELECT COUNT(*) AS total
|
||||
FROM `'._DB_PREFIX_.'wishlist`
|
||||
WHERE `name` = \''.pSQL($name).'\'
|
||||
AND `id_customer` = '.(int)($cookie->id_customer)
|
||||
AND `id_customer` = '.(int)$context->customer->id
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -30,6 +30,7 @@ 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);
|
||||
@@ -39,39 +40,39 @@ $quantity = (int)(Tools::getValue('quantity'));
|
||||
$id_product_attribute = (int)(Tools::getValue('id_product_attribute'));
|
||||
if (Configuration::get('PS_TOKEN_ENABLE') == 1 AND
|
||||
strcmp(Tools::getToken(false), Tools::getValue('token')) AND
|
||||
$cookie->isLogged() === true)
|
||||
$context->cookie->isLogged() === true)
|
||||
echo Tools::displayError('Invalid token');
|
||||
if ($cookie->isLogged())
|
||||
if ($context->cookie->isLogged())
|
||||
{
|
||||
if ($id_wishlist AND WishList::exists($id_wishlist, $cookie->id_customer) === true)
|
||||
$cookie->id_wishlist = (int)($id_wishlist);
|
||||
if (empty($cookie->id_wishlist) === true OR $cookie->id_wishlist == false)
|
||||
$smarty->assign('error', true);
|
||||
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($cookie->id_wishlist) OR $cookie->id_wishlist == '')
|
||||
if(!isset($context->cookie->id_wishlist) OR $context->cookie->id_wishlist == '')
|
||||
{
|
||||
$wishlist = new WishList();
|
||||
$modWishlist = new BlockWishList();
|
||||
$wishlist->name = $modWishlist->default_wishlist_name;
|
||||
$wishlist->id_customer = (int)($cookie->id_customer);
|
||||
$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_.$cookie->id_customer), 0, 16));
|
||||
$wishlist->token = strtoupper(substr(sha1(uniqid(rand(), true)._COOKIE_KEY_.$context->customer->id), 0, 16));
|
||||
$wishlist->add();
|
||||
$cookie->id_wishlist = (int)($wishlist->id);
|
||||
$context->cookie->id_wishlist = (int)($wishlist->id);
|
||||
}
|
||||
if ($add AND $quantity)
|
||||
WishList::addProduct($cookie->id_wishlist, $cookie->id_customer, $id_product, $id_product_attribute, $quantity);
|
||||
WishList::addProduct($context->cookie->id_wishlist, $context->customer->id, $id_product, $id_product_attribute, $quantity);
|
||||
else if ($delete)
|
||||
WishList::removeProduct($cookie->id_wishlist, $cookie->id_customer, $id_product, $id_product_attribute);
|
||||
WishList::removeProduct($context->cookie->id_wishlist, $context->customer->id, $id_product, $id_product_attribute);
|
||||
}
|
||||
$smarty->assign('products', WishList::getProductByIdCustomer($cookie->id_wishlist, $cookie->id_customer, $cookie->id_lang, null, true));
|
||||
$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'))
|
||||
$smarty->display(_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'))
|
||||
$smarty->display(dirname(__FILE__).'/blockwishlist-ajax.tpl');
|
||||
$context->smarty->display(dirname(__FILE__).'/blockwishlist-ajax.tpl');
|
||||
else
|
||||
echo Tools::displayError('No template found');
|
||||
}
|
||||
|
||||
@@ -31,8 +31,8 @@ $useSSL = true;
|
||||
require_once(dirname(__FILE__).'/../../config/config.inc.php');
|
||||
require_once(dirname(__FILE__).'/../../init.php');
|
||||
require_once(dirname(__FILE__).'/WishList.php');
|
||||
|
||||
if ($cookie->isLogged())
|
||||
$context = Context::getContext();
|
||||
if ($context->cookie->isLogged())
|
||||
{
|
||||
$action = Tools::getValue('action');
|
||||
$id_wishlist = (int)Tools::getValue('id_wishlist');
|
||||
@@ -51,26 +51,26 @@ if ($cookie->isLogged())
|
||||
else
|
||||
{
|
||||
if (!strcmp($action, 'delete'))
|
||||
WishList::removeProduct($id_wishlist, (int)($cookie->id_customer), $id_product, $id_product_attribute);
|
||||
WishList::removeProduct($id_wishlist, (int)$context->customer->id, $id_product, $id_product_attribute);
|
||||
|
||||
$products = WishList::getProductByIdCustomer($id_wishlist, $cookie->id_customer, $cookie->id_lang);
|
||||
$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, (int)($cookie->id_lang));
|
||||
$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((int)($cookie->id_lang));
|
||||
$combination_imgs = $obj->getCombinationImages($context->language->id);
|
||||
$products[$i]['cover'] = $obj->id.'-'.$combination_imgs[$products[$i]['id_product_attribute']][0]['id_image'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$images = $obj->getImages((int)($cookie->id_lang));
|
||||
$images = $obj->getImages($context->language->id);
|
||||
foreach ($images AS $k => $image)
|
||||
if ($image['cover'])
|
||||
{
|
||||
@@ -79,7 +79,7 @@ if ($cookie->isLogged())
|
||||
}
|
||||
}
|
||||
if (!isset($products[$i]['cover']))
|
||||
$products[$i]['cover'] = Language::getIsoById($cookie->id_lang).'-default';
|
||||
$products[$i]['cover'] = $context->language->iso_code.'-default';
|
||||
}
|
||||
$products[$i]['bought'] = false;
|
||||
for ($j = 0, $k = 0; $j < sizeof($bought); ++$j)
|
||||
@@ -95,7 +95,7 @@ if ($cookie->isLogged())
|
||||
foreach ($products as $product)
|
||||
if (sizeof($product['bought']))
|
||||
$productBoughts[] = $product;
|
||||
$smarty->assign(array(
|
||||
$context->smarty->assign(array(
|
||||
'products' => $products,
|
||||
'productsBoughts' => $productBoughts,
|
||||
'id_wishlist' => $id_wishlist,
|
||||
@@ -104,9 +104,9 @@ if ($cookie->isLogged())
|
||||
));
|
||||
|
||||
if (Tools::file_exists_cache(_PS_THEME_DIR_.'modules/blockwishlist/managewishlist.tpl'))
|
||||
$smarty->display(_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'))
|
||||
$smarty->display(dirname(__FILE__).'/managewishlist.tpl');
|
||||
$context->smarty->display(dirname(__FILE__).'/managewishlist.tpl');
|
||||
else
|
||||
echo Tools::displayError('No template found');
|
||||
}
|
||||
|
||||
@@ -32,6 +32,7 @@ include(dirname(__FILE__).'/../../config/config.inc.php');
|
||||
include(dirname(__FILE__).'/../../header.php');
|
||||
include_once(dirname(__FILE__).'/WishList.php');
|
||||
|
||||
$context = Context::getContext();
|
||||
$errors = array();
|
||||
|
||||
if ($cookie->isLogged())
|
||||
@@ -58,21 +59,21 @@ if ($cookie->isLogged())
|
||||
{
|
||||
$wishlist = new WishList();
|
||||
$wishlist->name = $name;
|
||||
$wishlist->id_customer = (int)$cookie->id_customer;
|
||||
$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_.$cookie->id_customer), 0, 16));
|
||||
$wishlist->token = strtoupper(substr(sha1(uniqid(rand(), true)._COOKIE_KEY_.$context->customer->id), 0, 16));
|
||||
$wishlist->add();
|
||||
Mail::Send((int)($cookie->id_lang), 'wishlink', Mail::l('Your wishlist\'s link'),
|
||||
Mail::Send($context->language->id, 'wishlink', Mail::l('Your wishlist\'s link'),
|
||||
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),
|
||||
$cookie->email, $cookie->firstname.' '.$cookie->lastname, NULL, strval(Configuration::get('PS_SHOP_NAME')), NULL, NULL, dirname(__FILE__).'/mails/');
|
||||
$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((int)($cookie->id_customer), (int)(Tools::getValue('id_wishlist')), (int)($cookie->id_lang));
|
||||
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));
|
||||
@@ -81,23 +82,23 @@ if ($cookie->isLogged())
|
||||
else
|
||||
$errors[] = Tools::displayError('Cannot delete this wishlist');
|
||||
}
|
||||
$smarty->assign('wishlists', WishList::getByIdCustomer((int)($cookie->id_customer)));
|
||||
$smarty->assign('nbProducts', WishList::getInfosByIdCustomer((int)($cookie->id_customer)));
|
||||
$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');
|
||||
}
|
||||
|
||||
$smarty->assign(array(
|
||||
'id_customer' => (int)($cookie->id_customer),
|
||||
$context->smarty->assign(array(
|
||||
'id_customer' => (int)$context->customer->id,
|
||||
'errors' => $errors
|
||||
));
|
||||
|
||||
if (Tools::file_exists_cache(_PS_THEME_DIR_.'modules/blockwishlist/mywishlist.tpl'))
|
||||
$smarty->display(_PS_THEME_DIR_.'modules/blockwishlist/mywishlist.tpl');
|
||||
$context->smarty->display(_PS_THEME_DIR_.'modules/blockwishlist/mywishlist.tpl');
|
||||
elseif (Tools::file_exists_cache(dirname(__FILE__).'/mywishlist.tpl'))
|
||||
$smarty->display(dirname(__FILE__).'/mywishlist.tpl');
|
||||
$context->smarty->display(dirname(__FILE__).'/mywishlist.tpl');
|
||||
else
|
||||
echo Tools::displayError('No template found');
|
||||
|
||||
|
||||
@@ -31,10 +31,10 @@ require_once(dirname(__FILE__).'/WishList.php');
|
||||
|
||||
if (Configuration::get('PS_TOKEN_ENABLE') == 1 AND
|
||||
strcmp(Tools::getToken(false), Tools::getValue('token')) AND
|
||||
$cookie->isLogged() === true)
|
||||
$context->cookie->isLogged() === true)
|
||||
exit(Tools::displayError('invalid token',false));
|
||||
|
||||
if ($cookie->isLogged())
|
||||
if ($context->cookie->isLogged())
|
||||
{
|
||||
$id_wishlist = (int)(Tools::getValue('id_wishlist'));
|
||||
if (empty($id_wishlist) === true)
|
||||
@@ -42,15 +42,15 @@ if ($cookie->isLogged())
|
||||
for ($i = 1; empty($_POST['email'.strval($i)]) === false; ++$i)
|
||||
{
|
||||
$to = Tools::getValue('email'.$i);
|
||||
$wishlist = WishList::exists($id_wishlist, $cookie->id_customer, true);
|
||||
$wishlist = WishList::exists($id_wishlist, $context->customer->id, true);
|
||||
if ($wishlist === false)
|
||||
exit(Tools::displayError('Invalid wishlist',false));
|
||||
if (WishList::addEmail($id_wishlist, $to) === false)
|
||||
exit(Tools::displayError('Wishlist send error',false));
|
||||
$toName = strval(Configuration::get('PS_SHOP_NAME'));
|
||||
$customer = new Customer((int)($cookie->id_customer));
|
||||
$customer = $context->customer;
|
||||
if (Validate::isLoadedObject($customer))
|
||||
Mail::Send((int)($cookie->id_lang), 'wishlist', Mail::l('Message from ').$customer->lastname.' '.$customer->firstname,
|
||||
Mail::Send($context->language->id, 'wishlist', Mail::l('Message from ').$customer->lastname.' '.$customer->firstname,
|
||||
array(
|
||||
'{lastname}' => $customer->lastname,
|
||||
'{firstname}' => $customer->firstname,
|
||||
|
||||
@@ -32,6 +32,7 @@ require_once(dirname(__FILE__).'/../../config/config.inc.php');
|
||||
require_once(dirname(__FILE__).'/../../header.php');
|
||||
require_once(dirname(__FILE__).'/WishList.php');
|
||||
|
||||
$context = Context::getContext();
|
||||
$token = Tools::getValue('token');
|
||||
if (empty($token) === false)
|
||||
{
|
||||
@@ -39,22 +40,22 @@ if (empty($token) === false)
|
||||
if (empty($result) === true || $result === false)
|
||||
$errors[] = Tools::displayError('Invalid wishlist token');
|
||||
WishList::refreshWishList($wishlist['id_wishlist']);
|
||||
$products = WishList::getProductByIdCustomer((int)($wishlist['id_wishlist']), (int)($wishlist['id_customer']), (int)($cookie->id_lang), null, true);
|
||||
$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, (int)($cookie->id_lang));
|
||||
$obj = new Product($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((int)($cookie->id_lang));
|
||||
$combination_imgs = $obj->getCombinationImages($context->language->id);
|
||||
$products[$i]['cover'] = $obj->id.'-'.$combination_imgs[$products[$i]['id_product_attribute']][0]['id_image'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$images = $obj->getImages((int)($cookie->id_lang));
|
||||
$images = $obj->getImages($context->language->id);
|
||||
foreach ($images AS $k => $image)
|
||||
{
|
||||
if ($image['cover'])
|
||||
@@ -64,13 +65,13 @@ if (empty($token) === false)
|
||||
}
|
||||
}
|
||||
if (!isset($products[$i]['cover']))
|
||||
$products[$i]['cover'] = Language::getIsoById((int)($cookie->id_lang)).'-default';
|
||||
$products[$i]['cover'] = $context->language->iso_code.'-default';
|
||||
}
|
||||
}
|
||||
}
|
||||
WishList::incCounter((int)($wishlist['id_wishlist']));
|
||||
$ajax = Configuration::get('PS_BLOCK_CART_AJAX');
|
||||
$smarty->assign(array (
|
||||
$context->context->smarty->assign(array (
|
||||
'current_wishlist' => $wishlist,
|
||||
'token' => $token,
|
||||
'ajax' => ((isset($ajax) AND (int)($ajax) == 1) ? '1' : '0'),
|
||||
@@ -79,9 +80,9 @@ if (empty($token) === false)
|
||||
}
|
||||
|
||||
if (Tools::file_exists_cache(_PS_THEME_DIR_.'modules/blockwishlist/view.tpl'))
|
||||
$smarty->display(_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'))
|
||||
$smarty->display(dirname(__FILE__).'/view.tpl');
|
||||
$context->smarty->display(dirname(__FILE__).'/view.tpl');
|
||||
else
|
||||
echo Tools::displayError('No template found');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user