Permalink
Fetching contributors…
Cannot retrieve contributors at this time
35 lines (29 sloc) 1.43 KB
module ProfilesHelper
def icon_for_profile(profile, size, options={})
if profile.icon?
federated_icon = profile.federated_profile_image_url
photo_url = (profile.icon_file_name=='default_profile.png' && !federated_icon.nil? && federated_icon) || profile.icon.url(size)
options.merge!(:alt => I18n.t("tog_social.profiles.helper.photo_for_user", :name => profile.full_name))
return image_tag(photo_url, options) if photo_url
else
return image_tag("/tog_social/images/#{config["plugins.tog_social.profile.image.default"]}" , options)
end
end
def its_me?(profile=@profile)
logged_in? && profile && current_user.profile == profile
end
def following_options(profile=@profile)
if logged_in? && current_user.profile.follows?(profile)
link_to I18n.t("tog_social.profiles.helper.unfollow_user", :name => profile.full_name), member_unfollow_user_path(profile)
else
link_to I18n.t("tog_social.profiles.helper.follow_user", :name => profile.full_name), member_follow_user_path(profile)
end
end
def friendship_options(profile=@profile)
if logged_in? && current_user.profile.is_friend_of?(profile)
link_to I18n.t("tog_social.profiles.helper.remove_friend", :name => profile.full_name), member_unfollow_user_path(profile)
else
link_to I18n.t("tog_social.profiles.helper.add_friend", :name => profile.full_name), member_add_friend_path(profile)
end
end
end