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

This commit is contained in:
gRoussac
2013-06-26 18:12:09 +02:00
27 changed files with 223 additions and 168 deletions
@@ -106,63 +106,61 @@
if ($(this).attr('name') == 'category_reduction['+$('[name="id_category"]:checked').val()+']') if ($(this).attr('name') == 'category_reduction['+$('[name="id_category"]:checked').val()+']')
{ {
exist = true; exist = true;
jAlert('{l s='This category already exists for this group.'}'); jAlert('{l s='This category already exists for this group.' js='1'}');
return false; return false;
} }
}); });
if (exist) if (exist)
return; return;
$.ajax({ $.ajax({
type:"POST", type:"POST",
url: "ajax-tab.php", url: "ajax-tab.php",
async: true, async: true,
dataType: "json", dataType: "json",
data : { data : {
ajax: "1", ajax: "1",
token: "{getAdminToken tab='AdminGroups'}", token: "{getAdminToken tab='AdminGroups'}",
controller: "AdminGroups", controller: "AdminGroups",
action: "addCategoryReduction", action: "addCategoryReduction",
category_reduction: $('#category_reduction_fancybox').val() , category_reduction: $('#category_reduction_fancybox').val() ,
id_category: $('[name="id_category"]:checked').val() id_category: $('[name="id_category"]:checked').val()
}, },
success : function(jsonData) success : function(jsonData) {
if (jsonData.hasError)
{ {
if (jsonData.hasError) var errors = '';
{ for (error in jsonData.errors)
var errors = ''; //IE6 bug fix
for(error in jsonData.errors) if (error != 'indexOf')
//IE6 bug fix errors += $('<div />').html(jsonData.errors[error]).text() + "\n";
if(error != 'indexOf') jAlert(errors);
errors += jsonData.errors[error] + "\n";
jAlert(errors);
}
else
{
$('#group_discount_category_table').append('<tr class="alt_row" id="'+jsonData.id_category+'"><td>'+jsonData.catPath+'</td><td>{l s='Discount:'}'+jsonData.discount+'{l s='%'}</td><td><a href="#" onclick="deleteCategoryReduction('+jsonData.id_category+');"><img src="../img/admin/delete.gif"></a></td></tr>');
var input_hidden = document.createElement("input");
input_hidden.setAttribute('type', 'hidden');
input_hidden.setAttribute('value', jsonData.discount);
input_hidden.setAttribute('name', 'category_reduction['+jsonData.id_category+']');
input_hidden.setAttribute('class', 'category_reduction');
$('#group_discount_category_table tr#'+jsonData.id_category+' > td:last').append(input_hidden);
$.fancybox.close();
}
} }
}); else
{
$('#group_discount_category_table').append('<tr class="alt_row" id="'+jsonData.id_category+'"><td>'+jsonData.catPath+'</td><td>{l s='Discount:'}'+jsonData.discount+'{l s='%'}</td><td><a href="#" onclick="deleteCategoryReduction('+jsonData.id_category+');"><img src="../img/admin/delete.gif"></a></td></tr>');
var input_hidden = document.createElement("input");
input_hidden.setAttribute('type', 'hidden');
input_hidden.setAttribute('value', jsonData.discount);
input_hidden.setAttribute('name', 'category_reduction['+jsonData.id_category+']');
input_hidden.setAttribute('class', 'category_reduction');
$('#group_discount_category_table tr#'+jsonData.id_category+' > td:last').append(input_hidden);
$.fancybox.close();
}
}
});
return false; return false;
} }
function initFancyBox() function initFancyBox()
{ {
$('[name="id_category"]:checked').removeAttr('checked'); $('[name="id_category"]:checked').removeAttr('checked');
collapseAllCategories(); collapseAllCategories();
$('#category_reduction_fancybox').val('0.00'); $('#category_reduction_fancybox').val('0.00');
} }
</script> </script>
<div class="margin-form"> <div class="margin-form">
<a class="button" href="#group_discount_category_fancybox" id="group_discount_category">{l s='Add a category discount'}</a> <a class="button" href="#group_discount_category_fancybox" id="group_discount_category">{l s='Add a category discount'}</a>
@@ -50,14 +50,14 @@
console.log(truncateAuthorized); console.log(truncateAuthorized);
if (truncateAuthorized) if (truncateAuthorized)
{ {
if (!confirm('{l s='Are you sure that you would like to delete this' js=1}' + ' ' + $.trim($('#entity > option:selected').text().toLowerCase()) + '{l s='?' js=1}')) if (!confirm('{l s='Are you sure that you would like to delete this' js=1}' + ' ' + $.trim($('#entity > option:selected').text().toLowerCase()) + '?'))
{ {
e.preventDefault(); e.preventDefault();
} }
} }
else else
{ {
jAlert('{l s='You do not have permission to delete here. When the multistore is enabled, only a SuperAdmin can delete all items before an import.'}'); jAlert('{l s='You do not have permission to delete here. When the multistore is enabled, only a SuperAdmin can delete all items before an import.' js='1'}');
return false; return false;
} }
} }
@@ -90,7 +90,7 @@
var table = $('#selectTables select').val(); var table = $('#selectTables select').val();
if (!table) if (!table)
jAlert("{l s='Please choose a table.'}"); jAlert("{l s='Please choose a table.' js='1'}");
else else
AddRequestSql(table); AddRequestSql(table);
}); });
@@ -24,9 +24,9 @@
*} *}
<a href="{$href}" class="delete" <a href="{$href}" class="delete"
{if in_array($id_shop, $shops_having_dependencies)} {if in_array($id_shop, $shops_having_dependencies)}
onclick="jAlert('{l s='You cannot delete this shop\'s (customer and/or order dependency)'}'); return false;" onclick="jAlert('{l s='You cannot delete this shop\'s (customer and/or order dependency)' js='1'}'); return false;"
{elseif isset($confirm)} {elseif isset($confirm)}
onclick="if (confirm('{$confirm}')){ return true; }else{ event.stopPropagation(); event.preventDefault();};" onclick="if (confirm('{$confirm}')){ return true; } else { event.stopPropagation(); event.preventDefault();};"
{/if} title="{$action}"> {/if} title="{$action}">
<img src="../img/admin/delete.gif" alt="{$action}" /> <img src="../img/admin/delete.gif" alt="{$action}" />
</a> </a>
@@ -138,7 +138,7 @@
// check if it's possible to add the product // check if it's possible to add the product
if (product_infos == null || $('#cur_product_name').val() == '') if (product_infos == null || $('#cur_product_name').val() == '')
{ {
jAlert('{l s='Please select at least one product.'}'); jAlert('{l s='Please select at least one product.' js='1'}');
return false; return false;
} }
+4 -4
View File
@@ -977,11 +977,11 @@ abstract class ObjectModelCore
// Checking for required fields // Checking for required fields
if (isset($data['required']) && $data['required'] && ($value = Tools::getValue($field, $this->{$field})) == false && (string)$value != '0') if (isset($data['required']) && $data['required'] && ($value = Tools::getValue($field, $this->{$field})) == false && (string)$value != '0')
if (!$this->id || $field != 'passwd') if (!$this->id || $field != 'passwd')
$errors[] = '<b>'.self::displayFieldName($field, get_class($this), $htmlentities).'</b> '.Tools::displayError('is required.'); $errors[$field] = '<b>'.self::displayFieldName($field, get_class($this), $htmlentities).'</b> '.Tools::displayError('is required.');
// Checking for maximum fields sizes // Checking for maximum fields sizes
if (isset($data['size']) && ($value = Tools::getValue($field, $this->{$field})) && Tools::strlen($value) > $data['size']) if (isset($data['size']) && ($value = Tools::getValue($field, $this->{$field})) && Tools::strlen($value) > $data['size'])
$errors[] = sprintf( $errors[$field] = sprintf(
Tools::displayError('%1$s is too long. Maximum length: %2$d'), Tools::displayError('%1$s is too long. Maximum length: %2$d'),
self::displayFieldName($field, get_class($this), $htmlentities), self::displayFieldName($field, get_class($this), $htmlentities),
$data['size'] $data['size']
@@ -992,7 +992,7 @@ abstract class ObjectModelCore
if (($value = Tools::getValue($field, $this->{$field})) || ($field == 'postcode' && $value == '0')) if (($value = Tools::getValue($field, $this->{$field})) || ($field == 'postcode' && $value == '0'))
{ {
if (isset($data['validate']) && !Validate::$data['validate']($value) && (!empty($value) || $data['required'])) if (isset($data['validate']) && !Validate::$data['validate']($value) && (!empty($value) || $data['required']))
$errors[] = '<b>'.self::displayFieldName($field, get_class($this), $htmlentities).'</b> '.Tools::displayError('is invalid.'); $errors[$field] = '<b>'.self::displayFieldName($field, get_class($this), $htmlentities).'</b> '.Tools::displayError('is invalid.');
else else
{ {
if (isset($data['copy_post']) && !$data['copy_post']) if (isset($data['copy_post']) && !$data['copy_post'])
@@ -1136,7 +1136,7 @@ abstract class ObjectModelCore
$value = Tools::getValue($field); $value = Tools::getValue($field);
if (empty($value)) if (empty($value))
$errors[] = sprintf(Tools::displayError('The field %s is required.'), self::displayFieldName($field, get_class($this), $htmlentities)); $errors[$field] = sprintf(Tools::displayError('The field %s is required.'), self::displayFieldName($field, get_class($this), $htmlentities));
} }
return $errors; return $errors;
+2 -1
View File
@@ -955,7 +955,8 @@ class AdminControllerCore extends Controller
continue; continue;
// Check if field is required // Check if field is required
if (isset($values['required']) && $values['required'] && !empty($_POST['multishopOverrideOption'][$field])) if ((!Shop::isFeatureActive() && isset($values['required']) && $values['required'])
|| (Shop::isFeatureActive() && isset($_POST['multishopOverrideOption'][$field]) && isset($values['required']) && $values['required']))
if (isset($values['type']) && $values['type'] == 'textLang') if (isset($values['type']) && $values['type'] == 'textLang')
{ {
foreach ($languages as $language) foreach ($languages as $language)
+3 -1
View File
@@ -169,6 +169,8 @@ abstract class DbCore
/* do not remove, useful for some modules */ /* do not remove, useful for some modules */
abstract public function set_db($db_name); abstract public function set_db($db_name);
abstract public function getBestEngine();
/** /**
* Get Db object instance * Get Db object instance
@@ -674,7 +676,7 @@ abstract class DbCore
return call_user_func_array(array(Db::getClass(), 'hasTableWithSamePrefix'), array($server, $user, $pwd, $db, $prefix)); return call_user_func_array(array(Db::getClass(), 'hasTableWithSamePrefix'), array($server, $user, $pwd, $db, $prefix));
} }
public static function checkCreatePrivilege($server, $user, $pwd, $db, $prefix, $engine) public static function checkCreatePrivilege($server, $user, $pwd, $db, $prefix, $engine = null)
{ {
return call_user_func_array(array(Db::getClass(), 'checkCreatePrivilege'), array($server, $user, $pwd, $db, $prefix, $engine)); return call_user_func_array(array(Db::getClass(), 'checkCreatePrivilege'), array($server, $user, $pwd, $db, $prefix, $engine));
} }
+26 -11
View File
@@ -172,21 +172,36 @@ class DbMySQLiCore extends Db
if (!$link->real_connect($server, $user, $pwd, $db)) if (!$link->real_connect($server, $user, $pwd, $db))
return (mysqli_connect_errno() == 1049) ? 2 : 1; return (mysqli_connect_errno() == 1049) ? 2 : 1;
if (strtolower($engine) == 'innodb')
{
$sql = 'SHOW VARIABLES WHERE Variable_name = \'have_innodb\'';
$result = $link->query($sql);
if (!$result)
return 4;
$row = $result->fetch_assoc();
if (!$row || strtolower($row['Value']) != 'yes')
return 4;
}
$link->close(); $link->close();
return 0; return 0;
} }
public static function checkCreatePrivilege($server, $user, $pwd, $db, $prefix, $engine) public function getBestEngine()
{
$value = 'InnoDB';
$sql = 'SHOW VARIABLES WHERE Variable_name = \'have_innodb\'';
$result = $this->link->query($sql);
if (!$result)
$value = 'MyISAM';
$row = $result->fetch_assoc();
if (!$row || strtolower($row['Value']) != 'yes')
$value = 'MyISAM';
/* MySQL >= 5.6 */
$sql = 'SHOW ENGINES';
$result = $this->link->query($sql);
while ($row = $result->fetch_assoc())
if ($row['Engine'] == 'InnoDB')
{
if (in_array($row['Support'], array('DEFAULT', 'YES')))
$value = 'InnoDB';
break;
}
return $value;
}
public static function checkCreatePrivilege($server, $user, $pwd, $db, $prefix, $engine = null)
{ {
$link = @new mysqli($server, $user, $pwd, $db); $link = @new mysqli($server, $user, $pwd, $db);
if (mysqli_connect_error()) if (mysqli_connect_error())
+26 -26
View File
@@ -174,7 +174,7 @@ class DbPDOCore extends Db
return (bool)$result->fetch(); return (bool)$result->fetch();
} }
public static function checkCreatePrivilege($server, $user, $pwd, $db, $prefix, $engine) public static function checkCreatePrivilege($server, $user, $pwd, $db, $prefix, $engine = null)
{ {
try { try {
$link = DbPDO::_getPDO($server, $user, $pwd, $db, 5); $link = DbPDO::_getPDO($server, $user, $pwd, $db, 5);
@@ -206,34 +206,34 @@ class DbPDOCore extends Db
} catch (PDOException $e) { } catch (PDOException $e) {
return ($e->getCode() == 1049) ? 2 : 1; return ($e->getCode() == 1049) ? 2 : 1;
} }
if (strtolower($engine) == 'innodb')
{
$value = 0;
$sql = 'SHOW VARIABLES WHERE Variable_name = \'have_innodb\'';
$result = $link->query($sql);
if (!$result)
$value = 4;
$row = $result->fetch();
if (!$row || strtolower($row['Value']) != 'yes')
$value = 4;
/* MySQL >= 5.6 */
$sql = 'SHOW ENGINES';
$result = $link->query($sql);
while ($row = $result->fetch())
if ($row['Engine'] == 'InnoDB')
{
if (in_array($row['Support'], array('DEFAULT', 'YES')))
$value = 0;
break;
}
return $value;
}
unset($link); unset($link);
return 0; return 0;
} }
public function getBestEngine()
{
$value = 'InnoDB';
$sql = 'SHOW VARIABLES WHERE Variable_name = \'have_innodb\'';
$result = $this->link->query($sql);
if (!$result)
$value = 'MyISAM';
$row = $result->fetch();
if (!$row || strtolower($row['Value']) != 'yes')
$value = 'MyISAM';
/* MySQL >= 5.6 */
$sql = 'SHOW ENGINES';
$result = $this->link->query($sql);
while ($row = $result->fetch())
if ($row['Engine'] == 'InnoDB')
{
if (in_array($row['Support'], array('DEFAULT', 'YES')))
$value = 'InnoDB';
break;
}
return $value;
}
/** /**
* @see Db::checkEncoding() * @see Db::checkEncoding()
+26 -26
View File
@@ -165,36 +165,36 @@ class MySQLCore extends Db
return 1; return 1;
if (!@mysql_select_db($db, $link)) if (!@mysql_select_db($db, $link))
return 2; return 2;
if (strtolower($engine) == 'innodb')
{
$value = 0;
$sql = 'SHOW VARIABLES WHERE Variable_name = \'have_innodb\'';
$result = mysql_query($sql);
if (!$result)
$value = 4;
$row = mysql_fetch_assoc($result);
if (!$row || strtolower($row['Value']) != 'yes')
$value = 4;
/* MySQL >= 5.6 */
$sql = 'SHOW ENGINES';
$result = mysql_query($sql);
while ($row = mysql_fetch_assoc($result))
if ($row['Engine'] == 'InnoDB')
{
if (in_array($row['Support'], array('DEFAULT', 'YES')))
$value = 0;
break;
}
return $value;
}
@mysql_close($link); @mysql_close($link);
return 0; return 0;
} }
public function getBestEngine()
{
$value = 'InnoDB';
$sql = 'SHOW VARIABLES WHERE Variable_name = \'have_innodb\'';
$result = mysql_query($sql);
if (!$result)
$value = 'MyISAM';
$row = mysql_fetch_assoc($result);
if (!$row || strtolower($row['Value']) != 'yes')
$value = 'MyISAM';
/* MySQL >= 5.6 */
$sql = 'SHOW ENGINES';
$result = mysql_query($sql);
while ($row = mysql_fetch_assoc($result))
if ($row['Engine'] == 'InnoDB')
{
if (in_array($row['Support'], array('DEFAULT', 'YES')))
$value = 'InnoDB';
break;
}
return $value;
}
public static function checkCreatePrivilege($server, $user, $pwd, $db, $prefix, $engine) public static function checkCreatePrivilege($server, $user, $pwd, $db, $prefix, $engine = null)
{ {
ini_set('mysql.connect_timeout', 5); ini_set('mysql.connect_timeout', 5);
if (!$link = @mysql_connect($server, $user, $pwd, true)) if (!$link = @mysql_connect($server, $user, $pwd, true))
@@ -231,7 +231,7 @@ class AdminPPreferencesControllerCore extends AdminController
// if advanced stock management is disabled, updates concerned tables // if advanced stock management is disabled, updates concerned tables
if (Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT') == 1 && if (Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT') == 1 &&
(int)Tools::getValue('PS_ADVANCED_STOCK_MANAGEMENT') == 0) (int)Tools::getValue('PS_ADVANCED_STOCK_MANAGEMENT') == 0 && Context::getContext()->shop->getContext() == Shop::CONTEXT_ALL)
{ {
ObjectModel::updateMultishopTable('Product', array('advanced_stock_management' => 0), 'product_shop.`advanced_stock_management` = 1'); ObjectModel::updateMultishopTable('Product', array('advanced_stock_management' => 0), 'product_shop.`advanced_stock_management` = 1');
+2 -2
View File
@@ -414,11 +414,11 @@ class AuthControllerCore extends FrontController
if ($error_phone) if ($error_phone)
$this->errors[] = Tools::displayError('You must register at least one phone number.'); $this->errors[] = Tools::displayError('You must register at least one phone number.');
$this->errors = array_unique(array_merge($this->errors, $customer->validateController())); $this->errors = array_unique(array_merge($this->errors, $customer->validateController()));
// Check the requires fields which are settings in the BO // Check the requires fields which are settings in the BO
$this->errors = array_merge($this->errors, $customer->validateFieldsRequiredDatabase()); $this->errors = $this->errors + $customer->validateFieldsRequiredDatabase();
if (!Configuration::get('PS_REGISTRATION_PROCESS_TYPE') && !$this->ajax && !Tools::isSubmit('submitGuestAccount')) if (!Configuration::get('PS_REGISTRATION_PROCESS_TYPE') && !$this->ajax && !Tools::isSubmit('submitGuestAccount'))
{ {
+10
View File
@@ -170,6 +170,7 @@ class ContactControllerCore extends FrontController
'{attached_file}' => '-', '{attached_file}' => '-',
'{message}' => Tools::nl2br(stripslashes($message)), '{message}' => Tools::nl2br(stripslashes($message)),
'{email}' => $from, '{email}' => $from,
'{product_name}' => '',
); );
if (isset($filename)) if (isset($filename))
@@ -177,6 +178,8 @@ class ContactControllerCore extends FrontController
$id_order = (int)Tools::getValue('id_order'); $id_order = (int)Tools::getValue('id_order');
$id_product = (int)Tools::getValue('id_product');
if (isset($ct) && Validate::isLoadedObject($ct)) if (isset($ct) && Validate::isLoadedObject($ct))
{ {
if ($ct->id_order) if ($ct->id_order)
@@ -193,6 +196,13 @@ class ContactControllerCore extends FrontController
$var_list['{id_order}'] = $id_order; $var_list['{id_order}'] = $id_order;
} }
if ($id_product)
{
$product = new Product((int)$id_product);
if (Validate::isLoadedObject($product) && isset($product->name[Context::getContext()->language->id]))
$var_list['{product_name}'] = $product->name[Context::getContext()->language->id];
}
if (empty($contact->email)) if (empty($contact->email))
Mail::Send($this->context->language->id, 'contact_form', $subject, $var_list, $from, null, null, null, $fileAttachment); Mail::Send($this->context->language->id, 'contact_form', $subject, $var_list, $from, null, null, null, $fileAttachment);
else else
+7 -7
View File
@@ -56,7 +56,6 @@ class InstallControllerHttpDatabase extends InstallControllerHttp
$this->session->database_login = trim(Tools::getValue('dbLogin')); $this->session->database_login = trim(Tools::getValue('dbLogin'));
$this->session->database_password = trim(Tools::getValue('dbPassword')); $this->session->database_password = trim(Tools::getValue('dbPassword'));
$this->session->database_prefix = trim(Tools::getValue('db_prefix')); $this->session->database_prefix = trim(Tools::getValue('db_prefix'));
$this->session->database_engine = Tools::getValue('dbEngine');
$this->session->database_clear = Tools::getValue('database_clear'); $this->session->database_clear = Tools::getValue('database_clear');
// Save email config // Save email config
@@ -81,13 +80,15 @@ class InstallControllerHttpDatabase extends InstallControllerHttp
$this->session->database_login, $this->session->database_login,
$this->session->database_password, $this->session->database_password,
$this->session->database_prefix, $this->session->database_prefix,
$this->session->database_engine,
// We do not want to validate table prefix if we are already in install process // We do not want to validate table prefix if we are already in install process
($this->session->step == 'process') ? true : $this->session->database_clear ($this->session->step == 'process') ? true : $this->session->database_clear
); );
if (count($this->errors))
return count($this->errors) ? false : true; return false;
if (!isset($this->session->database_engine))
$this->session->database_engine = $this->model_database->getBestEngine($this->session->database_server, $this->session->database_name, $this->session->database_login, $this->session->database_password);
return true;
} }
public function process() public function process()
@@ -108,10 +109,9 @@ class InstallControllerHttpDatabase extends InstallControllerHttp
$login = Tools::getValue('dbLogin'); $login = Tools::getValue('dbLogin');
$password = Tools::getValue('dbPassword'); $password = Tools::getValue('dbPassword');
$prefix = Tools::getValue('db_prefix'); $prefix = Tools::getValue('db_prefix');
$engine = Tools::getValue('dbEngine');
$clear = Tools::getValue('clear'); $clear = Tools::getValue('clear');
$errors = $this->model_database->testDatabaseSettings($server, $database, $login, $password, $prefix, $engine, $clear); $errors = $this->model_database->testDatabaseSettings($server, $database, $login, $password, $prefix, $clear);
$this->ajaxJsonAnswer( $this->ajaxJsonAnswer(
(count($errors)) ? false : true, (count($errors)) ? false : true,
+1 -1
View File
@@ -96,7 +96,7 @@
<access id="access_2_85" id_profile="Administrator" id_tab="Webservice" view="1" add="1" edit="1" delete="1"/> <access id="access_2_85" id_profile="Administrator" id_tab="Webservice" view="1" add="1" edit="1" delete="1"/>
<access id="access_2_86" id_profile="Administrator" id_tab="Preferences_1" view="1" add="1" edit="1" delete="1"/> <access id="access_2_86" id_profile="Administrator" id_tab="Preferences_1" view="1" add="1" edit="1" delete="1"/>
<access id="access_2_87" id_profile="Administrator" id_tab="Quick_Access" view="1" add="1" edit="1" delete="1"/> <access id="access_2_87" id_profile="Administrator" id_tab="Quick_Access" view="1" add="1" edit="1" delete="1"/>
<access id="access_2_88" id_profile="Administrator" id_tab="Employees" view="1" add="1" edit="1" delete="1"/> <access id="access_2_88" id_profile="Administrator" id_tab="Employees" view="1" add="0" edit="0" delete="0"/>
<access id="access_2_89" id_profile="Administrator" id_tab="Profiles" view="1" add="1" edit="1" delete="1"/> <access id="access_2_89" id_profile="Administrator" id_tab="Profiles" view="1" add="1" edit="1" delete="1"/>
<access id="access_2_90" id_profile="Administrator" id_tab="Permissions" view="1" add="1" edit="1" delete="1"/> <access id="access_2_90" id_profile="Administrator" id_tab="Permissions" view="1" add="1" edit="1" delete="1"/>
<access id="access_2_91" id_profile="Administrator" id_tab="Tabs" view="1" add="1" edit="1" delete="1"/> <access id="access_2_91" id_profile="Administrator" id_tab="Tabs" view="1" add="1" edit="1" delete="1"/>
+15 -13
View File
@@ -38,7 +38,7 @@ class InstallModelDatabase extends InstallAbstractModel
* @param bool $clear * @param bool $clear
* @return array List of errors * @return array List of errors
*/ */
public function testDatabaseSettings($server, $database, $login, $password, $prefix, $engine, $clear = false) public function testDatabaseSettings($server, $database, $login, $password, $prefix, $clear = false)
{ {
$errors = array(); $errors = array();
@@ -55,14 +55,11 @@ class InstallModelDatabase extends InstallAbstractModel
if ($prefix && !Validate::isTablePrefix($prefix)) if ($prefix && !Validate::isTablePrefix($prefix))
$errors[] = $this->language->l('Tables prefix is invalid'); $errors[] = $this->language->l('Tables prefix is invalid');
if (!Validate::isMySQLEngine($engine))
$errors[] = $this->language->l('Wrong engine chosen for MySQL');
if (!$errors) if (!$errors)
{ {
$dbtype = ' ('.Db::getClass().')'; $dbtype = ' ('.Db::getClass().')';
// Try to connect to database // Try to connect to database
switch (Db::checkConnection($server, $login, $password, $database, true, $engine)) switch (Db::checkConnection($server, $login, $password, $database, true))
{ {
case 0: case 0:
if (!Db::checkEncoding($server, $login, $password)) if (!Db::checkEncoding($server, $login, $password))
@@ -71,28 +68,33 @@ class InstallModelDatabase extends InstallAbstractModel
// Check if a table with same prefix already exists // Check if a table with same prefix already exists
if (!$clear && Db::hasTableWithSamePrefix($server, $login, $password, $database, $prefix)) if (!$clear && Db::hasTableWithSamePrefix($server, $login, $password, $database, $prefix))
$errors[] = $this->language->l('At least one table with same prefix was already found, please change your prefix or drop your database'); $errors[] = $this->language->l('At least one table with same prefix was already found, please change your prefix or drop your database');
if (($create_error = Db::checkCreatePrivilege($server, $login, $password, $database, $prefix, $engine)) !== true) if (($create_error = Db::checkCreatePrivilege($server, $login, $password, $database, $prefix)) !== true)
{ {
$errors[] = $this->language->l(sprintf('Your database login don\'t have the privileges to create table on the database "%s". Ask your hosting provider:', $database)); $errors[] = $this->language->l(sprintf('Your database login don\'t have the privileges to create table on the database "%s". Ask your hosting provider:', $database));
if ($create_error != false) if ($create_error != false)
$errors[] = $create_error; $errors[] = $create_error;
} }
break; break;
case 1: case 1:
$errors[] = $this->language->l('Database Server is not found. Please verify the login, password and server fields').$dbtype; $errors[] = $this->language->l('Database Server is not found. Please verify the login, password and server fields').$dbtype;
break; break;
case 2: case 2:
$errors[] = $this->language->l('Connection to MySQL server succeeded, but database "%s" not found', $database).$dbtype; $errors[] = $this->language->l('Connection to MySQL server succeeded, but database "%s" not found', $database).$dbtype;
break; break;
case 4:
$errors[] = $this->language->l('Engine innoDB is not supported by your MySQL server, please use MyISAM').$dbtype;
break;
} }
} }
return $errors; return $errors;
} }
public function getBestEngine($server, $database, $login, $password)
{
$class = Db::getClass();
$instance = new $class($server, $login, $password, $database, true);
$engine = $instance->getBestEngine();
unset($instance);
return $engine;
}
} }
+2 -1
View File
@@ -27,13 +27,14 @@
<label for="dbPassword"><?php echo $this->l('Database password:') ?> </label> <label for="dbPassword"><?php echo $this->l('Database password:') ?> </label>
<input class="text" size="10" type="password" id="dbPassword" name="dbPassword" value="<?php echo htmlspecialchars($this->database_password) ?>" /> <input class="text" size="10" type="password" id="dbPassword" name="dbPassword" value="<?php echo htmlspecialchars($this->database_password) ?>" />
</p> </p>
<!--
<p> <p>
<label for="dbEngine"><?php echo $this->l('Database Engine:') ?></label> <label for="dbEngine"><?php echo $this->l('Database Engine:') ?></label>
<select id="dbEngine" name="dbEngine"> <select id="dbEngine" name="dbEngine">
<option value="InnoDB" <?php if ($this->database_engine == 'InnoDB'): ?>selected="selected"<?php endif; ?>>InnoDB</option> <option value="InnoDB" <?php if ($this->database_engine == 'InnoDB'): ?>selected="selected"<?php endif; ?>>InnoDB</option>
<option value="MyISAM" <?php if ($this->database_engine == 'MyISAM'): ?>selected="selected"<?php endif; ?>>MyISAM</option> <option value="MyISAM" <?php if ($this->database_engine == 'MyISAM'): ?>selected="selected"<?php endif; ?>>MyISAM</option>
</select> </select>
</p> </p>-->
<p> <p>
<label for="db_prefix"><?php echo $this->l('Tables prefix:')?></label> <label for="db_prefix"><?php echo $this->l('Tables prefix:')?></label>
<input class="text" type="text" id="db_prefix" name="db_prefix" value="<?php echo htmlspecialchars($this->database_prefix) ?>" /> <input class="text" type="text" id="db_prefix" name="db_prefix" value="<?php echo htmlspecialchars($this->database_prefix) ?>" />
+2 -4
View File
@@ -470,8 +470,7 @@ function init()
cache: false, cache: false,
dataType: 'json', dataType: 'json',
data : query, data : query,
success : function(data) success : function(data) {
{
if (data.result) if (data.result)
{ {
go = false; go = false;
@@ -491,8 +490,7 @@ function init()
else else
jAlert(data.error); jAlert(data.error);
}, },
error : function(XMLHttpRequest, textStatus, errorThrown) error : function(XMLHttpRequest, textStatus, errorThrown) {
{
jAlert("Impossible to add the product to the cart.\n\ntextStatus: '" + textStatus + "'\nerrorThrown: '" + errorThrown + "'\nresponseText:\n" + XMLHttpRequest.responseText); jAlert("Impossible to add the product to the cart.\n\ntextStatus: '" + textStatus + "'\nerrorThrown: '" + errorThrown + "'\nresponseText:\n" + XMLHttpRequest.responseText);
} }
}); });
+1 -1
View File
@@ -161,7 +161,7 @@ function getHookableList() {
var errors = ''; var errors = '';
for (error in jsonData.errors) //IE6 bug fix for (error in jsonData.errors) //IE6 bug fix
if (error != 'indexOf') if (error != 'indexOf')
errors += jsonData.errors[error] + "\n"; errors += $('<div />').html(jsonData.errors[error]).text() + "\n";
alert(errors); alert(errors);
} }
else else
+1 -1
View File
@@ -20,7 +20,7 @@
<td>&nbsp;</td> <td>&nbsp;</td>
</tr> </tr>
<tr> <tr>
<td align="left">Your message has been sent successfully.<br /><br /> Message: {message}<br /><br /> Order ID : {order_name}<br /><br /> Attached file : {attached_file}</td> <td align="left">Your message has been sent successfully.<br /><br /> Message: {message}<br /><br /> Order ID : {order_name}<br /><br /> Product : {product_name}<br /><br /> Attached file : {attached_file}</td>
</tr> </tr>
<tr> <tr>
<td>&nbsp;</td> <td>&nbsp;</td>
+4 -4
View File
@@ -446,7 +446,7 @@ var ajaxCart = {
var name = (this.name.length > 12 ? this.name.substring(0, 10) + '...' : this.name); var name = (this.name.length > 12 ? this.name.substring(0, 10) + '...' : this.name);
content += '<a href="' + this.link + '" title="' + this.name + '" class="cart_block_product_name">' + name + '</a>'; content += '<a href="' + this.link + '" title="' + this.name + '" class="cart_block_product_name">' + name + '</a>';
if (parseFloat(this.price_float) > 0) if (this.is_gift != undefined && this.is_gift == 1)
content += '<span class="remove_link"><a rel="nofollow" class="ajax_cart_block_remove_link" href="' + baseUri + '?controller=cart&amp;delete=1&amp;id_product=' + productId + '&amp;token=' + static_token + (this.hasAttributes ? '&amp;ipa=' + parseInt(this.idCombination) : '') + '"> </a></span>'; content += '<span class="remove_link"><a rel="nofollow" class="ajax_cart_block_remove_link" href="' + baseUri + '?controller=cart&amp;delete=1&amp;id_product=' + productId + '&amp;token=' + static_token + (this.hasAttributes ? '&amp;ipa=' + parseInt(this.idCombination) : '') + '"> </a></span>';
else else
content += '<span class="remove_link"></span>'; content += '<span class="remove_link"></span>';
@@ -568,10 +568,10 @@ var ajaxCart = {
if (jsonData.hasError) if (jsonData.hasError)
{ {
var errors = ''; var errors = '';
for(error in jsonData.errors) for (error in jsonData.errors)
//IE6 bug fix //IE6 bug fix
if(error != 'indexOf') if (error != 'indexOf')
errors += jsonData.errors[error] + "\n"; errors += $('<div />').html(jsonData.errors[error]).text() + "\n";
alert(errors); alert(errors);
} }
else else
+33 -5
View File
@@ -740,10 +740,38 @@ class BlockCms extends Module
public function hookActionShopDataDuplication($params) public function hookActionShopDataDuplication($params)
{ {
Db::getInstance()->execute(' //get all cmd block to duplicate in new shop
INSERT IGNORE INTO '._DB_PREFIX_.'cms_block_shop (id_cms_block, id_shop) $cms_blocks = Db::getInstance()->executeS('
SELECT id_cms_block, '.(int)$params['new_id_shop'].' SELECT * FROM `'._DB_PREFIX_.'cms_block` cb
FROM '._DB_PREFIX_.'cms_block_shop LEFT JOIN `'._DB_PREFIX_.'cms_block_shop` cbf
WHERE id_shop = '.(int)$params['old_id_shop']); ON (cb.`id_cms_block` = cbf.`id_cms_block` AND cbf.`id_shop` = '.(int)$params['old_id_shop'].') ');
if (count($cms_blocks))
{
foreach ($cms_blocks as $cms_block)
{
Db::getInstance()->execute('
INSERT IGNORE INTO '._DB_PREFIX_.'cms_block (`id_cms_block`, `id_cms_category`, `location`, `position`, `display_store`)
VALUES (NULL, '.(int)$cms_block['id_cms_category'].', '.(int)$cms_block['location'].', '.(int)$cms_block['position'].', '.(int)$cms_block['display_store'].');');
$id_block_cms = Db::getInstance()->Insert_ID();
Db::getInstance()->execute('INSERT IGNORE INTO '._DB_PREFIX_.'cms_block_shop (`id_cms_block`, `id_shop`) VALUES ('.(int)$id_block_cms.', '.(int)$params['new_id_shop'].');');
$langs = Db::getInstance()->executeS('SELECT * FROM `'._DB_PREFIX_.'cms_block_lang` WHERE `id_cms_block` = '.(int)$cms_block['id_cms_block']);
foreach($langs as $lang)
Db::getInstance()->execute('
INSERT IGNORE INTO `'._DB_PREFIX_.'cms_block_lang` (`id_cms_block`, `id_lang`, `name`)
VALUES ('.(int)$id_block_cms.', '.(int)$lang['id_lang'].', \''.pSQL($lang['name']).'\');');
$pages = Db::getInstance()->executeS('SELECT * FROM `'._DB_PREFIX_.'cms_block_page` WHERE `id_cms_block` = '.(int)$cms_block['id_cms_block']);
foreach($pages as $page)
Db::getInstance()->execute('
INSERT IGNORE INTO `'._DB_PREFIX_.'cms_block_page` (`id_cms_block_page`, `id_cms_block`, `id_cms`, `is_category`)
VALUES (NULL, '.(int)$id_block_cms.', '.(int)$page['id_cms'].', '.(int)$page['is_category'].');');
}
}
} }
} }
+2 -2
View File
@@ -454,7 +454,7 @@ function upQuantity(id, qty)
for(var error in jsonData.errors) for(var error in jsonData.errors)
//IE6 bug fix //IE6 bug fix
if(error !== 'indexOf') if(error !== 'indexOf')
errors += jsonData.errors[error] + "\n"; errors += $('<div />').html(jsonData.errors[error]).text() + "\n";
alert(errors); alert(errors);
$('input[name=quantity_'+ id +']').val($('input[name=quantity_'+ id +'_hidden]').val()); $('input[name=quantity_'+ id +']').val($('input[name=quantity_'+ id +'_hidden]').val());
} }
@@ -539,7 +539,7 @@ function downQuantity(id, qty)
for(var error in jsonData.errors) for(var error in jsonData.errors)
//IE6 bug fix //IE6 bug fix
if(error !== 'indexOf') if(error !== 'indexOf')
errors += jsonData.errors[error] + "\n"; errors += $('<div />').html(jsonData.errors[error]).text() + "\n";
alert(errors); alert(errors);
$('input[name=quantity_'+ id +']').val($('input[name=quantity_'+ id +'_hidden]').val()); $('input[name=quantity_'+ id +']').val($('input[name=quantity_'+ id +'_hidden]').val());
} }
+1 -1
View File
@@ -121,7 +121,7 @@ function updateAddresses()
for(var error in jsonData.errors) for(var error in jsonData.errors)
//IE6 bug fix //IE6 bug fix
if(error !== 'indexOf') if(error !== 'indexOf')
errors += jsonData.errors[error] + "\n"; errors += $('<div />').html(jsonData.errors[error]).text() + "\n";
alert(errors); alert(errors);
} }
}, },
+4 -4
View File
@@ -93,7 +93,7 @@ function updateAddressSelection()
for(var error in jsonData.errors) for(var error in jsonData.errors)
//IE6 bug fix //IE6 bug fix
if(error !== 'indexOf') if(error !== 'indexOf')
errors += jsonData.errors[error] + "\n"; errors += $('<div />').html(jsonData.errors[error]).text() + "\n";
alert(errors); alert(errors);
} }
else else
@@ -186,7 +186,7 @@ function getCarrierListAndUpdate()
for(var error in jsonData.errors) for(var error in jsonData.errors)
//IE6 bug fix //IE6 bug fix
if(error !== 'indexOf') if(error !== 'indexOf')
errors += jsonData.errors[error] + "\n"; errors += $('<div />').html(jsonData.errors[error]).text() + "\n";
alert(errors); alert(errors);
} }
else else
@@ -236,7 +236,7 @@ function updateCarrierSelectionAndGift()
for(var error in jsonData.errors) for(var error in jsonData.errors)
//IE6 bug fix //IE6 bug fix
if(error !== 'indexOf') if(error !== 'indexOf')
errors += jsonData.errors[error] + "\n"; errors += $('<div />').html(jsonData.errors[error]).text() + "\n";
alert(errors); alert(errors);
} }
else else
@@ -703,7 +703,7 @@ function bindInputs()
for(var error in jsonData.errors) for(var error in jsonData.errors)
//IE6 bug fix //IE6 bug fix
if(error !== 'indexOf') if(error !== 'indexOf')
errors += jsonData.errors[error] + "\n"; errors += $('<div />').html(jsonData.errors[error]).text() + "\n";
alert(errors); alert(errors);
} }
else else
+2 -2
View File
@@ -170,7 +170,7 @@ function bindInputs()
for(var error in jsonData.errors) for(var error in jsonData.errors)
//IE6 bug fix //IE6 bug fix
if(error !== 'indexOf') if(error !== 'indexOf')
errors += jsonData.errors[error] + "\n"; errors += $('<div />').html(jsonData.errors[error]).text() + "\n";
alert(errors); alert(errors);
} }
else else
@@ -254,7 +254,7 @@ function updateCarrierSelectionAndGift()
for(var error in jsonData.errors) for(var error in jsonData.errors)
//IE6 bug fix //IE6 bug fix
if(error !== 'indexOf') if(error !== 'indexOf')
errors += jsonData.errors[error] + "\n"; errors += $('<div />').html(jsonData.errors[error]).text() + "\n";
alert(errors); alert(errors);
} }
else else