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
Requires
- php: ^8.2
- flarum/core: ^1.8.0
README
🔒 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
- Navigate to Admin Panel → Extensions
- Find Auto Lock extension
- Click Settings button
- 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:
- Admin selects exempt tags in extension settings
- When a post is published, the extension checks discussion tags
- If any tag matches exempt list → Skip auto-lock
- Otherwise → Apply normal threshold logic
Trigger Logic
- When a new post is published, the extension listens to the
Postedevent - It refreshes the discussion data and calculates total posts
- Checks if discussion has any exempt tags (v2.2)
- If total posts ≥ threshold and discussion is not locked, it locks the discussion
- All actions are logged for monitoring
License
This extension is licensed under the MIT License.
Links
- Packagist
- GitHub Repository
- Flarum Community
- This plugin is fully automatically developed using AiPy. Invitation Code: XOFS.
- 本插件使用AiPy全自动开发完成,邀请码:XOFS.
Developed by wszdb