Nuevo plugin Private Wiki 0.2.0
This commit is contained in:
parent
4e788bb03c
commit
49913ad11b
20 changed files with 480 additions and 0 deletions
38
plugins/redmine_private_wiki/lib/wiki_patches/application_helper_patch.rb
Executable file
38
plugins/redmine_private_wiki/lib/wiki_patches/application_helper_patch.rb
Executable file
|
@ -0,0 +1,38 @@
|
|||
require_dependency 'application_helper'
|
||||
module WikiPatches
|
||||
module ApplicationHelperPatch
|
||||
def self.included(base)
|
||||
base.class_eval do
|
||||
|
||||
#Override application's method to not display hidden wikis or to display it with the PRIVATE flag
|
||||
def render_page_hierarchy_with_wiki_hidding(pages, node=nil, options={})
|
||||
content = ''
|
||||
if pages[node]
|
||||
content << "<ul class=\"pages-hierarchy\">\n"
|
||||
pages[node].each do |page|
|
||||
if !page.private? then
|
||||
content << "<li>"
|
||||
content << link_to(h(page.pretty_title), {:controller => 'wiki', :action => 'show', :project_id => page.project, :id => page.title, :version => nil},
|
||||
:title => (options[:timestamp] && page.updated_on ? l(:label_updated_time, distance_of_time_in_words(Time.now, page.updated_on)) : nil))
|
||||
content << "\n" + render_page_hierarchy(pages, page.id, options) if pages[page.id]
|
||||
content << "</li>\n"
|
||||
elsif User.current.allowed_to?(:view_privates_wiki, @project) then
|
||||
content << "<li>"
|
||||
content << link_to(h(page.pretty_title), {:controller => 'wiki', :action => 'show', :project_id => page.project, :id => page.title, :version => nil},
|
||||
:title => (options[:timestamp] && page.updated_on ? l(:label_updated_time, distance_of_time_in_words(Time.now, page.updated_on)) : nil))
|
||||
content << " <span class='private_wiki_flag' style='display:inline-block;''>" + l(:private_flag) + " </span>"
|
||||
content << "\n" + render_page_hierarchy(pages, page.id, options) if pages[page.id]
|
||||
content << "</li>\n"
|
||||
end
|
||||
end
|
||||
content << "</ul>\n"
|
||||
end
|
||||
content.html_safe
|
||||
end
|
||||
|
||||
alias_method_chain :render_page_hierarchy, :wiki_hidding
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
7
plugins/redmine_private_wiki/lib/wiki_patches/hook.rb
Executable file
7
plugins/redmine_private_wiki/lib/wiki_patches/hook.rb
Executable file
|
@ -0,0 +1,7 @@
|
|||
module WikiPatches
|
||||
class WikiPatchesHook < Redmine::Hook::ViewListener
|
||||
#Add the content of private_wiki_management_views/_body_bottom.html.erb to general layout
|
||||
render_on :view_layouts_base_body_bottom, :partial => 'private_wiki_management_views/body_bottom'
|
||||
render_on :view_layouts_base_html_head, :partial => 'private_wiki_management_views/html_head'
|
||||
end
|
||||
end
|
28
plugins/redmine_private_wiki/lib/wiki_patches/wiki_controller_patch.rb
Executable file
28
plugins/redmine_private_wiki/lib/wiki_patches/wiki_controller_patch.rb
Executable file
|
@ -0,0 +1,28 @@
|
|||
module WikiPatches
|
||||
module WikiControllerPatch
|
||||
def self.included(base)
|
||||
base.send(:include, InstanceMethods)
|
||||
base.class_eval do
|
||||
unloadable
|
||||
#Test :valide before :show action on wiki_controller
|
||||
before_filter :validate, :only => [:show,:edit,:rename, :protect, :history, :diff, :annotate, :add_attachment, :destroy]
|
||||
end
|
||||
end
|
||||
|
||||
module InstanceMethods
|
||||
def change_privacy
|
||||
find_existing_page
|
||||
#":private" attribute of wiki page is set to :private parameter
|
||||
@page.update_attribute :private, params[:private]
|
||||
|
||||
#Then redirection to the previous page
|
||||
redirect_to project_wiki_page_path(@project, @page.title)
|
||||
end
|
||||
|
||||
def validate
|
||||
#If page is private and user not allowed to see it, then deny_access
|
||||
deny_access and return if @page.private? and !User.current.allowed_to?(:view_privates_wiki, @project)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
32
plugins/redmine_private_wiki/lib/wiki_patches/wiki_page_patch.rb
Executable file
32
plugins/redmine_private_wiki/lib/wiki_patches/wiki_page_patch.rb
Executable file
|
@ -0,0 +1,32 @@
|
|||
module WikiPatches
|
||||
module WikiPagePatch
|
||||
def self.included(base)
|
||||
base.send(:include, InstanceMethods)
|
||||
base.class_eval do
|
||||
unloadable
|
||||
end
|
||||
end
|
||||
|
||||
module InstanceMethods
|
||||
#Check if the wiki page as any private parent
|
||||
def has_private_parent?()
|
||||
@res = self.parent_title
|
||||
while @res != nil
|
||||
if self.project.wiki.find_page(@res).private?
|
||||
return true
|
||||
else
|
||||
@res = self.project.wiki.find_page(@res).parent_title
|
||||
end
|
||||
end
|
||||
return false;
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue