Jump to:

1036 Posts in 810 Topics by 315 members

Forum Module

SilverStripe Forums » Forum Module » Closing Thread

Discuss the Forum Module.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 471 Views
  • ihaveqquestion
    Community Member
    12 Posts

    Closing Thread Link to this post

    Hey there,

    I recently have installed forum in Silverstripe 3. What I am trying to do is to figure out how to close solved thread. Currently, it doesn't have any button or function, I can tell, which can be used for that in Forum module.

    The scenario:

    Whoever post thread should have the power to close it or mark as solved/completed.

    Next step after this is to make it popup on the homepage in order to be presented in 'solved topics' section.

    Can anyone give me an idea how to structure this close function? What do I need to do?


  • DryerLintPurple
    Community Member
    7 Posts

    Re: Closing Thread Link to this post

    So basically, you want a one-step process that locks a user's own thread and moves it to a subforum or something?

    Honestly, that's probably going to be a lot of work. I don't think Silverstripe's forum module has much in the way of permissions granularity that you could tap into for something like that. The functionality for editing your own post would be a starting point, and then you'd add locking and moving functionality to it. But again, you'd need to mind the permissions/security, and I'm not sure how much help you'd get there.

  • Willr
    Forum Moderator
    5508 Posts

    Re: Closing Thread Link to this post

    In terms of permission granularity I think you'd be fine as the only permission you have is for a user to edit their own post which is already there. As for steps to get it built (without editing the 'core' module)

    * Setup a Forum for the 'solved' post and set the CanPostType in the CMS to no one (so posts cannot be created solved)
    * Create a new Controller which has an action for the user to mark / unmark a thread as solved (and the permission check - can the user edit that post). That action should change $thread->ForumID to the ID of your solved forum.
    * Update your Forum templates to include the link for the author of the post to mark it as solved.

    Good Luck!

  • ihaveqquestion
    Community Member
    12 Posts

    Re: Closing Thread Link to this post

    Hey Willr,

    Thanks for your reply.

    For your solution, I thought its bit complex for me.

    Currently, what i am doing is to get it done on Forum.php.

    function AdminFormFeatures() {
          if (!$this->canPost()) return;

          $id = (isset($this->urlParams['ID'])) ? $this->urlParams['ID'] : false;
          $fields = new FieldList(
             new CheckboxField('IsReadOnly', _t('Forum.ISREADONLYTHREAD','Is this query solved?')),
             new HiddenField("ID", "Thread")
          if(($forums = Forum::get()) && $forums->exists()) {
             $fields->push(new DropdownField("ForumID", _t('Forum.CHANGETHREADFORUM',"Change Thread Forum"), $forums->map('ID', 'Title', 'Select New Category:')), '', null, 'Select New Location:');
          $actions = new FieldList(
             new FormAction('doAdminFormFeatures', _t('Forum.SAVE', 'Save'))
          $form = new Form($this, 'AdminFormFeatures', $fields, $actions);
          // need this id wrapper since the form method is called on save as
          // well and needs to return a valid form object
          if($id) {
             $thread = ForumThread::get()->byID($id);

          return $form;
        * Process's the moving of a given topic. Has to check for admin privledges,
        * passed an old topic id (post id in URL) and a new topic id
       function doAdminFormFeatures($data, $form) {
          if(isset($data['ID'])) {
             $thread = ForumThread::get()->byID($data['ID']);

             if($thread) {
                if (!$thread->canPost()) {
                   return Security::permissionFailure($this);
          return $this->redirect($this->Link());

    Basically, I have replaced 'canModerator' with 'canPost'. So as non-admin or non-moderator can switch this thread into readonly mode.

    However, there are two issues which are bothering me a lot.
    1. Even I have changed 'Is this a Read only Thread? ' into 'Is this query solved' on Forum.php, however, it doesnt show up on the site. Also, I couldn't any other code could be possible to store this label.

    2. I only wish the topic author can switch this thread into readonly mode. What's the code?

    Thanks so much for your help.

Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.