diff --git a/src/app/controllers/users_controller.rb b/src/app/controllers/users_controller.rb index 7dfb6e1a705..fd4341d9ae9 100644 --- a/src/app/controllers/users_controller.rb +++ b/src/app/controllers/users_controller.rb @@ -17,9 +17,9 @@ def section_id 'operations' end - before_filter :setup_options, :only => [:items, :index, :account] - before_filter :find_user, :only => [:index, :edit, :edit_environment, :update_environment, - :update, :update_roles, :clear_helptips, :destroy, :account] + before_filter :setup_options, :only => [:items, :index] + before_filter :find_user, :only => [:items, :index, :edit, :edit_environment, :update_environment, + :update, :update_roles, :clear_helptips, :destroy] before_filter :authorize skip_before_filter :require_org @@ -51,18 +51,20 @@ def rules :disable_helptip => user_helptip, } end - + + # Render list of users. Note that if the current user does not have permission + # to view all users, the results are restricted to just themselves. def items if User.any_readable? - render_panel_items(User.readable, @panel_options, params[:search], params[:offset]) + if params[:only] + users = [@user] + else + users = User.readable + end else - render_panel_items([current_user], @panel_options, params[:search], params[:offset]) + users = [current_user] end - end - - def account - @user = current_user - render_panel_items([current_user], @panel_options, params[:search], params[:offset]) + render_panel_items(users, @panel_options, params[:search], params[:offset]) end def edit diff --git a/src/app/views/layouts/_header.haml b/src/app/views/layouts/_header.haml index 02abde610da..73cee602640 100644 --- a/src/app/views/layouts/_header.haml +++ b/src/app/views/layouts/_header.haml @@ -13,7 +13,7 @@ = render :partial => '/layouts/org' %ul %li.hello - = link_to users_path do + = link_to users_path(:id => current_user, :only => true) do %strong = current_user.username %li diff --git a/src/app/views/users/index.html.haml b/src/app/views/users/index.html.haml index 33e33e69636..8b156272c50 100644 --- a/src/app/views/users/index.html.haml +++ b/src/app/views/users/index.html.haml @@ -1,4 +1,8 @@ = javascript :edit, :edit_helpers, :env_select += javascript do + :javascript + var only = '#{@only}' + .grid_16#main = two_panel(@users, @panel_options) diff --git a/src/public/javascripts/panel.js b/src/public/javascripts/panel.js index 4aa37d0ed88..af71a49186f 100644 --- a/src/public/javascripts/panel.js +++ b/src/public/javascripts/panel.js @@ -494,6 +494,17 @@ KT.panel = (function ($) { }); panels_list.push(new_panel); }, + // http://devnull.djolley.net/2010/11/accessing-query-string-parameters-from.html + queryParameters = function () { + var queryString = new Object; + var qstr=window.location.search.substring(1); + var params=qstr.split('&'); + for (var i=0; i