wszdb/flarum-autolock

Automatically lock discussions after reaching a specified number of posts

Installs: 60

Dependents: 0

Suggesters: 0

Security: 0

Stars: 1

Watchers: 0

Forks: 0

Open Issues: 0

Type:flarum-extension

pkg:composer/wszdb/flarum-autolock

v2.4 2025-10-12 03:02 UTC

This package is auto-updated.

Last update: 2025-11-12 04:06:45 UTC


README

License Flarum PHP Version

🔒 Automatically lock discussions when they reach a specified number of posts.

🔒 Flarum 贴子自动锁定插件,设置后,某个贴子回复数量超过特定楼层时,自动锁定,同时支持对特定标签(Tags)锁定豁免.

✨ New in v2.4.0

  • 🏷️ Tag Exemption: Configure specific tags to be exempt from auto-locking
  • 🎛️ Multi-Tag Support: Select one or multiple tags for exemption
  • 🌐 Enhanced UI: Intuitive tag selector in admin panel

Features

  • Automatic Locking: Discussions are automatically locked when reaching the configured post count
  • 🏷️ Tag Exemption: Exempt specific tags from auto-locking (NEW in v2.2)
  • ⚙️ Configurable Threshold: Set custom post count threshold in admin panel (default: 100)
  • 🎛️ Enable/Disable Toggle: Easy on/off switch in admin settings
  • 🌍 Multi-language Support: English and Simplified Chinese included
  • 🚀 Event-Driven: Uses Flarum's native event system for optimal performance
  • 🔧 Zero Configuration: Works out of the box with sensible defaults
  • 📊 Detailed Logging: Comprehensive logs for debugging and monitoring

Installation

Install via Composer:

composer require wszdb/flarum-autolock

Enable the extension:

php flarum extension:enable wszdb-autolock

Clear cache:

php flarum cache:clear

Configuration

  1. Navigate to Admin PanelExtensions
  2. Find Auto Lock extension
  3. Click Settings button
  4. Configure options:
    • Enable Auto Lock: Toggle to enable/disable the feature
    • Post Count Threshold: Set the number of posts after which discussions will be locked (minimum: 1, default: 100)
    • Exempt Tags: Select tags that should be exempt from auto-locking (NEW in v2.2)

How It Works

Post Count Calculation

The extension uses the following formula to calculate total posts:

Total Posts = comment_count (replies) + 1 (original post)

Example:
- Original post = Floor 1
- 99 replies = Floor 2-100
- Total = 100 floors

When total >= threshold → Auto lock ✅

Tag Exemption (v2.2)

Discussions with exempt tags will never be auto-locked, regardless of post count:

  1. Admin selects exempt tags in extension settings
  2. When a post is published, the extension checks discussion tags
  3. If any tag matches exempt list → Skip auto-lock
  4. Otherwise → Apply normal threshold logic
局部截取_20251012_114438

Trigger Logic

  1. When a new post is published, the extension listens to the Posted event
  2. It refreshes the discussion data and calculates total posts
  3. Checks if discussion has any exempt tags (v2.2)
  4. If total posts ≥ threshold and discussion is not locked, it locks the discussion
  5. All actions are logged for monitoring

License

This extension is licensed under the MIT License.

Links

Developed by wszdb