82 lines
2.0 KiB
PHP
82 lines
2.0 KiB
PHP
<?php
|
|
if (!defined('_PS_VERSION_'))
|
|
exit;
|
|
|
|
class ant_nw_frequences extends Module
|
|
{
|
|
public function __construct()
|
|
{
|
|
$this->name = 'ant_nw_frequences';
|
|
$this->tab = 'others';
|
|
$this->version = 0.1;
|
|
$this->author = 'Antadis';
|
|
$this->ps_versions_compliancy = array('min' => '1.6', 'max' => _PS_VERSION_);
|
|
|
|
parent::__construct();
|
|
|
|
$this->displayName = $this->l('Antadis - Newsletter Frequences');
|
|
}
|
|
|
|
public function install()
|
|
{
|
|
if (!parent::install()
|
|
|| !$this->installDb()
|
|
|| !$this->registerHook('ModuleRoutes')
|
|
){
|
|
$this->uninstallDb();
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
public function uninstall()
|
|
{
|
|
if(!parent::uninstall()){
|
|
return false;
|
|
}
|
|
$this->uninstallDb();
|
|
return true;
|
|
}
|
|
|
|
public function installDb()
|
|
{
|
|
$statements = array();
|
|
//$statements[] = 'ALTER TABLE `'._DB_PREFIX_.'customer` ADD `frequence_nw` TINYINT(1) DEFAULT 0;';
|
|
|
|
return $this->uninstallDb() && $this->updateDb($statements);
|
|
}
|
|
|
|
public function uninstallDb()
|
|
{
|
|
$statements = array();
|
|
//$statements[] = 'ALTER TABLE `'._DB_PREFIX_.'customer` DROP COLUMN `frequence_nw`;';
|
|
|
|
return $this->updateDb($statements);
|
|
}
|
|
|
|
public function updateDb($statements)
|
|
{
|
|
foreach($statements as $statement){
|
|
if( !Db::getInstance()->execute($statement)){
|
|
return false;
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
|
|
public function hookModuleRoutes($params)
|
|
{
|
|
$tab_routes['module-ant_nw_frequences-frequence'] = array(
|
|
'controller' => 'frequence',
|
|
'rule' => 'mes-newsletters',
|
|
'keywords' => array(
|
|
),
|
|
'params' => array(
|
|
'fc' => 'module',
|
|
'module' => 'ant_nw_frequences',
|
|
)
|
|
);
|
|
return $tab_routes;
|
|
}
|
|
|
|
} |