FANDOM


LockForums disables the replying field on threads that haven't been commented on in the past 30 days, effectively allowing them to be automatically archived over time. There are many configuration options, including the ability to set a warning period prior to locking, displaying a banner at the top of the page, and more. See Configuration for more details.

Note: For backwards-compatibility, message walls and message wall threads are left unlocked by default. You can change this by enabling the the lockMessageWalls flag.

Installation

Configuration

There are some custom configuration options that you can use if you want to:

Variable name Variable type Description Default value
lockMessageWalls Boolean If enabled, allows the script to operate on message walls in addition to forum threads. false
expiryDays Number The number of days after which a thread should be archived. 30
expiryMessage String The message that should be displayed to the user if commenting has been locked on the thread. "This thread hasn't been commented on for over <expiryDays> days. There is no need to reply."
warningDays Number The number of days after which a thread should display a warning that the thread is old and should only be replied to if necessary. Threads older than both <warningDays> and <expiryDays> will be locked and display the <expiryMessage>. 0 (disabled)
warningMessage String The message that should be displayed to the user if commenting is about to be locked on the thread. "This forum hasn't been commented on for over <warningDays> days. Please reply ONLY if a response is really needed."
disableOn String Array Array of thread ids to disable this script completely. []
banners Boolean If enabled, causes a banner to appear at the top of the page for both warnings and expired messages. false
expiryBannerMessage String The message that will be displayed at the top of the page for expired messages (if banners are enabled). "<span style='color: maroon; font-weight: bold;'>Note:</span> This topic has been unedited for <actualDays> days. It is considered <b>archived</b> - the discussion is over. If you feel this thread needs additional information, contact an administrator."
warningBannerMessage String The message that will be displayed at the top of the page for soon-to-be-expiring messages (if banners are enabled). "<span style='color: maroon; font-weight: bold;'>Note:</span> This topic has been unedited for <actualDays> days. It is considered <b>archived</b> - the discussion is over. Do not add to it unless it really <i>needs</i> a response."
expiryBannerStyle String or Object The configurable CSS style(s) of the expiry banner. Define this parameter as "stylesheet" in order to use your local CSS stylesheet (div#forum-warning-banner.warning-banner-expired). Otherwise you can use a key-value pair object to override the default style ({'tag1': 'value1', 'tag2': 'value2'}). {'border': '2px solid #f66', 'background-color': 'whitesmoke', 'margin': '0.8em 0px', 'padding': '0.5em 12px', 'color': 'black'}
warningBannerStyle String or Object The configurable CSS style(s) of the warning banner. Define this parameter as "stylesheet" in order to use your local CSS stylesheet (div#forum-warning-banner.warning-banner-expired-warning). Otherwise you can use a key-value pair object to override the default style ({'tag1': 'value1', 'tag2': 'value2'}). {'border': '2px solid #f66', 'background-color': 'whitesmoke', 'margin': '0.8em 0px', 'padding': '0.5em 12px', 'color': 'black'}
warningPopup Boolean If enabled, will cause a popup confirmation dialog to appear when someone attempts to post on a thread that has a warning message displayed. Canceling this confirmation dialog will cancel the post. false
warningPopupMessage String The text of the warning popup dialog message. "This thread has not had a response for over <actualDays> days; are you sure you want to reply?"

These configuration options should be added to MediaWiki:Common.js, and the syntax for using these options goes like this:

window.LockForums = {
    lockMessageWalls: boolean,
    expiryDays: number,
    expiryMessage: string,
    warningDays: number,
    warningMessage: string,
    disableOn: array,
    banners: boolean,
    expiryBannerMessage: string,
    expiryBannerStyle: object (or "stylesheet"),
    warningBannerMessage: string,
    warningBannerStyle: object (or "stylesheet"),
    warningPopup: boolean,
    warningPopupMessage: string
};

Note that you only need to define the fields you wish to change from the defaults, and they may be defined in any order.

Example 1

Let's say you want to do the following:

  • Old threads should be locked from replying after 60 days
  • The message should say This thread is considered archived because it hasn't been commented on in over 60 days, please don't bump this thread!

Here's the code you would put in your MediaWiki:Common.js with those configuration options:

window.LockForums = {
    expiryDays: 60,
    expiryMessage: "This thread is considered archived because it hasn\'t been commented on in over <expiryDays> days, please don\'t bump this thread!"
};

Example 2

Let's say you want to do the following:

  • Old threads should be locked from replying after 180 days
  • However, after 30 days, you want to warn people that they shouldn't be replying unless absolutely necessary.
  • The expiry message should say This thread has been automatically archived because its most recent comment is over 180 days old.
  • The warning message should say This thread is now [current days] old; out of courtesy to your fellow Wikians, please do not comment unless it is absolutely necessary. This thread will archive automatically when the last comment is 180 days old.
  • A banner at the top of the page should clearly mark the expired and warned threads. The default text is fine.
  • You would like a confirmation dialog to pop up for people posting on threads older than 30 days.
  • This popup message should read By posting on an old thread you may be filling up the e-mail boxes of many people who are still following this thread. Are you sure you want to do this?
  • Disable on Thread:12345 and Thread:67890

Here's the code you would put in your MediaWiki:Common.js with those configuration options:

window.LockForums = {
    expiryDays: 180,
    expiryMessage: "This thread has been automatically archived because its most recent comment is over <expiryDays> days old.",
    warningDays: 30,
    warningMessage: "This thread is now <actualDays> days old; out of courtesy to your fellow Wikians, please do not comment unless it is absolutely necessary. This thread will archive automatically when the last comment is <expiryDays> days old.",
    banners: true,
    warningPopup: true,
    warningPopupMessage: "By posting on an old thread you may be filling up the e-mail boxes of many people who are still following this thread. Are you sure you want to do this?",
    disableOn: ["12345", "67890"]
};

If the banner is used it will look like this (as a default):

Note: This thread has been unedited for 143 days. It is considered archived - the discussion is over. If you feel this thread needs additional information, contact an administrator.

Notes

  • Inside of the expiryMessage, warningMessage, expiryBannerMessage, warningBannerMessage and warningPopupMessage strings, The apostrophe character ' must be replaced with \' and the quote character " must be replaced with \". This is called an "escape character" in JavaScript.
  • Inside of these strings, you can (if you want to) use the <expiryDays> tag which will automatically be replaced with the expiryDays variable, which is 60 in this example. You may also use <warningDays> for the warningDays variable, and actualDays for the actual time elapsed since the most recent post.

Start a Discussion Discussions about LockForums

Community content is available under CC-BY-SA unless otherwise noted.