Merged r6163, r6171, r6172, r6174 from trunk.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.2-stable@6175 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
@@ -18,6 +18,8 @@
|
||||
require 'uri'
|
||||
require 'cgi'
|
||||
|
||||
class Unauthorized < Exception; end
|
||||
|
||||
class ApplicationController < ActionController::Base
|
||||
include Redmine::I18n
|
||||
|
||||
@@ -41,6 +43,7 @@ class ApplicationController < ActionController::Base
|
||||
protect_from_forgery
|
||||
|
||||
rescue_from ActionController::InvalidAuthenticityToken, :with => :invalid_authenticity_token
|
||||
rescue_from ::Unauthorized, :with => :deny_access
|
||||
|
||||
include Redmine::Search::Controller
|
||||
include Redmine::MenuManager::MenuController
|
||||
|
||||
@@ -70,6 +70,7 @@ module QueriesHelper
|
||||
cond = "project_id IS NULL"
|
||||
cond << " OR project_id = #{@project.id}" if @project
|
||||
@query = Query.find(params[:query_id], :conditions => cond)
|
||||
raise ::Unauthorized unless @query.visible?
|
||||
@query.project = @project
|
||||
session[:query] = {:id => @query.id, :project_id => @query.project_id}
|
||||
sort_clear
|
||||
|
||||
@@ -165,6 +165,11 @@ class Query < ActiveRecord::Base
|
||||
["o", "c", "!*", "*", "t", "w"].include? operator_for(field)
|
||||
end if filters
|
||||
end
|
||||
|
||||
# Returns true if the query is visible to +user+ or the current user.
|
||||
def visible?(user=User.current)
|
||||
self.is_public? || self.user_id == user.id
|
||||
end
|
||||
|
||||
def editable_by?(user)
|
||||
return false unless user
|
||||
|
||||
Reference in New Issue
Block a user