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.00

Author: janra [Info]

Description:

This provides the functionality of the story digests but only for stories in the edit and voting queues.

It requires a user pref named queue_digest which is a checkbox, and should use the Site Control 'enable_story_digests' and the perm 'moderate' for both view and edit (especially if your site restricts voting in the queue to a subset of registered users).

It requires the following blocks: queue_digest_subject, queue_digest_header, queue_digest_footer. You can optionally use queue_digest_headerfooter instead of the previous two if you want the header and footer to be identical. I suggest modelling the blocks after the digest_* blocks, as that's what I copied when creating this box.

Box Code:

my @date = localtime();

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

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->var('anon_user_nick') if $storydata->{aid} == -1;
$data .= $S->_cron_digest_format_stories($storydata);
}
$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!
Satanosphere
/* You are not expected to understand this. */

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