git-svn-id: https://192.168.0.254/svn/Rodax.redmine_rodax_crm/trunk@2 ff88604e-da85-c949-a72f-fc3aa3ba3724
76 lines
2.2 KiB
Ruby
76 lines
2.2 KiB
Ruby
require_dependency 'application_controller'
|
|
|
|
if (Redmine::VERSION.to_a.first(3).join('.') < '1.3.0')
|
|
def labelled_fields_for(*args, &proc)
|
|
args << {} unless args.last.is_a?(Hash)
|
|
options = args.last
|
|
options.merge!({:builder => TabularFormBuilder})
|
|
fields_for(*args, &proc)
|
|
end
|
|
|
|
def labelled_remote_form_for(*args, &proc)
|
|
args << {} unless args.last.is_a?(Hash)
|
|
options = args.last
|
|
options.merge!({:builder => TabularFormBuilder})
|
|
remote_form_for(*args, &proc)
|
|
end
|
|
|
|
def labelled_form_for(*args, &proc)
|
|
args << {} unless args.last.is_a?(Hash)
|
|
options = args.last
|
|
options.merge!({:builder => TabularFormBuilder})
|
|
form_for(*args, &proc)
|
|
end
|
|
end
|
|
|
|
|
|
module RedmineContacts
|
|
module Patches
|
|
module ApplicationControllerCompatibilityPatch
|
|
|
|
module InstanceMethods
|
|
|
|
# Find project of id params[:id]
|
|
def find_project
|
|
@project = Project.find(params[:id])
|
|
rescue ActiveRecord::RecordNotFound
|
|
render_404
|
|
end
|
|
|
|
# Find project of id params[:project_id]
|
|
def find_project_by_project_id
|
|
@project = Project.find(params[:project_id])
|
|
rescue ActiveRecord::RecordNotFound
|
|
render_404
|
|
end
|
|
|
|
# Find a project based on params[:project_id]
|
|
# TODO: some subclasses override this, see about merging their logic
|
|
def find_optional_project
|
|
@project = Project.find(params[:project_id]) unless params[:project_id].blank?
|
|
allowed = User.current.allowed_to?({:controller => params[:controller], :action => params[:action]}, @project, :global => true)
|
|
allowed ? true : deny_access
|
|
rescue ActiveRecord::RecordNotFound
|
|
render_404
|
|
end
|
|
|
|
end
|
|
|
|
def self.included(base) # :nodoc:
|
|
base.send(:include, InstanceMethods)
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
end
|
|
|
|
Dispatcher.to_prepare do
|
|
|
|
if !ApplicationController.included_modules.include?(RedmineContacts::Patches::ApplicationControllerCompatibilityPatch) && (Redmine::VERSION.to_a.first(3).join('.') < '1.1.0')
|
|
ApplicationController.send(:include, RedmineContacts::Patches::ApplicationControllerCompatibilityPatch)
|
|
end
|
|
|
|
end |