class Forum::ForumTopicsController < ApplicationController
  layout "forum"
  
  before_filter :auth_fuser
  


  def show
    @topic = ForumTopic.find(params[:id])

  end


  def new
    
    @topic = ForumTopic.new(:category_id => params[:category_id])
    @topic.forum_messages.new(:forum_user => current_fuser)
  end

  def edit
    @topic = ForumTopic.find(params[:id])
  
  end

  def create
  	@topic = ForumTopic.new(params[:forum_topic])
    @topic.forum_user = current_fuser
    if @topic.save
      redirect_to [:forum, @topic]
          
  	else
  		render :action => "new" 
  	end
  end

  def update
  	@topic = ForumTopic.find(params[:id])
    
    if @topic.update_attributes(params[:forum_topic])
      redirect_to forum_forum_category_path(@topic.category)
          
  	else
  		render :action => "edit" 
  	end
    
  end
  		


  def destroy
  	@topic = ForumTopic.find(params[:id])
	  @topic.destroy
    redirect_to forum_forum_category_path(@topic.category)

  end



end
