diff --git a/app/controllers/public/account_controller.rb b/app/controllers/public/account_controller.rb index 5dd5c37..9691667 100644 --- a/app/controllers/public/account_controller.rb +++ b/app/controllers/public/account_controller.rb @@ -261,7 +261,11 @@ class AccountController < ApplicationController end def go_to_user_initial_page - redirect_back_or_default(:controller => "profile_editor", :profile => current_user.login, :action => 'index') + if environment == current_user.environment + redirect_back_or_default(user.admin_url) + else + redirect_back_or_default(:controller => 'home') + end end end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 6cdebe2..2617ad9 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -121,13 +121,22 @@ module ApplicationHelper end def link_to_homepage(text, profile = nil, options = {}) - profile ||= current_user.login - link_to text, homepage_path(:profile => profile) , options + p = if profile + Profile[profile] + else + user + end + + link_to text, p.url, options end def link_to_myprofile(text, url = {}, profile = nil, options = {}) - profile ||= current_user.login - link_to text, { :profile => profile, :controller => 'profile_editor' }.merge(url), options + p = if profile + Profile[profile] + else + user + end + link_to text, p.admin_url.merge(url), options end def link_to_document(doc, text = nil) diff --git a/app/models/person.rb b/app/models/person.rb index e52bc76..7d21a82 100644 --- a/app/models/person.rb +++ b/app/models/person.rb @@ -154,8 +154,8 @@ class Person < Profile person.user.save! end - def is_admin? - role_assignments.map{|ra|ra.role.permissions}.any? do |ps| + def is_admin?(environment) + role_assignments.select { |ra| ra.resource == environment }.map{|ra|ra.role.permissions}.any? do |ps| ps.any? do |p| ActiveRecord::Base::PERMISSIONS['Environment'].keys.include?(p) end diff --git a/app/views/blocks/profile_info_actions/person.rhtml b/app/views/blocks/profile_info_actions/person.rhtml index 6f47392..054e2d2 100644 --- a/app/views/blocks/profile_info_actions/person.rhtml +++ b/app/views/blocks/profile_info_actions/person.rhtml @@ -2,7 +2,7 @@ <%if logged_in? && (user != profile) %> <% if !user.already_request_friendship?(profile) and !user.is_a_friend?(profile) %> -
  • <%= link_to content_tag('span', __('Add friend')), { :profile => user.identifier, :controller => 'friends', :action => 'add', :id => profile.id }, :class => 'button with-text icon-add' %>
  • +
  • <%= link_to content_tag('span', __('Add friend')), user.url.merge(:controller => 'friends', :action => 'add', :id => profile.id), :class => 'button with-text icon-add' %>
  • <% end %> <% if user.is_a_friend?(profile) && profile.enable_contact? %> diff --git a/app/views/home/index.rhtml b/app/views/home/index.rhtml index 19c9388..c764d74 100644 --- a/app/views/home/index.rhtml +++ b/app/views/home/index.rhtml @@ -1,5 +1,3 @@ -<%= flash[:notice] %> - <%= @environment.description %>