<?php
class ModelModuleLess extends Model {
	
    //Вывод емайла на который будет отправка
    public function getMail() {
        $query = $this->db->query("SELECT DISTINCT * FROM " . DB_PREFIX . "setting WHERE `group` = 'less' AND `key` = 'mail'");
        
        if(isset($query->row['value']))
        {
            return $query->row['value'];
        }

        $this->db->query("INSERT INTO `" . DB_PREFIX . "setting` (`group`, `key`, `value`) VALUES ('pre_order', 'mail', '')");
        
        return '';
    }

    //Изменения емайла на который будет отправка
    public function editMail($mail) {
        
        if( filter_var($mail, FILTER_VALIDATE_EMAIL) )
        {        
            $this->db->query("UPDATE `" . DB_PREFIX . "setting` SET `value` = '" . $mail . "' WHERE `group` = 'pre_order' AND `key` = 'mail'");
            return TRUE;
        }
        
        return FALSE;
    }
        
}
?>
