diff --git a/Gemfile b/Gemfile index 01af1938..bac187b1 100644 --- a/Gemfile +++ b/Gemfile @@ -14,8 +14,8 @@ group :test do gem 'edavis10-object_daddy', :require => 'object_daddy' gem 'mocha' - platforms :mri_18 do gem 'ruby-debug' end - platforms :mri_19 do gem 'ruby-debug19', :require => 'ruby-debug' end + platforms :mri_18, :mingw_18 do gem 'ruby-debug' end + platforms :mri_19, :mingw_19 do gem 'ruby-debug19', :require => 'ruby-debug' end end group :openid do @@ -32,7 +32,7 @@ end # orders of magnitude compared to their native counterparts. You have been # warned. -platforms :mri do +platforms :mri, :mingw do group :mysql do gem "mysql" # gem "ruby-mysql" @@ -48,13 +48,13 @@ platforms :mri do end end -platforms :mri_18 do +platforms :mri_18, :mingw_18 do group :sqlite do gem "sqlite3-ruby", "< 1.3", :require => "sqlite3" end end -platforms :mri_19 do +platforms :mri_19, :mingw_19 do group :sqlite do gem "sqlite3" end diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb index 8294586e..71d5077c 100644 --- a/app/controllers/issues_controller.rb +++ b/app/controllers/issues_controller.rb @@ -286,7 +286,7 @@ private render_error l(:error_no_tracker_in_project) return false end - @issue.start_date ||= User.current.today + @issue.start_date ||= User.current.today if Setting.issue_startdate_is_adddate? if params[:issue].is_a?(Hash) @issue.safe_attributes = params[:issue] if User.current.allowed_to?(:add_issue_watchers, @project) && @issue.new_record? diff --git a/app/models/query.rb b/app/models/query.rb index 052990ba..8056ffbd 100644 --- a/app/models/query.rb +++ b/app/models/query.rb @@ -208,7 +208,10 @@ class Query < ActiveRecord::Base @available_filters["assigned_to_role"] = { :type => :list_optional, :order => 7, :values => role_values } unless role_values.empty? if User.current.logged? - @available_filters["watcher_id"] = { :type => :list, :order => 15, :values => [["<< #{l(:label_me)} >>", "me"]] } + # populate the watcher list with the same user list as other user filters if the user has the :view_issue_watchers permission in at least one project + # TODO: this could be differentiated more, e.g. all users could watch issues in public projects, but won't necessarily be shown here + watcher_values = User.current.allowed_to_globally?(:view_issue_watchers, {}) ? user_values : [["<< #{l(:label_me)} >>", "me"]] + @available_filters["watcher_id"] = { :type => :list, :order => 15, :values => watcher_values } end if project @@ -442,8 +445,21 @@ class Query < ActiveRecord::Base elsif field == 'watcher_id' db_table = Watcher.table_name db_field = 'user_id' - sql << "#{Issue.table_name}.id #{ operator == '=' ? 'IN' : 'NOT IN' } (SELECT #{db_table}.watchable_id FROM #{db_table} WHERE #{db_table}.watchable_type='Issue' AND " - sql << sql_for_field(field, '=', v, db_table, db_field) + ')' + if User.current.admin? + # Admins can always see all watchers + sql << "#{Issue.table_name}.id #{operator == '=' ? 'IN' : 'NOT IN'} (SELECT #{db_table}.watchable_id FROM #{db_table} WHERE #{db_table}.watchable_type='Issue' AND #{sql_for_field field, '=', v, db_table, db_field})" + else + sql_parts = [] + if User.current.logged? && user_id = v.delete(User.current.id.to_s) + # a user can always see his own watched issues + sql_parts << "#{Issue.table_name}.id #{operator == '=' ? 'IN' : 'NOT IN'} (SELECT #{db_table}.watchable_id FROM #{db_table} WHERE #{db_table}.watchable_type='Issue' AND #{sql_for_field field, '=', [user_id], db_table, db_field})" + end + # filter watchers only in projects the user has the permission to view watchers in + project_ids = User.current.projects_by_role.collect {|r,p| p if r.permissions.include? :view_issue_watchers}.flatten.compact.collect(&:id).uniq + sql_parts << "#{Issue.table_name}.id #{operator == '=' ? 'IN' : 'NOT IN'} (SELECT #{db_table}.watchable_id FROM #{db_table} WHERE #{db_table}.watchable_type='Issue' AND #{sql_for_field field, '=', v, db_table, db_field})"\ + " AND #{Project.table_name}.id IN (#{project_ids.join(',')})" unless project_ids.empty? + sql << "(#{sql_parts.join(' OR ')})" + end elsif field == "member_of_group" # named field if operator == '*' # Any group groups = Group.all diff --git a/app/views/projects/_form.rhtml b/app/views/projects/_form.rhtml index 43f9a1b9..c54863f2 100644 --- a/app/views/projects/_form.rhtml +++ b/app/views/projects/_form.rhtml @@ -24,7 +24,7 @@ <% if @project.new_record? %> -
<%= l(:label_module_plural) %> +
<%= l(:label_module_plural) %> (<%= check_all_links 'project_modules' %>) <% Redmine::AccessControl.available_project_modules.each do |m| %>