Don't use hooks if the project doesn't have the module enabled. #1300

This commit is contained in:
Eric Davis
2008-06-19 16:52:21 -07:00
parent 8295b737a1
commit ab67d20fcf
2 changed files with 46 additions and 28 deletions

View File

@@ -8,8 +8,12 @@ class BudgetIssueHook < Redmine::Plugin::Hook::Base
# * :issue => Issue being rendered
#
def self.issue_show(context = { })
data = "<td><b>Deliverable :</b></td><td>#{help.html_escape context[:issue].deliverable.subject unless context[:issue].deliverable.nil?}</td>"
return "<tr>#{data}<td></td></tr>"
if context[:project].module_enabled?('budget_module')
data = "<td><b>Deliverable :</b></td><td>#{help.html_escape context[:issue].deliverable.subject unless context[:issue].deliverable.nil?}</td>"
return "<tr>#{data}<td></td></tr>"
else
return ''
end
end
# Renders a select tag with all the Deliverables
@@ -19,8 +23,12 @@ class BudgetIssueHook < Redmine::Plugin::Hook::Base
# * :project => Current project
#
def self.issue_edit(context = { })
select = context[:form].select :deliverable_id, Deliverable.find_all_by_project_id(context[:project]).collect { |d| [d.subject, d.id] }, :include_blank => true
return "<p>#{select}</p>"
if context[:project].module_enabled?('budget_module')
select = context[:form].select :deliverable_id, Deliverable.find_all_by_project_id(context[:project]).collect { |d| [d.subject, d.id] }, :include_blank => true
return "<p>#{select}</p>"
else
return ''
end
end
# Renders a select tag with all the Deliverables for the bulk edit page
@@ -29,12 +37,16 @@ class BudgetIssueHook < Redmine::Plugin::Hook::Base
# * :project => Current project
#
def self.issue_bulk_edit(context = { })
select = help.select_tag('deliverable_id',
help.content_tag('option', GLoc.l(:label_no_change_option), :value => '') +
help.content_tag('option', GLoc.l(:label_none), :value => 'none') +
help.options_from_collection_for_select(Deliverable.find_all_by_project_id(context[:project].id, :id, :subject), :id, :subject))
if context[:project].module_enabled?('budget_module')
select = help.select_tag('deliverable_id',
help.content_tag('option', GLoc.l(:label_no_change_option), :value => '') +
help.content_tag('option', GLoc.l(:label_none), :value => 'none') +
help.options_from_collection_for_select(Deliverable.find_all_by_project_id(context[:project].id, :id, :subject), :id, :subject))
return help.content_tag(:p, "<label>#{GLoc.l(:field_deliverable)}: " + select + "</label>")
return help.content_tag(:p, "<label>#{GLoc.l(:field_deliverable)}: " + select + "</label>")
else
return ''
end
end
# Saves the Deliverable assignment to the issue

View File

@@ -6,7 +6,11 @@ class BudgetProjectHook < Redmine::Plugin::Hook::Base
#
# Context: none
def self.member_list_header(context ={ })
return "<th>#{GLoc.l(:label_member_rate) }</th>"
if context[:project].module_enabled?('budget_module')
return "<th>#{GLoc.l(:label_member_rate) }</th>"
else
return ''
end
end
# Renders an AJAX from to update the member's billing rate
@@ -15,23 +19,25 @@ class BudgetProjectHook < Redmine::Plugin::Hook::Base
# * :member => Current Member record
#
def self.member_list_column_three(context = { })
# Build a form_remote_tag by hand since this isn't in the scope of a controller
form = help.form_tag({:controller => 'members', :action => 'edit', :id => context[:member].id, :host => Setting.host_name},
:onsubmit => help.remote_function(:url => {
:controller => 'members',
:action => 'edit',
:id => context[:member].id,
:host => Setting.host_name
},
:host => Setting.host_name,
:form => true,
:method => 'post',
:return => 'false' )+ '; return false;') +
help.text_field_tag('member[rate]', help.number_with_precision(context[:member].rate, 0), :class => "small") +
help.submit_tag(GLoc.l(:button_change), :class => "small") + "</form>"
return help.content_tag(:td, form, :align => 'center' )
if context[:project].module_enabled?('budget_module')
# Build a form_remote_tag by hand since this isn't in the scope of a controller
form = help.form_tag({:controller => 'members', :action => 'edit', :id => context[:member].id, :host => Setting.host_name},
:onsubmit => help.remote_function(:url => {
:controller => 'members',
:action => 'edit',
:id => context[:member].id,
:host => Setting.host_name
},
:host => Setting.host_name,
:form => true,
:method => 'post',
:return => 'false' )+ '; return false;') +
help.text_field_tag('member[rate]', help.number_with_precision(context[:member].rate, 0), :class => "small") +
help.submit_tag(GLoc.l(:button_change), :class => "small") + "</form>"
return help.content_tag(:td, form, :align => 'center' )
else
return ''
end
end
end