function prerender()
 {
     $ip = $_SERVER['REMOTE_ADDR'];
     //print_r($info);
     $info = $this->data();
     if (isset($info->id)) {
         $lists = SendPress_Data::get_list_ids_for_subscriber($info->id);
         //$lists = explode(',',$info->listids);
         foreach ($lists as $list) {
             $status = SendPress_Data::get_subscriber_list_status($list->listID, $info->id);
             if ($status->statusid == 1) {
                 SendPress_Data::update_subscriber_status($list->listID, $info->id, '2');
             }
         }
         SPNL()->db("Subscribers_Tracker")->open($info->report, $info->id, 4);
     }
     if (SendPress_Option::get('confirm-page') == 'custom') {
         $page = SendPress_Option::get('confirm-page-id');
         if ($page != false) {
             $plink = get_permalink($page);
             if ($plink != "") {
                 wp_safe_redirect(esc_url_raw($plink));
                 exit;
             }
         }
     }
 }
 function prerender()
 {
     $ip = $_SERVER['REMOTE_ADDR'];
     //print_r($info);
     $info = $this->data();
     if (isset($info->listids)) {
         $lists = explode(',', $info->listids);
         foreach ($lists as $list_id) {
             if ($list_id > 0) {
                 $status = SendPress_Data::get_subscriber_list_status($list_id, $info->id);
                 if (!isset($status) || $status->status != '2') {
                     SendPress_Data::update_subscriber_status($list_id, $info->id, '2');
                 }
             }
         }
     }
     if (SendPress_Option::get('confirm-page') == 'custom') {
         $page = SendPress_Option::get('confirm-page-id');
         if ($page != false) {
             $plink = get_permalink($page);
             if ($plink != "") {
                 wp_safe_redirect(esc_url_raw($plink));
                 exit;
             }
         }
     }
 }
    function html($sp)
    {
        ?>
	<div id="taskbar" class="lists-dashboard rounded group">
		<form id="subscriber-edit" method="post">
	<div style="float:right;" >
	<input type="submit" class="btn btn-primary btn-large " id="subscriber-save" value="<?php 
        _e('Save', 'sendpress');
        ?>
"/>
</div> 
		
	<h2><?php 
        _e('Edit Subscriber', 'sendpress');
        ?>
</h2>
	</div>
<?php 
        $sub = SendPress_Data::get_subscriber($_GET['subscriberID']);
        ?>
<div class="boxer">
	<div class="boxer-inner">
		<div class="spmedia">
			<div class="media-image">
		<?php 
        echo get_avatar($sub->email, $size = '96');
        ?>
		</div>
		<div class="media-body">
	
		<input type="hidden" name="listID" value="<?php 
        echo SPNL()->validate->int($_GET['listID']);
        ?>
" />
	    <input type="hidden" name="subscriberID" value="<?php 
        echo SPNL()->validate->int($_GET['subscriberID']);
        ?>
" />
	    <strong><?php 
        _e('Email', 'sendpress');
        ?>
</strong>: <input type="text" name="email" class="regular-text sp-text" value="<?php 
        echo $sub->email;
        ?>
" /><br><br>
	    <strong><?php 
        _e('Firstname', 'sendpress');
        ?>
</strong>: <input type="text" class="regular-text sp-text" name="firstname" value="<?php 
        echo $sub->firstname;
        ?>
" /><br><br>
	    <strong><?php 
        _e('Lastname', 'sendpress');
        ?>
</strong>: <input type="text" class="regular-text sp-text" name="lastname" value="<?php 
        echo $sub->lastname;
        ?>
" /><br>
	    <br>
<input type="checkbox" id="delete-this-user" name="delete-this-user" value="yes"/> Checking this box will remove this subscriber and all related data from the system.<br><br>

	  
	   <?php 
        wp_nonce_field($sp->_nonce_value);
        ?>

	
	</div></div>
	<?php 
        ?>

	<h3>Subscriptions</h3>
	<div class="well">
		<table class=" table table-bordered table-striped">
			<tr>
				<th>List Name</th>
				<th>Status</th>
			</tr>
			<?php 
        global $post;
        $args = array('post_type' => 'sendpress_list', 'post_status' => array('publish', 'draft'), 'posts_per_page' => 100, 'order' => 'ASC', 'orderby' => 'title');
        $postslist = get_posts($args);
        foreach ($postslist as $post) {
            setup_postdata($post);
            ?>
 
			
				<tr>
					<td><?php 
            the_title();
            ?>
</td>
					<td><?php 
            $info = SendPress_Data::get_subscriber_list_status($post->ID, $_GET['subscriberID']);
            if (isset($info) && $info !== false) {
                $cls = '';
                if ($info->statusid == 1) {
                    $cls = 'badge-warning';
                }
                if ($info->statusid == 2) {
                    $cls = 'badge-success';
                }
                if ($info->statusid == 3) {
                    $cls = 'badge-important';
                }
                if ($info->statusid == 4) {
                    $cls = 'badge-inverse';
                }
                echo "<span class='badge {$cls}'>&nbsp;</span> ";
                $this->status_select($info->statusid, $post->ID);
                $this->pn_select($_GET['subscriberID'], $post->ID);
            } else {
                echo '<span class="badge">&nbsp;</span> ';
                $this->status_select(0, $post->ID);
            }
            ?>
 </td>
				</tr>

			</div>
		<?php 
        }
        wp_reset_postdata();
        ?>
</table>


	
	    		 
</div>
</form>
<h3>Subscriber Actions and Events</h3>
	<div class="well">
		<?php 
        if (!defined("SENDPRESS_PRO_VERSION")) {
            _e('This feature requires SendPress Pro.', 'sendpress');
        } else {
            do_action('sendpress_subscriber_events_view', $_GET['subscriberID']);
        }
        ?>
	</div>

	


</div>
</div>



	<?php 
    }
 static function subscribe_user($listid, $email, $first, $last, $status = 2, $custom = array())
 {
     $success = false;
     $subscriberID = SendPress_Data::add_subscriber(array('firstname' => $first, 'lastname' => $last, 'email' => $email));
     //SendPress_Error::log($subscriberID);
     if (false === $subscriberID) {
         return false;
     }
     $args = array('post_type' => 'sendpress_list', 'numberposts' => -1, 'offset' => 0, 'orderby' => 'post_title', 'order' => 'DESC');
     $lists = get_posts($args);
     $listids = explode(',', $listid);
     $already_subscribed = false;
     if ($status == 2 && SendPress_Option::is_double_optin()) {
         $inlists = SendPress_Data::get_active_list_ids_for_subscriber($subscriberID);
         //SendPress_Error::log($inlists);
         if ($inlists) {
             $already_subscribed = true;
         } else {
             $status = 1;
             SendPress_Manager::send_optin($subscriberID, $listids, $lists);
         }
     }
     foreach ($lists as $list) {
         if (in_array($list->ID, $listids)) {
             $current_status = SendPress_Data::get_subscriber_list_status($list->ID, $subscriberID);
             if (empty($current_status) || isset($current_status->status) && $current_status->status < 2) {
                 $success = SendPress_Data::update_subscriber_status($list->ID, $subscriberID, $status);
             } else {
                 $success = true;
             }
             foreach ($custom as $key => $value) {
                 SendPress_Data::update_subscriber_meta($subscriberID, $key, $value, $list->ID);
             }
         }
     }
     if ($success == false) {
         return false;
     }
     return array('success' => $success, 'already' => $already_subscribed);
 }
 private static function handle_unsubscribes()
 {
     $_nonce_value = 'sendpress-is-awesome';
     $c = false;
     if (!empty($_POST) && check_admin_referer($_nonce_value)) {
         $args = array('meta_key' => 'public', 'meta_value' => 1, 'post_type' => 'sendpress_list', 'post_status' => 'publish', 'posts_per_page' => -1, 'ignore_sticky_posts' => 1);
         $my_query = new WP_Query($args);
         if ($my_query->have_posts()) {
             while ($my_query->have_posts()) {
                 $my_query->the_post();
                 $list_id = $my_query->post->ID;
                 if (isset($_POST['subscribe_' . $list_id])) {
                     $list_status = SendPress_Data::get_subscriber_list_status($list_id, $_POST['subscriberid']);
                     if (isset($list_status->status)) {
                         SendPress_Data::update_subscriber_status($list_id, $_POST['subscriberid'], $_POST['subscribe_' . $list_id]);
                     } elseif ($_POST['subscribe_' . $list_id] == '2') {
                         SendPress_Data::update_subscriber_status($list_id, $_POST['subscriberid'], $_POST['subscribe_' . $list_id]);
                     }
                 }
                 $c = true;
             }
         }
         //do_action('sendpress_public_view_manage_save', $_POST);
     }
     wp_reset_query();
     return $c;
 }
    static function load_page($attr, $content = null)
    {
        $action = get_query_var('spmanage');
        //Look for encrypted data
        $info = SendPress_Data::decrypt($action);
        //print_r( $info );
        ?>

<form action="" method="post">
<?php 
        wp_nonce_field(SendPress_Data::nonce());
        ?>
<input type="hidden" name="subscriberid" id="subscriberid" value="<?php 
        echo $info->id;
        ?>
" />
<input type="hidden" name="action" id="action" value="sendpress-manage-shortcode" />
<table cellpadding="0" cellspacing="0" class="table table-condensed table-striped table-bordered">
	<tr>
		<th  ><?php 
        _e('Subscribed', 'sendpress');
        ?>
</th>
		<th  ><?php 
        _e('Unsubscribed', 'sendpress');
        ?>
</th>
		<th  ><?php 
        _e('List', 'sendpress');
        ?>
</th>
		<th class="hidden-phone"><?php 
        _e('Updated', 'sendpress');
        ?>
</th>
		<th class="hidden-phone"><?php 
        _e('Other Info', 'sendpress');
        ?>
</th>
	</tr>
<?php 
        $lists = SendPress_Data::get_lists(apply_filters('sendpress_modify_manage_lists', array('meta_query' => array(array('key' => 'public', 'value' => true)))), false);
        foreach ($lists as $list) {
            $subscriber = SendPress_Data::get_subscriber_list_status($list->ID, $info->id);
            ?>
  	<tr>
  	<?php 
            $checked = isset($subscriber->statusid) && $subscriber->statusid == 2 ? 'checked' : '';
            echo '<td><input type="radio" class="xbutton" data-list="' . $list->ID . '" name="subscribe_' . $list->ID . '" ' . $checked . ' value="2"></td>';
            $checked = isset($subscriber->statusid) && $subscriber->statusid == 3 ? 'checked' : '';
            echo '<td><input type="radio" class="xbutton" data-list="' . $list->ID . '" name="subscribe_' . $list->ID . '" ' . $checked . ' value="3"></td>';
            ?>
  	<td><?php 
            echo $list->post_title;
            ?>
</td>
  	<td class="hidden-phone"><span id="list_<?php 
            echo $list->ID;
            ?>
"><?php 
            if (isset($subscriber->updated)) {
                echo $subscriber->updated;
            } else {
                _e('Never Subscribed', 'sendpress');
            }
            ?>
</span>
	</td>
	<td class="hidden-phone">
		<?php 
            if (is_object($subscriber)) {
                if ($subscriber->statusid != 3 && $subscriber->statusid != 2) {
                    echo $subscriber->status;
                }
            }
            ?>
	</td>
  	<tr>	
    <?php 
        }
        ?>

</table>
<br>
<?php 
        do_action('sendpress_manage_notifications', $info);
        ?>
<input type="submit" class="btn btn-primary" value="<?php 
        _e('Save My Settings', 'sendpress');
        ?>
"/>
</form><?php 
    }
Example #7
0
 function getSubscriberListsStatus($listID, $subscriberID)
 {
     _deprecated_function(__FUNCTION__, '0.8.9', 'SendPress_Data::get_subscriber_list_status($listID, $subscriberID)');
     return SendPress_Data::get_subscriber_list_status($listID, $subscriberID);
 }