Exemplo n.º 1
0
function display_page_content()
{
    $the_email = requestIdParam();
    $the_list = getRequestVarAtIndex(3);
    $list = NLLists::FindById($the_list);
    $email = NLEmails::FindByEmail($the_email);
    $email->detach($list);
}
Exemplo n.º 2
0
function initialize_page()
{
    $post_action = "";
    if (isset($_POST['submit'])) {
        $post_action = $_POST['submit'];
    }
    if ($post_action == "Add New List") {
        $success = '';
        $list = MyActiveRecord::Create('NLLists');
        $list->display_name = $_POST['name'];
        $list->name = slug($_POST['name']);
        $list->template = $_POST['template'];
        $list->description = $_POST['description'];
        $list->public = $_POST['public'];
        $list->save();
        $success .= "Mailing List Created";
        $emails = explode(",", str_replace(" ", "", $_POST['emails']));
        if (is_array($emails)) {
            $count = 0;
            foreach ($emails as $email) {
                if (!$list->emailLinked($email) && is_validemail($email)) {
                    // Check for an existing match in the system
                    $newAddy = NLEmails::FindByEmail($email);
                    if (!isset($newAddy) and !is_object($newAddy)) {
                        $newAddy = MyActiveRecord::Create('NLEmails');
                        $newAddy->email = $email;
                        $newAddy->save();
                        $count++;
                    }
                    // Existing or not, attach that email to this List
                    $query = "INSERT INTO nlemails_nllists VALUES ({$newAddy->id}, {$list->id});";
                    if (!mysql_query($query, MyActiveRecord::Connection())) {
                        die($query);
                    }
                }
            }
            if ($count > 0) {
                $success .= " / Emails Added to {$list->display_name}";
            } else {
                $success .= " / All Emails Added or Invalid";
            }
        }
        setFlash("<h3>" . $success . "</h3>");
    }
}
Exemplo n.º 3
0
function display_page_content()
{
    $useremail = requestIDparam();
    if ($useremail == "deleted") {
        $useremail = "";
    }
    if (!$_POST) {
        $lists = NLLists::FindPublic();
        $list_count = count($lists);
        $welcome_message = 'Subscribe to our mailing list';
        if ($list_count > 1) {
            $welcome_message .= "s";
        }
        if (requestIdParam() == "deleted") {
            echo '<div class="feedback feedback__alert"><p class="">That email has been removed</p></div>';
        }
        ?>
		
		<div class="subscriber">
			<script type="text/javascript">
				//<![CDATA[										
					$().ready(function() {
						$("#lists_form").validate({
							rules: {
								email: { required: true, email: true },
								"list[]": "required"
							},
							messages: {
								email: "Please enter a valid email address",
								"list[]": "Almost forgot! Select at least one list to subscribe to." 
							}
						});
					});
				//]]>
			</script>
			
			<h1 class="subscriber--title"><?php 
        echo $welcome_message;
        ?>
</h1>
			
			<form class="form form__subscribe-new" method="POST">
				
				<span class="form--input-group"><label for="email">Your Email</label>
                <input type="email" id="email" name="email" class="form--input" maxlength="128" required="required" value="<?php 
        echo $useremail;
        ?>
"></span>
				
				<div class="subscriber--lists">
<?php 
        foreach ($lists as $list) {
            if ($list->public) {
                echo '<div class="subscriber--list-wrapper"><p class="subscriber--list"><label for="' . $list->name . '" class="check"><input type="checkbox" name="selected_list[]" id="' . $list->name . '" value="' . $list->id . '"> ' . $list->display_name . '</label></p>';
                echo '<div class="subscriber--list--description">' . $list->description . '</div></div>';
            }
        }
        ?>
                
                </div>
                <p><input type="submit" class="button primary-action" name="submit" value="Save Subscription Settings"></p>

			</form>
		</div>

<?php 
    } else {
        // There is a POST. Display a Success page
        $useremail = $_POST['email'];
        $nlemail = NLEmails::FindByEmail($useremail);
        $thislists = $nlemail->getNLlists();
        ?>
		
		<div class="subscriber subscriber--feedback">
			<h1 class="subscriber--title">Thanks!</h1>
			<h3 class="subscriber--subtitle"><?php 
        echo $useremail;
        ?>
 is now subscribed to:</h3>
<?php 
        foreach ($thislists as $list) {
            echo '<h4 class="successfully_subscribed">' . $list->display_name . '</h4>';
        }
        ?>

			<p>&nbsp;</p>
			<p>Go to the <a href="<?php 
        echo get_link("users/manage/" . $useremail);
        ?>
">Manage Subscriptions</a> page to manage your subscriptions or provide additional information.</p>
		</div>
<?php 
    }
}
Exemplo n.º 4
0
function display_page_content()
{
    $useremail = requestIDparam();
    // Check email by getting it from the database. Find the subscriptions associated with it. If it is not a valid email in our database, then do not display the interface below. Instead, maybe we redirect them to the home page.
    $email = NLEmails::FindByEmail($useremail);
    $lists = NLLists::FindAll();
    echo '<div class="subscriber"><div id"status_message"></div>';
    displayFlash();
    echo '<h1 class="subscriber--title">Manage your Newsletter Subscriptions</h1>';
    // There is no email that we can take out of the URL string
    if ($useremail == "") {
        ?>

			<h3 class="subscriber--subtitle subscriber--error">An email was not detected&hellip; please enter one below:</h3>
			
			<form class="form form__subscriber-profile" method="POST">
				
				<span class="form--input-group"><label for="email" class="screen-reader-text">Email</label><input type="email" id="email" name="email" class="form--input" placeholder="*****@*****.**" maxlength="128" required="required" tabindex="1" value=""></span>
                
				<p><input type="submit" class="button primary-action" name="submit" value="Manage This Email" tabindex="2"></p>
			</form>
<?php 
        // There is an email, but we didn't find a user associated with it
    } else {
        if (!is_object($email)) {
            ?>

			<h3 class="subscriber--subtitle subscriber--error">Whoops&hellip; that email is not subscribed to any lists</h3>
			<h3><a href="<?php 
            echo get_link("mail/subscribe/" . $useremail);
            ?>
" title="Click here to choose an email list to subscribe this email to">Subscribe to a list.</a></h3>
			
<?php 
            // Found the email and the user.
        } else {
            ?>
			
			<form class="form form__subscriber-profile form__wide" method="POST">
				
				<span class="form--input-group"><label for="email">Your Email</label>
                <input type="email" id="email" name="email" class="form--input" maxlength="128" required="required" value="<?php 
            echo $email->email;
            ?>
"></span>
				
				<h2 class="subscriber--subtitle">Subscriptions</h2>
				<p><em>You may uncheck a box to be removed from that list</em></p>
				
				<div class="subscriber--lists">
<?php 
            hiddenField("oldemail", $email->email);
            foreach ($lists as $list) {
                if ($list->public) {
                    if ($email->is_linked($list)) {
                        $checked = "checked";
                    } else {
                        $checked = "";
                    }
                    echo '<div class="subscriber--list-wrapper"><p class="subscriber--list"><label for="' . $list->name . '" class="check"><input type="checkbox" name="' . $list->name . '" id="' . $list->name . '" value="' . $list->id . '" ' . $checked . '> ' . $list->display_name . '</label></p>';
                    echo '<div class="subscriber--list--description">' . $list->description . '</div></div>';
                }
            }
            ?>
                
                </div>
                <p><input type="submit" class="button primary-action" name="submit" value="Save Subscription Settings"></p>
                
                <div class="subscriber--details">
    				<h3>Optional Information:</h3>
    				<span class="form--input-group"><label for="first_name">First Name</label> <input type="text" id="first_name" name="first_name" class="form--input" value="<?php 
            echo $email->first_name;
            ?>
"></span>
    				<span class="form--input-group"><label for="last_name">Last Name</label> <input type="text" id="last_name" name="last_name" class="form--input" value="<?php 
            echo $email->last_name;
            ?>
"></span>
    				<span class="form--input-group"><label for="address1">Address 1</label> <input type="text" id="address1" name="address1" class="form--input" value="<?php 
            echo $email->address1;
            ?>
"></span>
    				<span class="form--input-group"><label for="address2">Address 2</label> <input type="text" id="address2" name="address2" class="form--input" value="<?php 
            echo $email->address2;
            ?>
"></span>
    				<span class="form--input-group"><label for="city">City</label> <input type="text" id="city" name="city" class="form--input" value="<?php 
            echo $email->city;
            ?>
"></span>
    				<span class="form--input-group"><label for="state">State</label> <?php 
            echo StateSelectList("state", $email->state);
            ?>
</span>
    				<span class="form--input-group"><label for="zip">Zip Code</label> <input type="text" id="zip" name="zip" class="form--input" value="<?php 
            echo $email->zip;
            ?>
"></span>
    				<span class="form--input-group"><label for="phone">Phone</label> <input type="tel" id="phone" name="phone" class="form--input" value="<?php 
            echo $email->phone;
            ?>
"></span>
				</div>
				
				<p><label for="delete" class="check"><input type="checkbox" name="delete" id="delete" value="<?php 
            echo $email->email;
            ?>
">&nbsp; Remove my email from the site completely.</label></p>
				
				<p><input type="submit" class="button primary-action" name="submit" value="Save Subscription Settings"></p>
			</form>
<?php 
        }
    }
    echo '</div><!-- end .subscriber -->';
}