[-] BO : error message on install module

This commit is contained in:
vAugagneur
2013-02-05 09:41:34 +01:00
74 changed files with 898 additions and 882 deletions
@@ -71,6 +71,7 @@ class AdminCurrenciesControllerCore extends AdminController
$this->_select .= 'currency_shop.conversion_rate conversion_rate';
$this->_join .= Shop::addSqlAssociation('currency', 'a');
$this->_group .= 'GROUP BY id_currency';
}
public function renderList()
+196 -184
View File
@@ -644,10 +644,14 @@ class AdminImportControllerCore extends AdminController
do $uniqid_path = _PS_UPLOAD_DIR_.uniqid(); while (file_exists($uniqid_path));
file_put_contents($uniqid_path, $field);
$fd = fopen($uniqid_path, 'r');
$tab = fgetcsv($fd, MAX_LINE_SIZE, $separator);
fclose($fd);
unlink($uniqid_path);
$tab = '';
if(!empty($uniqid_path))
{
$fd = fopen($uniqid_path, 'r');
$tab = fgetcsv($fd, MAX_LINE_SIZE, $separator);
fclose($fd);
unlink($uniqid_path);
}
if (empty($tab) || (!is_array($tab)))
return array();
@@ -727,8 +731,9 @@ class AdminImportControllerCore extends AdminController
public static function getMaskedRow($row)
{
$res = array();
foreach (self::$column_mask as $type => $nb)
$res[$type] = isset($row[$nb]) ? $row[$nb] : null;
if (is_array(self::$column_mask))
foreach (self::$column_mask as $type => $nb)
$res[$type] = isset($row[$nb]) ? $row[$nb] : null;
if (Tools::getValue('forceIds')) // if you choose to force table before import the column id is remove from the CSV file.
unset($res['id']);
@@ -899,7 +904,7 @@ class AdminImportControllerCore extends AdminController
$category_to_create->name[$default_language_id],
(isset($category_to_create->id) ? $category_to_create->id : 'null')
);
$this->errors[] = ($field_error !== true ? $field_error : '').($lang_field_error !== true ? $lang_field_error : '').
$this->errors[] = ($field_error !== true ? $field_error : '').(isset($lang_field_error) && $lang_field_error !== true ? $lang_field_error : '').
Db::getInstance()->getMsgError();
}
}
@@ -972,10 +977,10 @@ class AdminImportControllerCore extends AdminController
{
$this->errors[] = sprintf(
Tools::displayError('%1$s (ID: %2$s) cannot be saved'),
$info['name'],
(isset($info['id']) ? $info['id'] : 'null')
(isset($info['name']) ? Tools::safeOutput($info['name']) : 'No Name'),
(isset($info['id']) ? Tools::safeOutput($info['id']) : 'No ID')
);
$error_tmp = ($field_error !== true ? $field_error : '').($lang_field_error !== true ? $lang_field_error : '').Db::getInstance()->getMsgError();
$error_tmp = ($field_error !== true ? $field_error : '').(isset($lang_field_error) && $lang_field_error !== true ? $lang_field_error : '').Db::getInstance()->getMsgError();
if ($error_tmp != '')
$this->errors[] = $error_tmp;
}
@@ -1099,7 +1104,7 @@ class AdminImportControllerCore extends AdminController
$manufacturer->name,
(isset($manufacturer->id) ? $manufacturer->id : 'null')
);
$this->errors[] = ($field_error !== true ? $field_error : '').($lang_field_error !== true ? $lang_field_error : '').
$this->errors[] = ($field_error !== true ? $field_error : '').(isset($lang_field_error) && $lang_field_error !== true ? $lang_field_error : '').
Db::getInstance()->getMsgError();
}
}
@@ -1130,7 +1135,7 @@ class AdminImportControllerCore extends AdminController
$supplier->name,
(isset($supplier->id) ? $supplier->id : 'null')
);
$this->errors[] = ($field_error !== true ? $field_error : '').($lang_field_error !== true ? $lang_field_error : '').
$this->errors[] = ($field_error !== true ? $field_error : '').(isset($lang_field_error) && $lang_field_error !== true ? $lang_field_error : '').
Db::getInstance()->getMsgError();
}
}
@@ -1176,7 +1181,7 @@ class AdminImportControllerCore extends AdminController
$category_to_create->name[$default_language_id],
(isset($category_to_create->id) ? $category_to_create->id : 'null')
);
$this->errors[] = ($field_error !== true ? $field_error : '').($lang_field_error !== true ? $lang_field_error : '').
$this->errors[] = ($field_error !== true ? $field_error : '').(isset($lang_field_error) && $lang_field_error !== true ? $lang_field_error : '').
Db::getInstance()->getMsgError();
}
}
@@ -1208,7 +1213,7 @@ class AdminImportControllerCore extends AdminController
$category_to_create->name[$default_language_id],
(isset($category_to_create->id) ? $category_to_create->id : 'null')
);
$this->errors[] = ($field_error !== true ? $field_error : '').($lang_field_error !== true ? $lang_field_error : '').
$this->errors[] = ($field_error !== true ? $field_error : '').(isset($lang_field_error) && $lang_field_error !== true ? $lang_field_error : '').
Db::getInstance()->getMsgError();
}
}
@@ -1303,10 +1308,10 @@ class AdminImportControllerCore extends AdminController
{
$this->errors[] = sprintf(
Tools::displayError('%1$s (ID: %2$s) cannot be saved'),
$info['name'],
(isset($info['id']) ? $info['id'] : 'null')
(isset($info['name']) ? Tools::safeOutput($info['name']) : 'No Name'),
(isset($info['id']) ? Tools::safeOutput($info['id']) : 'No ID')
);
$this->errors[] = ($field_error !== true ? $field_error : '').($lang_field_error !== true ? $lang_field_error : '').
$this->errors[] = ($field_error !== true ? $field_error : '').(isset($lang_field_error) && $lang_field_error !== true ? $lang_field_error : '').
Db::getInstance()->getMsgError();
}
@@ -1347,7 +1352,7 @@ class AdminImportControllerCore extends AdminController
$specific_price->from = (isset($info['reduction_from']) && Validate::isDate($info['reduction_from'])) ? $info['reduction_from'] : '0000-00-00 00:00:00';
$specific_price->to = (isset($info['reduction_to']) && Validate::isDate($info['reduction_to'])) ? $info['reduction_to'] : '0000-00-00 00:00:00';
if (!$specific_price->add())
$this->addProductWarning($info['name'], $product->id, $this->l('Discount is invalid'));
$this->addProductWarning(Tools::safeOutput($info['name']), $product->id, $this->l('Discount is invalid'));
}
if (isset($product->tags) && !empty($product->tags))
@@ -1363,7 +1368,7 @@ class AdminImportControllerCore extends AdminController
$is_tag_added = Tag::addTags($key, $product->id, $tags, $this->multiple_value_separator);
if (!$is_tag_added)
{
$this->addProductWarning($info['name'], $product->id, $this->l('Tags list is invalid'));
$this->addProductWarning(Tools::safeOutput($info['name']), $product->id, $this->l('Tags list is invalid'));
break;
}
}
@@ -1380,7 +1385,7 @@ class AdminImportControllerCore extends AdminController
$is_tag_added = Tag::addTags($key, $product->id, $str, $this->multiple_value_separator);
if (!$is_tag_added)
{
$this->addProductWarning($info['name'], $product->id, 'Invalid tag(s) ('.$str.')');
$this->addProductWarning(Tools::safeOutput($info['name']), (int)$product->id, 'Invalid tag(s) ('.$str.')');
break;
}
}
@@ -1445,9 +1450,12 @@ class AdminImportControllerCore extends AdminController
$feature_name = trim($tab_feature[0]);
$feature_value = trim($tab_feature[1]);
$position = isset($tab_feature[2]) ? $tab_feature[2]: false;
$id_feature = Feature::addFeatureImport($feature_name, $position);
$id_feature_value = FeatureValue::addFeatureValueImport($id_feature, $feature_value);
Product::addFeatureProductImport($product->id, $id_feature, $id_feature_value);
if(!empty($feature_name) && !empty($feature_value))
{
$id_feature = Feature::addFeatureImport($feature_name, $position);
$id_feature_value = FeatureValue::addFeatureValueImport($id_feature, $feature_value);
Product::addFeatureProductImport($product->id, $id_feature, $id_feature_value);
}
}
// clean feature positions to avoid conflict
Feature::cleanPositions();
@@ -1464,9 +1472,6 @@ class AdminImportControllerCore extends AdminController
}
if (Configuration::get('PS_SEARCH_INDEXATION'))
Search::indexation(true);
$this->closeCsvFile($handle);
}
@@ -1511,8 +1516,12 @@ class AdminImportControllerCore extends AdminController
$id_shop_list[] = Shop::getIdByName($shop);
else
$id_shop_list[] = $shop;
$product = new Product((int)$info['id_product'], false, $default_language);
if(isset($info['id_product']))
$product = new Product((int)$info['id_product'], false, $default_language);
else
continue;
$id_image = null;
//delete existing images if "delete_existing_images" is set to 1
@@ -1552,7 +1561,7 @@ class AdminImportControllerCore extends AdminController
Tools::displayError('%s cannot be saved'),
(isset($image->id_product) ? ' ('.$image->id_product.')' : '')
);
$this->errors[] = ($field_error !== true ? $field_error : '').($lang_field_error !== true ? $lang_field_error : '').mysql_error();
$this->errors[] = ($field_error !== true ? $field_error : '').(isset($lang_field_error) && $lang_field_error !== true ? $lang_field_error : '').mysql_error();
}
}
elseif (isset($info['image_position']) && $info['image_position'])
@@ -1577,53 +1586,54 @@ class AdminImportControllerCore extends AdminController
$id_attribute_group = 0;
// groups
$groups_attributes = array();
foreach (explode($this->multiple_value_separator, $info['group']) as $key => $group)
{
$tab_group = explode(':', $group);
$group = trim($tab_group[0]);
if (!isset($tab_group[1]))
$type = 'select';
else
$type = trim($tab_group[1]);
// sets group
$groups_attributes[$key]['group'] = $group;
// if position is filled
if (isset($tab_group[2]))
$position = trim($tab_group[2]);
else
$position = false;
if (!isset($groups[$group]))
if(isset($info['group']))
foreach (explode($this->multiple_value_separator, $info['group']) as $key => $group)
{
$obj = new AttributeGroup();
$obj->is_color_group = false;
$obj->group_type = pSQL($type);
$obj->name[$default_language] = $group;
$obj->public_name[$default_language] = $group;
$obj->position = (!$position) ? AttributeGroup::getHigherPosition() + 1 : $position;
if (($field_error = $obj->validateFields(UNFRIENDLY_ERROR, true)) === true &&
($lang_field_error = $obj->validateFieldsLang(UNFRIENDLY_ERROR, true)) === true)
{
$obj->add();
$obj->associateTo($id_shop_list);
$groups[$group] = $obj->id;
}
$tab_group = explode(':', $group);
$group = trim($tab_group[0]);
if (!isset($tab_group[1]))
$type = 'select';
else
$this->errors[] = ($field_error !== true ? $field_error : '').($lang_field_error !== true ? $lang_field_error : '');
// fils groups attributes
$id_attribute_group = $obj->id;
$groups_attributes[$key]['id'] = $id_attribute_group;
$type = trim($tab_group[1]);
// sets group
$groups_attributes[$key]['group'] = $group;
// if position is filled
if (isset($tab_group[2]))
$position = trim($tab_group[2]);
else
$position = false;
if (!isset($groups[$group]))
{
$obj = new AttributeGroup();
$obj->is_color_group = false;
$obj->group_type = pSQL($type);
$obj->name[$default_language] = $group;
$obj->public_name[$default_language] = $group;
$obj->position = (!$position) ? AttributeGroup::getHigherPosition() + 1 : $position;
if (($field_error = $obj->validateFields(UNFRIENDLY_ERROR, true)) === true &&
($lang_field_error = $obj->validateFieldsLang(UNFRIENDLY_ERROR, true)) === true)
{
$obj->add();
$obj->associateTo($id_shop_list);
$groups[$group] = $obj->id;
}
else
$this->errors[] = ($field_error !== true ? $field_error : '').(isset($lang_field_error) && $lang_field_error !== true ? $lang_field_error : '');
// fils groups attributes
$id_attribute_group = $obj->id;
$groups_attributes[$key]['id'] = $id_attribute_group;
}
else // alreay exists
{
$id_attribute_group = $groups[$group];
$groups_attributes[$key]['id'] = $id_attribute_group;
}
}
else // alreay exists
{
$id_attribute_group = $groups[$group];
$groups_attributes[$key]['id'] = $id_attribute_group;
}
}
// inits attribute
$id_product_attribute = 0;
@@ -1631,116 +1641,118 @@ class AdminImportControllerCore extends AdminController
$attributes_to_add = array();
// for each attribute
foreach (explode($this->multiple_value_separator, $info['attribute']) as $key => $attribute)
{
$tab_attribute = explode(':', $attribute);
$attribute = trim($tab_attribute[0]);
// if position is filled
if (isset($tab_attribute[1]))
$position = trim($tab_attribute[1]);
else
$position = false;
if (isset($groups_attributes[$key]))
if(isset($info['attribute']))
foreach (explode($this->multiple_value_separator, $info['attribute']) as $key => $attribute)
{
$group = $groups_attributes[$key]['group'];
if (!isset($attributes[$group.'_'.$attribute]) && count($groups_attributes[$key]) == 2)
$tab_attribute = explode(':', $attribute);
$attribute = trim($tab_attribute[0]);
// if position is filled
if (isset($tab_attribute[1]))
$position = trim($tab_attribute[1]);
else
$position = false;
if (isset($groups_attributes[$key]))
{
$id_attribute_group = $groups_attributes[$key]['id'];
$obj = new Attribute();
// sets the proper id (corresponding to the right key)
$obj->id_attribute_group = $groups_attributes[$key]['id'];
$obj->name[$default_language] = str_replace('\n', '', str_replace('\r', '', $attribute));
$obj->position = (!$position) ? Attribute::getHigherPosition($groups[$group]) + 1 : $position;
if (($field_error = $obj->validateFields(UNFRIENDLY_ERROR, true)) === true &&
($lang_field_error = $obj->validateFieldsLang(UNFRIENDLY_ERROR, true)) === true)
$group = $groups_attributes[$key]['group'];
if (!isset($attributes[$group.'_'.$attribute]) && count($groups_attributes[$key]) == 2)
{
$obj->add();
$obj->associateTo($id_shop_list);
$attributes[$group.'_'.$attribute] = $obj->id;
}
else
$this->errors[] = ($field_error !== true ? $field_error : '').($lang_field_error !== true ? $lang_field_error : '');
}
$info['minimal_quantity'] = isset($info['minimal_quantity']) && $info['minimal_quantity'] ? (int)$info['minimal_quantity'] : 1;
$info['wholesale_price'] = str_replace(',', '.', $info['wholesale_price']);
$info['price'] = str_replace(',', '.', $info['price']);
$info['ecotax'] = str_replace(',', '.', $info['ecotax']);
$info['weight'] = str_replace(',', '.', $info['weight']);
// if a reference is specified for this product, get the associate id_product_attribute to UPDATE
if (isset($info['reference']) && !empty($info['reference']))
{
$id_product_attribute = Combination::getIdByReference($product->id, strval($info['reference']));
// updates the attribute
if ($id_product_attribute)
{
// gets all the combinations of this product
$attribute_combinations = $product->getAttributeCombinations($default_language);
foreach ($attribute_combinations as $attribute_combination)
$id_attribute_group = $groups_attributes[$key]['id'];
$obj = new Attribute();
// sets the proper id (corresponding to the right key)
$obj->id_attribute_group = $groups_attributes[$key]['id'];
$obj->name[$default_language] = str_replace('\n', '', str_replace('\r', '', $attribute));
$obj->position = (!$position && isset($groups[$group])) ? Attribute::getHigherPosition($groups[$group]) + 1 : $position;
if (($field_error = $obj->validateFields(UNFRIENDLY_ERROR, true)) === true &&
($lang_field_error = $obj->validateFieldsLang(UNFRIENDLY_ERROR, true)) === true)
{
if ($id_product_attribute && in_array($id_product_attribute, $attribute_combination))
$obj->add();
$obj->associateTo($id_shop_list);
$attributes[$group.'_'.$attribute] = $obj->id;
}
else
$this->errors[] = ($field_error !== true ? $field_error : '').(isset($lang_field_error) && $lang_field_error !== true ? $lang_field_error : '');
}
$info['minimal_quantity'] = isset($info['minimal_quantity']) && $info['minimal_quantity'] ? (int)$info['minimal_quantity'] : 1;
$info['wholesale_price'] = str_replace(',', '.', $info['wholesale_price']);
$info['price'] = str_replace(',', '.', $info['price']);
$info['ecotax'] = str_replace(',', '.', $info['ecotax']);
$info['weight'] = str_replace(',', '.', $info['weight']);
// if a reference is specified for this product, get the associate id_product_attribute to UPDATE
if (isset($info['reference']) && !empty($info['reference']))
{
$id_product_attribute = Combination::getIdByReference($product->id, strval($info['reference']));
// updates the attribute
if ($id_product_attribute)
{
// gets all the combinations of this product
$attribute_combinations = $product->getAttributeCombinations($default_language);
foreach ($attribute_combinations as $attribute_combination)
{
$product->updateAttribute(
$id_product_attribute,
(float)$info['wholesale_price'],
(float)$info['price'],
(float)$info['weight'],
0,
(float)$info['ecotax'],
$id_image,
strval($info['reference']),
strval($info['ean13']),
(int)$info['default_on'],
0,
strval($info['upc']),
(int)$info['minimal_quantity'],
0,
null,
$id_shop_list
);
$id_product_attribute_update = true;
if ($id_product_attribute && in_array($id_product_attribute, $attribute_combination))
{
$product->updateAttribute(
$id_product_attribute,
(float)$info['wholesale_price'],
(float)$info['price'],
(float)$info['weight'],
0,
(float)$info['ecotax'],
$id_image,
strval($info['reference']),
strval($info['ean13']),
(int)$info['default_on'],
0,
strval($info['upc']),
(int)$info['minimal_quantity'],
0,
null,
$id_shop_list
);
$id_product_attribute_update = true;
}
}
}
}
// if no attribute reference is specified, creates a new one
if (!$id_product_attribute)
{
$id_product_attribute = $product->addCombinationEntity(
(float)$info['wholesale_price'],
(float)$info['price'],
(float)$info['weight'],
0,
(float)$info['ecotax'],
(int)$info['quantity'],
$id_image,
strval($info['reference']),
0,
strval($info['ean13']),
(int)$info['default_on'],
0,
strval($info['upc']),
(int)$info['minimal_quantity'],
$id_shop_list
);
}
// fills our attributes array, in order to add the attributes to the product_attribute afterwards
if(isset($attributes[$group.'_'.$attribute]))
$attributes_to_add[] = (int)$attributes[$group.'_'.$attribute];
// after insertion, we clean attribute position and group attribute position
$obj = new Attribute();
$obj->cleanPositions((int)$id_attribute_group, false);
AttributeGroup::cleanPositions();
}
// if no attribute reference is specified, creates a new one
if (!$id_product_attribute)
{
$id_product_attribute = $product->addCombinationEntity(
(float)$info['wholesale_price'],
(float)$info['price'],
(float)$info['weight'],
0,
(float)$info['ecotax'],
(int)$info['quantity'],
$id_image,
strval($info['reference']),
0,
strval($info['ean13']),
(int)$info['default_on'],
0,
strval($info['upc']),
(int)$info['minimal_quantity'],
$id_shop_list
);
}
// fills our attributes array, in order to add the attributes to the product_attribute afterwards
$attributes_to_add[] = (int)$attributes[$group.'_'.$attribute];
// after insertion, we clean attribute position and group attribute position
$obj = new Attribute();
$obj->cleanPositions((int)$id_attribute_group, false);
AttributeGroup::cleanPositions();
}
}
$product->checkDefaultAttributes();
if (!$product->cache_default_attribute)
@@ -1907,7 +1919,7 @@ class AdminImportControllerCore extends AdminController
$info['email'],
(isset($info['id']) ? $info['id'] : 'null')
);
$this->errors[] = ($field_error !== true ? $field_error : '').($lang_field_error !== true ? $lang_field_error : '').
$this->errors[] = ($field_error !== true ? $field_error : '').(isset($lang_field_error) && $lang_field_error !== true ? $lang_field_error : '').
Db::getInstance()->getMsgError();
}
}
@@ -1954,7 +1966,7 @@ class AdminImportControllerCore extends AdminController
else
{
$this->errors[] = sprintf(Tools::displayError('%s cannot be saved'), $country->name[$default_language_id]);
$this->errors[] = ($field_error !== true ? $field_error : '').($lang_field_error !== true ? $lang_field_error : '').
$this->errors[] = ($field_error !== true ? $field_error : '').(isset($lang_field_error) && $lang_field_error !== true ? $lang_field_error : '').
Db::getInstance()->getMsgError();
}
}
@@ -1984,7 +1996,7 @@ class AdminImportControllerCore extends AdminController
else
{
$this->errors[] = sprintf(Tools::displayError('%s cannot be saved'), $state->name);
$this->errors[] = ($field_error !== true ? $field_error : '').($lang_field_error !== true ? $lang_field_error : '').
$this->errors[] = ($field_error !== true ? $field_error : '').(isset($lang_field_error) && $lang_field_error !== true ? $lang_field_error : '').
Db::getInstance()->getMsgError();
}
}
@@ -2053,7 +2065,7 @@ class AdminImportControllerCore extends AdminController
$manufacturer->name,
(isset($manufacturer->id) ? $manufacturer->id : 'null')
);
$this->errors[] = ($field_error !== true ? $field_error : '').($lang_field_error !== true ? $lang_field_error : '').
$this->errors[] = ($field_error !== true ? $field_error : '').(isset($lang_field_error) && $lang_field_error !== true ? $lang_field_error : '').
Db::getInstance()->getMsgError();
}
}
@@ -2074,7 +2086,7 @@ class AdminImportControllerCore extends AdminController
$supplier->name,
(isset($supplier->id) ? $supplier->id : 'null')
);
$this->errors[] = ($field_error !== true ? $field_error : '').($lang_field_error !== true ? $lang_field_error : '').
$this->errors[] = ($field_error !== true ? $field_error : '').(isset($lang_field_error) && $lang_field_error !== true ? $lang_field_error : '').
Db::getInstance()->getMsgError();
}
}
@@ -2188,10 +2200,10 @@ class AdminImportControllerCore extends AdminController
{
$this->errors[] = Db::getInstance()->getMsgError().' '.sprintf(
Tools::displayError('%1$s (ID: %2$s) cannot be saved'),
$info['name'],
(isset($info['id']) ? $info['id'] : 'null')
(isset($info['name']) ? Tools::safeOutput($info['name']) : 'No Name'),
(isset($info['id']) ? Tools::safeOutput($info['id']) : 'No ID')
);
$this->errors[] = ($field_error !== true ? $field_error : '').($lang_field_error !== true ? $lang_field_error : '').
$this->errors[] = ($field_error !== true ? $field_error : '').(isset($lang_field_error) && $lang_field_error !== true ? $lang_field_error : '').
Db::getInstance()->getMsgError();
}
}
@@ -2235,8 +2247,8 @@ class AdminImportControllerCore extends AdminController
if (!$res)
$this->errors[] = Db::getInstance()->getMsgError().' '.sprintf(
Tools::displayError('%1$s (ID: %2$s) cannot be saved'),
$info['name'],
(isset($info['id']) ? $info['id'] : 'null')
(isset($info['name']) ? Tools::safeOutput($info['name']) : 'No Name'),
(isset($info['id']) ? Tools::safeOutput($info['id']) : 'No ID')
);
else
{
@@ -2263,7 +2275,7 @@ class AdminImportControllerCore extends AdminController
else
{
$this->errors[] = $this->l('Supplier is invalid').' ('.$supplier->name.')';
$this->errors[] = ($field_error !== true ? $field_error : '').($lang_field_error !== true ? $lang_field_error : '');
$this->errors[] = ($field_error !== true ? $field_error : '').(isset($lang_field_error) && $lang_field_error !== true ? $lang_field_error : '');
}
}
$this->closeCsvFile($handle);
+1 -1
View File
@@ -215,7 +215,7 @@ class AdminLoginControllerCore extends AdminController
'{passwd}' => $pwd
);
if (Mail::Send((int)Configuration::get('PS_LANG_DEFAULT'), 'password', Mail::l('Your new password', (int)Configuration::get('PS_LANG_DEFAULT')), $params, $employee->email, $employee->firstname.' '.$employee->lastname))
if (Mail::Send($employee->id_lang, 'password', Mail::l('Your new password', $employee->id_lang), $params, $employee->email, $employee->firstname.' '.$employee->lastname))
{
// Update employee only if the mail can be sent
$result = $employee->update();
+1 -1
View File
@@ -61,7 +61,7 @@ class AdminLogsControllerCore extends AdminController
'submit' => array()
)
);
$this->list_no_link = true;
parent::__construct();
}
@@ -208,6 +208,7 @@ class AdminModulesControllerCore extends AdminController
die ('KO');
if ($result == 'OK')
{
Configuration::updateValue('PS_LOGGED_ON_ADDONS', 1);
$this->context->cookie->username_addons = pSQL(trim(Tools::getValue('username_addons')));
$this->context->cookie->password_addons = pSQL(trim(Tools::getValue('password_addons')));
}
+12 -12
View File
@@ -434,7 +434,7 @@ class AdminOrdersControllerCore extends AdminController
else
{
$message = $customer_message->message;
if (Configuration::get('PS_MAIL_TYPE') != Mail::TYPE_TEXT)
if (Configuration::get('PS_MAIL_TYPE', null, null, $order->id_shop) != Mail::TYPE_TEXT)
$message = Tools::nl2br($customer_message->message);
$varsTpl = array(
@@ -972,7 +972,7 @@ class AdminOrdersControllerCore extends AdminController
}
elseif (Tools::isSubmit('submitGenerateInvoice') && isset($order))
{
if (!Configuration::get('PS_INVOICE'))
if (!Configuration::get('PS_INVOICE', null, null, $order->id_shop))
$this->errors[] = Tools::displayError('Invoice management has been disabled');
elseif ($order->hasInvoice())
$this->errors[] = Tools::displayError('This order already has an invoice');
@@ -1102,7 +1102,7 @@ class AdminOrdersControllerCore extends AdminController
foreach ($order_invoices_collection as $order_invoice)
{
if (Tools::getValue('discount_value') > $order_invoice->total_paid_tax_incl)
$this->errors[] = Tools::displayError('Discount value is greater than the order invoice total (Invoice:').$order_invoice->getInvoiceNumberFormatted(Context::getContext()->language->id).')';
$this->errors[] = Tools::displayError('Discount value is greater than the order invoice total (Invoice:').$order_invoice->getInvoiceNumberFormatted(Context::getContext()->language->id, (int)$order->id_shop).')';
else
{
$cart_rules[$order_invoice->id]['value_tax_incl'] = Tools::ps_round(Tools::getValue('discount_value'), 2);
@@ -1292,7 +1292,7 @@ class AdminOrdersControllerCore extends AdminController
// display warning if there are products out of stock
$display_out_of_stock_warning = false;
$current_order_state = $order->getCurrentOrderState();
if ($current_order_state->delivery != 1 && $current_order_state->shipped != 1)
if (!Validate::isLoadedObject($current_order_state) || ($current_order_state->delivery != 1 && $current_order_state->shipped != 1))
$display_out_of_stock_warning = true;
// products current stock (from stock_available)
@@ -1352,7 +1352,7 @@ class AdminOrdersControllerCore extends AdminController
'invoices_collection' => $order->getInvoicesCollection(),
'not_paid_invoices_collection' => $order->getNotPaidInvoicesCollection(),
'payment_methods' => $payment_methods,
'invoice_management_active' => Configuration::get('PS_INVOICE')
'invoice_management_active' => Configuration::get('PS_INVOICE', null, null, $order->id_shop)
);
return parent::renderView();
@@ -1535,7 +1535,7 @@ class AdminOrdersControllerCore extends AdminController
$use_taxes = true;
$initial_product_price_tax_incl = Product::getPriceStatic($product->id, $use_taxes, isset($combination) ? $combination->id : null, 2, null, false, true, 1,
false, $order->id_customer, $cart->id, $order->{Configuration::get('PS_TAX_ADDRESS_TYPE')});
false, $order->id_customer, $cart->id, $order->{Configuration::get('PS_TAX_ADDRESS_TYPE', null, null, $order->id_shop)});
// Creating specific price if needed
if ($product_informations['product_price_tax_incl'] != $initial_product_price_tax_incl)
@@ -1612,11 +1612,11 @@ class AdminOrdersControllerCore extends AdminController
$order_invoice->id_order = $order->id;
if ($order_invoice->number)
Configuration::updateValue('PS_INVOICE_START_NUMBER', false);
Configuration::updateValue('PS_INVOICE_START_NUMBER', false, false, null, $order->id_shop);
else
$order_invoice->number = Order::getLastInvoiceNumber() + 1;
$invoice_address = new Address((int)$order->{Configuration::get('PS_TAX_ADDRESS_TYPE')});
$invoice_address = new Address((int)$order->{Configuration::get('PS_TAX_ADDRESS_TYPE', null, null, $order->id_shop)});
$carrier = new Carrier((int)$order->id_carrier);
$tax_calculator = $carrier->getTaxCalculator($invoice_address);
@@ -1713,7 +1713,7 @@ class AdminOrdersControllerCore extends AdminController
$invoice_array = array();
foreach ($invoice_collection as $invoice)
{
$invoice->name = $invoice->getInvoiceNumberFormatted(Context::getContext()->language->id);
$invoice->name = $invoice->getInvoiceNumberFormatted(Context::getContext()->language->id, (int)$order->id_shop);
$invoice_array[] = $invoice;
}
@@ -1909,14 +1909,14 @@ class AdminOrdersControllerCore extends AdminController
$product['quantity_refundable'] = $product['product_quantity'] - $resume['product_quantity'];
$product['amount_refundable'] = $product['total_price_tax_incl'] - $resume['amount_tax_incl'];
$product['amount_refund'] = Tools::displayPrice($resume['amount_tax_incl']);
$product['refund_history'] = OrderSlip::getProductSlipDetail($order_detail->id);
// Get invoices collection
$invoice_collection = $order->getInvoicesCollection();
$invoice_array = array();
foreach ($invoice_collection as $invoice)
{
$invoice->name = $invoice->getInvoiceNumberFormatted(Context::getContext()->language->id);
$invoice->name = $invoice->getInvoiceNumberFormatted(Context::getContext()->language->id, (int)$order->id_shop);
$invoice_array[] = $invoice;
}
@@ -2003,7 +2003,7 @@ class AdminOrdersControllerCore extends AdminController
$invoice_array = array();
foreach ($invoice_collection as $invoice)
{
$invoice->name = $invoice->getInvoiceNumberFormatted(Context::getContext()->language->id);
$invoice->name = $invoice->getInvoiceNumberFormatted(Context::getContext()->language->id, (int)$order->id_shop);
$invoice_array[] = $invoice;
}
@@ -725,6 +725,7 @@ class AdminPerformanceControllerCore extends AdminController
$cache_active = 0;
else
$cache_active = 1;
if (!$caching_system = Tools::getValue('caching_system'))
$this->errors[] = Tools::displayError('Caching system is missing');
else
@@ -733,6 +734,7 @@ class AdminPerformanceControllerCore extends AdminController
'define(\'_PS_CACHING_SYSTEM_\', \''.$caching_system.'\');',
$new_settings
);
if ($cache_active && $caching_system == 'CacheMemcache' && !extension_loaded('memcache'))
$this->errors[] = Tools::displayError('To use Memcached, you must install the Memcache PECL extension on your server.').'
<a href="http://www.php.net/manual/en/memcache.installation.php">http://www.php.net/manual/en/memcache.installation.php</a>';
@@ -759,7 +761,7 @@ class AdminPerformanceControllerCore extends AdminController
Configuration::updateValue('PS_CACHEFS_DIRECTORY_DEPTH', (int)$depth);
}
}
else if ($caching_system == 'MCached' && $cache_active && !_PS_CACHE_ENABLED_ && _PS_CACHING_SYSTEM_ == 'MCached')
else if ($caching_system == 'CacheMemcache' && $cache_active && !_PS_CACHE_ENABLED_ && _PS_CACHING_SYSTEM_ == 'CacheMemcache')
Cache::getInstance()->flush();
if (!count($this->errors))
@@ -778,8 +780,7 @@ class AdminPerformanceControllerCore extends AdminController
else
$this->errors[] = Tools::displayError('You do not have permission to edit here.');
}
if ($redirecAdmin)
if ($redirecAdmin && (!isset($this->errors) || !count($this->errors)))
Tools::redirectAdmin(self::$currentIndex.'&token='.Tools::getValue('token').'&conf=4');
else
return parent::postProcess();
@@ -1422,8 +1422,9 @@ class AdminProductsControllerCore extends AdminController
if (!Image::getCover($image->id_product))
{
$res &= Db::getInstance()->execute('
UPDATE `'._DB_PREFIX_.'image_shop` image_shop
SET image_shop.`cover` = 1
UPDATE `'._DB_PREFIX_.'image_shop` image_shop, '._DB_PREFIX_.'image i
SET image_shop.`cover` = 1,
i.cover = 1
WHERE image_shop.`id_image` = (SELECT id_image FROM
(SELECT image_shop.id_image
FROM '._DB_PREFIX_.'image i'.
@@ -1431,7 +1432,8 @@ class AdminProductsControllerCore extends AdminController
WHERE i.id_product ='.(int)$image->id_product.' LIMIT 1
) tmpImage)
AND id_shop='.(int)$this->context->shop->id.'
LIMIT 1');
AND i.id_image = image_shop.id_image
');
}
if (file_exists(_PS_TMP_IMG_DIR_.'product_'.$image->id_product.'.jpg'))
@@ -113,7 +113,7 @@ class AdminSearchConfControllerCore extends AdminController
'title' => $this->l('Blacklisted words'),
'size' => 35,
'validation' => 'isGenericName',
'desc' => $this->l('Please enter the index words separated by a "|".'|".'),
'desc' => $this->l('Please enter the index words separated by a "|".'),
'type' => 'textLang'
)
),
+5 -1
View File
@@ -202,7 +202,11 @@ class AdminSearchControllerCore extends AdminController
global $_LANGADM;
$tabs = array();
$key_match = array();
$result = Db::getInstance()->executeS('SELECT class_name, name FROM '._DB_PREFIX_.'tab t INNER JOIN '._DB_PREFIX_.'tab_lang tl ON t.id_tab = tl.id_tab AND tl.id_lang = '.(int)$this->context->language->id);
$result = Db::getInstance()->executeS('
SELECT class_name, name
FROM '._DB_PREFIX_.'tab t
INNER JOIN '._DB_PREFIX_.'tab_lang tl ON (t.id_tab = tl.id_tab AND tl.id_lang = '.(int)$this->context->language->id.')
WHERE active = 1');
foreach ($result as $row)
{
$tabs[strtolower($row['class_name'])] = $row['name'];
@@ -604,22 +604,32 @@ class AdminTranslationsControllerCore extends AdminController
$global = false;
foreach ($lines as $line)
{
// PHP tags
if (in_array($line, array('<?php', '?>', '')))
continue;
// Global variable declaration
if (!$global && preg_match('/^global\s+\$([a-z0-9-_]+)\s*;$/i', $line, $matches))
{
$global = $matches[1];
continue;
}
// Global variable initialization
if ($global != false && preg_match('/^\$'.preg_quote($global, '/').'\s*=\s*array\(\s*\)\s*;$/i', $line))
continue;
// Global variable initialization without declaration
if (!$global && preg_match('/^\$([a-z0-9-_]+)\s*=\s*array\(\s*\)\s*;$/i', $line, $matches))
{
$global = $matches[1];
continue;
}
// Assignation
if (preg_match('/^\$'.preg_quote($global, '/').'\[\''._PS_TRANS_PATTERN_.'\'\]\s*=\s*\''._PS_TRANS_PATTERN_.'\'\s*;$/i', $line))
continue;
// Sometimes the global variable is returned...
if (preg_match('/^return\s+\$'.preg_quote($global, '/').'\s*;$/i', $line, $matches))
continue;
return false;