|
|
|
@ -236,13 +236,7 @@ class ApplicationController < ActionController::Base
|
|
|
|
|
# Authorize the user for the requested action
|
|
|
|
|
def authorize(ctrl = params[:controller], action = params[:action], global = false)
|
|
|
|
|
#modify by NWB
|
|
|
|
|
if @project
|
|
|
|
|
allowed = User.current.allowed_to?({:controller => ctrl, :action => action}, @project || @projects, :global => global)
|
|
|
|
|
elsif @course
|
|
|
|
|
allowed = User.current.allowed_to?({:controller => ctrl, :action => action}, @course || @courses, :global => global)
|
|
|
|
|
else
|
|
|
|
|
allowed = User.current.allowed_to?({:controller => ctrl, :action => action}, @project || @projects, :global => global)
|
|
|
|
|
end
|
|
|
|
|
allowed = authorize_allowed(params[:controller], params[:action],global)
|
|
|
|
|
|
|
|
|
|
if allowed
|
|
|
|
|
true
|
|
|
|
@ -255,6 +249,17 @@ class ApplicationController < ActionController::Base
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def authorize_allowed(ctrl = params[:controller], action = params[:action], global = false)
|
|
|
|
|
#modify by NWB
|
|
|
|
|
if @project
|
|
|
|
|
allowed = User.current.allowed_to?({:controller => ctrl, :action => action}, @project || @projects, :global => global)
|
|
|
|
|
elsif @course
|
|
|
|
|
allowed = User.current.allowed_to?({:controller => ctrl, :action => action}, @course || @courses, :global => global)
|
|
|
|
|
else
|
|
|
|
|
allowed = User.current.allowed_to?({:controller => ctrl, :action => action}, @project || @projects, :global => global)
|
|
|
|
|
end
|
|
|
|
|
allowed
|
|
|
|
|
end
|
|
|
|
|
def authorize_attachment_download(ctrl = params[:controller], action = params[:action], global = false)
|
|
|
|
|
case @attachment.container_type
|
|
|
|
|
when "Memo"
|
|
|
|
|