|
|
|
@ -4,6 +4,8 @@ class ForumsController < ApplicationController
|
|
|
|
|
# GET /forums.json
|
|
|
|
|
before_filter :authenticate_user_edit, :only => [:edit, :update]
|
|
|
|
|
before_filter :authenticate_user_destroy, :only => [:destroy]
|
|
|
|
|
|
|
|
|
|
PageLimit = 20
|
|
|
|
|
|
|
|
|
|
def index
|
|
|
|
|
@offset, @limit = api_offset_and_limit({:limit => 10})
|
|
|
|
@ -101,7 +103,43 @@ class ForumsController < ApplicationController
|
|
|
|
|
format.json { head :no_content }
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def search_forum
|
|
|
|
|
# @forums = paginateHelper Forum.where("name LIKE '%#{params[:name]}%'")
|
|
|
|
|
@offset, @limit = api_offset_and_limit({:limit => 10})
|
|
|
|
|
@forums_all = Forum.where("name LIKE '%#{params[:name]}%'")
|
|
|
|
|
@forums_count = @forums_all.count
|
|
|
|
|
@forums_pages = Paginator.new @forums_count, @limit, params['page']
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@offset ||= @forums_pages.offset
|
|
|
|
|
@forums = @forums_all.offset(@offset).limit(@limit).all
|
|
|
|
|
respond_to do |format|
|
|
|
|
|
format.html {
|
|
|
|
|
render 'index'
|
|
|
|
|
}
|
|
|
|
|
format.json { render json: @forums }
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def search_memo
|
|
|
|
|
limit = PageLimit
|
|
|
|
|
@memo = Memo.new
|
|
|
|
|
@offset, @limit = api_offset_and_limit({:limit => limit})
|
|
|
|
|
@forum = Forum.find(params[:id])
|
|
|
|
|
@memos_all = @forum.topics.where("subject LIKE '%#{params[:name]}%'")
|
|
|
|
|
@topic_count = @memos_all.count
|
|
|
|
|
@topic_pages = Paginator.new @topic_count, @limit, params['page']
|
|
|
|
|
|
|
|
|
|
@offset ||= @topic_pages.offset
|
|
|
|
|
@memos = @memos_all.offset(@offset).limit(@limit).all
|
|
|
|
|
respond_to do |format|
|
|
|
|
|
format.html {
|
|
|
|
|
render 'show', :layout => 'base_forums'
|
|
|
|
|
}
|
|
|
|
|
format.json { render json: @forum }
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
|
@ -121,4 +159,5 @@ end
|
|
|
|
|
def authenticate_user_destroy
|
|
|
|
|
find_forum
|
|
|
|
|
render_403 unless @forum.destroyable_by? User.current
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|