diff --git a/admin-dev/ajax.php b/admin-dev/ajax.php
index e872f47dc..5ec0197ac 100644
--- a/admin-dev/ajax.php
+++ b/admin-dev/ajax.php
@@ -171,110 +171,6 @@ if (Tools::isSubmit('updateElementEmployee') && Tools::getValue('updateElementEm
die($notification->updateEmployeeLastElement(Tools::getValue('updateElementEmployeeType')));
}
-if (Tools::isSubmit('syncImapMail'))
-{
- if (!($url = Configuration::get('PS_SAV_IMAP_URL'))
- || !($port = Configuration::get('PS_SAV_IMAP_PORT'))
- || !($user = Configuration::get('PS_SAV_IMAP_USER'))
- || !($password = Configuration::get('PS_SAV_IMAP_PWD')))
- die('{"hasError" : true, "errors" : ["Configuration is not correct"]}');
-
- $conf = Configuration::getMultiple(array(
- 'PS_SAV_IMAP_OPT_NORSH', 'PS_SAV_IMAP_OPT_SSL',
- 'PS_SAV_IMAP_OPT_VALIDATE-CERT', 'PS_SAV_IMAP_OPT_NOVALIDATE-CERT',
- 'PS_SAV_IMAP_OPT_TLS', 'PS_SAV_IMAP_OPT_NOTLS'));
-
- $conf_str = '';
- if ($conf['PS_SAV_IMAP_OPT_NORSH'])
- $conf_str .= '/norsh';
- if ($conf['PS_SAV_IMAP_OPT_SSL'])
- $conf_str .= '/ssl';
- if ($conf['PS_SAV_IMAP_OPT_VALIDATE-CERT'])
- $conf_str .= '/validate-cert';
- if ($conf['PS_SAV_IMAP_OPT_NOVALIDATE-CERT'])
- $conf_str .= '/novalidate-cert';
- if ($conf['PS_SAV_IMAP_OPT_TLS'])
- $conf_str .= '/tls';
- if ($conf['PS_SAV_IMAP_OPT_NOTLS'])
- $conf_str .= '/notls';
-
- if (!function_exists('imap_open'))
- die('{"hasError" : true, "errors" : ["imap is not installed on this server"]}');
-
- $mbox = @imap_open('{'.$url.':'.$port.$conf_str.'}', $user, $password);
-
- //checks if there is no error when connecting imap server
- $errors = imap_errors();
- $str_errors = '';
- $str_error_delete = '';
- if (sizeof($errors) && is_array($errors))
- {
- var_dump($errors);
- $str_errors = '';
- foreach($errors as $error)
- $str_errors .= '"'.$error.'",';
- $str_errors = rtrim($str_errors, ',').'';
- }
- //checks if imap connexion is active
- if (!$mbox)
- die('{"hasError" : true, "errors" : ["Cannot connect to the mailbox"]}');
-
- //Returns information about the current mailbox. Returns FALSE on failure.
- $check = imap_check($mbox);
- if (!$check)
- die('{"hasError" : true, "errors" : ["Fail to get information about the current mailbox"]}');
-
- if ($check->Nmsgs == 0)
- die('{"hasError" : true, "errors" : ["NO message to sync"]}');
-
- $result = imap_fetch_overview($mbox,"1:{$check->Nmsgs}",0);
- foreach ($result as $overview)
- {
- //check if message exist in database
- if (isset($overview->subject))
- $subject = $overview->subject;
- else
- $subject = '';
-
- //Creating an md5 to check if message has been allready processed
- $md5 = md5($overview->date.$overview->from.$subject.$overview->msgno);
- $exist = Db::getInstance()->getValue(
- 'SELECT `md5_header`
- FROM `'._DB_PREFIX_.'customer_message_sync_imap`
- WHERE `md5_header` = \''.pSQL($md5).'\'');
- if ($exist)
- {
- if (Configuration::get('PS_SAV_IMAP_DELETE_MSG'))
- if (!imap_delete($mbox, $overview->msgno))
- $str_error_delete = ', "Fail to delete message"';
- }
- else
- {
- //check if subject has id_order
- preg_match('/\#ct([0-9]*)/', $subject, $matches1);
- preg_match('/\#tc([0-9-a-z-A-Z]*)/', $subject, $matches2);
-
- if (isset($matches1[1]) && isset($matches2[1]))
- {
- //check if order exist in database
- $ct = new CustomerThread((int)$matches1[1]);
-
- if (Validate::isLoadedObject($ct) && $ct->token == $matches2[1])
- {
- $cm = new CustomerMessage();
- $cm->id_customer_thread = $ct->id;
- $cm->message = imap_fetchbody($mbox, $overview->msgno, 1);
- $cm->add();
- }
- }
- Db::getInstance()->execute('INSERT INTO `'._DB_PREFIX_.'customer_message_sync_imap` (`md5_header`) VALUES (\''.pSQL($md5).'\')');
- }
- }
- imap_expunge($mbox);
- imap_close($mbox);
- die('{"hasError" : false, "errors" : ["'.$str_errors.$str_error_delete.'"]}');
-}
-
if (Tools::isSubmit('searchCategory'))
{
$q = Tools::getValue('q');
diff --git a/admin-dev/ajax_products_list.php b/admin-dev/ajax_products_list.php
index 8650abd8d..64ee54211 100644
--- a/admin-dev/ajax_products_list.php
+++ b/admin-dev/ajax_products_list.php
@@ -51,13 +51,16 @@ else
// Excluding downloadable products from packs because download from pack is not supported
$excludeVirtuals = (bool)Tools::getValue('excludeVirtuals', false);
+$exclude_packs = (bool)Tools::getValue('exclude_packs', false);
$sql = 'SELECT p.`id_product`, `reference`, pl.name
FROM `'._DB_PREFIX_.'product` p
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (pl.id_product = p.id_product AND pl.id_lang = '.(int)Context::getContext()->language->id.Shop::addSqlRestrictionOnLang('pl').')
WHERE (pl.name LIKE \'%'.pSQL($query).'%\' OR p.reference LIKE \'%'.pSQL($query).'%\')'.
(!empty($excludeIds) ? ' AND p.id_product NOT IN ('.$excludeIds.') ' : ' ').
- ($excludeVirtuals ? 'AND p.id_product NOT IN (SELECT pd.id_product FROM `'._DB_PREFIX_.'product_download` pd WHERE (pd.id_product = p.id_product))' : '');
+ ($excludeVirtuals ? 'AND p.id_product NOT IN (SELECT pd.id_product FROM `'._DB_PREFIX_.'product_download` pd WHERE (pd.id_product = p.id_product))' : '').
+ ($exclude_packs ? 'AND (p.cache_is_pack IS NULL OR p.cache_is_pack = 0)' : '');
+
$items = Db::getInstance()->executeS($sql);
if ($items)
diff --git a/admin-dev/themes/default/template/controllers/customer_threads/helpers/options/options.tpl b/admin-dev/themes/default/template/controllers/customer_threads/helpers/options/options.tpl
index eafc84173..2c25963bd 100644
--- a/admin-dev/themes/default/template/controllers/customer_threads/helpers/options/options.tpl
+++ b/admin-dev/themes/default/template/controllers/customer_threads/helpers/options/options.tpl
@@ -49,8 +49,15 @@
$('#ajax_loader').html('
');
ajaxQuery = $.ajax({
type: "POST",
- url: "ajax.php",
- data: "syncImapMail=1",
+ url: "index.php",
+ data: {
+ ajax: "1",
+ token: "{$token}",
+ syncImapMail: "1",
+ ajax:"1",
+ action:"syncImap",
+ tab:"AdminCustomerThreads"
+ },
dataType : "json",
success: function(jsonData) {
jsonError = '';
diff --git a/admin-dev/themes/default/template/controllers/products/informations.tpl b/admin-dev/themes/default/template/controllers/products/informations.tpl
index 26b38e36b..eabf0c984 100644
--- a/admin-dev/themes/default/template/controllers/products/informations.tpl
+++ b/admin-dev/themes/default/template/controllers/products/informations.tpl
@@ -97,9 +97,9 @@
-
+
-
+
diff --git a/classes/Cart.php b/classes/Cart.php
index 9b0b477e4..90ef11ea3 100644
--- a/classes/Cart.php
+++ b/classes/Cart.php
@@ -1191,6 +1191,7 @@ class CartCore extends ObjectModel
// refresh cache of self::_products
$this->_products = $this->getProducts(true);
CartRule::autoRemoveFromCart();
+ CartRule::autoAddToCart();
return $return;
}
diff --git a/classes/HelpAccess.php b/classes/HelpAccess.php
index 9097d041a..59f01dcc5 100644
--- a/classes/HelpAccess.php
+++ b/classes/HelpAccess.php
@@ -79,7 +79,7 @@ class HelpAccessCore
$tooltip = '';
$ctx = @stream_context_create(array('http' => array('timeout' => 10)));
- $res = @file_get_contents($url, 0, $ctx);
+ $res = Tools::file_get_contents($url, false, $ctx);
$infos = preg_split('/\|/', $res);
if (count($infos) > 0)
diff --git a/classes/Manufacturer.php b/classes/Manufacturer.php
index a2655810a..41ac93c5a 100644
--- a/classes/Manufacturer.php
+++ b/classes/Manufacturer.php
@@ -110,7 +110,7 @@ class ManufacturerCore extends ObjectModel
{
$address = new Address($this->id_address);
- if (!$address->delete())
+ if (Validate::isLoadedObject($address) AND !$address->delete())
return false;
if (parent::delete())
diff --git a/classes/ObjectModel.php b/classes/ObjectModel.php
index 29e48fe79..d0b70720d 100644
--- a/classes/ObjectModel.php
+++ b/classes/ObjectModel.php
@@ -389,7 +389,7 @@ abstract class ObjectModelCore
return (int)$value;
case self::TYPE_FLOAT :
- return (float)$value;
+ return (float)str_replace(',', '.', $value);
case self::TYPE_DATE :
if (!$value)
diff --git a/classes/controller/AdminController.php b/classes/controller/AdminController.php
index 08c904206..39696bb80 100644
--- a/classes/controller/AdminController.php
+++ b/classes/controller/AdminController.php
@@ -175,6 +175,9 @@ class AdminControllerCore extends Controller
/** @var array required_fields to display in the Required Fields form */
public $required_fields = array();
+
+ /** @var Helper */
+ protected $helper;
/**
* @var array actions to execute on multiple selections
@@ -1635,6 +1638,8 @@ class AdminControllerCore extends Controller
// For each action, try to add the corresponding skip elements list
$helper->list_skip_actions = $this->list_skip_actions;
+
+ $this->helper = $helper;
}
public function setMedia()
@@ -2790,7 +2795,7 @@ class AdminControllerCore extends Controller
{
$content = Tools::file_get_contents($external_file);
if ($content)
- return file_put_contents(_PS_ROOT_DIR_.$file_to_refresh, $content);
+ return (bool)file_put_contents(_PS_ROOT_DIR_.$file_to_refresh, $content);
return false;
}
diff --git a/classes/log/FileLogger.php b/classes/log/FileLogger.php
index a9dee40dd..1f68df9b6 100644
--- a/classes/log/FileLogger.php
+++ b/classes/log/FileLogger.php
@@ -37,7 +37,7 @@ class FileLoggerCore extends AbstractLogger
protected function logMessage($message, $level)
{
$formatted_message = '*'.$this->level_value[$level].'* '."\t".date('Y/m/d - H:i:s').': '.$message."\r\n";
- return file_put_contents($this->getFilename(), $formatted_message, FILE_APPEND);
+ return (bool)file_put_contents($this->getFilename(), $formatted_message, FILE_APPEND);
}
/**
diff --git a/config/config.inc.php b/config/config.inc.php
index 612fd961b..a08d75c66 100644
--- a/config/config.inc.php
+++ b/config/config.inc.php
@@ -164,15 +164,21 @@ else
if (isset($cookie->id_customer) && (int)$cookie->id_customer)
{
$customer = new Customer($cookie->id_customer);
- $customer->logged = $cookie->logged;
-
- if ($customer->id_lang != $context->language->id)
+ if(!Validate::isLoadedObject($customer))
+ $customer->logout();
+ else
{
- $customer->id_lang = $context->language->id;
- $customer->update();
+ $customer->logged = $cookie->logged;
+
+ if ($customer->id_lang != $context->language->id)
+ {
+ $customer->id_lang = $context->language->id;
+ $customer->update();
+ }
}
}
- else
+
+ if (!isset($customer) || !Validate::isLoadedObject($customer))
{
$customer = new Customer();
diff --git a/controllers/admin/AdminCartsController.php b/controllers/admin/AdminCartsController.php
index 8a99921a5..a0a85295e 100755
--- a/controllers/admin/AdminCartsController.php
+++ b/controllers/admin/AdminCartsController.php
@@ -746,4 +746,14 @@ class AdminCartsControllerCore extends AdminController
{
return ($echo == '0' ? Configuration::get('PS_SHOP_NAME') : $echo);
}
+
+ public function displayDeleteLink($token = null, $id, $name = null)
+ {
+ // don't display ordered carts
+ foreach ($this->_list as $row)
+ if ($row['id_cart'] == $id && isset($row['id_order']) && $row['id_order'])
+ return ;
+
+ return $this->helper->displayDeleteLink($token, $id, $name);
+ }
}
diff --git a/controllers/admin/AdminCustomerThreadsController.php b/controllers/admin/AdminCustomerThreadsController.php
index 356295477..207a3ea57 100644
--- a/controllers/admin/AdminCustomerThreadsController.php
+++ b/controllers/admin/AdminCustomerThreadsController.php
@@ -177,6 +177,11 @@ class AdminCustomerThreadsControllerCore extends AdminController
'desc' => $this->l('Delete messages after sync. If you do not active this option, the sync will take more time.'),
'type' => 'bool',
),
+ 'PS_SAV_IMAP_CREATE_THREADS' => array(
+ 'title' => $this->l('Create new threads'),
+ 'desc' => $this->l('Create new threads for unrecognized emails'),
+ 'type' => 'bool',
+ ),
'PS_SAV_IMAP_OPT_NORSH' => array(
'title' => $this->l('IMAP options').' (/norsh)',
'type' => 'bool',
@@ -343,7 +348,7 @@ class AdminCustomerThreadsControllerCore extends AdminController
$cm->add();
}
}
- else if ($email && Validate::isEmail($email))
+ elseif ($email && Validate::isEmail($email))
{
$params = array(
'{messages}' => Tools::nl2br(stripslashes($output)),
@@ -376,7 +381,7 @@ class AdminCustomerThreadsControllerCore extends AdminController
$cm->ip_address = ip2long($_SERVER['REMOTE_ADDR']);
if (isset($_FILES) && !empty($_FILES['joinFile']['name']) && $_FILES['joinFile']['error'] != 0)
$this->errors[] = Tools::displayError('An error occurred with the file upload.');
- else if ($cm->add())
+ elseif ($cm->add())
{
$file_attachment = null;
if (!empty($_FILES['joinFile']['name']))
@@ -393,11 +398,22 @@ class AdminCustomerThreadsControllerCore extends AdminController
),
);
//#ct == id_customer_thread #tc == token of thread <== used in the synchronization imap
+ $contact = new Contact((int)$ct->id_contact);
+ if (Validate::isLoadedObject($contact))
+ {
+ $from_name = $contact->name;
+ $from_email = $contact->email;
+ }
+ else
+ {
+ $from_name = null;
+ $from_email = null;
+ }
if (Mail::Send(
(int)$ct->id_lang,
'reply_msg',
sprintf(Mail::l('An answer to your message is available #ct%1$s #tc%2$s', $ct->id_lang), $ct->id, $ct->token),
- $params, Tools::getValue('msg_email'), null, null, null, $file_attachment, null,
+ $params, Tools::getValue('msg_email'), null, $from_email, $from_name, $file_attachment, null,
_PS_MAIL_DIR_, true))
{
$ct->status = 'closed';
@@ -642,15 +658,148 @@ class AdminCustomerThreadsControllerCore extends AdminController
public function updateOptionPsSavImapOpt($value)
{
+ if ($this->tabAccess['edit'] != '1')
+ throw new PrestaShopException(Tools::displayError('You do not have permission to edit here.'));
+
if (!$this->errors && $value)
Configuration::updateValue('PS_SAV_IMAP_OPT', implode('', $value));
}
public function ajaxProcessMarkAsRead()
{
+ if ($this->tabAccess['edit'] != '1')
+ throw new PrestaShopException(Tools::displayError('You do not have permission to edit here.'));
+
$id_thread = Tools::getValue('id_thread');
$messages = CustomerThread::getMessageCustomerThreads($id_thread);
if (count($messages))
Db::getInstance()->execute('UPDATE '._DB_PREFIX_.'customer_message set `read` = 1');
}
+
+ public function ajaxProcessSyncImap()
+ {
+ if ($this->tabAccess['edit'] != '1')
+ throw new PrestaShopException(Tools::displayError('You do not have permission to edit here.'));
+
+ if (Tools::isSubmit('syncImapMail'))
+ {
+ if (!($url = Configuration::get('PS_SAV_IMAP_URL'))
+ || !($port = Configuration::get('PS_SAV_IMAP_PORT'))
+ || !($user = Configuration::get('PS_SAV_IMAP_USER'))
+ || !($password = Configuration::get('PS_SAV_IMAP_PWD')))
+ die('{"hasError" : true, "errors" : ["Configuration is not correct"]}');
+
+ $conf = Configuration::getMultiple(array(
+ 'PS_SAV_IMAP_OPT_NORSH', 'PS_SAV_IMAP_OPT_SSL',
+ 'PS_SAV_IMAP_OPT_VALIDATE-CERT', 'PS_SAV_IMAP_OPT_NOVALIDATE-CERT',
+ 'PS_SAV_IMAP_OPT_TLS', 'PS_SAV_IMAP_OPT_NOTLS'));
+
+ $conf_str = '';
+ if ($conf['PS_SAV_IMAP_OPT_NORSH'])
+ $conf_str .= '/norsh';
+ if ($conf['PS_SAV_IMAP_OPT_SSL'])
+ $conf_str .= '/ssl';
+ if ($conf['PS_SAV_IMAP_OPT_VALIDATE-CERT'])
+ $conf_str .= '/validate-cert';
+ if ($conf['PS_SAV_IMAP_OPT_NOVALIDATE-CERT'])
+ $conf_str .= '/novalidate-cert';
+ if ($conf['PS_SAV_IMAP_OPT_TLS'])
+ $conf_str .= '/tls';
+ if ($conf['PS_SAV_IMAP_OPT_NOTLS'])
+ $conf_str .= '/notls';
+
+ if (!function_exists('imap_open'))
+ die('{"hasError" : true, "errors" : ["imap is not installed on this server"]}');
+
+ $mbox = @imap_open('{'.$url.':'.$port.$conf_str.'}', $user, $password);
+
+ //checks if there is no error when connecting imap server
+ $errors = imap_errors();
+ $str_errors = '';
+ $str_error_delete = '';
+ if (sizeof($errors) && is_array($errors))
+ {
+ $str_errors = '';
+ foreach($errors as $error)
+ $str_errors .= '"'.$error.'",';
+ $str_errors = rtrim($str_errors, ',').'';
+ }
+ //checks if imap connexion is active
+ if (!$mbox)
+ die('{"hasError" : true, "errors" : ["Cannot connect to the mailbox:.
'.addslashes($str_errors).'"]}');
+
+ //Returns information about the current mailbox. Returns FALSE on failure.
+ $check = imap_check($mbox);
+ if (!$check)
+ die('{"hasError" : true, "errors" : ["Fail to get information about the current mailbox"]}');
+
+ if ($check->Nmsgs == 0)
+ die('{"hasError" : true, "errors" : ["NO message to sync"]}');
+
+ $result = imap_fetch_overview($mbox,"1:{$check->Nmsgs}",0);
+ foreach ($result as $overview)
+ {
+ //check if message exist in database
+ if (isset($overview->subject))
+ $subject = $overview->subject;
+ else
+ $subject = '';
+ //Creating an md5 to check if message has been allready processed
+ $md5 = md5($overview->date.$overview->from.$subject.$overview->msgno);
+ $exist = Db::getInstance()->getValue(
+ 'SELECT `md5_header`
+ FROM `'._DB_PREFIX_.'customer_message_sync_imap`
+ WHERE `md5_header` = \''.pSQL($md5).'\'');
+ if ($exist)
+ {
+ if (Configuration::get('PS_SAV_IMAP_DELETE_MSG'))
+ if (!imap_delete($mbox, $overview->msgno))
+ $str_error_delete = ', "Fail to delete message"';
+ }
+ else
+ {
+ //check if subject has id_order
+ preg_match('/\#ct([0-9]*)/', $subject, $matches1);
+ preg_match('/\#tc([0-9-a-z-A-Z]*)/', $subject, $matches2);
+ $new_ct = (Configuration::get('PS_SAV_IMAP_CREATE_THREADS') && !isset($matches1[1]) && !isset($matches2[1]) && !preg_match('/[no_sync]/', $subject));
+ if (isset($matches1[1]) && isset($matches2[1]) || $new_ct)
+ {
+ if ($new_ct)
+ {
+ if (!preg_match('/<('.Tools::cleanNonUnicodeSupport('[a-z\p{L}0-9!#$%&\'*+\/=?^`{}|~_-]+[.a-z\p{L}0-9!#$%&\'*+\/=?^`{}|~_-]*@[a-z\p{L}0-9]+[._a-z\p{L}0-9-]*\.[a-z0-9]+').')>/', $overview->from, $result)
+ || !Validate::isEmail($from = $result[1]))
+ continue;
+
+ $contacts = Contact::getCategoriesContacts();
+ if (!$contacts)
+ continue;
+ $id_contact = $contacts[0]['id_contact'];
+
+ $ct = new CustomerThread();
+ $ct->email = $from;
+ $ct->id_contact = $id_contact;
+ $ct->id_lang = (int)Configuration::get('PS_LANG_DEFAULT');
+ $ct->status = 'open';
+ $ct->token = Tools::passwdGen(12);
+ $ct->add();
+ }
+ else
+ $ct = new CustomerThread((int)$matches1[1]); //check if order exist in database
+
+ if (Validate::isLoadedObject($ct) && ((isset($matches2[1]) && $ct->token == $matches2[1]) || $new_ct))
+ {
+ $cm = new CustomerMessage();
+ $cm->id_customer_thread = $ct->id;
+ $cm->message = imap_fetchbody($mbox, $overview->msgno, 1);
+ $cm->add();
+ }
+ }
+ Db::getInstance()->execute('INSERT INTO `'._DB_PREFIX_.'customer_message_sync_imap` (`md5_header`) VALUES (\''.pSQL($md5).'\')');
+ }
+ }
+ imap_expunge($mbox);
+ imap_close($mbox);
+ die('{"hasError" : false, "errors" : ["'.$str_errors.$str_error_delete.'"]}');
+ }
+ }
}
\ No newline at end of file
diff --git a/controllers/admin/AdminImportController.php b/controllers/admin/AdminImportController.php
index 6c3581753..be5678368 100644
--- a/controllers/admin/AdminImportController.php
+++ b/controllers/admin/AdminImportController.php
@@ -1023,6 +1023,7 @@ class AdminImportControllerCore extends AdminController
$handle = $this->openCsvFile();
$default_language_id = (int)Configuration::get('PS_LANG_DEFAULT');
AdminImportController::setLocale();
+ $shop_ids = Shop::getCompleteListOfShopsID();
for ($current_line = 0; $line = fgetcsv($handle, MAX_LINE_SIZE, $this->separator); $current_line++)
{
if (Tools::getValue('convert'))
@@ -1237,7 +1238,7 @@ class AdminImportControllerCore extends AdminController
if (!$valid_link)
$this->warnings[] = sprintf(
Tools::displayError('Rewrite link for %1$s (ID: %2$s) was re-written as %3$s.'),
- $link_rewrite,
+ $product->name[$default_language_id],
(isset($info['id']) ? $info['id'] : 'null'),
$link_rewrite
);
@@ -1250,6 +1251,11 @@ class AdminImportControllerCore extends AdminController
if (!empty($meta_keyword))
$meta_keyword = str_replace($this->multiple_value_separator, ',', $meta_keyword);
+ // Convert comma into dot for all floating values
+ foreach (Product::$definition['fields'] as $key => $array)
+ if ($array['type'] == Product::TYPE_FLOAT)
+ $product->{$key} = str_replace(',', '.', $product->{$key});
+
$res = false;
$field_error = $product->validateFields(UNFRIENDLY_ERROR, true);
$lang_field_error = $product->validateFieldsLang(UNFRIENDLY_ERROR, true);
@@ -1298,8 +1304,12 @@ class AdminImportControllerCore extends AdminController
{
$shop = trim($shop);
if (!is_numeric($shop))
- $shop = ShopGroup::getIdByName($shop);
- $shops[] = $shop;
+ $shop = Shop::getIdByName($shop);
+
+ if (in_array($shop, $shop_ids))
+ $shops[] = $shop;
+ else
+ $this->addProductWarning(Tools::safeOutput($info['name']), $product->id, $this->l('Shop is not valid'));
}
if (empty($shops))
$shops = Shop::getContextListShopID();
diff --git a/controllers/admin/AdminLanguagesController.php b/controllers/admin/AdminLanguagesController.php
index f9689f2cf..11ce73750 100644
--- a/controllers/admin/AdminLanguagesController.php
+++ b/controllers/admin/AdminLanguagesController.php
@@ -488,8 +488,8 @@ class AdminLanguagesControllerCore extends AdminController
{
// Get all iso code available
$lang_packs = Tools::file_get_contents('http://www.prestashop.com/download/lang_packs/get_language_pack.php?version='.(string)$_GET['ps_version'].'&iso_lang='.(string)$_GET['iso_lang']);
-
- if ($lang_packs !== '' && Tools::jsonDecode($lang_packs) !== null)
+ $result = Tools::jsonDecode($lang_packs);
+ if ($lang_packs !== '' && $result && !isset($result->error))
{
$this->status = 'ok';
$this->content = $lang_packs;
@@ -497,7 +497,10 @@ class AdminLanguagesControllerCore extends AdminController
else
{
$this->status = 'error';
- $this->errors[] = $this->l('Wrong ISO code, or the selectec language pack is unavailable.');
+ $msg = $this->l('Wrong ISO code, or the selected language pack is unavailable.');
+ if ($result)
+ $msg = $result->msg;
+ $this->errors[] = $msg;
}
}
else
diff --git a/controllers/admin/AdminProductsController.php b/controllers/admin/AdminProductsController.php
index a3b1045bf..8284e3da9 100644
--- a/controllers/admin/AdminProductsController.php
+++ b/controllers/admin/AdminProductsController.php
@@ -3379,6 +3379,7 @@ class AdminProductsControllerCore extends AdminController
$product->tags = Tag::getProductTags($product->id);
$data->assign('product_type', (int)Tools::getValue('type_product', $product->getType()));
+ $data->assign('is_in_pack', (int)Pack::isPacked($product->id));
$check_product_association_ajax = false;
if (Shop::isFeatureActive() && Shop::getContext() != Shop::CONTEXT_ALL)
@@ -4115,10 +4116,6 @@ class AdminProductsControllerCore extends AdminController
$this->tpl_form_vars['custom_form'] = Hook::exec('displayAdminProductsExtra', array(), (int)$id_module);
}
-
-
-
-
/**
* delete all items in pack, then check if type_product value is 2.
* if yes, add the pack items from input "inputPackItems"
@@ -4143,7 +4140,9 @@ class AdminProductsControllerCore extends AdminController
list($qty, $item_id) = explode('x', $line);
if ($qty > 0 && isset($item_id))
{
- if (!Pack::addItem((int)$product->id, (int)$item_id, (int)$qty))
+ if (Pack::isPack((int)$item_id))
+ $this->errors[] = Tools::displayError('You can\'t add product packs into a pack');
+ elseif (!Pack::addItem((int)$product->id, (int)$item_id, (int)$qty))
$this->errors[] = Tools::displayError('An error occurred while adding products to the pack.');
}
}
diff --git a/controllers/admin/AdminStatusesController.php b/controllers/admin/AdminStatusesController.php
index 2d75c1818..aa11ebdb4 100644
--- a/controllers/admin/AdminStatusesController.php
+++ b/controllers/admin/AdminStatusesController.php
@@ -139,6 +139,7 @@ class AdminStatusesControllerCore extends AdminController
$this->_orderBy = null;
$this->addRowAction('editstatus');
+ $this->addRowActionSkipList('delete', array(1, 2, 3, 4, 5));
$this->fields_list = array(
'id_order_return_state' => array(
diff --git a/controllers/front/CartController.php b/controllers/front/CartController.php
index 2dddaee6f..af84b5e59 100644
--- a/controllers/front/CartController.php
+++ b/controllers/front/CartController.php
@@ -257,6 +257,7 @@ class CartControllerCore extends FrontController
}
$removed = CartRule::autoRemoveFromCart();
+ CartRule::autoAddToCart();
if (count($removed) && (int)Tools::getValue('allow_refresh'))
$this->ajax_refresh = true;
}
diff --git a/controllers/front/ContactController.php b/controllers/front/ContactController.php
index eb3b9c20c..bba68d70a 100644
--- a/controllers/front/ContactController.php
+++ b/controllers/front/ContactController.php
@@ -114,27 +114,6 @@ class ContactControllerCore extends FrontController
$contact->email = '';
$contact->customer_service = 0;
}
- if (!empty($contact->email))
- {
- $id_order = (int)Tools::getValue('id_order', 0);
- $order = new Order($id_order);
-
- $mail_var_list = array(
- '{email}' => $from,
- '{message}' => Tools::nl2br(stripslashes($message)),
- '{id_order}' => $id_order,
- '{order_name}' => $order->getUniqReference(),
- '{attached_file}' => isset($_FILES['fileUpload'], $_FILES['fileUpload']['name']) ? $_FILES['fileUpload']['name'] : ''
- );
-
- if (Mail::Send($this->context->language->id, 'contact', Mail::l('Message from contact form'),
- $mail_var_list, $contact->email, $contact->name, $from, ($customer->id ? $customer->firstname.' '.$customer->lastname : ''),
- $fileAttachment) &&
- Mail::Send($this->context->language->id, 'contact_form', Mail::l('Your message has been correctly sent'), $mail_var_list, $from))
- $this->context->smarty->assign('confirmation', 1);
- else
- $this->errors[] = Tools::displayError('An error occurred while sending message.');
- }
if ($contact->customer_service)
{
@@ -177,34 +156,59 @@ class ContactControllerCore extends FrontController
$cm->file_name = $filename;
$cm->ip_address = ip2long($_SERVER['REMOTE_ADDR']);
$cm->user_agent = $_SERVER['HTTP_USER_AGENT'];
- if ($cm->add())
- {
- if (empty($contact->email))
- {
- $var_list = array(
- '{order_name}' => '-',
- '{attached_file}' => '-',
- '{message}' => stripslashes($message)
- );
- if ($ct->id_order)
- {
- $order = new Order($ct->id_order);
- $var_list['{order_name}'] = $order->reference;
- }
- if (isset($filename))
- $var_list['{attached_file}'] = $_FILES['fileUpload']['name'];
- Mail::Send($this->context->language->id, 'contact_form', Mail::l('Your message has been correctly sent'), $var_list, $from);
- }
- $this->context->smarty->assign('confirmation', 1);
- }
- else
+ if (!$cm->add())
$this->errors[] = Tools::displayError('An error occurred while sending message.');
}
else
$this->errors[] = Tools::displayError('An error occurred while sending message.');
}
+
+ if (!count($this->errors))
+ {
+ $var_list = array(
+ '{order_name}' => '-',
+ '{attached_file}' => '-',
+ '{message}' => Tools::nl2br(stripslashes($message)),
+ '{email}' => $from,
+ );
+
+ if (isset($filename))
+ $var_list['{attached_file}'] = $_FILES['fileUpload']['name'];
+
+ $id_order = (int)Tools::getValue('id_order');
+
+ if (isset($ct) && Validate::isLoadedObject($ct))
+ {
+ if ($ct->id_order)
+ $id_order = $ct->id_order;
+ $subject = sprintf(Mail::l('Your message has been correctly sent #ct%1$s #tc%2$s'), $ct->id, $ct->token);
+ }
+ else
+ $subject = Mail::l('Your message has been correctly sent');
+
+ if ($id_order)
+ {
+ $order = new Order((int)$id_order);
+ $var_list['{order_name}'] = $order->getUniqReference();
+ $var_list['{id_order}'] = $id_order;
+ }
+
+ if (empty($contact->email))
+ Mail::Send($this->context->language->id, 'contact_form', $subject, $var_list, $from, null, null, null, $fileAttachment);
+ else
+ {
+ if (!Mail::Send($this->context->language->id, 'contact', Mail::l('Message from contact form').' [no_sync]',
+ $var_list, $contact->email, $contact->name, $from, ($customer->id ? $customer->firstname.' '.$customer->lastname : ''),
+ $fileAttachment) ||
+ !Mail::Send($this->context->language->id, 'contact_form', $subject, $var_list, $from, null, $contact->email, $contact->name, $fileAttachment))
+ $this->errors[] = Tools::displayError('An error occurred while sending message.');
+ }
+ }
+
if (count($this->errors) > 1)
array_unique($this->errors);
+ else
+ $this->context->smarty->assign('confirmation', 1);
}
}
}
diff --git a/docs/CHANGELOG b/docs/CHANGELOG.txt
old mode 100755
new mode 100644
similarity index 100%
rename from docs/CHANGELOG
rename to docs/CHANGELOG.txt
diff --git a/install-dev/classes/simplexml.php b/install-dev/classes/simplexml.php
index cfbedd25b..d3a761dc9 100644
--- a/install-dev/classes/simplexml.php
+++ b/install-dev/classes/simplexml.php
@@ -65,7 +65,7 @@ class InstallSimplexmlElement extends SimpleXMLElement
$dom->loadXML(parent::asXML());
if ($filename)
- return file_put_contents($filename, $dom->saveXML());
+ return (bool)file_put_contents($filename, $dom->saveXML());
return $dom->saveXML();
}
}
\ No newline at end of file
diff --git a/install-dev/data/theme.sql b/install-dev/data/theme.sql
index 4a7fd363a..a121b7197 100644
--- a/install-dev/data/theme.sql
+++ b/install-dev/data/theme.sql
@@ -56,9 +56,9 @@ UPDATE `PREFIX_configuration` SET value = 'http://www.twitter.com/prestashop' WH
UPDATE `PREFIX_configuration` SET value = 'http://www.prestashop.com/blog/en/feed/' WHERE name = 'blocksocial_rss';
UPDATE `PREFIX_configuration` SET value = 'My Company' WHERE name = 'blockcontactinfos_company';
UPDATE `PREFIX_configuration` SET value = '42 avenue des Champs Elysées\n75000 Paris\nFrance' WHERE name = 'blockcontactinfos_address';
-UPDATE `PREFIX_configuration` SET value = '+33 (0)1.23.45.67.89' WHERE name = 'blockcontactinfos_phone';
+UPDATE `PREFIX_configuration` SET value = '0123-456-789' WHERE name = 'blockcontactinfos_phone';
UPDATE `PREFIX_configuration` SET value = 'sales@yourcompany.com' WHERE name = 'blockcontactinfos_email';
-UPDATE `PREFIX_configuration` SET value = '+33 (0)1.23.45.67.89' WHERE name = 'blockcontact_telnumber';
+UPDATE `PREFIX_configuration` SET value = '0123-456-789' WHERE name = 'blockcontact_telnumber';
UPDATE `PREFIX_configuration` SET value = 'sales@yourcompany.com' WHERE name = 'blockcontact_email';
UPDATE `PREFIX_configuration` SET value = '1' WHERE name = 'SUPPLIER_DISPLAY_TEXT';
UPDATE `PREFIX_configuration` SET value = '5' WHERE name = 'SUPPLIER_DISPLAY_TEXT_NB';
diff --git a/js/admin-products.js b/js/admin-products.js
index 88f36d8eb..1867893ba 100644
--- a/js/admin-products.js
+++ b/js/admin-products.js
@@ -991,7 +991,8 @@ product_tabs['Pack'] = new function(){
},
extraParams: {
excludeIds : getSelectedIds(),
- excludeVirtuals : 1
+ excludeVirtuals : 1,
+ exclude_packs: 1
}
}).result(function(event, item){
$('#curPackItemId').val(item[1]);
diff --git a/modules/blockcart/ajax-cart.js b/modules/blockcart/ajax-cart.js
index 4bae73e82..40d5f9480 100644
--- a/modules/blockcart/ajax-cart.js
+++ b/modules/blockcart/ajax-cart.js
@@ -353,7 +353,7 @@ var ajaxCart = {
var removeLinks = $('#cart_block_product_' + domIdProduct).find('a.ajax_cart_block_remove_link');
if (!product.hasCustomizedDatas && !removeLinks.length)
$('#' + domIdProduct + ' span.remove_link').html(' ');
- if (parseFloat(product.price_float) <= 0)
+ if (product.is_gift)
$('#' + domIdProduct + ' span.remove_link').html('');
},
@@ -453,7 +453,7 @@ var ajaxCart = {
else
content += '';
if (typeof(freeShippingTranslation) != 'undefined')
- content += '' + (parseFloat(this.price_float) > 0 ? this.priceByLine : freeProductTranslation) + '';
+ content += '' + (parseFloat(this.price_float) > 0 ? this.priceByLine : freeShippingTranslation) + '';
content += '';
if (this.hasAttributes)
content += '
- {l s='Cart' mod='blockcart'} + {l s='Cart' mod='blockcart'} {if $ajax_allowed} - {/if} + {/if}