application_helper.rb 786 Bytes
# 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)