// clean code && fix norm

This commit is contained in:
aFolletete
2012-02-07 15:31:59 +00:00
parent 5b046ab238
commit 5b6802f3e2
6 changed files with 243 additions and 216 deletions
+12 -1
View File
@@ -654,7 +654,7 @@ class ValidateCore
}
/**
* Check url valdity (disallowed empty string)
* Check url validity (disallowed empty string)
*
* @param string $url Url to validate
* @return boolean Validity is ok or not
@@ -664,6 +664,17 @@ class ValidateCore
return preg_match('/^[~:#,%&_=\(\)\.\? \+\-@\/a-zA-Z0-9]+$/', $url);
}
/**
* Check tracking number validity (disallowed empty string)
*
* @param string $tracking_number Tracking number to validate
* @return boolean Validity is ok or not
*/
public static function isTrackingNumber($tracking_number)
{
return preg_match('/^[~:#,%&_=\(\)\.\? \+\-@\/a-zA-Z0-9]+$/', $tracking_number);
}
/**
* Check url validity (allowed empty string)
*
+7 -3
View File
@@ -76,7 +76,11 @@ class OrderCore extends ObjectModel
/** @var string Gift message if specified */
public $gift_message;
/** @var string Shipping number */
/**
* @var string Shipping number
* @deprecated 1.5.0.4
* @see OrderCarrier->tracking_number
*/
public $shipping_number;
/** @var float Discounts total */
@@ -189,7 +193,7 @@ class OrderCore extends ObjectModel
'total_wrapping' => array('type' => self::TYPE_FLOAT, 'validate' => 'isPrice'),
'total_wrapping_tax_incl' => array('type' => self::TYPE_FLOAT, 'validate' => 'isPrice'),
'total_wrapping_tax_excl' => array('type' => self::TYPE_FLOAT, 'validate' => 'isPrice'),
'shipping_number' => array('type' => self::TYPE_STRING, 'validate' => 'isUrl'),
'shipping_number' => array('type' => self::TYPE_STRING, 'validate' => 'isTrackingNumber'),
'conversion_rate' => array('type' => self::TYPE_FLOAT, 'validate' => 'isFloat', 'required' => true),
'invoice_number' => array('type' => self::TYPE_INT),
'delivery_number' => array('type' => self::TYPE_INT),
@@ -1505,7 +1509,7 @@ class OrderCore extends ObjectModel
if ($currency->id == Configuration::get('PS_DEFAULT_CURRENCY'))
$total += $amount;
else
$total += Tool::convertPrice($amount, $currency->id, true);
$total += Tools::convertPrice($amount, $currency->id, true);
}
}
+2 -2
View File
@@ -67,7 +67,7 @@ class OrderCarrierCore extends ObjectModel
'weight' => array('type' => self::TYPE_FLOAT, 'validate' => 'isFloat'),
'shipping_cost_tax_excl' => array('type' => self::TYPE_FLOAT, 'validate' => 'isFloat'),
'shipping_cost_tax_incl' => array('type' => self::TYPE_FLOAT, 'validate' => 'isFloat'),
'tracking_number' => array('type' => self::TYPE_STRING, 'validate' => 'isAnything'),
'tracking_number' => array('type' => self::TYPE_STRING, 'validate' => 'isTrackingNumber'),
'date_add' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'),
),
);
@@ -78,4 +78,4 @@ class OrderCarrierCore extends ObjectModel
'id_carrier' => array('xlink_resource' => 'carriers'),
),
);
}
}
+3 -3
View File
@@ -185,7 +185,7 @@ class StockMvtCore extends ObjectModel
*/
public static function getNegativeStockMvts($id_order, $id_product, $id_product_attribute, $quantity, $id_warehouse = null)
{
$mvts = array();
$movements = array();
$quantity_total = 0;
$query = new DbQuery();
@@ -205,10 +205,10 @@ class StockMvtCore extends ObjectModel
if ($quantity_total >= $quantity)
break;
$quantity_total += (int)$row['physical_quantity'];
$mvts[] = $row;
$movements[] = $row;
}
return $mvts;
return $movements;
}
/**