Esempio n. 1
0
/**
 * AJAX CALLBACK: SIMPLENEWS SUBSCRIPTION FORM (FOOTER NEWSLETTER BLOCK: 2)
 */
function simplenews_block_form_ajax_submit_2($form, $form_state)
{
    $launch_list_subscription_id = theme_get_setting('launch_list_subscription_id');
    $return = '<div id="block-simplenews-' . $launch_list_subscription_id . '" class="block block-simplenews home-signin input-group wow fadeIn animated home-signin-return">';
    //$return .= '<h2>' . t('Newsletter') . '</h2>';
    if (!valid_email_address($form_state['values']['mail'])) {
        $return .= '<div class="form-validation alert alert-danger">' . t('The e-mail address is not valid.') . '</div>';
        return $return . render($form);
    } else {
        if (module_exists('simplenews')) {
            module_load_include('inc', 'simplenews', 'views/simplenews.subscription');
            $tid = $form['#tid'];
            $account = simplenews_load_user_by_mail($form_state['values']['mail']);
            $confirm = simplenews_require_double_opt_in($tid, $account);
            switch ($form_state['values']['action']) {
                case 'subscribe':
                    simplenews_subscribe_user($form_state['values']['mail'], $tid, $confirm, 'website');
                    if ($confirm) {
                        $return .= '<div class="form-validation alert alert-success">' . t('Success! Please check your e-mail to complete your subscription.') . '</div>';
                        return $return . render($form);
                    } else {
                        $return .= '<div class="form-validation alert alert-success">' . t('Success! You\'ve been subscribed to our newsletter.') . '</div>';
                        return $return . '<input disabled class="subscribe-form-submit btn-primary-full btn submit ajax-processed" data-loading-text="Loading..." type="submit" id="edit-submit" name="op" value="Subscribed">';
                    }
                    break;
                case 'unsubscribe':
                    simplenews_unsubscribe_user($form_state['values']['mail'], $tid, $confirm, 'website');
                    if ($confirm) {
                        $return .= '<div class="form-validation alert alert-success">' . t('You\'re nearly there. Please check your e-mail to confirm.') . '</div>';
                        return $return . render($form);
                    } else {
                        $return .= '<div class="form-validation alert alert-success">' . t('OK, you\'re unsubscribed. Sorry to see you go.') . '</div>';
                        return $return . '<input disabled class="subscribe-form-submit btn-primary-full btn submit ajax-processed" data-loading-text="Loading..." type="submit" id="edit-submit" name="op" value="Unsubscribed">';
                    }
                    break;
            }
        }
    }
    $return .= render($form);
    $return .= '</div>';
}
Esempio n. 2
0
		<!-- end #content -->

		</div>
		<!-- end content-container -->
	</div>
	<!-- END main-container -->
<?php 
} else {
    ?>



<?php 
    /* check for newsletter submission */
    if ($_POST['simplenews'] == "true") {
        simplenews_subscribe_user($_POST['email'], 0, FALSE, NULL);
        exit;
    }
    ?>


<?php 
    include "header.php";
    if (user_is_logged_in()) {
        ?>
<br class="clear" />
	<?php 
        include "admin_content.php";
        ?>
<br class="clear" />
<?php