Merge branch 'development' of https://github.com/PrestaShop/PrestaShop into development

This commit is contained in:
vAugagneur
2013-02-07 10:46:37 +01:00
30 changed files with 289 additions and 195 deletions
-104
View File
@@ -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');
+4 -1
View File
@@ -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)
@@ -49,8 +49,15 @@
$('#ajax_loader').html('<img src="{$smarty.const._PS_ADMIN_IMG_}ajax-loader.gif">');
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 = '';
@@ -97,9 +97,9 @@
<label class="text">{$bullet_common_field} {l s='Type:'}</label>
<input type="radio" name="type_product" id="simple_product" value="{Product::PTYPE_SIMPLE}" {if $product_type == Product::PTYPE_SIMPLE}checked="checked"{/if} />
<label class="radioCheck" for="simple_product">{l s='Product'}</label>
<input type="radio" name="type_product" id="pack_product" value="{Product::PTYPE_PACK}" {if $product_type == Product::PTYPE_PACK}checked="checked"{/if} />
<input type="radio" name="type_product" {if $is_in_pack}disabled="disabled"{/if} id="pack_product" value="{Product::PTYPE_PACK}" {if $product_type == Product::PTYPE_PACK}checked="checked"{/if} />
<label class="radioCheck" for="pack_product">{l s='Pack'}</label>
<input type="radio" name="type_product" id="virtual_product" value="{Product::PTYPE_VIRTUAL}" {if $product_type == Product::PTYPE_VIRTUAL}checked="checked"{/if} />
<input type="radio" name="type_product" id="virtual_product" {if $is_in_pack}disabled="disabled"{/if} value="{Product::PTYPE_VIRTUAL}" {if $product_type == Product::PTYPE_VIRTUAL}checked="checked"{/if} />
<label class="radioCheck" for="virtual_product">{l s='Virtual Product (services, booking or downloadable products)'}</label>
</div>
+1
View File
@@ -1191,6 +1191,7 @@ class CartCore extends ObjectModel
// refresh cache of self::_products
$this->_products = $this->getProducts(true);
CartRule::autoRemoveFromCart();
CartRule::autoAddToCart();
return $return;
}
+1 -1
View File
@@ -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)
+1 -1
View File
@@ -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())
+1 -1
View File
@@ -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)
+6 -1
View File
@@ -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;
}
+1 -1
View File
@@ -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);
}
/**
+12 -6
View File
@@ -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();
@@ -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);
}
}
@@ -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:.<br />'.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.'"]}');
}
}
}
+13 -3
View File
@@ -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();
@@ -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
@@ -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.');
}
}
@@ -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(
+1
View File
@@ -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;
}
+46 -42
View File
@@ -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);
}
}
}
View File
+1 -1
View File
@@ -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();
}
}
+2 -2
View File
@@ -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';
+2 -1
View File
@@ -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]);
+3 -3
View File
@@ -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('<a class="ajax_cart_block_remove_link" rel="nofollow" href="' + baseUri + '?controller=cart&amp;delete&amp;id_product=' + product['id'] + '&amp;ipa=' + product['idCombination'] + '&amp;token=' + static_token + '"> </a>');
if (parseFloat(product.price_float) <= 0)
if (product.is_gift)
$('#' + domIdProduct + ' span.remove_link').html('');
},
@@ -453,7 +453,7 @@ var ajaxCart = {
else
content += '<span class="remove_link"></span>';
if (typeof(freeShippingTranslation) != 'undefined')
content += '<span class="price">' + (parseFloat(this.price_float) > 0 ? this.priceByLine : freeProductTranslation) + '</span>';
content += '<span class="price">' + (parseFloat(this.price_float) > 0 ? this.priceByLine : freeShippingTranslation) + '</span>';
content += '</dt>';
if (this.hasAttributes)
content += '<dd id="cart_block_combination_of_' + domIdProduct + '" class="hidden"><a href="' + this.link + '" title="' + this.name + '">' + this.attributes + '</a>';
@@ -470,7 +470,7 @@ var ajaxCart = {
if($('#cart_block_product_' + domIdProduct + ' .quantity').text() != jsonProduct.quantity || $('dt#cart_block_product_' + domIdProduct + ' .price').text() != jsonProduct.priceByLine)
{
// Usual product
if (parseFloat(this.price_float) > 0)
if (!this.is_gift)
$('#cart_block_product_' + domIdProduct + ' .price').text(jsonProduct.priceByLine);
else
$('#cart_block_product_' + domIdProduct + ' .price').html(freeProductTranslation);
+1
View File
@@ -39,6 +39,7 @@
"price_float": "{$product.total}",
"idCombination": {if isset($product.attributes_small)}{$productAttributeId}{else}0{/if},
"idAddressDelivery": {if isset($product.id_address_delivery)}{$product.id_address_delivery}{else}0{/if},
"is_gift" : {if isset($product.is_gift) && $product.is_gift}1{else}0{/if},
{if isset($product.attributes_small)}
"hasAttributes": true,
"attributes": "{$product.attributes_small|addslashes|replace:'\\\'':'\''}",
+1
View File
@@ -89,6 +89,7 @@ class BlockCart extends Module
foreach ($products as &$product)
if ($product['id_product'] == $cart_rule['gift_product'] && $product['id_product_attribute'] == $cart_rule['gift_product_attribute'])
{
$product['is_gift'] = 1;
$product['total_wt'] = Tools::ps_round($product['total_wt'] - $product['price_wt'], (int)$currency->decimals * _PS_PRICE_DISPLAY_PRECISION_);
$product['total'] = Tools::ps_round($product['total'] - $product['price'], (int)$currency->decimals * _PS_PRICE_DISPLAY_PRECISION_);
$cart_rule['value_real'] = Tools::ps_round($cart_rule['value_real'] - $product['price_wt'], (int)$currency->decimals * _PS_PRICE_DISPLAY_PRECISION_);
+2 -2
View File
@@ -78,9 +78,9 @@ var delete_txt = '{l s='Delete' mod='blockcart' js=1}';
<span class="quantity-formated"><span class="quantity">{$product.cart_quantity}</span>x</span>
<a class="cart_block_product_name" href="{$link->getProductLink($product, $product.link_rewrite, $product.category, null, null, $product.id_shop, $product.id_product_attribute)}" title="{$product.name|escape:html:'UTF-8'}">
{$product.name|truncate:13:'...'|escape:html:'UTF-8'}</a>
<span class="remove_link">{if !isset($customizedDatas.$productId.$productAttributeId) && ($product.total > 0)}<a rel="nofollow" class="ajax_cart_block_remove_link" href="{$link->getPageLink('cart', true, NULL, "delete&amp;id_product={$product.id_product}&amp;ipa={$product.id_product_attribute}&amp;id_address_delivery={$product.id_address_delivery}&amp;token={$static_token}", true)}" title="{l s='remove this product from my cart' mod='blockcart'}">&nbsp;</a>{/if}</span>
<span class="remove_link">{if !isset($customizedDatas.$productId.$productAttributeId) && (!isset($product.is_gift) || !$product.is_gift)}<a rel="nofollow" class="ajax_cart_block_remove_link" href="{$link->getPageLink('cart', true, NULL, "delete&amp;id_product={$product.id_product}&amp;ipa={$product.id_product_attribute}&amp;id_address_delivery={$product.id_address_delivery}&amp;token={$static_token}", true)}" title="{l s='remove this product from my cart' mod='blockcart'}">&nbsp;</a>{/if}</span>
<span class="price">
{if $product.total > 0}
{if !isset($product.is_gift) || !$product.is_gift}
{if $priceDisplay == $smarty.const.PS_TAX_EXC}{displayWtPrice p="`$product.total`"}{else}{displayWtPrice p="`$product.total_wt`"}{/if}
{else}
<b>{l s='Free!' mod='blockcart'}</b>
+1 -5
View File
@@ -13,11 +13,7 @@
}
/* cart */
#shopping_cart {
}
.lt-ie6 #shopping_cart {width: 130px;}
#shopping_cart a{
height: 15px;
padding:15px 27px 10px 43px;
@@ -44,11 +44,11 @@ var delete_txt = '{l s='Delete' mod='blockcart' js=1}';
<!-- MODULE Block cart -->
<div id="cart_block" class="block exclusive">
<p class="title_block">
<a href="{$link->getPageLink("$order_process", true)}" title="{l s='View my shopping cart' mod='blockcart'}" rel="nofollow">{l s='Cart' mod='blockcart'}</a>
<a href="{$link->getPageLink("$order_process", true)}" title="{l s='View my shopping cart' mod='blockcart'}" rel="nofollow">{l s='Cart' mod='blockcart'}
{if $ajax_allowed}
<span id="block_cart_expand" {if isset($colapseExpandStatus) && $colapseExpandStatus eq 'expanded' || !isset($colapseExpandStatus)}class="hidden"{/if}>&nbsp;</span>
<span id="block_cart_collapse" {if isset($colapseExpandStatus) && $colapseExpandStatus eq 'collapsed'}class="hidden"{/if}>&nbsp;</span>
{/if}
{/if}</a>
</p>
<div class="block_content">
<!-- block summary -->
@@ -78,9 +78,9 @@ var delete_txt = '{l s='Delete' mod='blockcart' js=1}';
<span class="quantity-formated"><span class="quantity">{$product.cart_quantity}</span>x</span>
<a class="cart_block_product_name" href="{$link->getProductLink($product, $product.link_rewrite, $product.category, null, null, $product.id_shop, $product.id_product_attribute)}" title="{$product.name|escape:html:'UTF-8'}">
{$product.name|truncate:13:'...'|escape:html:'UTF-8'}</a>
<span class="remove_link">{if !isset($customizedDatas.$productId.$productAttributeId) && ($product.total > 0)}<a rel="nofollow" class="ajax_cart_block_remove_link" href="{$link->getPageLink('cart', true, NULL, "delete&amp;id_product={$product.id_product}&amp;ipa={$product.id_product_attribute}&amp;id_address_delivery={$product.id_address_delivery}&amp;token={$static_token}", true)}" title="{l s='remove this product from my cart' mod='blockcart'}">&nbsp;</a>{/if}</span>
<span class="remove_link">{if !isset($customizedDatas.$productId.$productAttributeId) && (!isset($product.is_gift) || !$product.is_gift)}<a rel="nofollow" class="ajax_cart_block_remove_link" href="{$link->getPageLink('cart', true, NULL, "delete&amp;id_product={$product.id_product}&amp;ipa={$product.id_product_attribute}&amp;id_address_delivery={$product.id_address_delivery}&amp;token={$static_token}", true)}" title="{l s='remove this product from my cart' mod='blockcart'}">&nbsp;</a>{/if}</span>
<span class="price">
{if $product.total > 0}
{if !isset($product.is_gift) || !$product.is_gift}
{if $priceDisplay == $smarty.const.PS_TAX_EXC}{displayWtPrice p="`$product.total`"}{else}{displayWtPrice p="`$product.total_wt`"}{/if}
{else}
<b>{l s='Free!' mod='blockcart'}</b>
+1 -1
View File
@@ -4112,7 +4112,7 @@ $_LANGADM['AdminTranslations1476dfb963d54c697399a79fafa90151'] = 'expressions';
$_LANGADM['AdminTranslations1e6d57e813355689e9c77e947d73ad8f'] = 'Depuis :';
$_LANGADM['AdminTranslations2303c057afcbe798a5d9811d36e88050'] = 'Modifier les traductions';
$_LANGADM['AdminTranslations24f4b4e58327af6b347c2894f3af7b63'] = 'Cette expression utilise ces syntaxes spécifiques :';
$_LANGADM['AdminTranslations26a8ee44d835a6301f1ffa7686749633'] = 'Demandez à votre hébergeur d\'augmenter les limites POST et REQUEST à';
$_LANGADM['AdminTranslations26a8ee44d835a6301f1ffa7686749633'] = 'Demandez à votre hébergeur d\'augmenter les limites POST, REQUEST et INPUT à';
$_LANGADM['AdminTranslations282d961c3071465db42647be8f662671'] = 'Traductions des noms des champs';
$_LANGADM['AdminTranslations28cbbb20b2a45b89ba9f8fc27cb4d4ce'] = 'Modifier ce modèle d\'e-mail';
$_LANGADM['AdminTranslations2e8d630dcde90b8b5be0468678f88551'] = 'Import/export de traductions';