Scoop -- the swiss army chainsaw of content management
Front Page Everything News Code Help! Wishlist Project Scoop Sites Dev Notes Latest CVS changes Development Activities
Scoop Box Exchange - Show Box: queue_digest 1.01

Author: janra [Info]

Description:

oops, tiny bug in 1.00 that kept it from finding subscribers to email...

Box Code:

my @date = localtime();

# get user list
my $where = "userprefs.prefname = 'queue_digest' AND userprefs.uid = users.uid AND userprefs.prefvalue = 'on'";

my ($rv, $sth) = $S->db_select({
WHAT => "userprefs.uid, userprefs.prefvalue, users.realemail, users.nickname",
FROM => "userprefs, users",
WHERE => $where
});

my @users;
while (my($uid, $prefvalue, $email, $nick) = $sth->fetchrow()) {
push(@users, {uid => $uid, nick => $nick, email => $email});
}
$sth->finish();

# Get digest contents
my $rollback = 60 * 24;
# one day; no weekly option for the queue

my $data = "";
my $excl_sql = $S->excluded_from_all_stories();


my ($rv, $sth) = $S->db_select({
FROM => 'stories LEFT JOIN users ON stories.aid = users.uid',
WHAT => 'sid, tid, aid, users.nickname AS nick, time, title, dept, introtext, section',
WHERE => "displaystatus = '-2' $excl_sql AND time >= DATE_SUB(NOW(), INTERVAL $rollback minute)",
ORDER_BY => 'time desc'
});

while (my $storydata = $sth->fetchrow_hashref()) {
$storydata->{nick} = $S->{UI}->{VARS}->{anon_user_nick} if $storydata->{aid} == -1;
$data .= $S->_cron_digest_format_stories($storydata);
warn "(queue_digest) sending story $storydata->{title}";
}
$sth->finish();

return 1 unless $data;
# no emails sent if no stories return

my $header = $S->{UI}->{BLOCKS}->{queue_digest_header} \|\| $S->{UI}->{BLOCKS}->{queue_digest_headerfooter};
my $footer = $S->{UI}->{BLOCKS}->{queue_digest_footer} \|\| $S->{UI}->{BLOCKS}->{queue_digest_headerfooter};
my $mail = join("\n\n",$header,$data,$footer);

my $errors;
foreach my $user (@users) {
# send each user the email
my $usermail = $S->interpolate($mail,$user);
my $ret = $S->mail($user->{email}, $S->{UI}->{BLOCKS}->{queue_digest_subject}, $usermail);
$errors .= $ret if ( $ret != 1 );
}

return $errors if $errors;
return 1;
Display: Sort:
Code (none / 0) (#1)
by Brian64 on Thu Jun 18, 2020 at 09:15:48 AM PST

Healthcare Solutions are the one who providing us the free codes which all developers and coders can use easily any time. I choose the best writing services where it's easier for me to know more about it.



Menu
create account
faq
search
report bugs
Scoop Administrators Guide
Scoop Box Exchange

Scoop Site Scroller: Get one yourself!
Kuro5hin.org
Cooler than Adequacy.org

Login
Make a new account
Username:
Password:

Hosted by ScoopHost.com Powered by Scoop
All trademarks and copyrights on this page are owned by their respective companies. Comments are owned by the Poster. The Rest 1999 The Management

create account | faq | search