106 lines
2.6 KiB
PHP
106 lines
2.6 KiB
PHP
<?php
|
|
/**
|
|
* Description of Sendmail
|
|
*
|
|
* @author Pierre Beaumont
|
|
* @company Antadis
|
|
*/
|
|
|
|
/**
|
|
*
|
|
*/
|
|
class Sendmail extends Module {
|
|
|
|
static $nbProductByPage = 30;
|
|
/**
|
|
*
|
|
* @param type $name
|
|
* @param Context $context
|
|
*/
|
|
public function __construct($name = null, Context $context = null) {
|
|
|
|
$this->name = 'sendmail';
|
|
$this->tab = 'front_office_features';
|
|
$this->version = '0.1';
|
|
$this->author = 'Antadis';
|
|
$this->need_instance = 0;
|
|
$this->module_key = "";
|
|
parent::__construct($name, $context);
|
|
|
|
$this->displayName = $this->l('Send Mail');
|
|
$this->description = $this->l('Send Mail with personnalized SMTP.');
|
|
$this->confirmUninstall = $this->l('Are you sure you want to delete ?');
|
|
|
|
$this->currentIndex = 'index.php?controller=AdminModules';
|
|
$this->base_config_url = $this->currentIndex .'&configure=' . $this->name . '&token=' . Tools::getValue('token');
|
|
}
|
|
|
|
/**
|
|
*
|
|
* @return boolean
|
|
*/
|
|
public function install() {
|
|
|
|
if (!parent::install()
|
|
|| !self::createTab(self::searchCreateTab($this->l('Antadis'), $this->name), $this->name, $this->l('Mail Configuration'), 'AdminSendMail')){
|
|
$this->uninstall();
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
/**
|
|
*
|
|
* @return boolean
|
|
*/
|
|
static function createTab($id_parent, $module, $name, $class_name)
|
|
{
|
|
$Tab = new Tab();
|
|
$Tab->module = $module;
|
|
foreach(Language::getLanguages(true) as $languages)
|
|
{
|
|
$Tab->name[$languages["id_lang"]] = $name;
|
|
}
|
|
|
|
$Tab->id_parent = $id_parent;
|
|
$Tab->class_name = $class_name;
|
|
$r = $Tab->save();
|
|
|
|
if($r === false)
|
|
return false;
|
|
|
|
return $Tab->id;
|
|
}
|
|
|
|
static function searchCreateTab($tab_name, $name)
|
|
{
|
|
$res = Db::getInstance()->getValue('
|
|
SELECT t.`id_tab`
|
|
FROM `'._DB_PREFIX_.'tab` t
|
|
LEFT JOIN `'._DB_PREFIX_.'tab_lang` tl
|
|
ON (t.`id_tab` = tl.`id_tab` AND tl.`id_lang` = '.(int)Context::getContext()->language->id.')
|
|
WHERE tl.`name` = "'.pSQL($tab_name).'"');
|
|
|
|
if(empty($res))
|
|
$res = self::createTab(0, $name, $tab_name, 'AdminSendMail');
|
|
|
|
return $res;
|
|
}
|
|
/**
|
|
*
|
|
* @return boolean
|
|
*/
|
|
public function uninstall() {
|
|
|
|
if(!parent::uninstall()){
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
/**
|
|
*
|
|
* @param type $params
|
|
* @return type
|
|
*/
|
|
} |