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: rand_poll_box 1.00

Author: schmolli [Info]

Description:

Basically the same idea as poll_box, except the poll displayed is selected randomly. Section permissions and list_polls perm are respected. Form creation code was largely stolen from the stock poll_box.

Box Code:

# users with list_polls priv get to see all polls
# everybody else only gets to see polls from sections that they have
# read access to, not including diaries
my $where = "s.displaystatus <= 1 AND s.displaystatus >= ";
if($S->have_perm('list_polls')) {
$where .= '-3';
} else {
$where .= '0';

# build a list of sections that this user can see and add a clause to
# $where to limit selection to those polls
my ($rv, $sth) = $S->db_select({
WHAT => 'section',
FROM => 'sections',
});
$rv or return 0;

# this is just a slight optimization to keep the number of conditions
# in $where to a minimum (is this a useful thing to do?)
my (@acc, @noacc, $secwhere);
while(my $sec = $sth->fetchrow_hashref) {
if($S->have_section_perm('norm_read_stories', $sec->{'section'}) and $sec->{'section'} ne "Diary") {
push @acc, $sec->{'section'};
} else {
push @noacc, $sec->{'section'};
}
}
$secwhere = ($#acc/2) >= $#noacc
? join(" AND ", map { 's.section != ' . $S->{DBH}->quote($_) } @noacc)
: join(" OR ", map { 's.section = ' . $S->{DBH}->quote($_) } @acc);
$where = "$where AND ( $secwhere )" if $secwhere;

$sth->finish();
}

$where = "s.attached_poll != '' AND $where";
$where .= ' AND s.attached_poll = p.qid';

my ($rv, $sth) = $S->db_select({
WHAT => 'p.qid, p.question, p.voters, p.post_date',
FROM => 'stories s, pollquestions p',
WHERE => "$where",
ORDER_BY => 'rand()',
LIMIT => 1,
});
$rv or return 0;

my $poll = $sth->fetchrow_hashref or return 0;
$sth->finish();

# first get the poll form all set up except for the answers
my $form = qq\|
<!-- begin poll form -->
<FORM ACTION="|rootdir|/" METHOD="POST">
<INPUT TYPE="hidden" NAME="op" VALUE="view_poll">
<INPUT TYPE="hidden" NAME="qid" VALUE="$poll->{'qid'}">
<INPUT type="hidden" name="ispoll" value="1">\|;

$form .= "<b>$poll->{'question'}</b><br>";

# here is where all the answer fields get filled in
my $qid = $S->{DBH}->quote($poll->{'qid'});
($rv, $sth) = $S->db_select({
WHAT => "qid,aid,answer,votes",
FROM => 'pollanswers',
WHERE => "qid = $qid",
ORDER_BY => "aid ASC",
});
$rv or return 0;
my $answer = [];
while(my $ans = $sth->fetchrow_hashref) { push @{$answer}, $ans }
$sth->finish();

# now check if they have already voted or haven't logged in
my $row;
if ( $S->_can_vote($poll->{'qid'}) ) {
foreach $row ( @{$answer} ) {
$form .= qq\|
<INPUT TYPE="radio" NAME="aid" VALUE="$row->{'aid'}"> $row->{'answer'}<BR>\|;
}
} else {
my $total_votes = $poll->{'voters'} ? $poll->{'voters'} : 1;
$form .= qq\|
<TABLE BORDER=0 CELLPADDING=2 CELLSPACING=0>\|;

foreach $row ( @{$answer} ) {
my $percent = int($row->{'votes'} / $total_votes * 100);
$form .= qq\|
<TR>
<TD valign="top">|norm_font||dot||norm_font_end|</TD>
<TD valign="top">|norm_font|$row->{'answer'}|norm_font_end|</TD>
<TD valign="top">|norm_font| $percent% |norm_font_end|</TD>
</TR>\|;
}
$form .= qq\|
</TABLE>\|;
}

# get the # of comments
my $comment_num = $S->poll_comment_num($poll->{'qid'});

# only show the vote button if they havn't voted
if ( $S->_can_vote($poll->{'qid'}) ) {
$form .= qq\|<BR><INPUT TYPE="submit" name="vote" VALUE="Vote">\|;
}


# now finish up the form
my $op = $S->{CGI}->param('op');
my $comm_disp = ($op ne 'displaystory')
? qq{
<TD>|norm_font|Votes: <b>$poll->{'voters'}</b>|norm_font_end|</TD>
<TD ALIGN="center" WIDTH=15>|norm_font|\||norm_font_end|</TD>
<TD ALIGN="right">|norm_font| Comments: <b>$comment_num</b>|norm_font_end|</TD>}
: qq{
<TD COLSPAN="3" ALIGN="center">|norm_font|Votes: <b>$poll->{'voters'}</b>|norm_font_end|</TD>};

$form .= qq{
</FORM>
<!-- end poll form -->
<P>
|norm_font|
<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 ALIGN="center">
<TR>
$comm_disp
</TR>
<TR>
<TD>|norm_font|<a href="|rootdir|/poll/$poll->{'qid'}">Results</a>|norm_font_end|</TD>
<TD ALIGN="center" WIDTH=15>|norm_font|\||norm_font_end|</TD>
<TD ALIGN="right">|norm_font| <a href="|rootdir|/?op=search;type=polls;search=Search">Other Polls</a>|norm_font_end|</TD>
</TR>
</TABLE>
|norm_font_end|
<!-- end poll content -->};

return '' unless $form;
return {content => qq{|norm_font|$form|norm_font_end|}, title => $title};
Display: Sort:
Carolyn Turner (none / 0) (#1)
by zacharymorgan on Fri Mar 30, 2018 at 08:32:23 AM PST

It is moreover an outstanding release we actually liked going through. It isn't really day-to-day i develop the chance to discover anything. Powerful 2018 SEO



janice owens (none / 0) (#2)
by zacharymorgan on Tue May 01, 2018 at 03:57:55 AM PST

There are many dissertation websites from the web stay get not surprisingly recognized within the web sites. 1xbet



juanlarson (none / 0) (#3)
by zacharymorgan on Tue May 08, 2018 at 02:23:54 AM PST

That'sthe reason advertising and marketing that you suitable homework in advance of crafting. It is also possible to jot down improved posting with this. labels



Carolyn Turner (none / 0) (#4)
by zacharymorgan on Mon May 14, 2018 at 12:51:35 AM PST

There are specific dissertation web-sites by way of the web to produce safe apparently documented inside your website. offshore hosting



juanlarson (none / 0) (#5)
by zacharymorgan on Sat May 19, 2018 at 06:25:17 AM PST

Automatically your blog can indisputably quite often come to be famous on the subject of nearly every one of web page consumers, resulting from fastidious assessments together with checks. professional moving and storage google



Eyan (none / 0) (#6)
by davidqq on Wed May 23, 2018 at 02:08:17 AM PST

It certainly possibly even a fairly good create which the reality is certainly cherished checking out. Not necessarily inevitably ordinary which include the choice to figure out an individual item. checkpoints near me



  • ad by cicogyj, 03/07/2021 11:49:03 AM PST (none / 0)
Kevin Barnett (none / 0) (#7)
by davidqq on Fri May 25, 2018 at 03:08:38 PM PST

It happens to be additionally a brilliant write-up i positively relished reading through. It certainly is not consequently day-to-day i establish time to locate things. https://www.myezbz.com/business/toronto-on/ross-taylor-and-associates/r_761405



Lopigo (none / 0) (#8)
by mubashirkhatri on Wed May 30, 2018 at 10:53:01 AM PST

I think this is one of the most significant information for me. And i'm glad reading your article. But should remark on some general things, The web site style is perfect, the articles is really great : D. Good job, cheers best Samsung tempered glass



asdasd (none / 0) (#9)
by mubashirkhatri on Thu May 31, 2018 at 07:11:04 AM PST

Thanks for your post. I've been thinking about writing a very comparable post over the last couple of weeks, I'll probably keep it short and sweet and link to this instead if thats cool. Thanks. som ambiente wi fi residencial



sohail khatri (none / 0) (#10)
by mubashirkhatri on Sat Jun 02, 2018 at 09:09:47 AM PST

i am always looking for some free stuffs over the internet. there are also some companies which gives free samples. Car



Carolyn Turner (none / 0) (#11)
by zacharymorgan on Mon Jun 04, 2018 at 07:46:32 AM PST

Document gift should never page. It is typically pretty decent to find out just about anyone teach you for sayings on the cardiovascular exercise using lucidity for the imperative subject will be fairly quickly personally seen. Tripps Travel Network



Thomas (none / 0) (#12)
by davidqq on Fri Jun 08, 2018 at 07:24:19 AM PST

I adore each strings, That i savored, It's safe to really love a great deal more material utilizing this type of, due to the fact it is actually extremely relaxing., Thankyou just for getting. http://proud2bme.org/users/askross



great post (none / 0) (#13)
by harry12 on Tue Jul 03, 2018 at 12:52:45 PM PST

Hello, this weekend is good for me, since this time i am reading this enormous informative article here at my home. Nude



great post (none / 0) (#14)
by harry12 on Tue Jul 03, 2018 at 12:53:26 PM PST

Hello, this weekend is good for me, since this time i am reading this enormous informative article here at my home. Nude



New to the area (none / 0) (#15)
by ashlydonovan on Mon Jul 16, 2018 at 01:30:14 PM PST

Great article while I research the content. I'm impressed with your work and skill. Thank you so much Holidays Lounge



Seo master (none / 0) (#16)
by jamesjack9 on Wed Jul 18, 2018 at 07:02:50 AM PST

thanks for this usefull article, waiting for this article like this again. natural breast enlargement



Re: Liquor outlets ordered to close on April 08, 0 (none / 0) (#17)
by mubashirkhatri on Sun Aug 05, 2018 at 01:50:55 PM PST

I got what you mean , thanks for posting .Woh I am happy to find this website through google. janitorial



Re: Liquor outlets ordered to close on April 08, 0 (none / 0) (#18)
by mubashirkhatri on Mon Aug 06, 2018 at 07:50:13 AM PST

Thanks for another excellent post. Where else could anybody get that type of info in such an ideal way of writing? In my opinion, my seeking has ended now. home cleaning



Re: Liquor outlets ordered to close on April 08, 0 (none / 0) (#19)
by mubashirkhatri on Sun Aug 26, 2018 at 11:09:36 AM PST

An interesting dialogue is price comment. I feel that it is best to write more on this matter, it may not be a taboo topic however usually individuals are not enough to talk on such topics. To the next. Cheers. climatizador de ar



Best med university (none / 0) (#20)
by jeangaray on Wed Sep 05, 2018 at 02:15:48 AM PST

I was looking at some of your posts on this website and I conceive this web site is really instructive! Keep putting up.. Best med university



Great articles and great (none / 0) (#21)
by mubashirkhatri on Thu Nov 01, 2018 at 05:01:20 AM PST

i love this text for the adeptly-researched content and notable wording. I got for that excuse practicing in this cloth that I couldnt decrease studying. i'm impressed once your fulfillment out and present. thank you correctly a good deal. resultados quiniela



altopdftoword.com (none / 0) (#22)
by AnaMattice on Mon Nov 04, 2019 at 05:40:23 AM PST

Bro, you are one of my favorite writers of all time! Stating that, I want to know if you can write an article on altopdftoword.com or not. I trust you a lot, and I don't want you to let me down, so please publish an article on this.



2020 takvimi (none / 0) (#23)
by AnaMattice on Mon Dec 23, 2019 at 01:48:39 AM PST

I haven't any word to value this post.....Really i am awed from this post....the individual who make this post it was an extraordinary human..thanks for imparted this to us. 2020 takvimi



Airport (none / 0) (#24)
by AnaMattice on Mon Dec 23, 2019 at 09:30:47 AM PST

TaxiOne propose une plate-forme sur le web depuis laquelle il est possible de réserver un taxi. Nous sommes spécialisés dans les navettes aéroports, gares depuis ou vers hotels et domiciles. Il y a différents modčles les de taxi, le minibus de luxe pour les businessmans, les vip ou tout simplement ceux qui aiment le maximum de confort et classe, ensuite, il y a le minibus normale pour n'importe quel réservation qui sera proposé ŕ moindre tarif que le minibus vip, mais qui a un quand męme me un confort de véhicule de dernier cris permettant d'accueillir un jusqu'ŕ 8 personnes et pour finir le modčle berline qui peut accueillir jusqu'ŕ 4 personnes avec un max de confort aussi car tout les véhicules ont moins de 7 ans. Airport



APPSC Jr Lecturer Selection process (none / 0) (#25)
by AnaMattice on Tue Dec 24, 2019 at 03:07:34 AM PST

Andhra Pradesh Public Service Commission APPSC Jr Lecturer Selection process has Going to Announce Notification for Recruitment of Junior Lecturer In A.P. ... The information Regarding Age Limit / Educational Qualification / Selection Process / how to apply / Application fee / and Other Details of APPSC Degree ...



Phone unlocking Bournemouth (none / 0) (#26)
by AnaMattice on Thu Dec 26, 2019 at 12:47:07 AM PST

This is exactly what I was looking for. Thanks for sharing this great article! That is very interesting Smile I love reading and I am always searching for informative information like this! Phone unlocking Bournemouth



Royalgreen (none / 0) (#27)
by AnaMattice on Thu Dec 26, 2019 at 07:00:58 AM PST

Thanks for the nice blog. It was very useful for me. I'm happy I found this blog. Thank you for sharing with us,I too always learn something new from your post. Royalgreen



Midwood (none / 0) (#28)
by AnaMattice on Sat Dec 28, 2019 at 02:17:53 AM PST

Nicely well-written article. It was an awesome article to read. Complete rich content and fully informative Midwood



good (none / 0) (#29)
by AnaMattice on Sun Dec 29, 2019 at 07:01:22 AM PST

I haven't any word to value this post.....Really i am awed from this post....the individual who make this post it was an extraordinary human..thanks for imparted this to us. طريقة تداول الاسهم للمبتدئين



gay photographer (none / 0) (#30)
by AnaMattice on Sun Dec 29, 2019 at 08:28:25 AM PST

To say the truth I am very impressed by what you told. You share tons of interesting info, neat and excellent design you've got here. It's certainly one of the most informative stuff on this topic I've ever read. gay photographer



Best Shower squeegee (none / 0) (#31)
by AnaMattice on Mon Dec 30, 2019 at 01:09:43 AM PST

This is exactly what I was looking for. Thanks for sharing this great article! That is very interesting Smile I love reading and I am always searching for informative information like this! Best Shower squeegee



jardin de fiestas en cancun (none / 0) (#32)
by AnaMattice on Mon Dec 30, 2019 at 06:12:51 AM PST

You have done a great job on this article. It's very readable and highly intelligent. You have even managed to make it understandable and easy to read. You have some real writing talent. Thank you jardin de fiestas en cancun



youtube comments (none / 0) (#33)
by AnaMattice on Tue Dec 31, 2019 at 05:06:43 AM PST

The web site is lovingly serviced and saved as much as date. So it should be, thanks for sharing this with us. youtube comments



amber park condo (none / 0) (#34)
by AnaMattice on Wed Jan 01, 2020 at 06:55:02 AM PST

This is some thing very informative and point to point. There is no round and round in this article. Like this smplicity . This clears my old point of view. THANKS amber park condo



treasure at tampines showflat (none / 0) (#35)
by AnaMattice on Wed Jan 01, 2020 at 07:18:08 AM PST

Thanks for sharing this quality information with us. I really enjoyed reading. Will surely going to share this URL with my friends treasure at tampines showflat



Roofers (none / 0) (#36)
by AnaMattice on Thu Jan 02, 2020 at 06:59:49 AM PST

You have done a great job on this article. It's very readable and highly intelligent. You have even managed to make it understandable and easy to read. You have some real writing talent. Thank you Roofers



The Avenir Condo (none / 0) (#37)
by AnaMattice on Tue Jan 07, 2020 at 01:40:28 AM PST

This is some thing very informative and point to point. There is no round and round in this article. Like this smplicity . This clears my old point of view. THANKS The Avenir Condo



good (none / 0) (#38)
by AnaMattice on Wed Feb 26, 2020 at 12:21:56 PM PST

Thank you for sharing this code with us today. I will use this code in my https://www.goodreads.com/user/show/109698631-monika-gehts project very soon. If you hadn't shared this code, my project would remain incomplete.



good (none / 0) (#41)
by AnaMattice on Sat Mar 28, 2020 at 10:48:54 AM PST

Remarkable article, it is particularly useful! I quietly began in this, and I'm becoming more acquainted with it better! Delights, keep doing more and extra impressive! https://caldwells.com/care_handling



asdasd (none / 0) (#43)
by Muneer1 on Sun Dec 20, 2020 at 10:02:28 AM PST

I am extremely delighted in for this web journal. Its a useful subject. It help me all that much to take care of a few issues. Its chance are so awesome and working style so rapid. Europa-Road traktor szállítás



thank (none / 0) (#44)
by jonesKierraa on Wed Dec 23, 2020 at 08:57:19 PM PST

Ahh that is incredible bless your heart! Useful for extraordinary requirements as well! hole io



asdasd (none / 0) (#45)
by Muneer1 on Sat Dec 26, 2020 at 06:49:32 AM PST

Pretty good post. I just stumbled upon your blog and wanted to say that I have really enjoyed reading your blog posts. Any way I'll be subscribing to your feed and I hope you post again soon. Big thanks for the useful info belföldi fuvarozás



asdas (none / 0) (#46)
by nacaj on Sun Dec 27, 2020 at 02:33:24 AM PST

I was surfing net and fortunately came across this site and found very interesting stuff here. Its really fun to read. I enjoyed a lot. Thanks for sharing this wonderful information. visit here



asdd (none / 0) (#47)
by nacaj on Sat Jan 02, 2021 at 05:41:42 PM PST

very interesting post.this is my first time visit here.i found so many interesting stuff in your blog especially its discussion..thanks for the post! mehr Abonnenten auf instagram



assad (none / 0) (#48)
by nacaj on Sun Jan 03, 2021 at 09:55:57 AM PST

I am very enjoyed for this blog. Its an informative topic. It help me very much to solve some problems. Its opportunity are so fantastic and working style so speedy. iluminaçăo controlo



asdasd (none / 0) (#49)
by nacaj on Mon Jan 04, 2021 at 12:26:01 PM PST

I have bookmarked your blog, the articles are way better than other similar blogs.. thanks for a great blog! online marketing



adasd (none / 0) (#50)
by Muneer1 on Mon Jan 11, 2021 at 06:34:41 AM PST

I'm constantly searching on the internet for posts that will help me. Too much is clearly to learn about this. I believe you created good quality items in Functions also. Keep working, congrats! Fókuszpályázat



assad (none / 0) (#51)
by nacaj on Sun Jan 17, 2021 at 08:29:18 AM PST

Thanks for taking the time to discuss this, I feel strongly about it and love learning more on this topic. rubbish removal bridgend



asddasdsadasd (none / 0) (#52)
by nacaj on Sun Jan 17, 2021 at 10:35:18 AM PST

I really enjoyed reading this post, big fan. Keep up the good work and please tell me when can you publish more articles or where can I read more on the subject? removals hartlepool



asdsa (none / 0) (#53)
by nacaj on Sun Jan 31, 2021 at 11:49:30 AM PST

You have a real ability for writing unique content. I like how you think and the way you represent your views in this article. I agree with your way of thinking. Thank you for sharing. Cozumel



assad (none / 0) (#54)
by nacaj on Wed Feb 03, 2021 at 09:14:28 AM PST

I really loved reading your blog. It was very well authored and easy to understand. Unlike other blogs I have read which are really not that good.Thanks alot! آموزش سیستم هوشمند



trip to chernobyl (none / 0) (#55)
by Muneer1 on Wed Feb 03, 2021 at 11:01:36 AM PST

It can be practically unattainable to come across well-updated readers on this area, trip to chernobyl



asdsad (none / 0) (#56)
by nacaj on Wed Feb 17, 2021 at 06:27:23 AM PST

I really thank you for the valuable info on this great subject and look forward to more great posts. Thanks a lot for enjoying this beauty article with me. I am appreciating it very much! Looking forward to another great article. Good luck to the author! All the best! pályázatírás Debrecen jelentős tapasztalattal



wsdw (none / 0) (#57)
by cicogyj on Sun Feb 21, 2021 at 11:01:03 AM PST

this is really nice to read..informative post is very good to read..thanks a lot! best smm panel



wsdw (none / 0) (#58)
by cicogyj on Sun Feb 21, 2021 at 11:01:45 AM PST

this is really nice to read..informative post is very good to read..thanks a lot! cheap smm panel



wsdw (none / 0) (#59)
by cicogyj on Sun Feb 21, 2021 at 11:16:11 PM PST

This is my first time visit here. From the tons of comments on your articles,I guess I am not only one having all the enjoyment right here! cenote a tulum



asdas (none / 0) (#60)
by nacaj on Wed Feb 24, 2021 at 06:22:19 AM PST

This is just the information I am finding everywhere. Thanks for your blog, I just subscribe your blog. This is a nice blog.. rumah pintar



asdsad (none / 0) (#61)
by nacaj on Tue Mar 02, 2021 at 05:31:12 AM PST

I can see that you are an expert at your field! I am launching a website soon, and your information will be very useful for me.. Thanks for all your help and wishing you all the success in your business. kifejezetten olcsó ügyvéd Debrecen



wsdw (none / 0) (#62)
by cicogyj on Wed Mar 03, 2021 at 04:04:09 AM PST

Thank you very much for the sharing! COOL.. best restaurant cozumel



ad (none / 0) (#63)
by cicogyj on Thu Mar 04, 2021 at 07:46:06 AM PST

Very nice article, I enjoyed reading your post, very nice share, I want to twit this to my followers. Thanks!. best snorkeling in cozumel



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