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.

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

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.

Sign In or Register to comment.