Please upgrade here. These earlier versions are no longer being updated and have security issues.

Is there a way to close the poll without closing the thread?

This discussion is related to the Discussion Polls addon.

Title is my question: any way to close a poll without closing the thread for discussion?

Tagged:

Comments

  • hgtonighthgtonight ∞ · New Moderator

    There is no way from the UI to close a poll. There is a method to close the poll via the model, so it would be relatively trivial to add.

    Something like the following:

    public function Base_DiscussionOptions_Handler($Sender) {
        if(!CheckPermission('Plugins.DiscussionPolls.Manage')) {
            return;
        }
    
        $Sender->Options .= Wrap(Anchor($Label, '/discussion/closepoll/' . $Discussion->DiscussionID), 'li');
    }
    
    public function DiscussionController_ClosePoll_Create($Sender, $Args) {
        if(!CheckPermission('Plugins.DiscussionPolls.Manage')) {
            throw PermissionException();
        }
        $DiscussionID = $Args[0];
        $Discussion = $Sender->DiscussionModel->GetID($DiscussionID);
    
        if ($Discussion) {
            $DPModel->Close($Discussion->DiscussionID);            
            Redirect('/discussion/' . $Discussion->DiscussionID);
        }
        else {
            throw NotFoundException();
        }
    }
    

    Untested, but that should add a new discussion option to forcibly close the poll. I would suggest adding a check to only have the option if the poll is currently open. And perhaps a method to reopen an accidentally closed poll.

    Search first

    Check out the Documentation! We are always looking for new content and pull requests.

    Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.

    dmsingerBleistivt
Sign In or Register to comment.