// Context part 31

git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@8087 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
tDidierjean
2011-08-17 10:07:12 +00:00
parent b8706ddd8a
commit cb3d802346
57 changed files with 200 additions and 165 deletions
+1 -1
View File
@@ -32,7 +32,7 @@ include(dirname(__FILE__).'/../../config/config.inc.php');
include(dirname(__FILE__).'/../../header.php');
include(dirname(__FILE__).'/bankwire.php');
if (!$cookie->isLogged(true))
if (!Context::getContext()->customer->isLogged(true))
Tools::redirect('index.php?controller=authentication&back=order.php');
$bankwire = new BankWire();
echo $bankwire->execPayment($cart);
+1 -1
View File
@@ -58,7 +58,7 @@ class BlockMyAccount extends Module
public function hookLeftColumn($params)
{
if (!$params['cookie']->isLogged())
if ($this->context->customer->isLogged())
return false;
$this->context->smarty->assign(array(
'voucherAllowed' => (int)(Configuration::get('PS_VOUCHERS')),
+4 -4
View File
@@ -62,10 +62,10 @@ class BlockUserInfo extends Module
$this->context->smarty->assign(array(
'cart' => $this->context->cart,
'cart_qties' => $this->context->cart->nbProducts(),
'logged' => $this->context->cookie->isLogged(),
'customerName' => ($this->context->cookie->logged ? $this->context->customer->firstname.' '.$this->context->customer->lastname : false),
'firstName' => ($this->context->cookie->logged ? $this->context->customer->firstname : false),
'lastName' => ($this->context->cookie->logged ? $this->context->customer->lastname : false),
'logged' => $this->context->customer->isLogged(),
'customerName' => ($this->context->customer->logged ? $this->context->customer->firstname.' '.$this->context->customer->lastname : false),
'firstName' => ($this->context->customer->logged ? $this->context->customer->firstname : false),
'lastName' => ($this->context->customer->logged ? $this->context->customer->lastname : false),
'order_process' => Configuration::get('PS_ORDER_PROCESS_TYPE') ? 'order-opc' : 'order'
));
return $this->display(__FILE__, 'blockuserinfo.tpl');
+2 -2
View File
@@ -28,8 +28,8 @@
<div id="header_user">
<p id="header_user_info">
{l s='Welcome' mod='blockuserinfo'},
{if $cookie->isLogged()}
<span>{$cookie->customer_firstname} {$cookie->customer_lastname}</span>
{if $logged}
<span>{$firstName} {$lastName}</span>
(<a href="{$link->getPageLink('index', true, NULL, "mylogout")}" title="{l s='Log me out' mod='blockuserinfo'}">{l s='Log out' mod='blockuserinfo'}</a>)
{else}
<a href="{$link->getPageLink('my-account', true)}">{l s='Log in' mod='blockuserinfo'}</a>
+7 -7
View File
@@ -178,26 +178,26 @@ class BlockWishList extends Module
global $errors;
require_once(dirname(__FILE__).'/WishList.php');
if ($params['cookie']->isLogged())
if ($this->context->customer->isLogged())
{
$wishlists = Wishlist::getByIdCustomer($params['cookie']->id_customer);
if (empty($params['cookie']->id_wishlist) === true ||
WishList::exists($params['cookie']->id_wishlist, $params['cookie']->id_customer) === false)
$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']);
$params['cookie']->id_wishlist = (int)($id_wishlist);
$this->context->cookie->id_wishlist = (int)($id_wishlist);
}
}
else
$id_wishlist = $params['cookie']->id_wishlist;
$id_wishlist = $this->context->cookie->id_wishlist;
$this->context->smarty->assign(array(
'id_wishlist' => $id_wishlist,
'isLogged' => true,
'wishlist_products' => ($id_wishlist == false ? false : WishList::getProductByIdCustomer($id_wishlist, $params['cookie']->id_customer, $params['cookie']->id_lang, null, 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)));
}
+2 -2
View File
@@ -40,9 +40,9 @@ $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
$context->cookie->isLogged() === true)
$context->customer->isLogged() === true)
echo Tools::displayError('Invalid token');
if ($context->cookie->isLogged())
if ($context->customer->isLogged())
{
if ($id_wishlist AND WishList::exists($id_wishlist, $context->customer->id) === true)
$context->cookie->id_wishlist = (int)($id_wishlist);
+1 -1
View File
@@ -32,7 +32,7 @@ require_once(dirname(__FILE__).'/../../config/config.inc.php');
require_once(dirname(__FILE__).'/../../init.php');
require_once(dirname(__FILE__).'/WishList.php');
$context = Context::getContext();
if ($context->cookie->isLogged())
if ($context->customer->isLogged())
{
$action = Tools::getValue('action');
$id_wishlist = (int)Tools::getValue('id_wishlist');
+1 -1
View File
@@ -35,7 +35,7 @@ include_once(dirname(__FILE__).'/WishList.php');
$context = Context::getContext();
$errors = array();
if ($cookie->isLogged())
if ($context->customer->isLogged())
{
$add = Tools::getIsset('add');
$add = (empty($add) === false ? 1 : 0);
+4 -2
View File
@@ -29,12 +29,14 @@ require_once(dirname(__FILE__).'/../../config/config.inc.php');
require_once(dirname(__FILE__).'/../../init.php');
require_once(dirname(__FILE__).'/WishList.php');
$context = Context::getContext();
if (Configuration::get('PS_TOKEN_ENABLE') == 1 AND
strcmp(Tools::getToken(false), Tools::getValue('token')) AND
$context->cookie->isLogged() === true)
$context->customer->isLogged() === true)
exit(Tools::displayError('invalid token',false));
if ($context->cookie->isLogged())
if ($context->customer->isLogged())
{
$id_wishlist = (int)(Tools::getValue('id_wishlist'));
if (empty($id_wishlist) === true)
+1 -1
View File
@@ -32,7 +32,7 @@ include(dirname(__FILE__).'/../../config/config.inc.php');
include(dirname(__FILE__).'/../../header.php');
include(dirname(__FILE__).'/cheque.php');
if (!Context::getContext()->cookie->isLogged(true))
if (!Context::getContext()->customer->isLogged(true))
Tools::redirect('index.php?controller=authentication&back=order.php');
$cheque = new Cheque();
@@ -33,7 +33,7 @@ require_once(dirname(__FILE__).'/../../init.php');
require_once(dirname(__FILE__).'/FavoriteProduct.php');
if (!Context::getContext()->cookie->isLogged())
if (!Context::getContext()->customer->isLogged())
Tools::redirect('authentication.php?back=modules/favoriteproducts/favoriteproducts.php');
include(dirname(__FILE__).'/../../header.php');
@@ -78,7 +78,7 @@ class FavoriteProducts extends Module
{
include_once(dirname(__FILE__).'/FavoriteProduct.php');
$favoriteProducts = FavoriteProduct::getFavoriteProducts((int)$this->context->cookie->id_customer, (int)$this->context->cookie->id_lang);
$favoriteProducts = FavoriteProduct::getFavoriteProducts($this->context->customer->id, $this->context->language->id);
$this->context->smarty->assign(array('favorite_products' => $favoriteProducts));
@@ -95,8 +95,8 @@ class FavoriteProducts extends Module
include_once(dirname(__FILE__).'/FavoriteProduct.php');
$this->context->smarty->assign(array(
'isCustomerFavoriteProduct' => (FavoriteProduct::isCustomerFavoriteProduct((int)($this->context->cookie->id_customer), Tools::getValue('id_product')) ? 1 : 0),
'isLogged' => (int)$this->context->cookie->id_customer));
'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');
}
+1 -1
View File
@@ -29,7 +29,7 @@ include(dirname(__FILE__).'/../../config/config.inc.php');
include(dirname(__FILE__).'/../../init.php');
include(dirname(__FILE__).'/gcheckout.php');
if (!$cookie->isLogged(true))
if (!Context::getContext()->customer->isLogged(true))
Tools::redirect('index.php?controller=authentication&back=order.php');
elseif (!$cart->getOrderTotal(true, Cart::BOTH))
Tools::displayError('Error: Empty cart');
+1 -1
View File
@@ -32,7 +32,7 @@ include(dirname(__FILE__).'/../../config/config.inc.php');
include(dirname(__FILE__).'/../../init.php');
include(dirname(__FILE__).'/hipay.php');
if (!$cookie->isLogged(true))
if (!Context::getContext()->customer->isLogged(true))
Tools::redirect('index.php?controller=authentication&back=order.php');
$hipay = new HiPay();
+2 -2
View File
@@ -34,10 +34,10 @@ require_once(dirname(__FILE__).'/../../init.php');
include_once(dirname(__FILE__).'/LoyaltyModule.php');
include_once(dirname(__FILE__).'/LoyaltyStateModule.php');
if (!$cookie->isLogged())
$context = Context::getContext();
if (!$context->customer->isLogged())
Tools::redirect('index.php?controller=authentication&back=modules/loyalty/loyalty-program.php');
$context = Context::getContext();
$context->controller->addCSS(_PS_CSS_DIR_.'jquery.cluetip.css', 'all');
$context->controller->addJS(array(_PS_JS_DIR_.'jquery/jquery.dimensions.js',_PS_JS_DIR_.'jquery/jquery.cluetip.js'));
+2 -2
View File
@@ -32,7 +32,7 @@ if (!$id_product = (int)(Tools::getValue('id_product')))
die ('0');
$id_product_attribute = (int)(Tools::getValue('id_product_attribute'));
if (!$cookie->isLogged())
if (!Context::getContext()->customer->isLogged())
{
$customer_email = trim(Tools::getValue('customer_email'));
if (empty($customer_email) OR !Validate::isEmail($customer_email))
@@ -53,7 +53,7 @@ if (!$cookie->isLogged())
}
else
{
$id_customer = (int)($cookie->id_customer);
$id_customer = (int)Context::getContext()->customer->id;
$customer_email = 0;
}
+2 -2
View File
@@ -29,10 +29,10 @@ include(dirname(__FILE__).'/../../config/config.inc.php');
include(dirname(__FILE__).'/../../init.php');
include(dirname(__FILE__).'/../../modules/mailalerts/mailalerts.php');
if (!$cookie->isLogged())
if (!Context::getContext()->customer->isLogged())
die('0');
$id_customer = (int)($cookie->id_customer);
$id_customer = (int)(Context::getContext()->customer->id);
if (!$id_product = (int)(Tools::getValue('id_product')))
die ('0');
$id_product_attribute = (int)(Tools::getValue('id_product_attribute'));
+1 -1
View File
@@ -258,7 +258,7 @@ class MailAlerts extends Module
$id_product = (int)($params['product']->id);
$id_product_attribute = 0;
if (!$this->context->cookie->isLogged())
if (!$this->context->customer->isLogged())
$this->context->smarty->assign('email', 1);
else
{
+4 -4
View File
@@ -34,24 +34,24 @@ include_once(dirname(__FILE__).'/mailalerts.php');
$errors = array();
if ($cookie->isLogged())
if (Context::getContext()->customer->isLogged())
{
if (Tools::getValue('action') == 'delete')
{
$id_customer = (int)($cookie->id_customer);
$id_customer = (int)(Context::getContext()->customer->id);
if (!$id_product = (int)(Tools::getValue('id_product')))
$errors[] = Tools::displayError('You must have a product to delete an alert.');
$id_product_attribute = (int)(Tools::getValue('id_product_attribute'));
$customer = new Customer((int)($id_customer));
MailAlerts::deleteAlert((int)($id_customer), 0, (int)($id_product), (int)($id_product_attribute));
}
$smarty->assign('alerts', MailAlerts::getProductsAlerts((int)($cookie->id_customer), (int)($cookie->id_lang)));
$smarty->assign('alerts', MailAlerts::getProductsAlerts(Context::getContext()->customer->id, (int)Context::getContext()->language->id));
}
else
$errors[] = Tools::displayError('You must be logged in to manage your alerts.');
$smarty->assign(array(
'id_customer' => (int)($cookie->id_customer),
'id_customer' => (int)(Context::getContext()->customer->id),
'errors' => $errors
));
+14 -8
View File
@@ -98,7 +98,7 @@ function displayConfirm()
{
global $ppExpress, $payerID;
if (!Context::getContext()->cookie->isLogged(true))
if (!Context::getContext()->customer->isLogged(true))
die('Not logged');
if (!$payerID AND !$payerID = Tools::htmlentitiesUTF8(strval(Tools::getValue('payerID'))))
die('No payer ID');
@@ -127,7 +127,7 @@ function submitConfirm()
{
global $ppExpress;
if (!Context::getContext()->cookie->isLogged(true))
if (!Context::getContext()->customer->isLogged(true))
die('Not logged');
elseif (!$currency = (int)(Tools::getValue('currency_payement')))
die('No currency');
@@ -187,6 +187,7 @@ function submitAccount()
$context->cookie->customer_firstname = $customer->firstname;
$context->cookie->passwd = $customer->passwd;
$context->cookie->logged = 1;
$customer->logged = 1;
$context->cookie->email = $customer->email;
Module::hookExec('createAccount', array(
'_POST' => $_POST,
@@ -232,6 +233,7 @@ function submitLogin()
$context->cookie->customer_lastname = $customer->lastname;
$context->cookie->customer_firstname = $customer->firstname;
$context->cookie->logged = 1;
$customer->logged = 1;
$context->cookie->passwd = $customer->passwd;
$context->cookie->email = $customer->email;
if (Configuration::get('PS_CART_FOLLOWING') AND (empty($context->cookie->id_cart) OR Cart::getNbProducts($context->cookie->id_cart) == 0))
@@ -252,11 +254,13 @@ function displayLogin()
// Customer exists, login form
// If customer already logged, check if same mail than PayPal, and go through, or unlog
if (Context::getContext()->cookie->isLogged(true) AND isset($result['EMAIL']) AND Context::getContext()->cookie->email == $result['EMAIL'])
if (Context::getContext()->customer->isLogged(true) AND isset($result['EMAIL']) AND Context::getContext()->customer->email == $result['EMAIL'])
displayProcess($payerID);
elseif (Context::getContext()->cookie->isLogged(true))
elseif (Context::getContext()->customer->isLogged(true))
{
Context::getContext()->cookie->makeNewLog();
Context::getContext()->customer = new Customer();
}
// Smarty assigns
Context::getContext()->smarty->assign(array(
'email' => $email,
@@ -279,9 +283,11 @@ function displayAccount()
// Customer does not exists, signup form
// If customer already logged, unlog him
if (Context::getContext()->cookie->isLogged(true))
if (Context::getContext()->customer->isLogged(true))
{
Context::getContext()->cookie->makeNewLog();
Context::getContext()->customer = new Customer();
}
// Generate years, months and days
if (isset($_POST['years']) AND is_numeric($_POST['years']))
$selectedYears = (int)($_POST['years']);
@@ -332,7 +338,7 @@ function displayAccount()
// #####
// Process !!
/*if (!Context::getContext()->cookie->isLogged(true))
/*if (!Context::getContext()->customer->isLogged(true))
{
displayAccount();
die('Not logged');
+4 -4
View File
@@ -73,7 +73,7 @@ function displayConfirm()
{
global $ppPayment;
if (!Context::getContext()->cookie->isLogged(true))
if (!Context::getContext()->customer->isLogged(true))
{
header('location:../../../'); exit;
die('Not logged');
@@ -109,7 +109,7 @@ function submitConfirm()
{
global $ppPayment;
if (!Context::getContext()->cookie->isLogged(true))
if (!Context::getContext()->customer->isLogged(true))
{
header('location:../../../'); exit;
die('Not logged');
@@ -128,7 +128,7 @@ function submitConfirm()
function validOrder()
{
global $ppPayment;
if (!Context::getContext()->cookie->isLogged(true))
if (!Context::getContext()->customer->isLogged(true))
{
header('location:../../../'); exit;
die('Not logged');
@@ -151,7 +151,7 @@ function validOrder()
// #####
// Process !!
if (!Context::getContext()->cookie->isLogged(true))
if (!Context::getContext()->customer->isLogged(true))
die('Not logged');
elseif (!Context::getContext()->cart->getOrderTotal(true, Cart::BOTH))
die('Empty cart');
+1 -1
View File
@@ -209,7 +209,7 @@ class PayPal extends PaymentModule
if (!$this->active)
return ;
if (Configuration::get('PAYPAL_EXPRESS_CHECKOUT') AND !$this->context->cookie->isLogged(true) AND $this->_isPayPalAPIAvailable())
if (Configuration::get('PAYPAL_EXPRESS_CHECKOUT') AND !$this->context->customer->isLogged(true) AND $this->_isPayPalAPIAvailable())
{
$this->context->smarty->assign('logo', $this->getLogo(true));
return $this->display(__FILE__, 'express/shopping_cart.tpl');
@@ -70,7 +70,7 @@
</div>
<div>
<a href="#idTab5">{l s='Read user reviews' mod='productcomments'} ({$nbComments})</a><br/>
{if ($too_early == false AND ($cookie->isLogged() OR $allow_guests))}
{if ($too_early == false AND ($logged OR $allow_guests))}
<a id="new_comment_btn" href="#new_comment_form">{l s='Give your advice' mod='productcomments'}</a>
{/if}
</div>
@@ -111,7 +111,7 @@
<input name="title" type="text" value=""/><br/>
<label for="content">{l s='Comment' mod='productcomments'} *:</label>
<textarea name="content"></textarea>
{if $allow_guests == true && $cookie->isLogged() == false}
{if $allow_guests == true && $logged == 0}
<label>{l s='Your name:' mod='productcomments'} *:</label>
<input name="customer_name" type="text" value=""/><br/>
{/if}
+2 -2
View File
@@ -606,7 +606,7 @@ class ProductComments extends Module
$image = Product::getCover((int)($_GET['id_product']));
Context::getContext()->smarty->assign(array(
'logged' => (int)Context::getContext()->cookie->id_customer,
'logged' => (int)Context::getContext()->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('medium'),
@@ -690,7 +690,7 @@ class ProductComments extends Module
$averageTotal = count($averages) ? ($averageTotal / count($averages)) : 0;
Context::getContext()->smarty->assign(array(
'logged' => (int)Context::getContext()->cookie->id_customer,
'logged' => (int)Context::getContext()->customer->isLogged(true),
'action_url' => '',
'comments' => ProductComment::getByProduct((int)Tools::getValue('id_product'), 1, null, Context::getContext()->cookie->id_customer),
'criterions' => ProductCommentCriterion::getByProduct((int)Tools::getValue('id_product'), Context::getContext()->language->id),
+1 -1
View File
@@ -111,7 +111,7 @@
{if $comment.total_advice > 0}
<li>{$comment.total_useful} {l s='out of' mod='productcomments'} {$comment.total_advice} {l s='people found this review useful' mod='productcomments'}</li>
{/if}
{if $cookie->isLogged() == true}
{if $logged == 1}
{if !$comment.customer_advice}
<li>{l s='Was this comment useful to you?' mod='productcomments'}<button class="usefulness_btn" id="comment_useful_yes_{$comment.id_product_comment}">{l s='yes' mod='productcomments'}</button><button class="usefulness_btn" id="comment_useful_no_{$comment.id_product_comment}">{l s='no' mod='productcomments'}</button></li>
{/if}
+3 -6
View File
@@ -27,13 +27,10 @@
require_once('../../config/config.inc.php');
require_once('../../init.php');
/*
if (!$cookie->isLogged())
Tools::redirect('../../authentication.php?back=modules/referralprogram/referralprogram-program.php');
*/
$shop_name = htmlentities(Configuration::get('PS_SHOP_NAME'), NULL, 'utf-8');
$shop_url = Tools::getHttpHost(true, true);
$customer = new Customer((int)($cookie->id_customer));
$customer = Context::getContext()->customer;
if (!preg_match("#.*\.html$#Ui", Tools::getValue('mail')) OR !preg_match("#.*\.html$#Ui", Tools::getValue('mail')))
die(Tools::displayError());
@@ -49,7 +46,7 @@ $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);
$file = str_replace('{discount}', Discount::display((float)(Configuration::get('REFERRAL_DISCOUNT_VALUE_' . $cookie->id_currency)), (int)(Configuration::get('REFERRAL_DISCOUNT_TYPE')), new Currency($cookie->id_currency)), $file);
$file = str_replace('{discount}', Discount::display((float)(Configuration::get('REFERRAL_DISCOUNT_VALUE_' . Context::getContext()->currency->id)), (int)(Configuration::get('REFERRAL_DISCOUNT_TYPE')), Context::getContext()->currency), $file);
echo $file;
@@ -32,10 +32,10 @@ require_once(dirname(__FILE__).'/../../init.php');
include_once(dirname(__FILE__).'/ReferralProgramModule.php');
if (!$cookie->isLogged())
$context = Context::getContext();
if (!$context->customer->isLogged())
Tools::redirect('index.php?controller=authentication&back=modules/referralprogram/referralprogram-program.php');
$context = Context::getContext();
$context->controller->addCSS(_PS_CSS_DIR_.'thickbox.css', 'all');
$context->controller->addJS(array(_PS_JS_DIR_.'jquery/thickbox-modified.js',_PS_JS_DIR_.'jquery/jquery.idTabs.modified.js'));
@@ -402,7 +402,7 @@ class TrustedShopsRating extends AbsTrustedShops
{
$buyer_email = '';
if (Context::getContext()->cookie->isLogged())
if (Context::getContext()->customer->isLogged())
{
if (empty($id_order) && !empty(Context::getContext()->customer->id))
$id_order = $this->_getLastOrderId(Context::getContext()->customer->id);