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