lib/contract/authorize.rb
def load_additional_resource(url,type=0)
		# type = 0 => print, 1 => revise
		if url.present?
			authorize = authorize_url(url)
			if authorize == true
				user_group = UserGroup.find(current_user.try(:user_group_id))
				menu_id = UserMenu.where(:url => url).first.try(:id)
				user_access = UserGroupUserMenu.where(:user_menu_id => menu_id.to_i, :user_group_id => user_group.id.to_i).last
				if user_access.present?
					if type.to_i == 0 # Print
						allow = user_access.can_print
					elsif type.to_i == 1 # Revise
						allow = user_access.can_revise
					else	
						allow = false
					end
				else
					allow = false
				end
			else
				# raise CanCan::AccessDenied
				allow = false
			end
		else
			# raise CanCan::AccessDenied
			allow = false
		end
		return allow
	end
# Check additional resource control for current_user
Check additional resource control for current_user
Check additional resource control for current_user
def load_additional_resource(url,type=0)
		if url.present?
			authorize = authorize_url(url)
			if authorize == true
				user_group = UserGroup.find(current_user.try(:user_group_id))
				menu_id = UserMenu.where(:url => url).first.try(:id)
				user_access = UserGroupUserMenu.where(:user_menu_id => menu_id.to_i, :user_group_id => user_group.id.to_i).last
				if user_access.present?
					if type.to_i == 0 
						allow = user_access.can_print
					elsif type.to_i == 1 
						allow = user_access.can_revise
					else	
						allow = false
					end
				else
					allow = false
				end
			else
				allow = false
			end
		else
			allow = false
		end
		return allow
	end
def load_additional_resource ( url , type = 0 ) if url . present? authorize = authorize_url ( url ) if authorize == true user_group = UserGroup . find ( current_user . try ( :user_group_id ) ) menu_id = UserMenu . where ( :url => url ) . first . try ( :id ) user_access = UserGroupUserMenu . where ( :user_menu_id => menu_id . to_i , :user_group_id => user_group . id . to_i ) . last if user_access . present? if type . to_i == 0 allow = user_access . can_print elsif type . to_i == 1 allow = user_access . can_revise else allow = false end else allow = false end else allow = false end else allow = false end return allow end
Check additional resource control for current_user
Check additional resource control for current_user
# type = 0 => print, 1 => revise # Print # Revise # raise CanCan::AccessDenied # raise CanCan::AccessDenied
url
type