Sha256: 7ae6898b57c267d48df3dfefbdce55d5fb506b065bb7d3179f91540430d8f677

Contents?: true

Size: 1.9 KB

Versions: 4

Compression:

Stored size: 1.9 KB

Contents

class Admin::ForumController < AdminController
  before_filter { licensed("forums") }

  layout 'cms-boxed'


  def index
   @topic_category ||= TopicCategory.new 
   @topic ||= Topic.new
   @selected_cat = params[:selected_cat]
  end

  def delete_category
    @category = TopicCategory.find_sys_id(_sid, params[:id])

    if @category.topics.count > 0 
      flash[:notice] = "This category can't be deleted because it contains topic(s).  Delete those first."
    else
      TopicCategory.delete_all("id = #{params[:id]} and system_id = #{_sid}")
      flash[:notice] = "Category deleted"
    end

    redirect_to "/admin/forums"
  end

  def edit_category
    @category = TopicCategory.find_sys_id(_sid, params[:id])
    render "admin/forum/category"
  end

  def update_category
    @category = TopicCategory.find_sys_id(_sid, params[:id])
    if @category.update_attributes(params[:topic_category])
      flash[:notice] = "Category Updated"
      redirect_to "/admin/forums"
    else
      render "admin/forum/category"
    end
  end


  def create_topic
    add_sid(:topic)
    @topic = Topic.new(params[:topic])
    @topic.is_open = true
    @topic.system_id = _sid
    @topic.is_visible = true
    @topic.read_access_level = 0
    @topic.write_access_level = 1

    @selected_cat = @topic.topic_category_id
   @topic_category ||= TopicCategory.new 

    if @topic.save
      flash[:notice] = "Topic created"
      redirect_to "/admin/forums?selected_cat=#{@selected_cat}"
    else
      render "index"
    end
  end

  def create_category
    add_sid(:topic_category)
    @topic_category = TopicCategory.new(params[:topic_category])

    @topic_category.read_access_level = 0
    @topic_category.write_access_level = 1
    @topic_category.is_open = true
    if @topic_category.save
      flash[:notice] = "Category created"
      redirect_to "/admin/forums"
    else
      @topic ||= Topic.new
      render "index"
    end 
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
kit_cms-2.3.9 app/controllers/admin/forum_controller.rb
kit_cms-2.3.8 app/controllers/admin/forum_controller.rb
kit_cms-2.3.7 app/controllers/admin/forum_controller.rb
kit_cms-2.3.6 app/controllers/admin/forum_controller.rb