<?php
defined('_JEXEC') or die;

require_once dirname(__FILE__) . '/helper.php';

if (isset($_POST['subscribe-newsletter-btn'])) {
    $user = ModAlNewsletterHelper::insertUser($_POST['name'], $_POST['email']);

    unset($_POST['subscribe-newsletter-btn']);
    unset($_POST['name']);
    unset($_POST['email']);

    if ($user) {
        $app = JFactory::getApplication();
        $app->enqueueMessage(JText::_('MOD_AL_NEWSLETTER_DONE'));
    }
}

require JModuleHelper::getLayoutPath('mod_al_newsletter', $params->get('layout', 'default'));
