## Adding Moderation to forums

### Requirements

Who administers the site will be decided by priviledge granted to the Forum Application. There will be a distinction between Forum Administrators and Forum Moderators, a new priviledge called "forum_moderate" will be added, and a party created. Parties that can moderate will be added to this party.

- A forum can have moderation turned on or off
- Admin users can be created for a forum
- Admin users get notified when a new message is posted that requires approval
- Admin users get a page with a list of messages that require approval
- When a message is rejected, the original subimitter receives an email notice with a link to the message and comment from the Admin user
- The original submitter can edit the message and submit it for a second review

#### Potential additional features

- Admin user can reject a message and add a comment as to why

### Changes required

#### Status

The draft state (pending approval) and approved states will be handl ed by adding a "status" attribute to ForumMessage.

- pending - Message only visible to moderators
- approved - Message visible to all</l>
- rejected - Message only visible to moderators
- reapprove - Message visible, but content hidden
- supressed - Message visible, but ontent hidden

Use cases
- New message
  1. Submitter posts (notify admin)
  2. -> Admin 'approve' / 'reject'
  3. -> APPROVED Message goes live
  4. OR -> Message stays as draft and submitter is notified go back to 3)
- Edit message
  1. Submitter edits already approved message (notify admin) status changes to 'reapprove'
  2. -> Admin moderates, change state to 'approve', 'supressed', or 'rejected' depending on whether they want to hide the entire thread or just the content of the message.
  3. -> APPROVED new version of message goes live
  4. OR -> REJECTED old version of message stays around?
- user deletes message
  1. -> Status change to 'supressed'
- Moderator changes decision
  1. Change status to 'supressed' or 'rejected', depending on wheather they want to remove the entire thread or just the content of the message.

When the forum is not moderated, the message filters on the display will be turned off. This means that when forum moderation is turned on after the forum has been active for a while, all messages will be at the "pending" or "reapprove" status.

When a moderated forum is changed to unmoderated, all PENDING posts will be automatically approved.

#### Views

For the moderators the thread list will have two viewing flags

- Include 'pending' or 'reapprove' messages
- Include 'rejected' or 'suppressed' messages

#### Datamodel

Create new DomainObject Post with the following additional attributes:

- status (pending, approved, rejected, reapprove, suppressed)
- UID of moderator who last changed the status

    object type Post extends com.arsdigita.messaging.ThreadedMessage {

        String [1..1] status = forum_posts.status CHAR(20);
        reference key(forum_posts.post_id);
        aggressive load(moderator.id);
    }

    association {
       Party [0..1] moderator = join forum_posts.moderator to parties.party_id;
       Post [0..1] moderatedMessage = join parties.party_id to forum_posts.moderator;
    }

Add moderated boolean attribute to Forum.pdl

    object type Forum extends Application {

        Post[0..n] posts =
            join forum_forums.forum_id to messages.object_id;

        Boolean [1..1] isModerated  = forum_forums.is_moderated;

        component ForumSubscription[0..n] subscriptions =
            join forum_forums.forum_id to forum_subscriptions.forum_id;
        component Category[1..1] category =
            join forum_forums.category_id to cat_categories.category_id;

        reference key (forum_forums.forum_id);
    }

Remove the category related named queries with Categorization API in Forum.pdl. Alter named query categoryObject and uncategoryObject

#### UI changes

Change index and thread pages to only show approved content.

Creation steps | Change the message create/edit form to set the status apropreately. | DONE
Post listings

new | Make MessageList into a MessageTable. Refactor ReplyPostForm, EditPostForm to use ACSObjectSelectionModel. | DONE (.5)
new | Remove visiblity control from the subcomponents MessageTable, ReplyToPostForm, EditPostForm, MessageView and move it to the parent container ThreadComponent. | DONE (.1d)

Add filters on the post table dynamically based on priviledge. Implement these views:

1. Moderator view: has links to include "pending", "reapprove", "rejected", and "suppressed" messages.
2. User view: only shows approved messages
3. Moderator can change the status of messages via these views

Estimate: 0.5 Actual: 0.5DONE

| Add a filter to thread listing in ForumUserView, ThreadListing | Estimate: .5 Actual: about 2 hours DONE
Permission checking new | Don't think the user pages has proper permission checking, so all the pages needs to be checked. | Estimate 1 day? DONE, It actually appears to be okay (about 2 hours)

Modertaion Administration pane

Add another tab to ForumComponent.java

- Add another "admin" tab to manage Moderation on/off
- Show administrators for this forum

DONE (1d) but needs more cleaning +.5

email notifications

Notifications only go out for approved messages.

Notify moderators when a new post is made or if a post is edited

Notifications are sent by the various forms calling Post.sendNotifications() during the process() method. EditPostForm, NewPostForm, and ReplyToPostForm needs to call a similar method to send moderation noticies. Make a new message class, that extends com.arsdigita.forum.Subscription and implement custom methods for getHeader(), getSignature().

Create a new class called ModerationNotice with a new object type that extends ForumSubscriptions. This is created when a forum i screated.

Estimate: 1

Only send subscription emails for approved posts | Forum.getSubscriptions(); * add approved messages filter to this method ForumSubscription.sendNotification(); (Notification.sendNotification) | Estimate: 1

### Future Improvements

- Make the use of Post consistent throughout, instead of mixing ThreadedMessage and Post. (MessageListing should be PostListing etc).
- The distinction between ThreadedMessage and MessageThread is not really necessary. Make the use of MessageThread obsolete
- c.a.forum.ui.Constants has a bunch of constants. This should be moved to the globalization properties in c.a.forum.ui.ForumResources.
- Make the configuration for forums take an XML file instead of this list of list in enterprise.init.in

Last modified: Thu Jun 5 18:40:28 BST 2003