You are viewing this forum as a guest. Login to an existing account, or create a new account, to reply to topics and to create new topics.
We did this as a hack for someone before. The trick is to add new email addresses to the mail list as they're read in in ./library/common/site_usr_define.pl.
At the bottom of the routine: site_update_user_cookie_info
add the lines:
### CUT
$fd_temp_pg = "$form_data{'pg'}";
if ($form_data_user_realname ne "" && $form_data_user_email ne "" && $fd_temp_pg !~ /maillist/) {
&site_user_add_maillist;
} ######### End of if statement.
### CUT
Right before the close of the last if statement in the routine. Then, add this routine to the bottom of the file:
### CUT
#######################################################################
# Sub Site User Add Maillist #
#######################################################################
sub site_user_add_maillist {
$address_found_in_maillist = "no";
$current_maillist_ref_no = "1";
@temp_lines = "";
open (FILE, "$data_path_maillist_data$current_maillist_ref_no.$data_ext");
flock (FILE, 2);
@lines = <FILE>;
close(FILE);
foreach $line(@lines){
($subscriber_ref_no,$subscriber_name,$subscriber_email) = split(/|/,$line);
chop($subscriber_email);
push(@subscriber_ref_no,$subscriber_ref_no);
} ######### End of foreach statement.
$highest_value = $subscriber_ref_no<$#subscriber_ref_no>;
$highest_value++;
$new_subscriber_ref_no = $highest_value;
foreach $line(@lines){
($subscriber_ref_no,$subscriber_name,$subscriber_email) = split(/|/,$line);
chop($subscriber_email);
if ($user_data_email eq "$subscriber_email") {
$address_found_in_maillist = "yes";
} else {
$temp_line = "$subscriber_ref_no|$subscriber_name|$subscriber_email";
push(@temp_lines,$temp_line);
} ######### End of if statement.
} ######### End of foreach statement.
if ($address_found_in_maillist eq "no") {
$temp_line = "$new_subscriber_ref_no|$user_data_realname|$user_data_email";
push(@temp_lines,$temp_line);
open (FILE, ">$data_path_maillist_data$current_maillist_ref_no.$data_ext");
flock (FILE, 2);
foreach $line(@temp_lines){
($subscriber_ref_no,$subscriber_name,$subscriber_email) = split(/|/,$line);
if ($line ne "" && $subscriber_ref_no ne ""){
print (FILE "$linen");
} ######### End of if statement.
} ######### End of foreach statement.
close(FILE);
@temp_lines = "";
open (FILE, "$maillist_db_file");
flock (FILE, 2);
@lines = <FILE>;
close(FILE);
foreach $line(@lines){
($maillist_ref_no,$maillist_name,$maillist_active,$maillist_subscriber_no,$maillist_description) = split(/|/,$line);
chop($maillist_description);
if ($current_maillist_ref_no eq "$maillist_ref_no") {
$maillist_subscriber_no++;
$temp_line = "$maillist_ref_no|$maillist_name|$maillist_active|$maillist_subscriber_no|$maillist_description";
push(@temp_lines,$temp_line);
} else {
$temp_line = "$maillist_ref_no|$maillist_name|$maillist_active|$maillist_subscriber_no|$maillist_description";
push(@temp_lines,$temp_line);
} ######### End of if statement.
} ######### End of foreach statement.
open (FILE, ">$maillist_db_file");
flock (FILE, 2);
foreach $line(@temp_lines){
($maillist_ref_no,$maillist_name,$maillist_active,$maillist_subscriber_no,$maillist_description) = split(/|/,$line);
if ($line ne "" && $maillist_ref_no ne ""){
print (FILE "$linen");
} ######### End of if statement.
} ######### End of foreach statement.
close(FILE);
} ######### End of if statement.
}
### CUT
That will add the user to the main (#1) maillist if they don't already subscribe to it. It works any time cookie info is updated and the email address and real name aren't blank. Hope that helps.
PS. In CCP5, this code would be in the ./library/modules/ste_usr.pl file and would consist of about 15 lines of code (including two SQL statements - one to figure out if the user is subscribed and the other to add them if they aren't subscribed).
Offline