Page 1 of 1

Polls Module

Posted: Mon Apr 04, 2005 10:31 am
by brownrl
Thanks to the nice tutorial and new module API making my first module for CMS MS was ^simple^.

http://www.hostlounge.be/Polls.zip

This is very small and it is a version .01.

This will only give some basic poll functionality. Ballot stuffing is blocked via a $_SESSION var which should keep your polls for the most part honest. If some one does ballot stuff with a script then the number of votes can be changed in the admin system.

Adjust the code and smarty tpl's for your liking. "Vote" "Total Votes:" etc...

I will post updates to here as needed when I do some more coding on it. If you have some ideas or changes let me know through here and I will integrate them in.

Peace!
Rob

Re: Polls Module

Posted: Mon Sep 05, 2005 3:25 am
by perl4ever
I'm in need of a poll module - and I just tried yours.  I am using CMSMS 0.10 (latest?) and while it plugs into the admin Extensions : Modules menu, and allows me to create a new poll, I cannot edit it.  And, when I display it on the site, I get {cache} type tags showing up, and broken pages.

So, is this compatible with the latest CMSMS, and, if not, what should I look for to fix?  Or, is there a newer/better poll module available?

Thanks.

Re: Polls Module

Posted: Wed Sep 21, 2005 12:13 am
by brownrl
Anyone with perl in their name atleast deserves a reply ;)

The poll module I think was developed under the old orange admin interface .09 versions.

I have no idea if it works these days and judging by your post probably not.

Essentially, it was made as a super simple module. Made in one evening.

At present time I am on a contract for another project. When I am back home, I will go to my dev server and fish it out. Rebuild it!

I really think that this thing is the most simpliest solution.

Read through the code a bit, I try to write cleanly, but be advised that this was the absolute first module that I ever wrote for CMS MS.

There should be two tables: polls, poll_options

The back end manages the two tables, polls should have a quasi mysql one to many relationship with poll_options and the admin backend should manage that.

I think that the cache tag errors occur because the back end of the module was using smarty and I think that API was changed between .09 and .1. Additionally, I think moduleinterface.php on the front side of CMS MS play differently now than before. Also make sure that when you use it, it should be something like this if I remember correctly:

{cms_module module="Polls" poll_id="x"} where x is the poll_id in the polls table.

I know that I have a still working version on my internal dev server which as I said when I get back in October will go through.

if you get it working let me know please. It probably just has to be calmly re-written for version .1

Good luck will update soon.


 

Re: Polls Module

Posted: Thu Sep 22, 2005 12:04 pm
by Lennynero
Nice module, though I had to make some changes:

1st: in polls.module.php I had to replace "poll_option_poll_alias" with "poll_option_alias" (maybe a change of the dbase would be another solution).

Furthermore I added the following lines just after the start of "showEditPollForm":
[php]
        if (isset ($_GET['m1_poll_alias']))
        {
            $get_post_alias = "WHERE poll_alias = '".$_GET['m1_poll_alias']."' ";
        }
        elseif (isset ($_POST['m1_poll_alias']))
        {
            $get_post_alias = "WHERE poll_alias = '".$_POST['m1_poll_alias']."' ";
        }/**/
       
$db = $this->cms->db;
$query = "SELECT * FROM ".cms_db_prefix().'module_polls'." LEFT JOIN ".cms_db_prefix().'module_poll_options'." ON poll_option_alias = poll_alias ".$get_post_alias." ORDER BY poll_option_id";
[/php]
Otherwise the "update" and "insert" Option functions would lead to a screen showing all polls.


Apart from that: nice module!

Re: Polls Module

Posted: Wed Sep 28, 2005 4:00 pm
by brownrl
thanks for the help out:

Just a brief statement on mysql-ing:

a field named poll_option_poll_id typically is a foreign key to another table.

in this case the poll_id in the polls table.

If you made a change and it works cool. however, I wonder how well. As I said earlier when I am back in Belgium I will have it up and going.

additionally, poll_alias as I recall was something different than poll_id. Alias is a moniker to make it easier to call it later in content like:

{cms_modle module="Polls" poll_alias="alias" }

We'll see when I am back.

Thx
Rob

Re: Polls Module

Posted: Thu Oct 20, 2005 9:23 am
by brownrl
New version coming soon!

Still very simple, had one bug that killed it somewhat. In the creation of the table for the poll options the field: poll_option_alias should be poll_option_poll_alias.

Now having trouble with the new moduleinterface.php on the user end. When you do a RedirectContent( $resultid ) ?CMSSESSID=ASDJKHAKLSDH gets put at the end and thus funks up the bouncing back to the page.

Posted that problem in the other forum Hopefully will have it for you by the end of today.

Regards,
Rob

Re: Polls Module

Posted: Fri Dec 30, 2005 10:53 am
by katon
Any news yet?  The version downloadable from this thread won't install...

Re: Polls Module

Posted: Sat Jun 03, 2006 1:30 pm
by Grega
Hi Rob.

I wonder, if you found some time to fix yourpoll?  :) I changed the table poll_option_alias into poll_option_poll_alias, but it's not working.  :'( When I click on "Modules" in the Adminpanel, I get these errors:
Polls

Notice: Undefined variable: returnid in /www/htdocs/blabla/modules/Polls/Polls.module.php on line 213

Notice: Undefined variable: returnid in /www/htdocs/blabla/modules/Polls/Polls.module.php on line 214

Notice: Undefined variable: polls in /www/htdocs/blabla/modules/Polls/Polls.module.php on line 210

Notice: Undefined variable: returnid in /www/htdocs/blabla/modules/Polls/Polls.module.php on line 213

Notice: Undefined variable: returnid in /www/htdocs/blabla/modules/Polls/Polls.module.php on line 214
It is possible to create a new poll, but I can't edit or delete it!  ??? Any ideas or updates?

[EDIT]
Oh, and what do you think: Instead of using an alias in the content page, is it possible that always the latest poll will be displayed? I mean: You start a poll, it runs a while and after that, you start a new poll. So the old one can be deleted/overwritten (if there is no need for an archiv...).
[/EDIT]