// Merge -> 8910
This commit is contained in:
@@ -828,7 +828,7 @@ abstract class AdminTabCore
|
||||
$type = (array_key_exists('filter_type', $field) ? $field['filter_type'] : (array_key_exists('type', $field) ? $field['type'] : false));
|
||||
if (($type == 'date' OR $type == 'datetime') AND is_string($value))
|
||||
$value = unserialize($value);
|
||||
$key = isset($tmpTab[1]) ? $tmpTab[0].'.`'.$tmpTab[1].'`' : '`'.$tmpTab[0].'`';
|
||||
$key = isset($tmpTab[1]) ? $tmpTab[0].'.'.$tmpTab[1] : $tmpTab[0];
|
||||
if (array_key_exists('tmpTableFilter', $field))
|
||||
$sqlFilter = & $this->_tmpTableFilter;
|
||||
elseif (array_key_exists('havingFilter', $field))
|
||||
@@ -844,7 +844,7 @@ abstract class AdminTabCore
|
||||
if (!Validate::isDate($value[0]))
|
||||
$this->_errors[] = Tools::displayError('\'from:\' date format is invalid (YYYY-MM-DD)');
|
||||
else
|
||||
$sqlFilter .= ' AND `'.bqSQL($key).'` >= \''.pSQL(Tools::dateFrom($value[0])).'\'';
|
||||
$sqlFilter .= ' AND '.bqSQL($key).' >= \''.pSQL(Tools::dateFrom($value[0])).'\'';
|
||||
}
|
||||
|
||||
if (isset($value[1]) AND !empty($value[1]))
|
||||
@@ -852,7 +852,7 @@ abstract class AdminTabCore
|
||||
if (!Validate::isDate($value[1]))
|
||||
$this->_errors[] = Tools::displayError('\'to:\' date format is invalid (YYYY-MM-DD)');
|
||||
else
|
||||
$sqlFilter .= ' AND `'.bqSQL($key).'` <= \''.pSQL(Tools::dateTo($value[1])).'\'';
|
||||
$sqlFilter .= ' AND '.bqSQL($key).' <= \''.pSQL(Tools::dateTo($value[1])).'\'';
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
+11
-13
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/*
|
||||
* 2007-2011 PrestaShop
|
||||
* 2007-2011 PrestaShop
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
@@ -26,15 +26,15 @@
|
||||
*/
|
||||
|
||||
class CacheFSCore extends Cache {
|
||||
|
||||
|
||||
protected $_depth;
|
||||
|
||||
|
||||
protected function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->_init();
|
||||
}
|
||||
|
||||
|
||||
protected function _init()
|
||||
{
|
||||
$this->_depth = Db::getInstance()->getValue('SELECT value FROM '._DB_PREFIX_.'configuration WHERE name=\'PS_CACHEFS_DIRECTORY_DEPTH\'', false);
|
||||
@@ -45,23 +45,20 @@ class CacheFSCore extends Cache {
|
||||
{
|
||||
$path = $this->getPath();
|
||||
for ($i = 0; $i < $this->_depth; $i++)
|
||||
{
|
||||
$path .= $key[$i].'/';
|
||||
}
|
||||
|
||||
if (file_put_contents($path.$key, serialize($value)))
|
||||
if (@file_put_contents($path.$key, serialize($value)))
|
||||
{
|
||||
$this->_keysCached[$key] = true;
|
||||
return $key;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public function setNumRows($key, $value, $expire = 0)
|
||||
{
|
||||
return $this->set($key.'_nrows', $value, $expire);
|
||||
}
|
||||
|
||||
|
||||
public function getNumRows($key)
|
||||
{
|
||||
return $this->get($key.'_nrows');
|
||||
@@ -150,8 +147,9 @@ class CacheFSCore extends Cache {
|
||||
public function __destruct()
|
||||
{
|
||||
parent::__destruct();
|
||||
file_put_contents($this->getPath().'keysCached', serialize($this->_keysCached));
|
||||
file_put_contents($this->getPath().'tablesCached', serialize($this->_tablesCached));
|
||||
|
||||
@file_put_contents($this->getPath().'keysCached', serialize($this->_keysCached));
|
||||
@file_put_contents($this->getPath().'tablesCached', serialize($this->_tablesCached));
|
||||
}
|
||||
|
||||
public static function deleteCacheDirectory()
|
||||
@@ -173,7 +171,7 @@ class CacheFSCore extends Cache {
|
||||
self::createCacheDirectories($level_depth - 1, $new_dir);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected function getPath()
|
||||
{
|
||||
return (defined('_PS_CACHEFS_DIRECTORY_') ? _PS_CACHEFS_DIRECTORY_ : dirname(__FILE__).'/../cache/cachefs/');
|
||||
|
||||
+8
-8
@@ -35,7 +35,7 @@ class CarrierCore extends ObjectModel
|
||||
const CARRIERS_MODULE_NEED_RANGE = 3;
|
||||
const PS_CARRIERS_AND_CARRIER_MODULES_NEED_RANGE = 4;
|
||||
const ALL_CARRIERS = 5;
|
||||
|
||||
|
||||
const SHIPPING_METHOD_DEFAULT = 0;
|
||||
const SHIPPING_METHOD_WEIGHT = 1;
|
||||
const SHIPPING_METHOD_PRICE = 2;
|
||||
@@ -412,23 +412,23 @@ class CarrierCore extends ObjectModel
|
||||
{
|
||||
if (!Validate::isBool($activeCountries) OR !Validate::isBool($activeCarriers))
|
||||
die(Tools::displayError());
|
||||
|
||||
|
||||
$states = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS('
|
||||
SELECT s.*
|
||||
FROM `'._DB_PREFIX_.'state` s
|
||||
ORDER BY s.`name` ASC');
|
||||
|
||||
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS('
|
||||
SELECT cl.*,c.*, cl.`name` AS country, zz.`name` AS zone FROM `'._DB_PREFIX_.'country` c
|
||||
LEFT JOIN `'._DB_PREFIX_.'country_lang` cl ON (c.`id_country` = cl.`id_country` AND cl.`id_lang` = 1)
|
||||
SELECT cl.*,c.*, cl.`name` AS country, zz.`name` AS zone FROM `'._DB_PREFIX_.'country` c
|
||||
LEFT JOIN `'._DB_PREFIX_.'country_lang` cl ON (c.`id_country` = cl.`id_country` AND cl.`id_lang` = 1)
|
||||
INNER JOIN (`'._DB_PREFIX_.'carrier_zone` cz INNER JOIN `'._DB_PREFIX_.'carrier` cr ON ( cr.id_carrier = cz.id_carrier AND cr.deleted = 0 '.($activeCarriers ?
|
||||
'AND cr.active = 1) ' : ') ').'
|
||||
LEFT JOIN `'._DB_PREFIX_.'zone` zz ON cz.id_zone = zz.id_zone) ON zz.`id_zone` = c.`id_zone`
|
||||
LEFT JOIN `'._DB_PREFIX_.'zone` zz ON cz.id_zone = zz.id_zone) ON zz.`id_zone` = c.`id_zone`
|
||||
WHERE 1
|
||||
'.($activeCountries ? 'AND c.active = 1' : '').'
|
||||
'.(!is_null($containStates) ? 'AND c.`contains_states` = '.(int)($containStates) : '').'
|
||||
ORDER BY cl.name ASC');
|
||||
|
||||
|
||||
$countries = array();
|
||||
foreach ($result AS &$country)
|
||||
$countries[$country['id_country']] = $country;
|
||||
@@ -438,12 +438,12 @@ class CarrierCore extends ObjectModel
|
||||
|
||||
return $countries;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @param int $id_zone
|
||||
* @param Array $groups group of the customer
|
||||
* @return Array
|
||||
* @return Array
|
||||
*/
|
||||
public static function getCarriersForOrder($id_zone, $groups = NULL)
|
||||
{
|
||||
|
||||
+6
-4
@@ -986,14 +986,16 @@ class OrderCore extends ObjectModel
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function setCurrentState($id_order_state)
|
||||
public function setCurrentState($id_order_state, $id_employee)
|
||||
{
|
||||
if (empty($id_order_state))
|
||||
return false;
|
||||
$history = new OrderHistory();
|
||||
$history->id_order = (int)($this->id);
|
||||
$history->changeIdOrderState((int)$id_order_state, (int)($this->id));
|
||||
$res = Db::getInstance()->getRow('SELECT `invoice_number`, `invoice_date`, `delivery_number`, `delivery_date`
|
||||
$history->id_order = (int)$this->id;
|
||||
$history->id_employee = (int)$id_employee;
|
||||
$history->changeIdOrderState((int)$id_order_state, (int)$this->id);
|
||||
$res = Db::getInstance()->getRow('
|
||||
SELECT `invoice_number`, `invoice_date`, `delivery_number`, `delivery_date`
|
||||
FROM `'._DB_PREFIX_.'orders`
|
||||
WHERE `id_order` = '.(int)$this->id);
|
||||
$this->invoice_date = $res['invoice_date'];
|
||||
|
||||
@@ -62,9 +62,9 @@ class OrderHistoryCore extends ObjectModel
|
||||
{
|
||||
$this->validateFields();
|
||||
|
||||
$fields['id_order'] = (int)($this->id_order);
|
||||
$fields['id_order_state'] = (int)($this->id_order_state);
|
||||
$fields['id_employee'] = (int)($this->id_employee);
|
||||
$fields['id_order'] = (int)$this->id_order;
|
||||
$fields['id_order_state'] = (int)$this->id_order_state;
|
||||
$fields['id_employee'] = (int)$this->id_employee;
|
||||
$fields['date_add'] = pSQL($this->date_add);
|
||||
|
||||
return $fields;
|
||||
@@ -143,18 +143,17 @@ class OrderHistoryCore extends ObjectModel
|
||||
LEFT JOIN `'._DB_PREFIX_.'customer` c ON o.`id_customer` = c.`id_customer`
|
||||
LEFT JOIN `'._DB_PREFIX_.'order_state` os ON oh.`id_order_state` = os.`id_order_state`
|
||||
LEFT JOIN `'._DB_PREFIX_.'order_state_lang` osl ON (os.`id_order_state` = osl.`id_order_state` AND osl.`id_lang` = o.`id_lang`)
|
||||
WHERE oh.`id_order_history` = '.(int)($this->id).'
|
||||
AND os.`send_email` = 1');
|
||||
WHERE oh.`id_order_history` = '.(int)($this->id).' AND os.`send_email` = 1');
|
||||
|
||||
if (isset($result['template']) AND Validate::isEmail($result['email']))
|
||||
{
|
||||
$topic = $result['osname'];
|
||||
$data = array('{lastname}' => $result['lastname'], '{firstname}' => $result['firstname'], '{id_order}' => (int)($this->id_order));
|
||||
$data = array('{lastname}' => $result['lastname'], '{firstname}' => $result['firstname'], '{id_order}' => (int)$this->id_order);
|
||||
if ($templateVars)
|
||||
$data = array_merge($data, $templateVars);
|
||||
$order = new Order((int)($this->id_order));
|
||||
$data['{total_paid}'] = Tools::displayPrice((float)($order->total_paid), new Currency((int)($order->id_currency)), false);
|
||||
$data['{order_name}'] = sprintf("#%06d", (int)($order->id));
|
||||
$order = new Order((int)$this->id_order);
|
||||
$data['{total_paid}'] = Tools::displayPrice((float)$order->total_paid, new Currency((int)$order->id_currency), false);
|
||||
$data['{order_name}'] = sprintf("#%06d", (int)$order->id);
|
||||
|
||||
// An additional email is sent the first time a virtual item is validated
|
||||
if ($virtualProducts = $order->getVirtualProducts() AND (!$lastOrderState OR !$lastOrderState->logable) AND $newOrderState = new OrderState($this->id_order_state, Configuration::get('PS_LANG_DEFAULT')) AND $newOrderState->logable)
|
||||
|
||||
@@ -128,6 +128,10 @@ class PDFCore extends PDF_PageGroupCore
|
||||
$this->AddFont($font);
|
||||
$this->AddFont($font, 'B');
|
||||
}
|
||||
|
||||
/* If the user is using a ISO code no present in the languages, use the first language available instead */
|
||||
if (!isset(self::$_pdfparams[self::$_iso]) && isset($languages[0]['iso_code']))
|
||||
self::$_iso = strtoupper($languages[0]['iso_code']);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -145,9 +149,19 @@ class PDFCore extends PDF_PageGroupCore
|
||||
$conf['PS_SHOP_STATE'] = isset($conf['PS_SHOP_STATE']) ? Tools::iconv('utf-8', self::encoding(), $conf['PS_SHOP_STATE']) : '';
|
||||
|
||||
if (file_exists(_PS_IMG_DIR_.'/logo_invoice.jpg'))
|
||||
{
|
||||
if ($this->_isPngFile(_PS_IMG_DIR_.'/logo_invoice.jpg'))
|
||||
$this->Image(_PS_IMG_DIR_.'/logo_invoice.jpg', 10, 8, 0, 15, 'PNG');
|
||||
else
|
||||
$this->Image(_PS_IMG_DIR_.'/logo_invoice.jpg', 10, 8, 0, 15);
|
||||
}
|
||||
else if (file_exists(_PS_IMG_DIR_.'/logo.jpg'))
|
||||
{
|
||||
if ($this->_isPngFile(_PS_IMG_DIR_.'/logo.jpg'))
|
||||
$this->Image(_PS_IMG_DIR_.'/logo.jpg', 10, 8, 0, 15, 'PNG');
|
||||
else
|
||||
$this->Image(_PS_IMG_DIR_.'/logo.jpg', 10, 8, 0, 15);
|
||||
}
|
||||
$this->SetFont(self::fontname(), 'B', 15);
|
||||
$this->Cell(115);
|
||||
|
||||
@@ -164,6 +178,31 @@ class PDFCore extends PDF_PageGroupCore
|
||||
}
|
||||
|
||||
/*
|
||||
* Detect if the file header match a PNG file
|
||||
*
|
||||
* @param string $file Filename to check (include full path)
|
||||
* @return boolean True if the file is a PNG file
|
||||
*/
|
||||
private function _isPngFile($file)
|
||||
{
|
||||
$pngReferenceHeader = array(137, 80, 78, 71, 13, 10, 26, 10);
|
||||
$fp = fopen($file, 'r');
|
||||
if ($fp)
|
||||
{
|
||||
for ($n = 0; $n < 8; $n++)
|
||||
if (ord(fread($fp, 1)) !== $pngReferenceHeader[$n])
|
||||
{
|
||||
fclose($fp);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* Return the complete Address format
|
||||
*/
|
||||
private function _getCompleteUSAddressFormat($conf)
|
||||
@@ -209,6 +248,7 @@ class PDFCore extends PDF_PageGroupCore
|
||||
"\n".(!empty($conf['PS_SHOP_DETAILS']) ? self::l('Details:').' '.$conf['PS_SHOP_DETAILS'].' - ' : '').
|
||||
(!empty($conf['PS_SHOP_PHONE']) ? self::l('PHONE:').' '.$conf['PS_SHOP_PHONE'] : '');
|
||||
}
|
||||
|
||||
return $footerText;
|
||||
}
|
||||
|
||||
|
||||
@@ -364,7 +364,7 @@ abstract class PaymentModuleCore extends Module
|
||||
ProductSale::addProductSale((int)$product['id_product'], (int)$product['cart_quantity']);
|
||||
}
|
||||
|
||||
if (isset($outOfStock) AND $outOfStock)
|
||||
if (isset($outOfStock) && $outOfStock && Configuration::get('PS_STOCK_MANAGEMENT'))
|
||||
{
|
||||
$history = new OrderHistory();
|
||||
$history->id_order = (int)$order->id;
|
||||
|
||||
+6
-6
@@ -79,7 +79,7 @@ class StoreCore extends ObjectModel
|
||||
public $active = true;
|
||||
|
||||
protected $fieldsRequired = array('id_country', 'name', 'address1', 'city', 'active');
|
||||
protected $fieldsSize = array('name' => 128, 'address1' => 128, 'address2' => 128, 'postcode' => 12, 'city' => 64, 'latitude' => 10, 'longitude' => 10, 'hours' => 254, 'phone' => 16, 'fax' => 16, 'email' => 128, 'note' => 65000);
|
||||
protected $fieldsSize = array('name' => 128, 'address1' => 128, 'address2' => 128, 'postcode' => 12, 'city' => 64, 'latitude' => 12, 'longitude' => 12, 'hours' => 254, 'phone' => 16, 'fax' => 16, 'email' => 128, 'note' => 65000);
|
||||
protected $fieldsValidate = array('id_country' => 'isUnsignedId', 'id_state' => 'isNullOrUnsignedId', 'name' => 'isGenericName', 'address1' => 'isAddress', 'address2' => 'isAddress',
|
||||
'city' => 'isCityName', 'latitude' => 'isCoordinate', 'longitude' => 'isCoordinate', 'hours' => 'isSerializedArray', 'phone' => 'isPhoneNumber', 'fax' => 'isPhoneNumber',
|
||||
'note' => 'isCleanHtml', 'email' => 'isEmail', 'active' => 'isBool');
|
||||
@@ -99,15 +99,15 @@ class StoreCore extends ObjectModel
|
||||
{
|
||||
$this->validateFields();
|
||||
|
||||
$fields['id_country'] = (int)($this->id_country);
|
||||
$fields['id_state'] = (int)($this->id_state);
|
||||
$fields['id_country'] = (int)$this->id_country;
|
||||
$fields['id_state'] = (int)$this->id_state;
|
||||
$fields['name'] = pSQL($this->name);
|
||||
$fields['address1'] = pSQL($this->address1);
|
||||
$fields['address2'] = pSQL($this->address2);
|
||||
$fields['postcode'] = pSQL($this->postcode);
|
||||
$fields['city'] = pSQL($this->city);
|
||||
$fields['latitude'] = (float)($this->latitude);
|
||||
$fields['longitude'] = (float)($this->longitude);
|
||||
$fields['latitude'] = (float)$this->latitude;
|
||||
$fields['longitude'] = (float)$this->longitude;
|
||||
$fields['hours'] = pSQL($this->hours);
|
||||
$fields['phone'] = pSQL($this->phone);
|
||||
$fields['fax'] = pSQL($this->fax);
|
||||
@@ -115,7 +115,7 @@ class StoreCore extends ObjectModel
|
||||
$fields['email'] = pSQL($this->email);
|
||||
$fields['date_add'] = pSQL($this->date_add);
|
||||
$fields['date_upd'] = pSQL($this->date_upd);
|
||||
$fields['active'] = (int)($this->active);
|
||||
$fields['active'] = (int)$this->active;
|
||||
|
||||
return $fields;
|
||||
}
|
||||
|
||||
@@ -67,7 +67,8 @@ class UpgraderCore
|
||||
if (empty($this->link))
|
||||
$this->checkPSVersion();
|
||||
|
||||
if (@copy($this->link, realpath($dest).DIRECTORY_SEPARATOR.$filename))
|
||||
$destPath = realpath($dest).DIRECTORY_SEPARATOR.$filename;
|
||||
if (@copy($this->link, $destPath) && md5_file($destPath) == $this->md5 )
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
|
||||
@@ -849,7 +849,7 @@ class ValidateCore
|
||||
*/
|
||||
public static function isCoordinate($data)
|
||||
{
|
||||
return ($data == NULL) OR (bool)(preg_match('/^\-?[0-9]{1,6}\.[0-9]{1,6}$/s', $data));
|
||||
return ($data == NULL) OR (bool)(preg_match('/^\-?[0-9]{1,8}\.[0-9]{1,8}$/s', $data));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user