fixes #139: New forum threads submitted locked/stickied are neither.
This commit is contained in:
@@ -30,7 +30,7 @@ class ForumTopicsController < ApplicationController
|
||||
end
|
||||
|
||||
def create
|
||||
@forum_topic = ForumTopic.create(params[:forum_topic])
|
||||
@forum_topic = ForumTopic.create(params[:forum_topic], :as => CurrentUser.role)
|
||||
respond_with(@forum_topic)
|
||||
end
|
||||
|
||||
@@ -38,7 +38,7 @@ class ForumTopicsController < ApplicationController
|
||||
@forum_topic = ForumTopic.find(params[:id])
|
||||
check_privilege(@forum_topic)
|
||||
assign_special_attributes(@forum_topic)
|
||||
@forum_topic.update_attributes(params[:forum_topic])
|
||||
@forum_topic.update_attributes(params[:forum_topic], :as => CurrentUser.role)
|
||||
respond_with(@forum_topic)
|
||||
end
|
||||
|
||||
|
||||
@@ -119,6 +119,10 @@ class AnonymousUser
|
||||
def update_column(*params)
|
||||
end
|
||||
|
||||
def role
|
||||
:anonymous
|
||||
end
|
||||
|
||||
%w(member banned privileged contributor janitor moderator admin).each do |name|
|
||||
define_method("is_#{name}?") do
|
||||
false
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
class ForumTopic < ActiveRecord::Base
|
||||
attr_accessible :title, :original_post_attributes
|
||||
attr_accessible :is_sticky, :is_locked, :as => :janitor
|
||||
belongs_to :creator, :class_name => "User"
|
||||
belongs_to :updater, :class_name => "User"
|
||||
has_many :posts, :class_name => "ForumPost", :order => "forum_posts.id asc", :foreign_key => "topic_id", :dependent => :destroy
|
||||
|
||||
@@ -199,6 +199,28 @@ class User < ActiveRecord::Base
|
||||
end
|
||||
end
|
||||
|
||||
def role
|
||||
case level
|
||||
when Levels::MEMBER
|
||||
:member
|
||||
|
||||
when Levels::PRIVILEGED
|
||||
:privileged
|
||||
|
||||
when Levels::CONTRIBUTOR
|
||||
:contributor
|
||||
|
||||
when Levels::JANITOR
|
||||
:janitor
|
||||
|
||||
when Levels::MODERATOR
|
||||
:moderator
|
||||
|
||||
when Levels::ADMIN
|
||||
:admin
|
||||
end
|
||||
end
|
||||
|
||||
def level_string
|
||||
case level
|
||||
when Levels::MEMBER
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
<div id="c-forum-topics">
|
||||
<div id="a-show">
|
||||
<h1>Topic: <%= @forum_topic.title %></h1>
|
||||
|
||||
<% if @forum_topic.is_locked? %>
|
||||
<div class="notice">
|
||||
<p>This topic has been locked.</p>
|
||||
|
||||
Reference in New Issue
Block a user