Fix module name
This commit is contained in:
parent
3580bdef15
commit
dbd82073f5
@ -10,7 +10,7 @@ class Contactform extends Module {
|
||||
private $assets_module_dir;
|
||||
|
||||
public function __construct() {
|
||||
$this->name = 'Contactform';
|
||||
$this->name = 'contactform';
|
||||
$this->tab = 'advertising_marketing';
|
||||
$this->version = '1.0';
|
||||
$this->author = 'Antadis';
|
||||
@ -43,11 +43,18 @@ class Contactform extends Module {
|
||||
`type` INT(11) NOT NULL,
|
||||
PRIMARY KEY (`id_contactform`)
|
||||
) ENGINE='._MYSQL_ENGINE_.' DEFAULT CHARSET=utf8;
|
||||
')
|
||||
&& Db::getInstance()->Execute('
|
||||
CREATE TABLE IF NOT EXISTS `'._DB_PREFIX_.'contactform_email` (
|
||||
`id_contactform_email` INT UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
`email` VARCHAR(255) NULL,
|
||||
PRIMARY KEY (`id_contactform_email`)
|
||||
) ENGINE='._MYSQL_ENGINE_.' DEFAULT CHARSET=utf8;
|
||||
');
|
||||
}
|
||||
|
||||
public function uninstallDB() {
|
||||
return Db::getInstance()->Execute('DROP TABLE `'._DB_PREFIX_.'contactform`;');
|
||||
return Db::getInstance()->Execute('DROP TABLE `'._DB_PREFIX_.'contactform`;') && Db::getInstance()->Execute('DROP TABLE `'._DB_PREFIX_.'contactform_email`;');
|
||||
}
|
||||
|
||||
public function install() {
|
||||
@ -64,4 +71,41 @@ class Contactform extends Module {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
public function getContent() {
|
||||
|
||||
$content = "
|
||||
{{ error }}
|
||||
<form method='post'>
|
||||
<textarea name='emails'></textarea>
|
||||
<input type='submit' value='Modifier'>
|
||||
<form>
|
||||
";
|
||||
|
||||
if ($_POST) {
|
||||
if (empty($_POST['emails'])) {
|
||||
$content = str_replace('{{ error }}', "Aucune adresse email n'a été renseignée", $content);
|
||||
return $content;
|
||||
}
|
||||
$emails = explode("\n", $_POST['emails']);
|
||||
foreach ($emails as $k => $email) {
|
||||
$email[$k] = trim($email);
|
||||
}
|
||||
$emails = array_unique($emails);
|
||||
foreach ($emails as $k => $email) {
|
||||
if ($this->emailExistInDb($email) == 0) {
|
||||
$content = str_replace('{{ error }}', "Existe pas", $content);
|
||||
}
|
||||
var_dump(Db::getInstance());
|
||||
}
|
||||
$content = str_replace('{{ error }}', "Existe", $content);
|
||||
}
|
||||
|
||||
$content = str_replace('{{ error }}', "", $content);
|
||||
return $content;
|
||||
}
|
||||
|
||||
private function emailExistInDb($email) {
|
||||
return Db::getInstance()->executeS("SELECT COUNT(*) as count FROM `"._DB_PREFIX_."contactform_email` WHERE email = \"".pSQL($email)."\" ")[0]['count'];
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user