//PasswordController+PdfInvoiceController+PdfOrderReturnController+PdfOrederSlipController+PricesDropController : Refacto done
This commit is contained in:
@@ -31,11 +31,15 @@ class PasswordControllerCore extends FrontController
|
||||
{
|
||||
public $php_self = 'password';
|
||||
|
||||
public function process()
|
||||
/**
|
||||
* Start forms process
|
||||
* @see FrontController::preProcess()
|
||||
*/
|
||||
public function preProcess()
|
||||
{
|
||||
if (Tools::isSubmit('email'))
|
||||
{
|
||||
if (!($email = Tools::getValue('email')) OR !Validate::isEmail($email))
|
||||
if (!($email = Tools::getValue('email')) || !Validate::isEmail($email))
|
||||
$this->errors[] = Tools::displayError('Invalid e-mail address');
|
||||
else
|
||||
{
|
||||
@@ -50,10 +54,11 @@ class PasswordControllerCore extends FrontController
|
||||
else
|
||||
{
|
||||
if (Mail::Send($this->context->language->id, 'password_query', Mail::l('Password query confirmation'),
|
||||
array('{email}' => $customer->email,
|
||||
'{lastname}' => $customer->lastname,
|
||||
'{firstname}' => $customer->firstname,
|
||||
'{url}' => $this->context->link->getPageLink('password', true, NULL, 'token='.$customer->secure_key.'&id_customer='.(int)$customer->id)),
|
||||
array(
|
||||
'{email}' => $customer->email,
|
||||
'{lastname}' => $customer->lastname,
|
||||
'{firstname}' => $customer->firstname,
|
||||
'{url}' => $this->context->link->getPageLink('password', true, null, 'token='.$customer->secure_key.'&id_customer='.(int)$customer->id)),
|
||||
$customer->email,
|
||||
$customer->firstname.' '.$customer->lastname))
|
||||
$this->context->smarty->assign(array('confirmation' => 2, 'email' => $customer->email));
|
||||
@@ -63,7 +68,7 @@ class PasswordControllerCore extends FrontController
|
||||
}
|
||||
}
|
||||
}
|
||||
elseif (($token = Tools::getValue('token')) && ($id_customer = (int)(Tools::getValue('id_customer'))))
|
||||
else if (($token = Tools::getValue('token')) && ($id_customer = (int)(Tools::getValue('id_customer'))))
|
||||
{
|
||||
$email = Db::getInstance()->getValue('SELECT `email` FROM '._DB_PREFIX_.'customer c WHERE c.`secure_key` = "'.pSQL($token).'" AND c.id_customer='.(int)($id_customer));
|
||||
if ($email)
|
||||
@@ -79,10 +84,11 @@ class PasswordControllerCore extends FrontController
|
||||
if ($customer->update())
|
||||
{
|
||||
if (Mail::Send($this->context->language->id, 'password', Mail::l('Your password'),
|
||||
array('{email}' => $customer->email,
|
||||
'{lastname}' => $customer->lastname,
|
||||
'{firstname}' => $customer->firstname,
|
||||
'{passwd}' => $password),
|
||||
array(
|
||||
'{email}' => $customer->email,
|
||||
'{lastname}' => $customer->lastname,
|
||||
'{firstname}' => $customer->firstname,
|
||||
'{passwd}' => $password),
|
||||
$customer->email,
|
||||
$customer->firstname.' '.$customer->lastname))
|
||||
$this->context->smarty->assign(array('confirmation' => 1, 'email' => $customer->email));
|
||||
@@ -96,9 +102,16 @@ class PasswordControllerCore extends FrontController
|
||||
else
|
||||
$this->errors[] = Tools::displayError('We cannot regenerate your password with the data you submitted');
|
||||
}
|
||||
elseif (($token = Tools::getValue('token')) || ($id_customer = Tools::getValue('id_customer')))
|
||||
else if (($token = Tools::getValue('token')) || ($id_customer = Tools::getValue('id_customer')))
|
||||
$this->errors[] = Tools::displayError('We cannot regenerate your password with the data you submitted');
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Assign template vars related to page content
|
||||
* @see FrontController::process()
|
||||
*/
|
||||
public function process()
|
||||
{
|
||||
$this->setTemplate(_PS_THEME_DIR_.'password.tpl');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,22 +27,26 @@
|
||||
|
||||
class PdfInvoiceControllerCore extends FrontController
|
||||
{
|
||||
/**
|
||||
* Assign template vars related to page content
|
||||
* @see FrontController::process()
|
||||
*/
|
||||
public function process()
|
||||
{
|
||||
$this->displayHeader(false);
|
||||
$this->displayFooter(false);
|
||||
|
||||
if (!$this->context->customer->isLogged() AND !Tools::getValue('secure_key'))
|
||||
if (!$this->context->customer->isLogged() && !Tools::getValue('secure_key'))
|
||||
Tools::redirect('index.php?controller=authentication&back=pdf-invoice');
|
||||
if (!(int)(Configuration::get('PS_INVOICE')))
|
||||
die(Tools::displayError('Invoices are disabled in this shop.'));
|
||||
if (isset($_GET['id_order']) AND Validate::isUnsignedId($_GET['id_order']))
|
||||
if (isset($_GET['id_order']) && Validate::isUnsignedId($_GET['id_order']))
|
||||
$order = new Order((int)($_GET['id_order']));
|
||||
if (!isset($order) OR !Validate::isLoadedObject($order))
|
||||
die(Tools::displayError('Invoice not found'));
|
||||
elseif ((isset($this->context->customer->id) AND $order->id_customer != $this->context->customer->id) OR (Tools::isSubmit('secure_key') AND $order->secure_key != Tools::getValue('secure_key')))
|
||||
die(Tools::displayError('Invoice not found'));
|
||||
elseif (!OrderState::invoiceAvailable($order->getCurrentState()) AND !$order->invoice_number)
|
||||
if (!isset($order) || !Validate::isLoadedObject($order))
|
||||
die(Tools::displayError('Invoice not found'));
|
||||
else if ((isset($this->context->customer->id) && $order->id_customer != $this->context->customer->id) || (Tools::isSubmit('secure_key') && $order->secure_key != Tools::getValue('secure_key')))
|
||||
die(Tools::displayError('Invoice not found'));
|
||||
else if (!OrderState::invoiceAvailable($order->getCurrentState()) && !$order->invoice_number)
|
||||
die(Tools::displayError('No invoice available'));
|
||||
else
|
||||
PDF::invoice($order);
|
||||
|
||||
@@ -27,6 +27,10 @@
|
||||
|
||||
class PdfOrderReturnControllerCore extends FrontController
|
||||
{
|
||||
/**
|
||||
* Assign template vars related to page content
|
||||
* @see FrontController::process()
|
||||
*/
|
||||
public function process()
|
||||
{
|
||||
$this->displayHeader(false);
|
||||
@@ -35,14 +39,14 @@ class PdfOrderReturnControllerCore extends FrontController
|
||||
if (!$this->context->customer->isLogged())
|
||||
Tools::redirect('index.php?controller=authentication&back=order-follow');
|
||||
|
||||
if (isset($_GET['id_order_return']) AND Validate::isUnsignedId($_GET['id_order_return']))
|
||||
if (isset($_GET['id_order_return']) && Validate::isUnsignedId($_GET['id_order_return']))
|
||||
$orderReturn = new OrderReturn((int)($_GET['id_order_return']));
|
||||
if (!isset($orderReturn) OR !Validate::isLoadedObject($orderReturn))
|
||||
die(Tools::displayError('Order return not found'));
|
||||
if (!isset($orderReturn) || !Validate::isLoadedObject($orderReturn))
|
||||
die(Tools::displayError('Order return not found'));
|
||||
else if ($orderReturn->id_customer != $this->context->customer->id)
|
||||
die(Tools::displayError('Order return not found'));
|
||||
die(Tools::displayError('Order return not found'));
|
||||
else if ($orderReturn->state < 2)
|
||||
die(Tools::displayError('Order return not confirmed'));
|
||||
die(Tools::displayError('Order return not confirmed'));
|
||||
else
|
||||
PDF::orderReturn($orderReturn);
|
||||
}
|
||||
|
||||
@@ -27,6 +27,10 @@
|
||||
|
||||
class PdfOrderSlipControllerCore extends FrontController
|
||||
{
|
||||
/**
|
||||
* Assign template vars related to page content
|
||||
* @see FrontController::process()
|
||||
*/
|
||||
public function process()
|
||||
{
|
||||
$this->displayHeader(false);
|
||||
@@ -35,17 +39,17 @@ class PdfOrderSlipControllerCore extends FrontController
|
||||
if (!$this->context->customer->isLogged())
|
||||
Tools::redirect('index.php?controller=authentication&back=order-follow');
|
||||
|
||||
if (isset($_GET['id_order_slip']) AND Validate::isUnsignedId($_GET['id_order_slip']))
|
||||
if (isset($_GET['id_order_slip']) && Validate::isUnsignedId($_GET['id_order_slip']))
|
||||
$orderSlip = new OrderSlip((int)($_GET['id_order_slip']));
|
||||
if (!isset($orderSlip) OR !Validate::isLoadedObject($orderSlip))
|
||||
die(Tools::displayError('Order return not found'));
|
||||
elseif ($orderSlip->id_customer != $this->context->customer->id)
|
||||
die(Tools::displayError('Order return not found'));
|
||||
if (!isset($orderSlip) || !Validate::isLoadedObject($orderSlip))
|
||||
die(Tools::displayError('Order return not found'));
|
||||
else if ($orderSlip->id_customer != $this->context->customer->id)
|
||||
die(Tools::displayError('Order return not found'));
|
||||
$order = new Order((int)($orderSlip->id_order));
|
||||
if (!Validate::isLoadedObject($order))
|
||||
die(Tools::displayError('Order not found'));
|
||||
die(Tools::displayError('Order not found'));
|
||||
$order->products = OrderSlip::getOrdersSlipProducts((int)($orderSlip->id), $order);
|
||||
$ref = NULL;
|
||||
$ref = null;
|
||||
PDF::invoice($order, 'D', false, $ref, $orderSlip);
|
||||
}
|
||||
}
|
||||
@@ -35,10 +35,14 @@ class PricesDropControllerCore extends FrontController
|
||||
$this->addCSS(_THEME_CSS_DIR_.'product_list.css');
|
||||
}
|
||||
|
||||
/**
|
||||
* Assign template vars related to page content
|
||||
* @see FrontController::process()
|
||||
*/
|
||||
public function process()
|
||||
{
|
||||
$this->productSort();
|
||||
$nbProducts = Product::getPricesDrop($this->context->language->id, NULL, NULL, true);
|
||||
$nbProducts = Product::getPricesDrop($this->context->language->id, null, null, true);
|
||||
$this->pagination($nbProducts);
|
||||
|
||||
$this->context->smarty->assign(array(
|
||||
|
||||
Reference in New Issue
Block a user