Disable default modules

This commit is contained in:
Solotchi Veaceslav
2015-02-05 14:16:07 +02:00
parent 19a8e31833
commit d0780ee633
5 changed files with 116 additions and 1 deletions
+11
View File
@@ -94,6 +94,17 @@
#
# === More configuration options
#
# Disable default module:
#
# By default user may choose which modules can be disabled,
# they should be listed as an array in yml format more information
# regarding yml format you can find here:
# http://symfony.com/doc/current/components/yaml/yaml_format.html
#
# disabled_modules:
# - module_name_1
# - module_name_2
#
# See following page:
#
# http://guides.rubyonrails.org/action_mailer_basics.html#action-mailer-configuration
+33
View File
@@ -0,0 +1,33 @@
#-- encoding: UTF-8
#-- copyright
# OpenProject is a project management system.
# Copyright (C) 2012-2014 the OpenProject Foundation (OPF)
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License version 3.
#
# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
# Copyright (C) 2006-2013 Jean-Philippe Lang
# Copyright (C) 2010-2013 the ChiliProject Team
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# See doc/COPYRIGHT.rdoc for more details.
#++
unless OpenProject::Configuration['disabled_modules'].empty?
to_disable = OpenProject::Configuration['disabled_modules']
OpenProject::Plugins::ModuleHandler.disable_modules(to_disable)
end
+4 -1
View File
@@ -74,7 +74,10 @@ module OpenProject
'disable_password_login' => false,
'omniauth_direct_login_provider' => nil,
'disable_password_choice' => false
'disable_password_choice' => false,
# allow to disable default modules
'disabled_modules' => []
}
@config = nil
@@ -0,0 +1,50 @@
#-- encoding: UTF-8
#-- copyright
# OpenProject is a project management system.
# Copyright (C) 2012-2015 the OpenProject Foundation (OPF)
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License version 3.
#
# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
# Copyright (C) 2006-2013 Jean-Philippe Lang
# Copyright (C) 2010-2013 the ChiliProject Team
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# See doc/COPYRIGHT.rdoc for more details.
#++project_module
module OpenProject::Plugins
class ModuleHandler
@@disabled_modules = []
class << self
def disable_modules(module_names)
@@disabled_modules += Array(module_names).map(&:to_sym)
end
def disable(disabled_modules)
disabled_modules.map do |module_name|
Redmine::AccessControl.remove_modules_permissions(module_name)
end
end
end
OpenProject::Application.config.to_prepare do
OpenProject::Plugins::ModuleHandler.disable(@@disabled_modules)
end
end
end
+18
View File
@@ -76,6 +76,24 @@ module Redmine
def modules_permissions(modules)
@permissions.select { |p| p.project_module.nil? || modules.include?(p.project_module.to_s) }
end
def remove_modules_permissions(module_name)
permissions = @permissions
module_permissions = permissions.select { |p| p.project_module.to_s == module_name.to_s }
reset
@permissions = permissions - module_permissions
end
def reset
@permissions = nil
@available_project_modules = nil
@public_permissions = nil
@members_only_permissions = nil
@loggedin_only_permissions = nil
end
end
class Mapper