Ejemplo n.º 1
0
}
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    // Add email to maillist
    if ($mode == 'update') {
        if (!empty($_REQUEST['subscribe_email'])) {
            fn_em_subscribe_email($_REQUEST['subscribe_email'], array('name' => fn_em_get_subscriber_name()));
        }
    }
    return array(CONTROLLER_STATUS_REDIRECT);
}
if ($mode == 'unsubscribe') {
    if (!empty($_REQUEST['unsubscribe_key'])) {
        fn_em_unsubscribe($_REQUEST['unsubscribe_key']);
        Registry::get('view')->assign('notification_msg', __('email_marketing.text_unsubscribe_successful'));
        $msg = Registry::get('view')->fetch('addons/email_marketing/common/notification.tpl');
        fn_set_notification('I', __('email_marketing.unsubscribe_successful'), $msg);
    }
    return array(CONTROLLER_STATUS_REDIRECT, fn_url());
} elseif ($mode == 'confirm') {
    if (!empty($_REQUEST['ekey'])) {
        $email = fn_get_object_by_ekey($_REQUEST['ekey'], 'E');
        if (!empty($email) && fn_em_confirm_subscription($email)) {
            Registry::get('view')->assign('notification_msg', __('email_marketing.text_subscription_confirmed_2'));
            $msg = Registry::get('view')->fetch('addons/email_marketing/common/notification.tpl');
            fn_set_notification('I', __('email_marketing.subscription_confirmed_2'), $msg);
        } else {
            fn_set_notification('E', __('error'), __('text_ekey_not_valid'));
        }
    }
    return array(CONTROLLER_STATUS_REDIRECT, fn_url());
}
Ejemplo n.º 2
0
function fn_em_subscribe_email($email, $data = array())
{
    $subscriber_id = fn_em_update_subscriber(array('email' => $email, 'name' => !empty($data['name']) ? $data['name'] : '', 'status' => 'P'), 0, false);
    if (!empty($subscriber_id)) {
        if (Registry::get('addons.email_marketing.em_double_opt_in') == 'Y') {
            Tygh::$app['view']->assign('notification_msg', __('email_marketing.text_subscription_pending'));
            $msg = Tygh::$app['view']->fetch('addons/email_marketing/common/notification.tpl');
            fn_set_notification('I', __('email_marketing.subscription_pending'), $msg);
            Mailer::sendMail(array('to' => $email, 'from' => 'default_company_newsletter_email', 'data' => array('url' => fn_url('em_subscribers.confirm?ekey=' . fn_generate_ekey($email, 'E', SECONDS_IN_DAY))), 'tpl' => 'addons/email_marketing/confirmation.tpl'));
        } else {
            if (fn_em_confirm_subscription($email)) {
                Tygh::$app['view']->assign('notification_msg', __('email_marketing.text_subscription_confirmed'));
                $msg = Tygh::$app['view']->fetch('addons/email_marketing/common/notification.tpl');
                fn_set_notification('I', __('email_marketing.subscription_confirmed'), $msg);
            } else {
                fn_em_delete_subscribers_by_email(array($email));
            }
        }
    }
}