commontator 4.0.1 → 4.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -5
- data/app/controllers/commontator/comments_controller.rb +6 -6
- data/app/controllers/commontator/subscriptions_controller.rb +2 -2
- data/app/controllers/commontator/threads_controller.rb +2 -2
- data/app/views/commontator/comments/_actions.html.erb +1 -1
- data/app/views/commontator/comments/_votes.html.erb +4 -4
- data/app/views/commontator/shared/_thread.html.erb +1 -1
- data/app/views/commontator/subscriptions/_link.html.erb +1 -1
- data/app/views/commontator/threads/_show.html.erb +1 -1
- data/config/routes.rb +9 -9
- data/lib/commontator/version.rb +1 -1
- data/spec/app/controllers/commontator/comments_controller_spec.rb +40 -40
- data/spec/app/controllers/commontator/subscriptions_controller_spec.rb +12 -12
- data/spec/app/controllers/commontator/threads_controller_spec.rb +12 -12
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/log/test.log +4176 -0
- metadata +4 -91
- data/app/controllers/commontator/application_controller.rb~ +0 -27
- data/app/controllers/commontator/comments_controller.rb~ +0 -144
- data/app/controllers/commontator/subscriptions_controller.rb~ +0 -32
- data/app/controllers/commontator/threads_controller.rb~ +0 -42
- data/app/mailers/commontator/subscriptions_mailer.rb~ +0 -50
- data/app/models/commontator/comment.rb~ +0 -104
- data/app/models/commontator/subscription.rb~ +0 -18
- data/app/models/commontator/thread.rb~ +0 -124
- data/app/models/commontator/tree.rb~ +0 -123
- data/app/views/commontator/comments/_actions.html.erb~ +0 -30
- data/app/views/commontator/comments/_body.html.erb~ +0 -8
- data/app/views/commontator/comments/_form.html.erb~ +0 -38
- data/app/views/commontator/comments/_show.html.erb~ +0 -44
- data/app/views/commontator/comments/_votes.html.erb~ +0 -57
- data/app/views/commontator/comments/delete.js.erb~ +0 -17
- data/app/views/commontator/shared/_thread.html.erb~ +0 -20
- data/app/views/commontator/subscriptions/_link.html.erb~ +0 -16
- data/app/views/commontator/threads/_show.html.erb~ +0 -62
- data/config/initializers/commontator.rb~ +0 -171
- data/config/routes.rb~ +0 -22
- data/db/migrate/0_install.rb~ +0 -50
- data/lib/commontator.rb~ +0 -61
- data/lib/commontator/acts_as_commontable.rb~ +0 -45
- data/lib/commontator/acts_as_commontator.rb~ +0 -31
- data/lib/commontator/controller_includes.rb~ +0 -22
- data/lib/commontator/security_transgression.rb~ +0 -3
- data/lib/commontator/shared_helper.rb~ +0 -42
- data/lib/commontator/version.rb~ +0 -3
- data/lib/tasks/commontator_tasks.rake~ +0 -42
- data/spec/app/controllers/commontator/comments_controller_spec.rb~ +0 -563
- data/spec/app/controllers/commontator/subscriptions_controller_spec.rb~ +0 -99
- data/spec/app/controllers/commontator/threads_controller_spec.rb~ +0 -121
- data/spec/app/helpers/commontator/application_helper_spec.rb~ +0 -9
- data/spec/app/helpers/commontator/threads_helper_spec.rb~ +0 -17
- data/spec/app/mailers/commontator/subscriptions_mailer_spec.rb~ +0 -30
- data/spec/app/models/commontator/comment_observer_spec.rb~ +0 -27
- data/spec/app/models/commontator/comment_spec.rb~ +0 -61
- data/spec/app/models/commontator/subscription_spec.rb~ +0 -28
- data/spec/app/models/commontator/thread_spec.rb~ +0 -130
- data/spec/dummy/README.md~ +0 -3
- data/spec/dummy/Rakefile~ +0 -7
- data/spec/dummy/config.ru~ +0 -4
- data/spec/dummy/config/application.rb~ +0 -23
- data/spec/dummy/config/environment.rb~ +0 -5
- data/spec/dummy/config/environments/development.rb~ +0 -31
- data/spec/dummy/config/environments/production.rb~ +0 -67
- data/spec/dummy/config/environments/test.rb~ +0 -31
- data/spec/dummy/config/initializers/secret_token.rb~ +0 -12
- data/spec/lib/commontator/acts_as_commontable_spec.rb~ +0 -26
- data/spec/lib/commontator/acts_as_commontator_spec.rb~ +0 -25
- data/spec/lib/commontator/commontable_config_spec.rb~ +0 -26
- data/spec/lib/commontator/commontator_config_spec.rb~ +0 -26
- data/spec/lib/commontator/controller_includes_spec.rb~ +0 -15
- data/spec/lib/commontator/shared_helper_spec.rb~ +0 -16
- data/spec/lib/commontator_spec.rb~ +0 -23
- data/spec/minitest_helper.rb~ +0 -35
- data/spec/spec_helper.rb~ +0 -36
- data/spec/test_helper.rb~ +0 -37
@@ -1,42 +0,0 @@
|
|
1
|
-
module Commontator
|
2
|
-
class ThreadsController < Commontator::ApplicationController
|
3
|
-
before_filter :get_thread
|
4
|
-
before_filter :set_commontable_url, :only => :show
|
5
|
-
|
6
|
-
# GET /threads/1
|
7
|
-
def show
|
8
|
-
commontator_thread_show(@thread.commontable)
|
9
|
-
|
10
|
-
respond_to do |format|
|
11
|
-
format.html { redirect_to commontable_url }
|
12
|
-
format.js
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
# PATCH /threads/1/close
|
17
|
-
def close
|
18
|
-
raise SecurityTransgression unless @thread.can_be_edited_by?(@user)
|
19
|
-
|
20
|
-
@thread.errors.add(:base, 'This thread has already been closed.') \
|
21
|
-
unless @thread.close(@user)
|
22
|
-
|
23
|
-
respond_to do |format|
|
24
|
-
format.html { redirect_to @thread }
|
25
|
-
format.js { render :show }
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
# PUT /threads/1/reopen
|
30
|
-
def reopen
|
31
|
-
raise SecurityTransgression unless @thread.can_be_edited_by?(@user)
|
32
|
-
|
33
|
-
@thread.errors.add(:base, 'This thread is not closed.') \
|
34
|
-
unless @thread.reopen
|
35
|
-
|
36
|
-
respond_to do |format|
|
37
|
-
format.html { redirect_to @thread }
|
38
|
-
format.js { render :show }
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
@@ -1,50 +0,0 @@
|
|
1
|
-
module Commontator
|
2
|
-
class SubscriptionsMailer < ActionMailer::Base
|
3
|
-
include SharedHelper
|
4
|
-
include ThreadsHelper
|
5
|
-
|
6
|
-
def comment_created(comment, recipients)
|
7
|
-
setup_variables(comment, recipients)
|
8
|
-
|
9
|
-
mail :to => 'Undisclosed Recipients'
|
10
|
-
:bcc => @bcc,
|
11
|
-
:from => @from,
|
12
|
-
:subject => @subject
|
13
|
-
end
|
14
|
-
|
15
|
-
protected
|
16
|
-
|
17
|
-
def setup_variables(comment, recipients)
|
18
|
-
@comment = comment
|
19
|
-
@thread = @comment.thread
|
20
|
-
@creator = @comment.creator
|
21
|
-
|
22
|
-
@commontable = @thread.commontable
|
23
|
-
@config = @thread.config
|
24
|
-
|
25
|
-
@creator_name = commontator_name(@creator)
|
26
|
-
@comment_timestamp = @comment.timestamp
|
27
|
-
|
28
|
-
@commontable_name = commontable_name(@thread)
|
29
|
-
@commontable_id = commontable_id(@thread).to_s
|
30
|
-
|
31
|
-
@commontable_url = ApplicationController.commontable_url
|
32
|
-
|
33
|
-
params = Hash.new
|
34
|
-
params[:comment] = @comment
|
35
|
-
params[:thread] = @thread
|
36
|
-
params[:creator] = @creator
|
37
|
-
params[:commontable] = @commontable
|
38
|
-
params[:config] = @config
|
39
|
-
params[:creator_name] = @creator_name
|
40
|
-
params[:comment_timestamp] = @comment_timestamp
|
41
|
-
params[:commontable_name] = @commontable_name
|
42
|
-
params[:commontable_id] = @commontable_id
|
43
|
-
params[:commontable_url] = @commontable_url
|
44
|
-
|
45
|
-
@bcc = recipients.collect{|s| commontator_email(s)}
|
46
|
-
@from = @config.subscription_email_from_proc.call(params)
|
47
|
-
@subject = @config.subscription_email_subject_proc.call(params)
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
@@ -1,104 +0,0 @@
|
|
1
|
-
module Commontator
|
2
|
-
class Comment < ActiveRecord::Base
|
3
|
-
belongs_to :creator, :polymorphic => true
|
4
|
-
belongs_to :editor, :polymorphic => true
|
5
|
-
belongs_to :thread
|
6
|
-
|
7
|
-
has_one :commontable, :through => :thread
|
8
|
-
|
9
|
-
attr_accessible :body if respond_to?(:attr_accessible)
|
10
|
-
|
11
|
-
validates_presence_of :creator, :on => :create
|
12
|
-
validates_presence_of :editor, :on => :update
|
13
|
-
validates_presence_of :thread
|
14
|
-
validates_presence_of :body
|
15
|
-
|
16
|
-
validates_uniqueness_of :body, :scope => [:creator_type, :creator_id, :thread_id],
|
17
|
-
:message => 'has already been posted'
|
18
|
-
|
19
|
-
protected
|
20
|
-
|
21
|
-
cattr_accessor :acts_as_votable_initialized
|
22
|
-
|
23
|
-
public
|
24
|
-
|
25
|
-
def is_votable?
|
26
|
-
return true if acts_as_votable_initialized
|
27
|
-
return false unless self.class.respond_to?(:acts_as_votable)
|
28
|
-
self.class.acts_as_votable
|
29
|
-
self.class.acts_as_votable_initialized = true
|
30
|
-
end
|
31
|
-
|
32
|
-
def get_vote_by(user)
|
33
|
-
return nil unless is_votable?
|
34
|
-
votes.where(:voter_type => user.class.name, :voter_id => user.id).first
|
35
|
-
end
|
36
|
-
|
37
|
-
def is_modified?
|
38
|
-
!editor.nil?
|
39
|
-
end
|
40
|
-
|
41
|
-
def is_deleted?
|
42
|
-
!deleted_at.blank?
|
43
|
-
end
|
44
|
-
|
45
|
-
def delete_by(user)
|
46
|
-
return false if is_deleted?
|
47
|
-
self.deleted_at = Time.now
|
48
|
-
self.editor = user
|
49
|
-
self.save
|
50
|
-
end
|
51
|
-
|
52
|
-
def undelete_by(user)
|
53
|
-
return false unless is_deleted?
|
54
|
-
self.deleted_at = nil
|
55
|
-
self.editor = user
|
56
|
-
self.save
|
57
|
-
end
|
58
|
-
|
59
|
-
def timestamp
|
60
|
-
config = thread.config
|
61
|
-
"#{config.comment_create_verb_past.capitalize} on " + \
|
62
|
-
created_at.strftime(config.timestamp_format) + \
|
63
|
-
(is_modified? ? " | Last #{config.comment_edit_verb_past} on " + \
|
64
|
-
updated_at.strftime(config.timestamp_format) : '')
|
65
|
-
end
|
66
|
-
|
67
|
-
##################
|
68
|
-
# Access Control #
|
69
|
-
##################
|
70
|
-
|
71
|
-
def can_be_read_by?(user)
|
72
|
-
(thread.can_be_read_by?(user) && \
|
73
|
-
(!is_deleted? || thread.config.deleted_comments_are_visible)) ||\
|
74
|
-
thread.can_be_edited_by?(user)
|
75
|
-
end
|
76
|
-
|
77
|
-
def can_be_created_by?(user)
|
78
|
-
!thread.is_closed? && thread.can_be_read_by?(user) && user == creator
|
79
|
-
end
|
80
|
-
|
81
|
-
def can_be_edited_by?(user)
|
82
|
-
!thread.is_closed? && !is_deleted? &&\
|
83
|
-
((user == creator && thread.config.can_edit_own_comments && thread.can_be_read_by?(user)) ||\
|
84
|
-
(thread.can_be_edited_by?(user) && thread.config.admin_can_edit_comments)) &&\
|
85
|
-
(thread.comments.last == self || thread.config.can_edit_old_comments)
|
86
|
-
end
|
87
|
-
|
88
|
-
def can_be_deleted_by?(user)
|
89
|
-
(!thread.is_closed? &&\
|
90
|
-
((user == creator && thread.config.can_delete_own_comments && \
|
91
|
-
thread.can_be_read_by?(user) && (!is_deleted? || editor == user)) &&\
|
92
|
-
(thread.comments.last == self || thread.config.can_delete_old_comments))) ||\
|
93
|
-
thread.can_be_edited_by?(user)
|
94
|
-
end
|
95
|
-
|
96
|
-
def can_be_voted_on?
|
97
|
-
!thread.is_closed? && is_votable? && !is_deleted? && thread.config.can_vote_on_comments
|
98
|
-
end
|
99
|
-
|
100
|
-
def can_be_voted_on_by?(user)
|
101
|
-
can_be_voted_on? && thread.can_be_read_by?(user) && user != creator
|
102
|
-
end
|
103
|
-
end
|
104
|
-
end
|
@@ -1,18 +0,0 @@
|
|
1
|
-
module Commontator
|
2
|
-
class Subscription < ActiveRecord::Base
|
3
|
-
belongs_to :subscriber, :polymorphic => true
|
4
|
-
|
5
|
-
belongs_to :thread
|
6
|
-
|
7
|
-
validates_presence_of :subscriber, :thread
|
8
|
-
validates_uniqueness_of :thread_id, :scope => [:subscriber_type, :subscriber_id]
|
9
|
-
|
10
|
-
def mark_as_read
|
11
|
-
update_attribute(:unread, 0)
|
12
|
-
end
|
13
|
-
|
14
|
-
def add_unread
|
15
|
-
update_attribute(:unread, unread + 1)
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
@@ -1,124 +0,0 @@
|
|
1
|
-
module Commontator
|
2
|
-
class Thread < ActiveRecord::Base
|
3
|
-
belongs_to :closer, :polymorphic => true
|
4
|
-
belongs_to :commontable, :polymorphic => true
|
5
|
-
|
6
|
-
has_many :comments, :dependent => :destroy
|
7
|
-
has_many :subscriptions, :dependent => :destroy
|
8
|
-
|
9
|
-
validates_presence_of :commontable, :unless => :is_closed?
|
10
|
-
validates_uniqueness_of :commontable_id, :scope => :commontable_type, :allow_nil => true
|
11
|
-
|
12
|
-
def config
|
13
|
-
commontable.try(:commontable_config) || Commontator
|
14
|
-
end
|
15
|
-
|
16
|
-
def ordered_comments
|
17
|
-
(config.can_vote_on_comments && config.comments_ordered_by_votes) ? \
|
18
|
-
comments.order("cached_votes_down - cached_votes_up") : comments
|
19
|
-
end
|
20
|
-
|
21
|
-
def is_closed?
|
22
|
-
!closed_at.blank?
|
23
|
-
end
|
24
|
-
|
25
|
-
def subscribers
|
26
|
-
subscriptions.collect{|s| s.subscriber}
|
27
|
-
end
|
28
|
-
|
29
|
-
def active_subscribers
|
30
|
-
subscribers.select{|s| s.is_commontator && s.commontator_config.subscription_email_enable_proc.call(s)}
|
31
|
-
end
|
32
|
-
|
33
|
-
def subscription_for(subscriber)
|
34
|
-
return nil if subscriber.nil? || !subscriber.is_commontator
|
35
|
-
subscriber.subscriptions.where(:thread_id => self.id).first
|
36
|
-
end
|
37
|
-
|
38
|
-
def is_subscribed?(subscriber)
|
39
|
-
!subscription_for(subscriber).blank?
|
40
|
-
end
|
41
|
-
|
42
|
-
def subscribe(subscriber)
|
43
|
-
return false if is_subscribed?(subscriber) || !subscriber.is_commontator
|
44
|
-
subscription = Subscription.new
|
45
|
-
subscription.subscriber = subscriber
|
46
|
-
subscription.thread => self
|
47
|
-
subscription.save
|
48
|
-
end
|
49
|
-
|
50
|
-
def unsubscribe(subscriber)
|
51
|
-
subscription = subscription_for(subscriber)
|
52
|
-
return false if subscription.blank?
|
53
|
-
subscription.destroy
|
54
|
-
end
|
55
|
-
|
56
|
-
def add_unread_except_for(subscriber)
|
57
|
-
Subscription.transaction do
|
58
|
-
subscriptions.each{|s| s.add_unread unless s.subscriber == subscriber}
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
def mark_as_read_for(subscriber)
|
63
|
-
return if !subscription_for(subscriber)
|
64
|
-
subscription_for(subscriber).mark_as_read
|
65
|
-
end
|
66
|
-
|
67
|
-
def close(user = nil)
|
68
|
-
return false if is_closed?
|
69
|
-
self.closed_at = Time.now
|
70
|
-
self.closer = user
|
71
|
-
save
|
72
|
-
end
|
73
|
-
|
74
|
-
def reopen
|
75
|
-
return false unless is_closed? && !commontable.nil?
|
76
|
-
self.closed_at = nil
|
77
|
-
save
|
78
|
-
end
|
79
|
-
|
80
|
-
# Creates a new empty thread and assigns it to the commontable
|
81
|
-
# The old thread is kept in the database for archival purposes
|
82
|
-
def clear(user = nil)
|
83
|
-
return if commontable.blank?
|
84
|
-
new_thread = Thread.new
|
85
|
-
new_thread.commontable = commontable
|
86
|
-
with_lock do
|
87
|
-
self.commontable = nil
|
88
|
-
self.closed_at = Time.now
|
89
|
-
self.closer = user
|
90
|
-
save!
|
91
|
-
new_thread.save!
|
92
|
-
subscriptions.each do |s|
|
93
|
-
s.thread = new_thread
|
94
|
-
s.save!
|
95
|
-
s.mark_as_read
|
96
|
-
end
|
97
|
-
end
|
98
|
-
end
|
99
|
-
|
100
|
-
##################
|
101
|
-
# Access Control #
|
102
|
-
##################
|
103
|
-
|
104
|
-
# Reader and poster capabilities
|
105
|
-
def can_be_read_by?(user)
|
106
|
-
(!commontable.nil? && \
|
107
|
-
(!is_closed? || config.closed_threads_are_readable) && \
|
108
|
-
config.can_read_thread_proc.call(self, user)) || \
|
109
|
-
can_be_edited_by?(user)
|
110
|
-
end
|
111
|
-
|
112
|
-
# Thread moderator capabilities
|
113
|
-
def can_be_edited_by?(user)
|
114
|
-
(!commontable.nil? && \
|
115
|
-
config.can_edit_thread_proc.call(self, user)) || \
|
116
|
-
(!user.nil? && user.is_commontator && \
|
117
|
-
user.commontator_config.user_admin_proc.call(user))
|
118
|
-
end
|
119
|
-
|
120
|
-
def can_subscribe?(user)
|
121
|
-
!commontable.nil? && config.can_subscribe_to_thread && !is_closed? && can_be_read_by?(user)
|
122
|
-
end
|
123
|
-
end
|
124
|
-
end
|
@@ -1,123 +0,0 @@
|
|
1
|
-
module Linkifier
|
2
|
-
class Tree < ActiveRecord::Base
|
3
|
-
belongs_to :closer, :polymorphic => true
|
4
|
-
belongs_to :commontable, :polymorphic => true
|
5
|
-
|
6
|
-
has_many :comments, :dependent => :destroy
|
7
|
-
has_many :subscriptions, :dependent => :destroy
|
8
|
-
|
9
|
-
validates_presence_of :commontable, :on => :create
|
10
|
-
|
11
|
-
attr_accessible :is_closed
|
12
|
-
|
13
|
-
def config
|
14
|
-
commontable.try(:commontable_config)
|
15
|
-
end
|
16
|
-
|
17
|
-
def ordered_comments
|
18
|
-
(!commontable.blank? && config.can_vote_on_comments && config.comments_ordered_by_votes) ? \
|
19
|
-
comments.order("cached_votes_down - cached_votes_up") : comments
|
20
|
-
end
|
21
|
-
|
22
|
-
def subscribers
|
23
|
-
subscriptions.collect{|s| s.subscriber}
|
24
|
-
end
|
25
|
-
|
26
|
-
def active_subscribers
|
27
|
-
subscribers.select{|s| s.commontator_config.subscription_email_enable_proc.call(s)}
|
28
|
-
end
|
29
|
-
|
30
|
-
def subscription_for(subscriber)
|
31
|
-
return nil if subscriber.nil?
|
32
|
-
Subscription.find_by_thread_id_and_subscriber_id_and_subscriber_type(self.id, subscriber.id, subscriber.class.name)
|
33
|
-
end
|
34
|
-
|
35
|
-
def is_closed?
|
36
|
-
!closed_at.blank?
|
37
|
-
end
|
38
|
-
|
39
|
-
def is_subscribed?(subscriber)
|
40
|
-
!subscription_for(subscriber).blank?
|
41
|
-
end
|
42
|
-
|
43
|
-
def subscribe(subscriber)
|
44
|
-
return false if is_subscribed?(subscriber)
|
45
|
-
subscription = Subscription.create(
|
46
|
-
:subscriber => subscriber, :thread => self)
|
47
|
-
end
|
48
|
-
|
49
|
-
def unsubscribe(subscriber)
|
50
|
-
subscription = subscription_for(subscriber)
|
51
|
-
return false if subscription.blank?
|
52
|
-
subscription.destroy
|
53
|
-
end
|
54
|
-
|
55
|
-
def mark_as_read_for(subscriber)
|
56
|
-
return if !subscription_for(subscriber)
|
57
|
-
subscription_for(subscriber).mark_as_read
|
58
|
-
end
|
59
|
-
|
60
|
-
def add_unread_except_for(subscriber)
|
61
|
-
Subscription.transaction do
|
62
|
-
subscriptions.each{|s| s.add_unread unless s.subscriber == subscriber}
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
def close(user = nil)
|
67
|
-
return false if is_closed?
|
68
|
-
self.closed_at = Time.now
|
69
|
-
self.closer = user
|
70
|
-
self.save!
|
71
|
-
end
|
72
|
-
|
73
|
-
def reopen
|
74
|
-
return false unless is_closed?
|
75
|
-
self.closed_at = nil
|
76
|
-
self.save!
|
77
|
-
end
|
78
|
-
|
79
|
-
# Creates a new empty thread and assigns it to the commontable
|
80
|
-
# The old thread is kept in the database for archival purposes
|
81
|
-
|
82
|
-
def clear(user = nil)
|
83
|
-
return if commontable.blank?
|
84
|
-
new_thread = Thread.new
|
85
|
-
new_thread.commontable = commontable
|
86
|
-
self.with_lock do
|
87
|
-
new_thread.save!
|
88
|
-
commontable.thread = new_thread
|
89
|
-
commontable.save!
|
90
|
-
subscriptions.each do |s|
|
91
|
-
s.thread = new_thread
|
92
|
-
s.save!
|
93
|
-
s.mark_as_read
|
94
|
-
end
|
95
|
-
self.commontable = nil
|
96
|
-
self.close(user)
|
97
|
-
end
|
98
|
-
end
|
99
|
-
|
100
|
-
##########################
|
101
|
-
# Access control methods #
|
102
|
-
##########################
|
103
|
-
|
104
|
-
# Reader and poster capabilities
|
105
|
-
def can_be_read_by?(user)
|
106
|
-
(!commontable.blank? && \
|
107
|
-
(!is_closed? || config.closed_threads_are_readable) && \
|
108
|
-
config.can_read_thread_proc.call(self, user)) || \
|
109
|
-
can_be_edited_by?(user)
|
110
|
-
end
|
111
|
-
|
112
|
-
# Thread moderator capabilities
|
113
|
-
def can_be_edited_by?(user)
|
114
|
-
!commontable.blank? && \
|
115
|
-
(config.can_edit_thread_proc.call(self, user) || \
|
116
|
-
(!user.nil? && user.commontator_config.user_admin_proc.call(user)))
|
117
|
-
end
|
118
|
-
|
119
|
-
def can_subscribe?(user)
|
120
|
-
!commontable.blank? && config.can_subscribe_to_thread && !is_closed? && can_be_read_by?(user)
|
121
|
-
end
|
122
|
-
end
|
123
|
-
end
|