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 %>
diff --git a/app/views/profile_editor/index.rhtml b/app/views/profile_editor/index.rhtml
index dd30ecc..c6259ba 100644
--- a/app/views/profile_editor/index.rhtml
+++ b/app/views/profile_editor/index.rhtml
@@ -21,7 +21,7 @@
<%= file_manager_button(_('Edit Appearance'), 'icons-app/design-editor.png', :controller => 'themes', :action => 'index') %>
- <%= file_manager_button(_('Edit Header and Footer'), 'icons-app/header-and-footer.png', :controller => 'profile_editor', :action => 'header_footer') unless profile.enterprise? && environment.enabled?('disable_header_and_footer') && !user.is_admin? %>
+ <%= file_manager_button(_('Edit Header and Footer'), 'icons-app/header-and-footer.png', :controller => 'profile_editor', :action => 'header_footer') unless profile.enterprise? && environment.enabled?('disable_header_and_footer') && !user.is_admin?(environment) %>
<%= file_manager_button(_('Manage Content'), 'icons-app/cms.png', :controller => 'cms') unless environment.enabled?('disable_cms') || profile.community? %>
diff --git a/app/views/search/communities.rhtml b/app/views/search/communities.rhtml
index a178f9c..cd1eb52 100644
--- a/app/views/search/communities.rhtml
+++ b/app/views/search/communities.rhtml
@@ -14,7 +14,8 @@
<% if logged_in? %>
<% button_bar do %>
- <%= button(:add, _('New community'), :controller => 'memberships', :action => 'new_community', :profile => current_user.person.identifier) %>
+ <%# FIXME shouldn't the user create the community in the current environment instead of going to its home environment? %>
+ <%= button(:add, _('New community'), user.url.merge(:controller => 'memberships', :action => 'new_community')) %>
<% end %>
<% end %>
diff --git a/app/views/shared/user_menu.rhtml b/app/views/shared/user_menu.rhtml
index d90bf9b..f32f724 100644
--- a/app/views/shared/user_menu.rhtml
+++ b/app/views/shared/user_menu.rhtml
@@ -15,9 +15,9 @@