Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

New Poll addon would be great. Anybody willing to do one?

SheilaSheila ✭✭
edited June 2012 in Vanilla 2.0 - 2.8

Hi! Would anybody be interested of adopting one of the current poll addons or even making a new one? I think it's fair to assume at this point, that current addons are not actively maintained, since there has been vulnerability reports about them without any response.

And now to the topic. The features I'm looking for are:

Basic features

  • Poll with question title and x amount of voting options
  • Label 'Poll' in a discussion view and in poll topic title stating automaticly 'Poll: ' when a certain topic contains a poll
  • Let users see what others voted before they submit their own vote _yes/no_
  • Let users select multiple voting options _yes/no_
  • Ability to localize it
  • Ability to fine tune poll in general and especially the results listing with css or even graphics
  • Does not contain any current security threat

Roles

  • Can view a poll and vote
  • Can set up a new poll
  • Can add a poll to a existing discussion
  • Can add a poll to a existing own discussion
  • Can edit all polls (admin only)

Most best ideal option (feature) would be ability to start a new poll instead of a new discussion. This would naturally funtion on a legacy forum style that that the first post of a thread contains the poll question and voting options instead of showing them in a sidebar.
Maybe this feature could be built with using some functionality of current Q&A Addon?

If somebody is willing to write this addon, maybe it could be sponsored by multiple, shared community donations? I'm pretty sure that many people would love this addon.

Tagged:

Comments

  • can you post a mockup of some images of what you would like to see. Hard to visualize.
    Also which current poll program do you like(forgetting about the security problem for a moment - since maybe that can be address or expanded upon).

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • SheilaSheila ✭✭

    With graphic visualizing I mean just a ability to show poll bars as images, like this or even so that the bars are made of three separate images in order to have nice, controlled roundish ends even on poor browsers. But to show results (poll bars) as images is just a cream on top ie nothing really vital..

    Come to think of it, maybe some parts similar to show polls as a first post of a discussion might have all ready been done with Progress Bars? It uses only css and does it really nicely.

    Have tested both, kPoll and Poll, and Poll seems to be imo more advanced and better working.

  • peregrineperegrine MVP
    edited June 2012

    I guess I meant a mockup of an image of what you want for each feature circled in the image.

    I posted what I think will fix the security problem with poll here. If anybody else has further suggestions to security fix - feel free.

    http://vanillaforums.org/discussion/comment/163979/#Comment_163979

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • not the greatest code because it does a db read for every discussion - but...

    @Sheila said..

    Label 'Poll' in a discussion view and in poll topic title stating automaticly 'Poll: ' when a certain topic contains a poll >

    you could change default.php around line 333

    from
      public function Setup()
    
    to
    
    
     public function DiscussionsController_DiscussionMeta_Handler(&$Sender) {
               $Object = ($Sender->EventArguments['Discussion']);
               $did = $Object->DiscussionID;
               $SQL = Gdn::SQL();
               $inpoll = $SQL->Select('discussion_id')->From('Poll')->Where('discussion_id ',$did )->Get()->FirstRow();
          if (!empty($inpoll))
                      echo "Poll";
                   }
        public function Setup()
    

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • SheilaSheila ✭✭
    edited June 2012

    peregrine said:
    I guess I meant a mockup of an image of what you want for each feature circled in the image.

    Ok, naturally! That just might take some days since I have no photoshop at home, and totally zero time at work to do my own projects but I'll see what I'll come up.

    Meanwhile I try visualize it with few screenshots and additional explanations. Here's the first part...

    Starting a poll in a discussion
    http://img856.imageshack.us/img856/8105/nyttkuva20120630kohtees.png

    Basicly same screen than when starting a new discussion/question, but with a new 'Start a new poll' -link on the right side of the current category dropdown.
    When you click that 'Start a new poll' -link, ajax loads screen that lets user to submit x amount of poll answer options. Options are textfields.

    Under those poll option textfields two selects, which let user deside, if other users can see what others voted before they submit their own vote and if users can select multiple voting options.

    When starting a new poll, best option would be if discussion title is used as a question title and message body as addional explanation field. So if my poll would be about aadvarks and their fur color, this is what I'd have in front of my when starting a new poll.

    Discussion Title Poll: Aadvarks

    Category: Off Topic

    Question1 brown

    Question2 brown tabby

    Question3 bald

    Message: Hi, I always wondered what is the most common fur colour for aadvarks.

    select box: Let users see what others voted before they submit their own vote

    select box: Let users select multiple voting options

    All Discussions view

    On all discussions the discussion would print out actually quite exactly like now when a thread has been tagged with a poll. Naturally tags and labels need to be styled with css to prevent confusion. Poll added to title automatically would also be good, informative feature. So if the topic in a screenshot would be a poll, it would read 'Poll: Is anyone concerned about this? Has this been tested?'

    http://img24.imageshack.us/img24/8105/nyttkuva20120630kohtees.png

    edit:

    peregrine said:
    not the greatest code because it does a db read for every discussion - but...

    you could change default.php around line 333

    Are you sure you need any further details since you seem to be doing the plugin already? :D

    Btw I noticed that @matt has possibly been talking about similar boosted poll -addon

  • I was trying to understand what you wanted, so it would be clearer for whoever makes a poll program. But I figured I would provide some fixes for the current poll. - security and putting a label on the page.

    Actually, I thought of trying to write a new one, if no one picked up the lead, but you pointed out Matt was already working on it. So ...

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • SheilaSheila ✭✭
    edited June 2012

    Ok :)

    Current poll addon is most likely the not ideal one, so completely new could be a best option. Not sure, if @matt is actually working with a new one, just sounded he was interested of same kind on poll. Let's see if he answers here and if parts of what he's done with progress bars could be implemented to 'boosted poll'.

    Just realized one basic feature missing from my original list

    • When topic gets new vote(s), it moves to a beginning of a all discussions view like 'normal' discussions when they have new replies

    Meanwhile, tested your fixes for the current poll. The new label in a discussion view seems to work fine. edit: the new label shows in index.php?p=/discussions but not in index.php?p=/categories/

  • to fix viewing in category
    
         public function DiscussionsController_DiscussionMeta_Handler(&$Sender) {
                   $Object = ($Sender->EventArguments['Discussion']);
                   $did = $Object->DiscussionID;
                   $SQL = Gdn::SQL();
                   $inpoll = $SQL->Select('discussion_id')->From('Poll')->Where('discussion_id ',$did )->Get()->FirstRow();
              if (!empty($inpoll))
                          echo "Poll";
    
                       }
    
           public function CategoriesController_DiscussionMeta_Handler(&$Sender) {
               $this->DiscussionsController_DiscussionMeta_Handler($Sender);
            }   
    
    
            public function Setup()
            {
    
    
    
    
    
    If you want to create a Poll category (this will be the only category that allows polls)
    
    you could completely remove this --
    
           public function DiscussionController_BeforeDiscussionRender_Handler(&$Sender) 
            {
    
              $Sender->AddCSSFile('plugins/Poll/design/poll.css'); 
    
        #    $Session = Gdn::Session();
    
            #echo $DiscussionID = GetValue('DiscussionID', $Sender->EventArguments, 0);
           # $Object = GetValue('Object', $Sender->EventArguments);
    
         #   $DiscussionID = GetValue('DiscussionID', $Sender->EventArguments, 0);
    
    
    
    
              #print_r($Sender->Discussion->DiscussionID);
    
              include_once(PATH_PLUGINS.DS.'Poll'.DS.'class.pollmodule.php');
              $PollModule = new PollModule($Sender);
              $PollModule->SetID($Sender->DiscussionID);
              $PollModule->GetData();
              $Sender->AddModule($PollModule);
    
              #die;
         #   $Sender->Options .= '<li>'.Anchor(T('Attach a poll'), 'vanilla/discussion/startpoll/'.$DiscussionID.'/'.$Session->TransientKey().'?Target='.urlencode($Sender->SelfUrl), 'StartPoll') . '</li>'; 
    
            }
    
            and replace it with this function.
    
             public function DiscussionController_BeforeDiscussionTitle_Handler(&$Sender) 
            {
                   $Sender->AddCSSFile('plugins/Poll/design/poll.css'); 
                   include_once(PATH_PLUGINS.DS.'Poll'.DS.'class.pollmodule.php');
                   $PollModule = new PollModule($Sender);
                   $PollModule->SetID($Sender->DiscussionID);
                   $PollModule->GetData();
                   $Sender->AddModule($PollModule);
                   }
            }
    
    
    
    
    also this is the line to change to 
     if  ($Sender->Discussion->Category == "Poll") {
    
    for finnish
    if  ($Sender->Discussion->Category == "Polaakaasi") { 
    
     :)
    

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • snavesnave New
    edited February 2013

    wondering if it's possible to add/define more labels to disscussion, in the same way above...
    have something like this...

    image


    @peregrine said:
    to fix viewing in category

    public function DiscussionsController_DiscussionMeta_Handler(&$Sender) {
    $Object = ($Sender->EventArguments['Discussion']);
    $did = $Object->DiscussionID;
    $SQL = Gdn::SQL();
    $inpoll = $SQL->Select('discussion_id')->From('Poll')->Where('discussion_id ',$did )->Get()->FirstRow();
    if (!empty($inpoll))
    echo "Poll";

    }

    public function CategoriesController_DiscussionMeta_Handler(&$Sender) {
    $this->DiscussionsController_DiscussionMeta_Handler($Sender);
    }


    public function Setup()
    {





    If you want to create a Poll category (this will be the only category that allows polls)

    you could completely remove this --

    public function DiscussionController_BeforeDiscussionRender_Handler(&$Sender)
    {

    $Sender->AddCSSFile('plugins/Poll/design/poll.css');

    # $Session = Gdn::Session();

    #echo $DiscussionID = GetValue('DiscussionID', $Sender->EventArguments, 0);
    # $Object = GetValue('Object', $Sender->EventArguments);

    # $DiscussionID = GetValue('DiscussionID', $Sender->EventArguments, 0);




    #print_r($Sender->Discussion->DiscussionID);

    include_once(PATH_PLUGINS.DS.'Poll'.DS.'class.pollmodule.php');
    $PollModule = new PollModule($Sender);
    $PollModule->SetID($Sender->DiscussionID);
    $PollModule->GetData();
    $Sender->AddModule($PollModule);

    #die;
    # $Sender->Options .= '

    '.Anchor(T('Attach a poll'), 'vanilla/discussion/startpoll/'.$DiscussionID.'/'.$Session->TransientKey().'?Target='.urlencode($Sender->SelfUrl), 'StartPoll') . '';

    }

    and replace it with this function.

    public function DiscussionController_BeforeDiscussionTitle_Handler(&$Sender)
    {
    $Sender->AddCSSFile('plugins/Poll/design/poll.css');
    include_once(PATH_PLUGINS.DS.'Poll'.DS.'class.pollmodule.php');
    $PollModule = new PollModule($Sender);
    $PollModule->SetID($Sender->DiscussionID);
    $PollModule->GetData();
    $Sender->AddModule($PollModule);
    }
    }




    also this is the line to change to
    if ($Sender->Discussion->Category == "Poll") {

    for finnish
    if ($Sender->Discussion->Category == "Polaakaasi") {

    :)





Sign In or Register to comment.