[-] MO : editorial : bugfix on install/uninstall, norm
This commit is contained in:
@@ -50,19 +50,19 @@ class Editorial extends Module
|
|||||||
|
|
||||||
public function install()
|
public function install()
|
||||||
{
|
{
|
||||||
if (!parent::install() OR !$this->registerHook('displayHome') OR !$this->registerHook('displayHeader'));
|
if (!parent::install() || !$this->registerHook('displayHome') || !$this->registerHook('displayHeader'))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!Db::getInstance()->execute('
|
$res = Db::getInstance()->execute('
|
||||||
CREATE TABLE `'._DB_PREFIX_.'editorial` (
|
CREATE TABLE IF NOT EXISTS `'._DB_PREFIX_.'editorial` (
|
||||||
`id_editorial` int(10) unsigned NOT NULL auto_increment,
|
`id_editorial` int(10) unsigned NOT NULL auto_increment,
|
||||||
`body_home_logo_link` varchar(255) NOT NULL,
|
`body_home_logo_link` varchar(255) NOT NULL,
|
||||||
PRIMARY KEY (`id_editorial`))
|
PRIMARY KEY (`id_editorial`))
|
||||||
ENGINE='._MYSQL_ENGINE_.' DEFAULT CHARSET=utf8'))
|
ENGINE='._MYSQL_ENGINE_.' DEFAULT CHARSET=utf8');
|
||||||
return false;
|
|
||||||
|
|
||||||
if (!Db::getInstance()->execute('
|
if ($res)
|
||||||
CREATE TABLE `'._DB_PREFIX_.'editorial_lang` (
|
$res &= Db::getInstance()->execute('
|
||||||
|
CREATE TABLE IF NOT EXISTS `'._DB_PREFIX_.'editorial_lang` (
|
||||||
`id_editorial` int(10) unsigned NOT NULL,
|
`id_editorial` int(10) unsigned NOT NULL,
|
||||||
`id_lang` int(10) unsigned NOT NULL,
|
`id_lang` int(10) unsigned NOT NULL,
|
||||||
`body_title` varchar(255) NOT NULL,
|
`body_title` varchar(255) NOT NULL,
|
||||||
@@ -70,18 +70,17 @@ class Editorial extends Module
|
|||||||
`body_paragraph` text NOT NULL,
|
`body_paragraph` text NOT NULL,
|
||||||
`body_logo_subheading` varchar(255) NOT NULL,
|
`body_logo_subheading` varchar(255) NOT NULL,
|
||||||
PRIMARY KEY (`id_editorial`, `id_lang`))
|
PRIMARY KEY (`id_editorial`, `id_lang`))
|
||||||
ENGINE='._MYSQL_ENGINE_.' DEFAULT CHARSET=utf8'))
|
ENGINE='._MYSQL_ENGINE_.' DEFAULT CHARSET=utf8');
|
||||||
return false;
|
|
||||||
|
|
||||||
if (!Db::getInstance()->execute('
|
if ($res)
|
||||||
|
$res &= Db::getInstance()->execute('
|
||||||
INSERT INTO `'._DB_PREFIX_.'editorial`(`body_home_logo_link`)
|
INSERT INTO `'._DB_PREFIX_.'editorial`(`body_home_logo_link`)
|
||||||
VALUES("http://www.prestashop.com")'))
|
VALUES("http://www.prestashop.com")');
|
||||||
return false;
|
if ($res)
|
||||||
|
{
|
||||||
$id_editorial = Db::getInstance()->Insert_ID();
|
$id_editorial = Db::getInstance()->Insert_ID();
|
||||||
$result = true;
|
|
||||||
foreach (Language::getLanguages(false) as $lang)
|
foreach (Language::getLanguages(false) as $lang)
|
||||||
$result &= Db::getInstance()->autoExecute(_DB_PREFIX_.'editorial_lang', array(
|
$res &= Db::getInstance()->autoExecute(_DB_PREFIX_.'editorial_lang', array(
|
||||||
'id_editorial' => $id_editorial,
|
'id_editorial' => $id_editorial,
|
||||||
'id_lang' => $lang['id_lang'],
|
'id_lang' => $lang['id_lang'],
|
||||||
'body_title' => 'Lorem ipsum dolor sit amet',
|
'body_title' => 'Lorem ipsum dolor sit amet',
|
||||||
@@ -89,16 +88,23 @@ class Editorial extends Module
|
|||||||
'body_paragraph' => '<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum</p>',
|
'body_paragraph' => '<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum</p>',
|
||||||
'body_logo_subheading' => 'Lorem ipsum presta shop amet',
|
'body_logo_subheading' => 'Lorem ipsum presta shop amet',
|
||||||
), 'INSERT');
|
), 'INSERT');
|
||||||
|
}
|
||||||
|
|
||||||
return $result;
|
if (!$res)
|
||||||
|
$res &= $this->uninstall();
|
||||||
|
|
||||||
|
return $res;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function uninstall()
|
public function uninstall()
|
||||||
{
|
{
|
||||||
if (!parent::uninstall())
|
$res = Db::getInstance()->execute('DROP TABLE IF EXISTS `'._DB_PREFIX_.'editorial`');
|
||||||
|
$res &= Db::getInstance()->execute('DROP TABLE IF EXISTS `'._DB_PREFIX_.'editorial_lang`');
|
||||||
|
|
||||||
|
if (!$res || !parent::uninstall())
|
||||||
return false;
|
return false;
|
||||||
return (Db::getInstance()->execute('DROP TABLE `'._DB_PREFIX_.'editorial`') AND
|
|
||||||
Db::getInstance()->execute('DROP TABLE `'._DB_PREFIX_.'editorial_lang`'));
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function putContent($xml_data, $key, $field, $forbidden, $section)
|
public function putContent($xml_data, $key, $field, $forbidden, $section)
|
||||||
|
|||||||
Reference in New Issue
Block a user