Project

General

Profile

Patch #21055 » patch_user-auth-source-filter_RM3.1.1.patch

patch based on Redmine 3.1.1_stable code - Olivier Houdas, 2015-10-23 12:36

View differences:

app/controllers/users_controller.rb Sun Sep 20 06:20:40 2015 +0000 → app/controllers/users_controller.rb Fri Oct 23 12:28:55 2015 +0200
scope = User.logged.status(@status).preload(:email_address)
scope = scope.like(params[:name]) if params[:name].present?
scope = scope.in_group(params[:group_id]) if params[:group_id].present?
scope = scope.auth_source(params[:auth_source]) if (params[:auth_source].present? && !params[:auth_source].blank?)
@user_count = scope.count
@user_pages = Paginator.new @user_count, @limit, params['page']
app/helpers/users_helper.rb Sun Sep 20 06:20:40 2015 +0000 → app/helpers/users_helper.rb Fri Oct 23 12:28:44 2015 +0200
["#{l(:status_locked)} (#{user_count_by_status[3].to_i})", '3']], selected.to_s)
end
def users_auth_sources_options_for_select(selected)
options = [[l(:label_all), ''],
[l(:label_internal), 'NULL']]
AuthSource.all.each do |as|
options << [as.name, as.id]
end
options_for_select(options, selected.to_s)
end
def user_mail_notification_options(user)
user.valid_notification_options.collect {|o| [l(o.last), o.first]}
end
app/models/user.rb Sun Sep 20 06:20:40 2015 +0000 → app/models/user.rb Fri Oct 23 12:29:06 2015 +0200
none
end
}
scope :auth_source, lambda {|auth_source_id|
if (auth_source_id == 'NULL')
where("#{User.table_name}.auth_source_id IS NULL", auth_source_id)
else
where("#{User.table_name}.auth_source_id = ?", auth_source_id)
end
}
def set_mail_notification
self.mail_notification = Setting.default_notification_option if self.mail_notification.blank?
app/views/users/index.html.erb Sun Sep 20 06:20:40 2015 +0000 → app/views/users/index.html.erb Fri Oct 23 12:29:20 2015 +0200
<label for='name'><%= l(:label_user) %>:</label>
<%= text_field_tag 'name', params[:name], :size => 30 %>
<label for='auth_source'><%= l(:label_auth_source) %>:</label>
<%= select_tag 'auth_source', users_auth_sources_options_for_select(params[:auth_source]), :onchange => "this.form.submit(); return false;" %>
<%= submit_tag l(:button_apply), :class => "small", :name => nil %>
<%= link_to l(:button_clear), users_path, :class => 'icon icon-reload' %>
</fieldset>
    (1-1/1)