课程留言、讨论区增加权限控制

This commit is contained in:
sw 2014-12-05 14:41:53 +08:00
parent a2537899b7
commit dc5be133c2
2 changed files with 32 additions and 22 deletions

View File

@ -39,13 +39,18 @@ class BoardsController < ApplicationController
end
render :layout => false if request.xhr?
elsif @course
@boards = @course.boards.includes(:last_message => :author).all
@boards = [] << @boards[0] if @boards.any?
if @boards.size == 1
@board = @boards.first
show and return
if (User.current.admin? || @course.is_public == 1 || (@course.is_public == 0 && User.current.member_of_course?(@course)))
@boards = @course.boards.includes(:last_message => :author).all
@boards = [] << @boards[0] if @boards.any?
if @boards.size == 1
@board = @boards.first
show and return
end
render :layout => 'base_courses'
else
render_403
end
render :layout => 'base_courses'
end
end

View File

@ -669,24 +669,29 @@ class CoursesController < ApplicationController
end
def feedback
page = params[:page]
# Find the page of the requested reply
@jours = @course.journals_for_messages.where('m_parent_id IS NULL').order('created_on DESC')
@limit = 10
if params[:r] && page.nil?
offset = @jours.count(:conditions => ["#{JournalsForMessage.table_name}.id > ?", params[:r].to_i])
page = 1 + offset / @limit
if (User.current.admin? || @course.is_public == 1 || (@course.is_public == 0 && User.current.member_of_course?(@course)))
page = params[:page]
# Find the page of the requested reply
@jours = @course.journals_for_messages.where('m_parent_id IS NULL').order('created_on DESC')
@limit = 10
if params[:r] && page.nil?
offset = @jours.count(:conditions => ["#{JournalsForMessage.table_name}.id > ?", params[:r].to_i])
page = 1 + offset / @limit
end
#@feedback_count = @jours.count
#@feedback_pages = Paginator.new @feedback_count, @limit, page
#@offset ||= @feedback_pages.offset
@jour = paginateHelper @jours,10
@state = false
respond_to do |format|
format.html{render :layout => 'base_courses'}
format.api
end
else
render_403
end
#@feedback_count = @jours.count
#@feedback_pages = Paginator.new @feedback_count, @limit, page
#@offset ||= @feedback_pages.offset
@jour = paginateHelper @jours,10
@state = false
respond_to do |format|
format.html{render :layout => 'base_courses'}
format.api
end
end