1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
|
<?LassoScript
/****************************************************************************
Set up the 12all in type;
The 1-2All type allows several simple methods to interface with the 1-2All email marketing software. 1-2all maintains two tables, one for subscribes and one for unsubscribes. At this time the type supports on some simple options for subscribing and unsubscribing. I've left the tags in the type to output the SQL that's generated, so you might want to remove them after you are done testing. Also a couple of the parameters have some foreign key in the nl column, which could be the list ID, test your subscriptions and find out what real subscriptions look like in your SQL tables and adjust. The ID also returns an array if the email address is in the 1-2all system more than once. Emails are non distinct in 1-2all as the user tables can contain a foreign key for different lists that address is subscribed to
*****************************************************************************/
define_type(
'12all',
-prototype,
-description='Lasso wrapper for the 12all mailer.'
);
define_tag(
'_unknowntag',
-encodenone
);
/define_tag;
define_tag:'email', -optional='email';
return: #email;
/define_tag;
/****************************************************************************
This checks the 12all subscribed table for instances of the email address
*****************************************************************************/
define_tag:'id_from_email_subscribed', -required='email';
local('ids_from_email')=array;
inline: $dbconn2, -table='12all_listmembers', -op='EQ', 'email'=#email, -Search;
rows;
#ids_from_email->insert(column('id'));
/rows;
return: #ids_from_email;
/inline;
/define_tag;
/****************************************************************************
This checks the 12all unsubscribed table for instances of the email address
*****************************************************************************/
define_tag:'id_from_email_unsubscribed', -required='email';
local('ids_from_email')=array;
inline: $dbconn2, -table='12all_listmembersu', -op='EQ', 'em'=#email, -Search;
rows;
#ids_from_email->insert(column('id'));
/rows;
return: #ids_from_email;
/inline;
/define_tag;
/****************************************************************************
Is in subscribed can return one or zero
*****************************************************************************/
define_tag:'is_subscribed', -required='email';
inline: $dbconn2, -table='12all_listmembers', -op='EQ', 'email'=#email, -Search;
//return: found_count; return:action_statement;
(found_count > 0) ?
return:1 | return:0;
/inline;
/define_tag;
/****************************************************************************
Is in unsubscribed can return one or zero
*****************************************************************************/
define_tag:'is_unsubscribed', -required='email';
inline: $dbconn2, -table='12all_listmembersu', -op='EQ', 'em'=#email, -Search;
(found_count > 0) ?
return:1 | return:0;
/inline;
/define_tag;
/****************************************************************************
Subscribe a Person to 12all
*****************************************************************************/
define_tag:'subscribe', -required='email', -required='name';
local('result_string'=string);
//return: self->is_subscribed(#email);
inline($dbconn2);
if(self->is_unsubscribed(#email) == 1);
local('listmemberu_del') = (autoctype(-table='12all_listmembersu',-id=(self->(id_from_email_unsubscribed(#email)->first))));
#listmemberu_del->delete;
#result_string += #listmemberu_del->code;
/if;
if(self->is_subscribed(#email) != 1);
local('listmember') = (autoctype(-table='12all_listmembers'));
#listmember->sip='Synced';
#listmember->comp='Synced';
#listmember->sdate=(date_format:date,-format='%Q');
#listmember->email=#email;
#listmember->name=#name;
#listmember->bounced=0;
#listmember->soft_bounced=0;
#listmember->bounced_d='0000-00-00';
#listmember->active=0;
#listmember->nl=5;
#listmember->stime=(date_format:date,-format='%T');
#listmember->respond='';
#listmember->last_send=0;
#listmember->no_autoresponders=0;
#listmember->sync=1;
#listmember->subscription_form_id=0;
#listmember->save;
#result_string += #listmember->code;
/if;
/inline;
if(#result_string != '');
return: #result_string;
else;
return(false);
/if;
/define_tag;
/****************************************************************************
Unsubscribe a Person to 12all
*****************************************************************************/
define_tag:'unsubscribe', -required='email';
local('result_string'=string);
inline($dbconn2);
if(self->is_subscribed(#email) == 1);
local('listmember_del') = (autoctype(-table='12all_listmembers',-id=(self->(id_from_email_subscribed(#email)->first))));
#listmember_del->delete;
#result_string += #listmember_del->code;
/if;
if(self->is_unsubscribed(#email) != 1);
local('listmemberu') = (autoctype(-table='12all_listmembersu'));
#listmemberu->em=#email;
#listmemberu->reason=1;
#listmemberu->nl=5;
#listmemberu->date=(date_format:date,-format='%Q %T');
#listmemberu->date_subscribed=(date_format:date,-format='%Q');
#listmemberu->reason='';
#listmemberu->mesg_id='';
#listmemberu->respond_id='';
#listmemberu->b=0;
#listmemberu->time_subscribed=(date_format:date,-format='%T');
#listmemberu->subscribe_ip='';
#listmemberu->save;
#result_string += #listmemberu->code;
/if;
/inline;
if(#result_string != '');
return: #result_string;
else;
return(false);
/if;
/define_tag;
/define_type;
?>
|
Requires autoctype
Looking through the code, it looks as if it relies on autoctype - this is listed as related but should be noted in the comments or description, or maybe add a -critera in an oncreate().