├── README.md ├── config ├── locales │ └── server.en.yml └── settings.yml ├── plugin.rb └── LICENSE /README.md: -------------------------------------------------------------------------------- 1 | # Edit History Override Plugin 2 | 3 | A simple plugin to allow additional groups to be able to view post edit history when site setting is set for **Staff** only. -------------------------------------------------------------------------------- /config/locales/server.en.yml: -------------------------------------------------------------------------------- 1 | en: 2 | site_settings: 3 | edit_history_override_enabled: "Allow selected groups to view edit history" 4 | edit_history_override_permitGroups: "Allow members of these groups to view edit history. Staff and post owners can always view post edit history" 5 | -------------------------------------------------------------------------------- /config/settings.yml: -------------------------------------------------------------------------------- 1 | plugins: 2 | edit_history_override_enabled: 3 | default: false 4 | client: false 5 | # Default Moderators and TL4 6 | edit_history_override_permitGroups: 7 | type: group_list 8 | list_type: compact 9 | default: "2|14" 10 | allow_any: false 11 | refresh: true 12 | -------------------------------------------------------------------------------- /plugin.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | # name: edit-history-override 4 | # about: A super simple plugin to change post edit history privs 5 | # version: 0.0.3 6 | # authors: thess 7 | # url: https://github.com/openwrt/forum-edit-history-override 8 | 9 | enabled_site_setting :edit_history_override_enabled 10 | 11 | require_dependency 'guardian' 12 | require_dependency 'guardian/post_guardian' 13 | 14 | class ::Guardian 15 | end 16 | 17 | module ::PostGuardian 18 | def can_view_edit_history?(post) 19 | return false unless post 20 | 21 | if !post.hidden 22 | return true if post.wiki || SiteSetting.edit_history_visible_to_public 23 | end 24 | 25 | # Logged-in and (staff | override group member | post_owner) and visible 26 | authenticated? && (is_staff? || 27 | (SiteSetting.edit_history_override_enabled && 28 | @user.in_any_groups?(SiteSetting.edit_history_override_permitGroups_map)) || 29 | @user.id == post.user_id) && 30 | can_see_post?(post) 31 | end 32 | end 33 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | SOFTWARE. 20 | --------------------------------------------------------------------------------