Dynamiczne odczytywanie katalogów z IMAGE_DIR.
[redakcja.git] / redmine / redmine_publications / lib / issue_publication_hook.rb
1 # Provides a link to the document on the platform
2 class IssuesPublicationHook < Redmine::Hook::ViewListener
3
4   def view_issues_show_details_bottom(context)
5         # TODO: złapać wyjątek konwersji
6         if context[:issue].tracker_id == Setting.plugin_redmine_publications[:tracker].to_i
7           result = "<tr><td><b>Publication(s):</b></td><td>"
8           names = context[:issue].publication_names {|name| "<span>" + name + "</span>"} 
9           result << names.join(', ')
10           result << "</td></tr>"
11         end
12   end
13
14   def controller_issues_edit_before_save(context)
15         if context[:issue].tracker.id == Setting.plugin_redmine_publications[:tracker].to_i
16           old_value = context[:issue].publication_names
17           new_value = context[:params][:publications].split(',').map { |n| n.strip }
18           context[:journal].details << JournalDetail.new(
19                 :property => 'attr', :prop_key => "publications", 
20                 :old_value => old_value.join(', '), 
21                 :value => new_value.join(', ') ) unless new_value==old_value
22           context[:issue].publication_names = new_value
23         end
24   end
25
26
27   def controller_issues_new_after_save(context)
28         if context[:issue].tracker.id == Setting.plugin_redmine_publications[:tracker].to_i
29           value = context[:params][:publications].split(',').map { |n| n.strip }
30           context[:issue].publication_names = value
31           context[:issue].save
32         end
33   end
34         
35   render_on :view_issues_form_details_bottom, :partial => 'issue_form_pub'
36 end