diff --git a/app/controllers/public/account_controller.rb b/app/controllers/public/account_controller.rb
index 5b0e39a..d8dadd1 100644
--- a/app/controllers/public/account_controller.rb
+++ b/app/controllers/public/account_controller.rb
@@ -238,7 +238,7 @@ class AccountController < ApplicationController
def user_data
user_data =
if logged_in?
- { "login" => current_user.login, "is_admin" => user.is_admin?(environment), 'since_month' => user.created_at.month, 'since_year' => user.created_at.year }
+ { "login" => current_user.login, "is_admin" => user.is_admin?(environment), 'since_month' => user.created_at.month, 'since_year' => user.created_at.year, 'email_domain' => current_user.enable_email ? current_user.email_domain : nil }
else
{ }
end
diff --git a/app/views/shared/user_menu.rhtml b/app/views/shared/user_menu.rhtml
index a749414..051ead7 100644
--- a/app/views/shared/user_menu.rhtml
+++ b/app/views/shared/user_menu.rhtml
@@ -29,11 +29,11 @@
- <%# if MailConf.enabled? && current_user.enable_email %>
-
- <%# link_to '' + _('Webmail'), MailConf.webmail_url(user.identifier, current_user.email_domain) %>
+ <% if MailConf.enabled? %>
+
+ <%= link_to '' + _('Webmail'), MailConf.webmail_url('%{login}', '%{email_domain}') %>
- <%# end %>
+ <% end %>
<%= link_to(''+ _('Control panel'), '/myprofile/%{login}', :id => 'link_edit_profile') %>
diff --git a/public/javascripts/application.js b/public/javascripts/application.js
index 788daca..acf7355 100644
--- a/public/javascripts/application.js
+++ b/public/javascripts/application.js
@@ -442,13 +442,20 @@ jQuery(function($) {
// logged in
$('#user .logged-in, .login-block .logged-user-info').each(function() {
$(this).find('a[href]').each(function() {
- $(this).attr('href', $(this).attr('href').replace('%{login}', data.login))
+ var new_href = $(this).attr('href').replace('%{login}', data.login);
+ if (data.email_domain) {
+ new_href = new_href.replace('%{email_domain}', data.email_domain);
+ }
+ $(this).attr('href', new_href);
});
var html = $(this).html().replace(/%{login}/g, data.login).replace('%{month}', data.since_month).replace('%{year}', data.since_year);
$(this).html(html).fadeIn();
if (data.is_admin) {
$('#user .admin-link').show();
}
+ if (data.email_domain) {
+ $('#user .webmail-link').show();
+ }
});
} else {
// not logged in
diff --git a/test/functional/application_controller_test.rb b/test/functional/application_controller_test.rb
index bb26a36..9fb3771 100644
--- a/test/functional/application_controller_test.rb
+++ b/test/functional/application_controller_test.rb
@@ -201,12 +201,11 @@ class ApplicationControllerTest < Test::Unit::TestCase
assert_tag :tag => 'option', :attributes => { :value => 'it' }, :content => 'Italiano'
end
- should 'display link to webmail if enabled for system and for user' do
+ should 'display link to webmail if enabled for system' do
@controller.stubs(:get_layout).returns('application')
login_as('ze')
MailConf.expects(:enabled?).returns(true)
MailConf.expects(:webmail_url).returns('http://web.mail/')
- User.any_instance.expects(:enable_email).returns(true)
get :index
assert_tag :tag => 'div', :attributes => { :id => 'user_box' }, :descendant => { :tag => 'a', :attributes => { :href => 'http://web.mail/' } }
@@ -221,16 +220,6 @@ class ApplicationControllerTest < Test::Unit::TestCase
assert_no_tag :tag => 'div', :attributes => { :id => 'user_box' }, :descendant => { :tag => 'a', :attributes => { :href => 'http://web.mail/' } }
end
- should 'not display link in menu to webmail if not enabled for user' do
- @controller.stubs(:get_layout).returns('application')
- login_as('ze')
- MailConf.expects(:enabled?).returns(true)
- User.any_instance.expects(:enable_email).returns(false)
-
- get :index
- assert_no_tag :tag => 'div', :attributes => { :id => 'user_box' }, :descendant => { :tag => 'a', :attributes => { :href => 'http://web.mail/' } }
- end
-
should 'display theme test panel when testing theme' do
@request.session[:theme] = 'my-test-theme'
theme = mock
--
libgit2 0.21.2