PluginProbe
s2Member – Excellent for All Kinds of Memberships, Content Restriction Paywalls & Member Access Subscriptions / trunk
s2Member – Excellent for All Kinds of Memberships, Content Restriction Paywalls & Member Access Subscriptions vtrunk
260913 260909 260829 260814 260805 110710 110731 110812 110815 110912 110913 110915 110926 110927 111002 111003 111011 111017 111029 111105 111206 111216 111220 120213 120219 All 188 releases
s2member / src / includes / classes / aweber-e.inc.php

aweber-e.inc.php in s2Member – Excellent for All Kinds of Memberships, Content Restriction Paywalls & Member Access Subscriptions trunk, at src/includes/classes/aweber-e.inc.php

153 lines 6.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 // @codingStandardsIgnoreFile
3 /**
4 * AWeber (Old via Email)
5 *
6 * Copyright: © 2009-2011
7 * {@link http://websharks-inc.com/ WebSharks, Inc.}
8 * (coded in the USA)
9 *
10 * Released under the terms of the GNU General Public License.
11 * You should have received a copy of the GNU General Public License,
12 * along with this software. In the main directory, see: /licensing/
13 * If not, see: {@link http://www.gnu.org/licenses/}.
14 *
15 * @since 141004
16 * @package s2Member\List_Servers
17 */
18 if(!defined('WPINC')) // MUST have WordPress.
19 exit('Do not access this file directly.');
20
21 if(!class_exists('c_ws_plugin__s2member_aweber_e'))
22 {
23 /**
24 * AWeber (Old via Email)
25 *
26 * @since 141004
27 * @package s2Member\List_Servers
28 */
29 class c_ws_plugin__s2member_aweber_e extends c_ws_plugin__s2member_list_server_base
30 {
31 /**
32 * Subscribe.
33 *
34 * @since 141004
35 * @package s2Member\List_Servers
36 *
37 * @param array $args Input arguments.
38 *
39 * @return bool True if successful.
40 */
41 public static function subscribe($args)
42 {
43 if(!($args = self::validate_args($args)))
44 return FALSE; // Invalid args.
45
46 if(!$args->opt_in) // Double check.
47 return FALSE; // Must say explicitly.
48
49 if(empty($GLOBALS['WS_PLUGIN__']['s2member']['o']['level'.$args->level.'_aweber_list_ids']))
50 return FALSE; // No list configured at this level.
51
52 $aw_level_list_ids = $GLOBALS['WS_PLUGIN__']['s2member']['o']['level'.$args->level.'_aweber_list_ids'];
53
54 foreach(preg_split('/['."\r\n\t".'\s;,]+/', $aw_level_list_ids, -1, PREG_SPLIT_NO_EMPTY) as $_aw_list)
55 {
56 $_aw = array(
57 'args' => $args,
58 'function' => __FUNCTION__,
59 'list' => trim($_aw_list),
60 'list_id' => trim($_aw_list),
61 'api_method' => 'listSubscribe'
62 );
63 if(!$_aw['list']) continue; // List missing.
64
65 $_aw['bcc'] = apply_filters('ws_plugin__s2member_aweber_bcc', FALSE, get_defined_vars());
66 $_aw['pass_inclusion'] = apply_filters('ws_plugin__s2member_aweber_pass_inclusion', FALSE, get_defined_vars()) && $args->pass ? "\n".'Pass: '.$args->pass : '';
67
68 if($_aw['wp_mail_response'] = wp_mail($_aw['list_id'].'@aweber.com', // Converts to email address @aweber.com.
69 ($_aw['wp_mail_sbj'] = apply_filters('ws_plugin__s2member_aweber_sbj', 's2Member Subscription Request', get_defined_vars())), // These filters make it possible to customize these emails.
70 ($_aw['wp_mail_msg'] = apply_filters('ws_plugin__s2member_aweber_msg', 's2Member Subscription Request'."\n".'s2Member w/ PayPal Email ID'."\n".'Ad Tracking: s2Member-'.(is_multisite() && !is_main_site() ? $GLOBALS['current_blog']->domain.$GLOBALS['current_blog']->path : $_SERVER['HTTP_HOST'])."\n".'EMail Address: '.$args->email."\n".'Buyer: '.$args->name."\n".'Full Name: '.$args->name."\n".'First Name: '.$args->fname."\n".'Last Name: '.$args->lname."\n".'IP Address: '.$args->ip."\n".'User ID: '.$args->user_id."\n".'Login: '.$args->login.$_aw['pass_inclusion']."\n".'Role: '.$args->role."\n".'Level: '.$args->level."\n".'CCaps: '.$args->ccaps."\n".' - end.', get_defined_vars())),
71 ($_aw['wp_mail_headers'] = 'From: "'.preg_replace('/"/', "'", $GLOBALS['WS_PLUGIN__']['s2member']['o']['reg_email_from_name']).'" <'.$GLOBALS['WS_PLUGIN__']['s2member']['o']['reg_email_from_email'].'>'.($_aw['bcc'] ? "\r\n".'Bcc: '.$_aw['bcc'] : '')."\r\n".'Content-Type: text/plain; charset=UTF-8'))
72 ) $_aw['wp_mail_success'] = $success = TRUE; // Flag this as `TRUE`; assists with return value below.
73
74 c_ws_plugin__s2member_utils_logs::log_entry('aweber-api', $_aw);
75 }
76 unset($_aw_list, $_aw); // Just a little housekeeping.
77
78 return !empty($success); // If one suceeds.
79 }
80
81 /**
82 * Unsubscribe.
83 *
84 * @since 141004
85 * @package s2Member\List_Servers
86 *
87 * @param array $args Input arguments.
88 *
89 * @return bool True if successful.
90 */
91 public static function unsubscribe($args)
92 {
93 if(!($args = self::validate_args($args)))
94 return FALSE; // Invalid args.
95
96 if(!$args->opt_out) // Double check.
97 return FALSE; // Must say explicitly.
98
99 if(empty($GLOBALS['WS_PLUGIN__']['s2member']['o']['level'.$args->level.'_aweber_list_ids']))
100 return FALSE; // No list configured at this level.
101
102 $aw_level_list_ids = $GLOBALS['WS_PLUGIN__']['s2member']['o']['level'.$args->level.'_aweber_list_ids'];
103
104 $email_configs_were_on = c_ws_plugin__s2member_email_configs::email_config_status();
105 if(!$email_configs_were_on) c_ws_plugin__s2member_email_configs::email_config(); // MUST be ON for removal requests.
106 // `From:` address MUST match AWeber account. See: <http://www.aweber.com/faq/questions/62/Can+I+Unsubscribe+People+Via+Email%3F>.
107
108 foreach(preg_split('/['."\r\n\t".'\s;,]+/', $aw_level_list_ids, -1, PREG_SPLIT_NO_EMPTY) as $_aw_list)
109 {
110 $_aw = array(
111 'args' => $args,
112 'function' => __FUNCTION__,
113 'list' => trim($_aw_list),
114 'list_id' => trim($_aw_list),
115 'api_method' => 'listUnsubscribe'
116 );
117 if(!$_aw['list']) continue; // List missing.
118
119 $_aw['removal_bcc'] = apply_filters('ws_plugin__s2member_aweber_removal_bcc', FALSE, get_defined_vars());
120
121 if($_aw['wp_mail_response'] = wp_mail($_aw['list_id'].'@aweber.com', // Converts to email address @aweber.com.
122 ($_aw['wp_mail_sbj'] = apply_filters('ws_plugin__s2member_aweber_removal_sbj', 'REMOVE#'.$args->email.'#s2Member#'.$_aw['list_id'], get_defined_vars())), // Bug fix. AWeber does not like dots (possibly other chars) in the Ad Tracking field. Now using just: `s2Member`.
123 ($_aw['wp_mail_msg'] = 'REMOVE'), ($_aw['wp_mail_headers'] = 'From: "'.preg_replace('/"/', "'", $GLOBALS['WS_PLUGIN__']['s2member']['o']['reg_email_from_name']).'" <'.$GLOBALS['WS_PLUGIN__']['s2member']['o']['reg_email_from_email'].'>'.($_aw['removal_bcc'] ? "\r\n".'Bcc: '.$_aw['removal_bcc'] : '')."\r\n".'Content-Type: text/plain; charset=UTF-8'))
124 ) $_aw['wp_mail_success'] = $success = TRUE; // Flag this as `TRUE`; assists with return value below.
125
126 c_ws_plugin__s2member_utils_logs::log_entry('aweber-api', $_aw);
127 }
128 unset($_aw_list, $_aw); // Just a little housekeeping.
129
130 if(!$email_configs_were_on) // Turn them off now?
131 c_ws_plugin__s2member_email_configs::email_config_release();
132
133 return !empty($success); // If one suceeds.
134 }
135
136 /**
137 * Transition.
138 *
139 * @since 141004
140 * @package s2Member\List_Servers
141 *
142 * @param array $old_args Input arguments.
143 * @param array $new_args Input arguments.
144 *
145 * @return bool True if successful.
146 */
147 public static function transition($old_args, $new_args)
148 {
149 return self::unsubscribe($old_args) && self::subscribe($new_args);
150 }
151 }
152 }
153