-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Dmitriy Brodnitskiy
committed
Feb 18, 2013
1 parent
2e41099
commit 463ad68
Showing
7 changed files
with
123 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
module RedmineAttachmentsHelperIncognitoPatch | ||
def self.included(base) | ||
base.send(:include, InstanceMethods) | ||
base.class_eval do | ||
alias_method_chain :link_to_attachments, :incognito | ||
end | ||
end | ||
|
||
module InstanceMethods | ||
def link_to_attachments_with_incognito(container, options = {}) | ||
options.assert_valid_keys(:author, :thumbnails) | ||
|
||
project = params[:project_id] ? Project.find(params[:project_id]) : Issue.find(params[:id]).project if params[:controller] == 'issues' | ||
if container.attachments.any? && User.current.allowed_to?(:no_show_names, project) && !User.current.admin? | ||
options = {:deletable => container.attachments_deletable?, :author => false}.merge(options) | ||
render :partial => 'attachments/links', | ||
:locals => {:attachments => container.attachments, :options => options, :thumbnails => (options[:thumbnails] && Setting.thumbnails_enabled?)} | ||
else | ||
link_to_attachments_without_incognito(container, options) | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
module RedmineGroupIncognitoPatch | ||
def self.included(base) | ||
base.class_eval do | ||
|
||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
module RedmineIssuesHelperIncognitoPatch | ||
def self.included(base) | ||
base.send(:include, InstanceMethods) | ||
base.class_eval do | ||
alias_method_chain :find_name_by_reflection, :incognito | ||
end | ||
end | ||
|
||
module InstanceMethods | ||
def find_name_by_reflection_with_incognito(field, id) | ||
association = Issue.reflect_on_association(field.to_sym) | ||
if association | ||
record = association.class_name.constantize.find_by_id(id) | ||
|
||
if record | ||
if field == 'assigned_to' | ||
if params[:controller] == 'issues' | ||
project = params[:project_id] ? Project.find(params[:project_id]) : Issue.find(params[:id]).project | ||
elsif params[:controller] == 'projects' | ||
project = Project.find(params[:id]) | ||
end | ||
|
||
if User.current.allowed_to?(:no_show_names, project) && !User.current.admin? && params[:controller] = 'issues'||'projects' | ||
return record.roles_for_project(project).collect{|role| "#{role.name}" }.join(' ') | ||
end | ||
end | ||
find_name_by_reflection_without_incognito(field, id) | ||
end | ||
|
||
end | ||
end | ||
|
||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
module RedmineQueriesHelperIncognitoPatch | ||
def self.included(base) | ||
base.send(:include, InstanceMethods) | ||
base.class_eval do | ||
alias_method_chain :retrieve_query, :incognito | ||
end | ||
end | ||
|
||
module InstanceMethods | ||
|
||
def retrieve_query_with_incognito | ||
retrieve_query_without_incognito | ||
if params[:controller] == 'issues' | ||
project = params[:project_id] ? Project.find(params[:project_id]) : Issue.find(params[:id]).project | ||
elsif params[:controller] == 'projects' | ||
project = Project.find(params[:id]) | ||
end | ||
|
||
if User.current.allowed_to?(:no_show_names, project) && !User.current.admin? | ||
af = @query.available_filters | ||
%w(author_id assigned_to_id assigned_to_role watcher_id member_of_group).each do |filter| | ||
af.delete(filter) | ||
@query.available_filters = af | ||
end | ||
else | ||
retrieve_query_without_incognito | ||
end | ||
end | ||
|
||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
module RedmineQueryIncognitoPatch | ||
def self.included(base) | ||
base.class_eval do | ||
|
||
def available_filters=(value) | ||
@available_filters = value | ||
end | ||
|
||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,15 @@ | ||
require 'patches/redmine_user_incognito_patch' | ||
require 'patches/redmine_issues_helper_incognito_patch' | ||
require 'patches/redmine_query_incognito_patch' | ||
require 'patches/redmine_queries_helper_incognito_patch' | ||
require 'patches/redmine_attachments_helper_incognito_patch' | ||
|
||
Rails.configuration.to_prepare do | ||
ApplicationHelper.send(:include, RedmineUserIncognitoPatch) | ||
IssuesHelper.send(:include, RedmineIssuesHelperIncognitoPatch) | ||
Query.send(:include, RedmineQueryIncognitoPatch) | ||
QueriesHelper.send(:include, RedmineQueriesHelperIncognitoPatch) | ||
AttachmentsHelper.send(:include, RedmineAttachmentsHelperIncognitoPatch) | ||
|
||
|
||
end |