comparison app/controllers/.svn/text-base/users_controller.rb.svn-base @ 441:cbce1fd3b1b7 redmine-1.2

Update to Redmine 1.2-stable branch (Redmine SVN rev 6000)
author Chris Cannam
date Mon, 06 Jun 2011 14:24:13 +0100
parents 07fa8a8b56a8
children 0c939c159af4
comparison
equal deleted inserted replaced
245:051f544170fe 441:cbce1fd3b1b7
1 # Redmine - project management software 1 # Redmine - project management software
2 # Copyright (C) 2006-2010 Jean-Philippe Lang 2 # Copyright (C) 2006-2011 Jean-Philippe Lang
3 # 3 #
4 # This program is free software; you can redistribute it and/or 4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License 5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2 6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version. 7 # of the License, or (at your option) any later version.
36 @offset, @limit = api_offset_and_limit 36 @offset, @limit = api_offset_and_limit
37 else 37 else
38 @limit = per_page_option 38 @limit = per_page_option
39 end 39 end
40 40
41 scope = User
42 scope = scope.in_group(params[:group_id].to_i) if params[:group_id].present?
43
41 @status = params[:status] ? params[:status].to_i : 1 44 @status = params[:status] ? params[:status].to_i : 1
42 c = ARCondition.new(@status == 0 ? "status <> 0" : ["status = ?", @status]) 45 c = ARCondition.new(@status == 0 ? "status <> 0" : ["status = ?", @status])
43 46
44 unless params[:name].blank? 47 unless params[:name].blank?
45 name = "%#{params[:name].strip.downcase}%" 48 name = "%#{params[:name].strip.downcase}%"
46 c << ["LOWER(login) LIKE ? OR LOWER(firstname) LIKE ? OR LOWER(lastname) LIKE ? OR LOWER(mail) LIKE ?", name, name, name, name] 49 c << ["LOWER(login) LIKE ? OR LOWER(firstname) LIKE ? OR LOWER(lastname) LIKE ? OR LOWER(mail) LIKE ?", name, name, name, name]
47 end 50 end
48 51
49 @user_count = User.count(:conditions => c.conditions) 52 @user_count = scope.count(:conditions => c.conditions)
50 @user_pages = Paginator.new self, @user_count, @limit, params['page'] 53 @user_pages = Paginator.new self, @user_count, @limit, params['page']
51 @offset ||= @user_pages.current.offset 54 @offset ||= @user_pages.current.offset
52 @users = User.find :all, 55 @users = scope.find :all,
53 :order => sort_clause, 56 :order => sort_clause,
54 :conditions => c.conditions, 57 :conditions => c.conditions,
55 :limit => @limit, 58 :limit => @limit,
56 :offset => @offset 59 :offset => @offset
57 60
58 respond_to do |format| 61 respond_to do |format|
59 format.html { render :layout => !request.xhr? } 62 format.html {
63 @groups = Group.all.sort
64 render :layout => !request.xhr?
65 }
60 format.api 66 format.api
61 end 67 end
62 end 68 end
63 69
64 def show 70 def show
65 # show projects based on current user visibility 71 # show projects based on current user visibility
66 @memberships = @user.memberships.all(:conditions => Project.visible_by(User.current)) 72 @memberships = @user.memberships.all(:conditions => Project.visible_condition(User.current))
67 73
68 events = Redmine::Activity::Fetcher.new(User.current, :author => @user).events(nil, nil, :limit => 10) 74 events = Redmine::Activity::Fetcher.new(User.current, :author => @user).events(nil, nil, :limit => 10)
69 @events_by_day = events.group_by(&:event_date) 75 @events_by_day = events.group_by(&:event_date)
70 76
71 unless User.current.admin? 77 unless User.current.admin?