diff plugins/redmine_bibliography/lib/bibliography/my_helper_patch.rb @ 1234:e0167f4e1d8a redmine-2.2-integration

We have a MyHelper now, so we need a MyHelperPatch (also some other minor fixes)
author Chris Cannam <chris.cannam@soundsoftware.ac.uk>
date Wed, 13 Mar 2013 14:00:01 +0000
parents plugins/redmine_bibliography/app/helpers/my_helper.rb@b4b72f1eb644
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/redmine_bibliography/lib/bibliography/my_helper_patch.rb	Wed Mar 13 14:00:01 2013 +0000
@@ -0,0 +1,52 @@
+module Bibliography
+  module MyHelperPatch
+
+    def self.included(base) # :nodoc:
+      base.send(:include, InstanceMethods)
+
+      base.class_eval do
+        unloadable
+      end
+    end
+
+    module InstanceMethods
+
+      def get_my_publications()
+        if not User.current.author.nil?
+          @my_publications = Publication.all(:include => :authors, :conditions => "authors.id = #{User.current.author.id}")
+        else
+          @my_publications = []
+        end
+      end 
+
+      def render_publications_projects(publication)    
+        s = ""
+        projs = []
+        
+        publication.projects.each do |proj|
+          projs << link_to(proj.name, proj)
+        end
+        
+        s << projs.join(', ')
+        
+        s.html_safe
+      end
+
+      def render_publications_authors(publication)    
+        s = ""
+        auths = []
+        
+        publication.authorships.each do |auth|
+          auths << h(auth.name_on_paper)
+        end
+        
+        s << auths.join(', ')
+
+        s.html_safe
+      end
+
+
+    end
+  end
+end
+