comment_group_plugin.rb
1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
class CommentGroupPlugin < Noosfero::Plugin
def self.plugin_name
"Comment Group"
end
def self.plugin_description
_("A plugin that display comment groups.")
end
def unavailable_comments(scope)
scope.without_group
end
def comment_form_extra_contents(args)
comment = args[:comment]
group_id = comment.group_id || args[:group_id]
proc {
hidden_field_tag('comment[group_id]', group_id) if group_id
}
end
def js_files
'comment_group_macro.js'
end
def stylesheet?
true
end
def article_extra_toolbar_buttons(article)
user = context.send :user
return [] if !article.allow_edit?(user) || article.comments.where("comments.group_id is not null").empty?
[
{
:title => _('Export Comments'),
:url => {:controller => 'comment_group_plugin_profile', :profile => article.profile.identifier, :action => 'export_comments', :id => article.id},
:icon => :toggle_comment_paragraph
}
]
end
end
require_dependency 'comment_group_plugin/macros/allow_comment'