//OrderDetailController : Refacto done + modify some comments

git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@8869 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
mDeflotte committed 2011-09-29 11:53:00 +00:00
1 parent 590fbe0ef0
commit f9c565699b
6 files changed
+42 -27

No files matched your search

+1 -1
View File
@@ -96,7 +96,7 @@ class AddressControllerCore extends FrontController
/** /**
* Start forms process * Start forms process
* @see FrontController::preProcess() * @see FrontController::postProcess()
*/ */
public function postProcess() public function postProcess()
{ {
+2 -2
View File
@@ -75,8 +75,8 @@ class AddressesControllerCore extends FrontController
} }
// Retro theme 1.4.2 // Retro theme 1.4.2
if ($key = array_search('Country:name', $ordered_fields)) if ($key = array_search('Country:name', $ordered_fields))
$ordered_fields[$key] = 'country'; $ordered_fields[$key] = 'country';
$this->context->smarty->assign('addresses_style', array( $this->context->smarty->assign('addresses_style', array(
'company' => 'address_company', 'company' => 'address_company',
+33 -22
View File
@@ -31,33 +31,38 @@ class OrderDetailControllerCore extends FrontController
public $authRedirection = 'history'; public $authRedirection = 'history';
public $ssl = true; public $ssl = true;
public function __construct() /**
{ * Initialize order detail controller
parent::__construct(); * @see FrontController::init()
*/
header("Cache-Control: no-cache, must-revalidate");
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
}
public function init() public function init()
{ {
parent::init(); parent::init();
header('Cache-Control: no-cache, must-revalidate');
header('Expires: Sat, 26 Jul 1997 05:00:00 GMT');
}
/**
* Start forms process
* @see FrontController::postProcess()
*/
public function postProcess()
{
if (Tools::isSubmit('submitMessage')) if (Tools::isSubmit('submitMessage'))
{ {
$idOrder = (int)(Tools::getValue('id_order')); $idOrder = (int)(Tools::getValue('id_order'));
$msgText = htmlentities(Tools::getValue('msgText'), ENT_COMPAT, 'UTF-8'); $msgText = htmlentities(Tools::getValue('msgText'), ENT_COMPAT, 'UTF-8');
if (!$idOrder OR !Validate::isUnsignedId($idOrder)) if (!$idOrder || !Validate::isUnsignedId($idOrder))
$this->errors[] = Tools::displayError('Order is no longer valid'); $this->errors[] = Tools::displayError('Order is no longer valid');
elseif (empty($msgText)) else if (empty($msgText))
$this->errors[] = Tools::displayError('Message cannot be blank'); $this->errors[] = Tools::displayError('Message cannot be blank');
elseif (!Validate::isMessage($msgText)) else if (!Validate::isMessage($msgText))
$this->errors[] = Tools::displayError('Message is invalid (HTML is not allowed)'); $this->errors[] = Tools::displayError('Message is invalid (HTML is not allowed)');
if (!sizeof($this->errors)) if (!count($this->errors))
{ {
$order = new Order($idOrder); $order = new Order($idOrder);
if (Validate::isLoadedObject($order) AND $order->id_customer == $this->context->customer->id) if (Validate::isLoadedObject($order) && $order->id_customer == $this->context->customer->id)
{ {
//check if a thread already exist //check if a thread already exist
$id_customer_thread = CustomerThread::getIdCustomerThreadByEmailAndIdOrder($this->context->customer->email, $order->id); $id_customer_thread = CustomerThread::getIdCustomerThreadByEmailAndIdOrder($this->context->customer->email, $order->id);
@@ -112,19 +117,25 @@ class OrderDetailControllerCore extends FrontController
$this->errors[] = Tools::displayError('Order not found'); $this->errors[] = Tools::displayError('Order not found');
} }
} }
}
if (!$id_order = (int)(Tools::getValue('id_order')) OR !Validate::isUnsignedId($id_order))
/**
* Assign template vars related to page content
* @see FrontController::process()
*/
public function process()
{
if (!$id_order = (int)(Tools::getValue('id_order')) || !Validate::isUnsignedId($id_order))
$this->errors[] = Tools::displayError('Order ID required'); $this->errors[] = Tools::displayError('Order ID required');
else else
{ {
$order = new Order($id_order); $order = new Order($id_order);
if (Validate::isLoadedObject($order) AND $order->id_customer == $this->context->customer->id) if (Validate::isLoadedObject($order) && $order->id_customer == $this->context->customer->id)
{ {
$id_order_state = (int)($order->getCurrentState()); $id_order_state = (int)($order->getCurrentState());
$carrier = new Carrier((int)($order->id_carrier), (int)($order->id_lang)); $carrier = new Carrier((int)($order->id_carrier), (int)($order->id_lang));
$addressInvoice = new Address((int)($order->id_address_invoice)); $addressInvoice = new Address((int)($order->id_address_invoice));
$addressDelivery = new Address((int)($order->id_address_delivery)); $addressDelivery = new Address((int)($order->id_address_delivery));
// $stateInvoiceAddress = new State((int)$addressInvoice->id_state);
$inv_adr_fields = AddressFormat::getOrderedAddressFields($addressInvoice->id_country); $inv_adr_fields = AddressFormat::getOrderedAddressFields($addressInvoice->id_country);
$dlv_adr_fields = AddressFormat::getOrderedAddressFields($addressDelivery->id_country); $dlv_adr_fields = AddressFormat::getOrderedAddressFields($addressDelivery->id_country);
@@ -148,19 +159,19 @@ class OrderDetailControllerCore extends FrontController
'currency' => new Currency($order->id_currency), 'currency' => new Currency($order->id_currency),
'order_state' => (int)($id_order_state), 'order_state' => (int)($id_order_state),
'invoiceAllowed' => (int)(Configuration::get('PS_INVOICE')), 'invoiceAllowed' => (int)(Configuration::get('PS_INVOICE')),
'invoice' => (OrderState::invoiceAvailable($id_order_state) AND $order->invoice_number), 'invoice' => (OrderState::invoiceAvailable($id_order_state) && $order->invoice_number),
'order_history' => $order->getHistory($this->context->language->id, false, true), 'order_history' => $order->getHistory($this->context->language->id, false, true),
'products' => $products, 'products' => $products,
'discounts' => $order->getDiscounts(), 'discounts' => $order->getDiscounts(),
'carrier' => $carrier, 'carrier' => $carrier,
'address_invoice' => $addressInvoice, 'address_invoice' => $addressInvoice,
'invoiceState' => (Validate::isLoadedObject($addressInvoice) AND $addressInvoice->id_state) ? new State($addressInvoice->id_state) : false, 'invoiceState' => (Validate::isLoadedObject($addressInvoice) && $addressInvoice->id_state) ? new State($addressInvoice->id_state) : false,
'address_delivery' => $addressDelivery, 'address_delivery' => $addressDelivery,
'inv_adr_fields' => $inv_adr_fields, 'inv_adr_fields' => $inv_adr_fields,
'dlv_adr_fields' => $dlv_adr_fields, 'dlv_adr_fields' => $dlv_adr_fields,
'invoiceAddressFormatedValues' => $invoiceAddressFormatedValues, 'invoiceAddressFormatedValues' => $invoiceAddressFormatedValues,
'deliveryAddressFormatedValues' => $deliveryAddressFormatedValues, 'deliveryAddressFormatedValues' => $deliveryAddressFormatedValues,
'deliveryState' => (Validate::isLoadedObject($addressDelivery) AND $addressDelivery->id_state) ? new State($addressDelivery->id_state) : false, 'deliveryState' => (Validate::isLoadedObject($addressDelivery) && $addressDelivery->id_state) ? new State($addressDelivery->id_state) : false,
'is_guest' => false, 'is_guest' => false,
'messages' => CustomerMessage::getMessagesByOrderId((int)($order->id), false), 'messages' => CustomerMessage::getMessagesByOrderId((int)($order->id), false),
'CUSTOMIZE_FILE' => Product::CUSTOMIZE_FILE, 'CUSTOMIZE_FILE' => Product::CUSTOMIZE_FILE,
@@ -169,7 +180,7 @@ class OrderDetailControllerCore extends FrontController
'use_tax' => Configuration::get('PS_TAX'), 'use_tax' => Configuration::get('PS_TAX'),
'group_use_tax' => (Group::getPriceDisplayMethod($customer->id_default_group) == PS_TAX_INC), 'group_use_tax' => (Group::getPriceDisplayMethod($customer->id_default_group) == PS_TAX_INC),
'customizedDatas' => $customizedDatas)); 'customizedDatas' => $customizedDatas));
if ($carrier->url AND $order->shipping_number) if ($carrier->url && $order->shipping_number)
$this->context->smarty->assign('followup', str_replace('@', $order->shipping_number, $carrier->url)); $this->context->smarty->assign('followup', str_replace('@', $order->shipping_number, $carrier->url));
$this->context->smarty->assign('HOOK_ORDERDETAILDISPLAYED', Module::hookExec('orderDetailDisplayed', array('order' => $order))); $this->context->smarty->assign('HOOK_ORDERDETAILDISPLAYED', Module::hookExec('orderDetailDisplayed', array('order' => $order)));
Module::hookExec('OrderDetail', array('carrier' => $carrier, 'order' => $order)); Module::hookExec('OrderDetail', array('carrier' => $carrier, 'order' => $order));
+1 -1
View File
@@ -31,7 +31,7 @@ class OrderOpcControllerCore extends ParentOrderController
public $isLogged; public $isLogged;
/** /**
* Initialize supplier controller * Initialize order opc controller
* @see FrontController::init() * @see FrontController::init()
*/ */
public function init() public function init()
@@ -32,6 +32,10 @@ class OrderReturnControllerCore extends FrontController
public $authRedirection = 'order-follow'; public $authRedirection = 'order-follow';
public $ssl = true; public $ssl = true;
/**
* Initialize order return controller
* @see FrontController::init()
*/
public function init() public function init()
{ {
parent::init(); parent::init();
+1 -1
View File
@@ -40,7 +40,7 @@ class ParentOrderControllerCore extends FrontController
public $nbProducts; public $nbProducts;
/** /**
* Initialize product controller * Initialize parent order controller
* @see FrontController::init() * @see FrontController::init()
*/ */
public function init() public function init()