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: This script is for the forum boards i.e. forums in the Thread: namespace.

Installation

See also: Help:Including additional CSS and JS, Help:Advanced CSS and JS
  • For site-wide use, an administrator can add the line below to the wiki's MediaWiki:ImportJS page. Note that JavaScript must be enabled on the wiki.
dev:LockForums/code.js

Configuration

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

Variable name Variable type Description Default value
expiryDays Number The number of days after which a forum post should be archived. 30
expiryMessage String The message that should be displayed to the user if commenting has been locked on the forum post. "This forum hasn't been commented on for over <expiryDays> days. There is no need to reply."
warningDays Number The number of days after which a forum post should display a warning that the thread is old and should only be replied to if necessary. Messages 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 forum post. "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 numbers to disable this script completely. []
ignoreDeletes Boolean Causes the code to ignore deleted messages when calculating the age of the post. The default behavior uses the time of the most recent post, whether or not it has been deleted. false
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 forum 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 forum 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 forum has not had a response for over <actualDays> days; are you sure you want to reply?"
boxHeight Number The height (in pixels) of the comment box. 50

The syntax for using these configuration options goes like this:

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

Note that you only need to define the fields you wish to change from the defaults, and they may be defined in any order. However, this definition must precede the importArticles() call!

Example 1

Let's say you want to do the following:

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

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

window.LockForums = {
    expiryDays: 60,
    expiryMessage: "This forum is considered archived because it hasn\'t been commented on in over <expiryDays> days, please don\'t bump this forum!"
};
 
importArticles({
    type: "script",
    articles: [
        "w:c:dev:LockForums/code.js"
    ]
});

Example 2

Let's say you want to do the following:

  • Old forums should be locked from commenting after 180 days
  • However, after 30 days, you want to warn people that they shouldn't be commenting unless absolutely necessary.
  • The expiry message should say This forum has been automatically archived because its most recent comment is over 180 days old.
  • The warning message should say This forum is now [current days] old; out of courtesy to your fellow Wikians, please do not comment unless it is absolutely necessary. This forum 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 to ignore deleted messages when calculating the age of the most recent thread.
  • You would like a confirmation dialog to pop up for people posting on forums older than 30 days.
  • This popup message should read By posting on an old forum you may be filling up the e-mail boxes of many people who are still following this post. 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 forum has been automatically archived because its most recent comment is over <expiryDays> days old.",
    warningDays: 30,
    warningMessage: "This forum is now <actualDays> days old; out of courtesy to your fellow Wikians, please do not comment unless it is absolutely necessary. This forum will archive automatically when the last comment is <expiryDays> days old.",
    banners: true,
    ignoreDeletes: true,
    warningPopup: true,
    warningPopupMessage: "By posting on an old forum you may be filling up the e-mail boxes of many people who are still following this topic. Are you sure you want to do this?",
    disableOn: ["12345", "67890"]
};
 
importArticles({
    type: "script",
    articles: [
        "w:c:dev:LockForums/code.js"
    ]
});

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

Note: This topic has been unedited for 143 days. It is considered archived - the discussion is over. If you feel this forum 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.
  • Important reminder: Note that the importArticles() call comes after the configuration options!

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.