// Normalize

git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@12691 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
rMalie
2012-01-25 16:39:34 +00:00
parent b2e21e6ce1
commit 359b51d1ea
14 changed files with 61 additions and 64 deletions
@@ -39,7 +39,7 @@ class AdminAccountingExportControllerCore extends AdminController
public $exportSelected = ''; public $exportSelected = '';
public $fd = NULL; public $fd = null;
public $date = array( public $date = array(
'begin' => '', 'begin' => '',
@@ -218,7 +218,7 @@ class AdminAccountingExportControllerCore extends AdminController
{ {
$this->checkRights(); $this->checkRights();
if (!count($this->errors) && $this->fd !== NULL) if (!count($this->errors) && $this->fd !== null)
{ {
$buffer = ''; $buffer = '';
foreach ($this->exportTypeList[$this->exportSelected]['fields'] as $key => $translation) foreach ($this->exportTypeList[$this->exportSelected]['fields'] as $key => $translation)
@@ -301,7 +301,7 @@ class AdminAccountingExportControllerCore extends AdminController
break; break;
case 1: case 1:
$line[2] = !empty($row['account']) ? $row['account'] : $line[2] = !empty($row['account']) ? $row['account'] :
Configuration::get('default_account_number', NULL, NULL, $row['id_shop']); Configuration::get('default_account_number', null, null, $row['id_shop']);
// Force an empty string if Configuration send false // Force an empty string if Configuration send false
$line[2] = empty($line[2]) ? '' : $line[2]; $line[2] = empty($line[2]) ? '' : $line[2];
$line[5] = $row['product_price_ht']; $line[5] = $row['product_price_ht'];
@@ -337,7 +337,7 @@ class AdminAccountingExportControllerCore extends AdminController
// Need to Generate 3 lines for a product // Need to Generate 3 lines for a product
for ($i = 0; $i < 3; ++$i) for ($i = 0; $i < 3; ++$i)
// Create the two first line and check if a tax exist for the last one // Create the two first line and check if a tax exist for the last one
if ($i < 2 || ($i == 2 && $row['id_tax'] !== NULL)) if ($i < 2 || ($i == 2 && $row['id_tax'] !== null))
{ {
// Generate a product line // Generate a product line
$line = $this->createLine($row, $i); $line = $this->createLine($row, $i);
@@ -56,8 +56,7 @@ class AdminAccountingManagementControllerCore extends AdminController
$shop['name'] = $this->context->shop->name; $shop['name'] = $this->context->shop->name;
} }
$shop['default_account_number'] = Configuration::get('default_account_number', $shop['default_account_number'] = Configuration::get('default_account_number', null, null, $id_shop);
NULL, NULL, $id_shop);
ksort($shop['zones']); ksort($shop['zones']);
$zoneShopList = Accounting::getAccountNumberZoneShop($id_shop); $zoneShopList = Accounting::getAccountNumberZoneShop($id_shop);
@@ -84,7 +84,7 @@ class AdminCartRulesControllerCore extends AdminController
$this->afterAdd($currentObject); $this->afterAdd($currentObject);
} }
// TODO Move this function into CartRule /* @TODO Move this function into CartRule */
public function afterAdd($currentObject) public function afterAdd($currentObject)
{ {
// Add restrictions for generic entities like country, carrier and group // Add restrictions for generic entities like country, carrier and group
@@ -289,20 +289,20 @@ class AdminCartRulesControllerCore extends AdminController
// All the filter are prefilled with the correct information // All the filter are prefilled with the correct information
$customer_filter = ''; $customer_filter = '';
if (Validate::isUnsignedId($current_object->id_customer) AND if (Validate::isUnsignedId($current_object->id_customer) &&
$customer = new Customer($current_object->id_customer) AND ($customer = new Customer($current_object->id_customer)) &&
Validate::isLoadedObject($customer)) Validate::isLoadedObject($customer))
$customer_filter = $customer->firstname.' '.$customer->lastname.' ('.$customer->email.')'; $customer_filter = $customer->firstname.' '.$customer->lastname.' ('.$customer->email.')';
$gift_product_filter = ''; $gift_product_filter = '';
if (Validate::isUnsignedId($current_object->gift_product) AND if (Validate::isUnsignedId($current_object->gift_product) &&
$product = new Product($current_object->gift_product, false, Context::getContext()->language->id) AND ($product = new Product($current_object->gift_product, false, Context::getContext()->language->id)) &&
Validate::isLoadedObject($product)) Validate::isLoadedObject($product))
$gift_product_filter = trim($product->reference.' '.$product->name); $gift_product_filter = trim($product->reference.' '.$product->name);
$reduction_product_filter = ''; $reduction_product_filter = '';
if (Validate::isUnsignedId($current_object->reduction_product) AND if (Validate::isUnsignedId($current_object->reduction_product) &&
$product = new Product($current_object->reduction_product, false, Context::getContext()->language->id) AND ($product = new Product($current_object->reduction_product, false, Context::getContext()->language->id)) &&
Validate::isLoadedObject($product)) Validate::isLoadedObject($product))
$reduction_product_filter = trim($product->reference.' '.$product->name); $reduction_product_filter = trim($product->reference.' '.$product->name);
+2 -4
View File
@@ -245,7 +245,7 @@ class AdminCartsControllerCore extends AdminController
return; return;
if ($this->context->cart->OrderExists()) if ($this->context->cart->OrderExists())
$errors[] = Tools::displayError('An order already placed with this cart'); $errors[] = Tools::displayError('An order already placed with this cart');
elseif (!($id_product = (int)Tools::getValue('id_product')) OR !($product = new Product((int)$id_product, true, $this->context->language->id))) elseif (!($id_product = (int)Tools::getValue('id_product')) || !($product = new Product((int)$id_product, true, $this->context->language->id)))
$errors[] = Tools::displayError('Invalid product'); $errors[] = Tools::displayError('Invalid product');
elseif (!($qty = Tools::getValue('qty')) || $qty == 0) elseif (!($qty = Tools::getValue('qty')) || $qty == 0)
$errors[] = Tools::displayError('Invalid quantity'); $errors[] = Tools::displayError('Invalid quantity');
@@ -355,9 +355,7 @@ class AdminCartsControllerCore extends AdminController
if ($this->tabAccess['edit'] === '1') if ($this->tabAccess['edit'] === '1')
{ {
$errors = array(); $errors = array();
$customer = new Customer((int)$this->context->cart->id_customer); if (!$id_cart_rule = Tools::getValue('id_cart_rule') || !$cart_rule = new CartRule((int)$id_cart_rule))
if (!$id_cart_rule = Tools::getValue('id_cart_rule') OR !$cart_rule = new CartRule((int)$id_cart_rule))
$errors[] = Tools::displayError('Invalid voucher'); $errors[] = Tools::displayError('Invalid voucher');
else if ($err = $cart_rule->checkValidity($this->context)) else if ($err = $cart_rule->checkValidity($this->context))
$errors[] = $err; $errors[] = $err;
@@ -160,7 +160,7 @@ class AdminCategoriesControllerCore extends AdminController
asort($categories_tree); asort($categories_tree);
$this->tpl_list_vars['categories_tree'] = $categories_tree; $this->tpl_list_vars['categories_tree'] = $categories_tree;
if (Tools::isSubmit('submitBulkdelete'.$this->table) OR Tools::isSubmit('delete'.$this->table)) if (Tools::isSubmit('submitBulkdelete'.$this->table) || Tools::isSubmit('delete'.$this->table))
{ {
$category = new Category(Tools::getValue('id_category')); $category = new Category(Tools::getValue('id_category'));
if ($category->is_root_category) if ($category->is_root_category)
@@ -265,9 +265,9 @@ class AdminCategoriesControllerCore extends AdminController
$guest = new Group(Configuration::get('PS_GUEST_GROUP')); $guest = new Group(Configuration::get('PS_GUEST_GROUP'));
$default = new Group(Configuration::get('PS_CUSTOMER_GROUP')); $default = new Group(Configuration::get('PS_CUSTOMER_GROUP'));
$unidentified_group_information = sprintf($this->l('%s - All persons without a customer account or unauthenticated.'), "<b>".$unidentified->name[$this->context->language->id]."</b>"); $unidentified_group_information = sprintf($this->l('%s - All persons without a customer account or unauthenticated.'), '<b>'.$unidentified->name[$this->context->language->id].'</b>');
$guest_group_information = sprintf($this->l('%s - Customer who placed an order with the Guest Checkout.'), "<b>".$guest->name[$this->context->language->id]."</b>"); $guest_group_information = sprintf($this->l('%s - Customer who placed an order with the Guest Checkout.'), '<b>'.$guest->name[$this->context->language->id].'</b>');
$default_group_information = sprintf($this->l('%s - All persons who created an account on this site.'), "<b>".$default->name[$this->context->language->id]."</b>"); $default_group_information = sprintf($this->l('%s - All persons who created an account on this site.'), '<b>'.$default->name[$this->context->language->id].'</b>');
$root_category = Category::getRootCategory(); $root_category = Category::getRootCategory();
$root_category = array('id_category' => $root_category->id_category, 'name' => $root_category->name); $root_category = array('id_category' => $root_category->id_category, 'name' => $root_category->name);
$this->fields_form = array( $this->fields_form = array(
@@ -511,9 +511,8 @@ class AdminCategoriesControllerCore extends AdminController
if (Validate::isLoadedObject($object = $this->loadObject()) && isset($this->fieldImageSettings)) if (Validate::isLoadedObject($object = $this->loadObject()) && isset($this->fieldImageSettings))
{ {
if ($object->isRootCategoryForAShop()) if ($object->isRootCategoryForAShop())
{
$this->errors[] = Tools::displayError('You cannot remove this category because a shop uses this category as a root category.'); $this->errors[] = Tools::displayError('You cannot remove this category because a shop uses this category as a root category.');
}// check if request at least one object with noZeroObject // check if request at least one object with noZeroObject
elseif (isset($object->noZeroObject) && elseif (isset($object->noZeroObject) &&
count($taxes = call_user_func(array($this->className, $object->noZeroObject))) <= 1) count($taxes = call_user_func(array($this->className, $object->noZeroObject))) <= 1)
$this->errors[] = Tools::displayError('You need at least one object.').' <b>'. $this->errors[] = Tools::displayError('You need at least one object.').' <b>'.
@@ -73,7 +73,7 @@ class AdminCmsCategoriesControllerCore extends AdminController
parent::getList($id_lang, $order_by, $order_way, $start, $limit, $id_lang_shop); parent::getList($id_lang, $order_by, $order_way, $start, $limit, $id_lang_shop);
} }
public function postProcess($token = NULL) public function postProcess($token = null)
{ {
$this->tabAccess = Profile::getProfileAccess($this->context->employee->id_profile, $this->id); $this->tabAccess = Profile::getProfileAccess($this->context->employee->id_profile, $this->id);
if (Tools::isSubmit('submitAdd'.$this->table)) if (Tools::isSubmit('submitAdd'.$this->table))
@@ -89,7 +89,7 @@ class AdminCmsCategoriesControllerCore extends AdminController
} }
} }
/* Change object statuts (active, inactive) */ /* Change object statuts (active, inactive) */
elseif (isset($_GET['statuscms_category']) AND Tools::getValue($this->identifier)) elseif (isset($_GET['statuscms_category']) && Tools::getValue($this->identifier))
{ {
if ($this->tabAccess['edit'] === '1') if ($this->tabAccess['edit'] === '1')
{ {
@@ -111,10 +111,10 @@ class AdminCmsCategoriesControllerCore extends AdminController
{ {
if ($this->tabAccess['delete'] === '1') if ($this->tabAccess['delete'] === '1')
{ {
if (Validate::isLoadedObject($object = $this->loadObject()) AND isset($this->fieldImageSettings)) if (Validate::isLoadedObject($object = $this->loadObject()) && isset($this->fieldImageSettings))
{ {
// check if request at least one object with noZeroObject // check if request at least one object with noZeroObject
if (isset($object->noZeroObject) AND sizeof($taxes = call_user_func(array($this->className, $object->noZeroObject))) <= 1) if (isset($object->noZeroObject) && count($taxes = call_user_func(array($this->className, $object->noZeroObject))) <= 1)
$this->errors[] = Tools::displayError('You need at least one object.').' <b>'.$this->table.'</b><br />'.Tools::displayError('You cannot delete all of the items.'); $this->errors[] = Tools::displayError('You need at least one object.').' <b>'.$this->table.'</b><br />'.Tools::displayError('You cannot delete all of the items.');
else else
{ {
@@ -34,7 +34,7 @@ class AdminCmsContentControllerCore extends AdminController
private $adminCMS; private $adminCMS;
/** @var object Category() instance for navigation*/ /** @var object Category() instance for navigation*/
private static $_category = NULL; private static $_category = null;
public function __construct() public function __construct()
{ {
+8 -8
View File
@@ -185,12 +185,12 @@ class AdminCmsControllerCore extends AdminController
return parent::renderList(); return parent::renderList();
} }
public function displayList($token = NULL) public function displayList($token = null)
{ {
/* Display list header (filtering, pagination and column names) */ /* Display list header (filtering, pagination and column names) */
$this->displayListHeader($token); $this->displayListHeader($token);
if (!sizeof($this->_list)) if (!count($this->_list))
echo '<tr><td class="center" colspan="'.(sizeof($this->fieldsDisplay) + 2).'">'.$this->l('No items found').'</td></tr>'; echo '<tr><td class="center" colspan="'.(count($this->fieldsDisplay) + 2).'">'.$this->l('No items found').'</td></tr>';
/* Show the content of the table */ /* Show the content of the table */
$this->displayListContent($token); $this->displayListContent($token);
@@ -212,9 +212,9 @@ class AdminCmsControllerCore extends AdminController
parent::getList($id_lang, $order_by, $order_way, $start, $limit, $id_lang_shop); parent::getList($id_lang, $order_by, $order_way, $start, $limit, $id_lang_shop);
} }
function postProcess() public function postProcess()
{ {
if (Tools::isSubmit('viewcms') AND ($id_cms = (int)(Tools::getValue('id_cms'))) AND $cms = new CMS($id_cms, $this->context->language->id) AND Validate::isLoadedObject($cms)) if (Tools::isSubmit('viewcms') && ($id_cms = (int)Tools::getValue('id_cms')) && ($cms = new CMS($id_cms, $this->context->language->id)) && Validate::isLoadedObject($cms))
{ {
$redir = $this->context->link->getCMSLink($cms); $redir = $this->context->link->getCMSLink($cms);
if (!$cms->active) if (!$cms->active)
@@ -262,10 +262,10 @@ class AdminCmsControllerCore extends AdminController
else else
$this->errors[] = Tools::displayError('You do not have permission to delete here.'); $this->errors[] = Tools::displayError('You do not have permission to delete here.');
} }
elseif (Tools::isSubmit('submitAddcms') OR Tools::isSubmit('submitAddcmsAndPreview')) elseif (Tools::isSubmit('submitAddcms') || Tools::isSubmit('submitAddcmsAndPreview'))
{ {
parent::validateRules(); parent::validateRules();
if (!sizeof($this->errors)) if (!count($this->errors))
{ {
if (!$id_cms = (int)(Tools::getValue('id_cms'))) if (!$id_cms = (int)(Tools::getValue('id_cms')))
{ {
@@ -330,7 +330,7 @@ class AdminCmsControllerCore extends AdminController
Tools::redirectAdmin(self::$currentIndex.'&'.$this->table.'Orderby=position&'.$this->table.'Orderway=asc&conf=4'.(($id_category = (int)(Tools::getValue('id_cms_category'))) ? ('&id_cms_category='.$id_category) : '').'&token='.Tools::getAdminTokenLite('AdminCmsContent')); Tools::redirectAdmin(self::$currentIndex.'&'.$this->table.'Orderby=position&'.$this->table.'Orderway=asc&conf=4'.(($id_category = (int)(Tools::getValue('id_cms_category'))) ? ('&id_cms_category='.$id_category) : '').'&token='.Tools::getAdminTokenLite('AdminCmsContent'));
} }
/* Change object statuts (active, inactive) */ /* Change object statuts (active, inactive) */
elseif (Tools::isSubmit('status') AND Tools::isSubmit($this->identifier)) elseif (Tools::isSubmit('status') && Tools::isSubmit($this->identifier))
{ {
if ($this->tabAccess['edit'] === '1') if ($this->tabAccess['edit'] === '1')
{ {
+2 -2
View File
@@ -43,11 +43,11 @@ class AdminContactControllerCore extends AdminController
$this->context = Context::getContext(); $this->context = Context::getContext();
$countryList = array(); $countryList = array();
$countryList[] = array('id' => '0', 'name' => $this->l('Choose your country')); $countryList[] = array('id' => '0', 'name' => $this->l('Choose your country'));
foreach (Country::getCountries($this->context->language->id) AS $country) foreach (Country::getCountries($this->context->language->id) as $country)
$countryList[] = array('id' => $country['id_country'], 'name' => $country['name']); $countryList[] = array('id' => $country['id_country'], 'name' => $country['name']);
$stateList = array(); $stateList = array();
$stateList[] = array('id' => '0', 'name' => $this->l('Choose your state (if applicable)')); $stateList[] = array('id' => '0', 'name' => $this->l('Choose your state (if applicable)'));
foreach (State::getStates($this->context->language->id) AS $state) foreach (State::getStates($this->context->language->id) as $state)
$stateList[] = array('id' => $state['id_state'], 'name' => $state['name']); $stateList[] = array('id' => $state['id_state'], 'name' => $state['name']);
$formFields = array( $formFields = array(
@@ -296,7 +296,7 @@ class AdminCurrenciesControllerCore extends AdminController
public function processExchangeRates($token) public function processExchangeRates($token)
{ {
if (!$this->errors[] = Currency::refreshCurrencies()) if (!$this->errors[] = Currency::refreshCurrencies())
Tools::redirectAdmin(self::$currentIndex . '&conf=6' . '&token=' . $this->token); Tools::redirectAdmin(self::$currentIndex.'&conf=6&token='.$this->token);
} }
/** /**
@@ -199,7 +199,7 @@ class AdminCustomersControllerCore extends AdminController
LIMIT 1 LIMIT 1
) as connect'; ) as connect';
if (Tools::isSubmit('submitBulkdelete'.$this->table) OR Tools::isSubmit('delete'.$this->table)) if (Tools::isSubmit('submitBulkdelete'.$this->table) || Tools::isSubmit('delete'.$this->table))
$this->tpl_list_vars = array( $this->tpl_list_vars = array(
'delete_customer' => true, 'delete_customer' => true,
'REQUEST_URI' => $_SERVER['REQUEST_URI'], 'REQUEST_URI' => $_SERVER['REQUEST_URI'],
@@ -397,7 +397,8 @@ class AdminCustomersControllerCore extends AdminController
); );
} }
if (Configuration::get('PS_B2B_ENABLE')) { if (Configuration::get('PS_B2B_ENABLE'))
{
$risks = Risk::getRisks(); $risks = Risk::getRisks();
$list_risks = array(); $list_risks = array();
+2 -2
View File
@@ -34,7 +34,7 @@ class AdminEmailsControllerCore extends AdminController
parent::__construct(); parent::__construct();
foreach (Contact::getContacts($this->context->language->id) AS $contact) foreach (Contact::getContacts($this->context->language->id) as $contact)
$arr[] = array('email_message' => $contact['id_contact'], 'name' => $contact['name']); $arr[] = array('email_message' => $contact['id_contact'], 'name' => $contact['name']);
$this->options = array( $this->options = array(
@@ -89,7 +89,7 @@ class AdminEmailsControllerCore extends AdminController
if (isset($_POST['PS_SHOP_EMAIL'])) if (isset($_POST['PS_SHOP_EMAIL']))
$_POST['PS_SHOP_EMAIL'] = Configuration::get('PS_SHOP_EMAIL'); $_POST['PS_SHOP_EMAIL'] = Configuration::get('PS_SHOP_EMAIL');
if ($_POST['PS_MAIL_METHOD'] == 2 AND (empty($_POST['PS_MAIL_SERVER']) OR empty($_POST['PS_MAIL_SMTP_PORT']))) if ($_POST['PS_MAIL_METHOD'] == 2 && (empty($_POST['PS_MAIL_SERVER']) || empty($_POST['PS_MAIL_SMTP_PORT'])))
$this->errors[] = Tools::displayError('You must define a SMTP server and a SMTP port. If you do not know, use the PHP mail() function instead.'); $this->errors[] = Tools::displayError('You must define a SMTP server and a SMTP port. If you do not know, use the PHP mail() function instead.');
} }
} }