Blame view

lib/redmine_cps/patches/app/helpers/application_helper.rb 786 Bytes
redmine authored
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
# encoding: UTF-8

require 'application_helper'

module CPS
	module ApplicationHelperPatch
		def self.included(base)
			base.extend(ClassMethods)
			base.send(:include, InstanceMethods)

			base.class_eval do
				alias_method_chain :link_to_user, :cps
			end
		end

		module ClassMethods
		end

		module InstanceMethods
			def link_to_user_with_cps(user, options={})
				if user.is_a?(User)
					name = h(user.name(options[:format]))
					if user.active? || (User.current.admin? && user.logged?)
						link_to "#{name}", user_path(user), {:class => user.css_classes, :title => "#{user.lastname} #{user.firstname}; #{user.appointment}"}
					else
						name
					end
				else
					h(user.to_s)
				end
			end
		end
	end
end
ApplicationHelper.send(:include, CPS::ApplicationHelperPatch)