diff --git a/plugins/redmine_private_wiki/LICENSE b/plugins/redmine_private_wiki/LICENSE
new file mode 100755
index 0000000..3d4d0d7
--- /dev/null
+++ b/plugins/redmine_private_wiki/LICENSE
@@ -0,0 +1,20 @@
+Copyright (c) 2017 Alexandre BOUDINE, previous owner(s) : Oleg Kandaurov
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/plugins/redmine_private_wiki/README.md b/plugins/redmine_private_wiki/README.md
new file mode 100755
index 0000000..8e4dd2f
--- /dev/null
+++ b/plugins/redmine_private_wiki/README.md
@@ -0,0 +1,39 @@
+# Private Wiki
+## A RedMine plugin
+
+This plugin is based on the existing plugin "Redmine Private Wiki", developped by Oleg Kandaurov
+Link of the original plugin : https://github.com/f0y/redmine_private_wiki
+
+## Features :
+
+As original plugin :
+* It allows to set individual pages of wiki as privates
+* Thoses privates pages are only visibles to the roles with the right permission
+* Privatize pages are also a permission
+
+## New Features :
+
+New features :
+* Hide private wikis in index and date_index for non-authorized users
+* Add [PRIVATE] tag in index for authorized users
+
+## Use :
+
+To set public/private wiki page :
+ Projects -> MyProject -> Wiki -> select wiki page -> set private
+
+## Installation :
+
+ $cd /path/to/redmine/directory/plugins
+ $git clone https://github.com/BlueXML/redmine_private_wiki.git
+ $bundle exec rake redmine:plugins:migrate RAILS_ENV=production
+
+## Compatibility :
+Tested for RedMine 3.3.* (Manually)
+
+## License :
+This plugin is licensed under the MIT license.
+
+
+
+
diff --git a/plugins/redmine_private_wiki/app/views/private_wiki_management_views/_body_bottom.html.erb b/plugins/redmine_private_wiki/app/views/private_wiki_management_views/_body_bottom.html.erb
new file mode 100755
index 0000000..1c33e0f
--- /dev/null
+++ b/plugins/redmine_private_wiki/app/views/private_wiki_management_views/_body_bottom.html.erb
@@ -0,0 +1,19 @@
+
+<% if controller and controller.class.name == 'WikiController' and controller.action_name == "show" and @page and @page.id and @page.visible? %>
+
+
+ <% if @page.private? and User.current.allowed_to?(:view_privates_wiki, @project) %>
+ <%= l(:private_flag) %>
+ <% end %>
+
+
+ <%= link_to_if_authorized(l(:button_setprivate_wiki), {:action => 'change_privacy', :id => @page.title, :private => 1}, :method => :post, :class => 'icon icon-setprivate') if !@page.private? %>
+ <%= link_to_if_authorized(l(:button_setpublic_wiki), {:action => 'change_privacy', :id => @page.title, :private => 0}, :method => :post, :class => 'icon icon-setpublic') if @page.private? %>
+
+
+
+<% end %>
\ No newline at end of file
diff --git a/plugins/redmine_private_wiki/app/views/private_wiki_management_views/_html_head.html.erb b/plugins/redmine_private_wiki/app/views/private_wiki_management_views/_html_head.html.erb
new file mode 100755
index 0000000..47cb123
--- /dev/null
+++ b/plugins/redmine_private_wiki/app/views/private_wiki_management_views/_html_head.html.erb
@@ -0,0 +1,7 @@
+
+<% if controller and controller.class.name == 'WikiController' and (controller.action_name == "show" or controller.action_name == "index" or controller.action_name == "date_index") %>
+
+
+ <%= stylesheet_link_tag "private_wiki.css", :plugin => "redmine_private_wiki", :media => "screen" %>
+
+<% end %>
\ No newline at end of file
diff --git a/plugins/redmine_private_wiki/app/views/wiki/date_index.html.erb b/plugins/redmine_private_wiki/app/views/wiki/date_index.html.erb
new file mode 100755
index 0000000..6141cdb
--- /dev/null
+++ b/plugins/redmine_private_wiki/app/views/wiki/date_index.html.erb
@@ -0,0 +1,60 @@
+
+<% if User.current.allowed_to?(:edit_wiki_pages, @project) %>
+<%= link_to l(:label_wiki_page_new), new_project_wiki_page_path(@project), :remote => true, :class => 'icon icon-add' %>
+<% end %>
+<%= watcher_link(@wiki, User.current) %>
+
+
+<%= l(:label_index_by_date) %>
+
+<% if @pages.empty? %>
+<%= l(:label_no_data) %>
+<% end %>
+
+<% @pages_by_date.keys.sort.reverse.each do |date| %>
+
+ <% all_private = true %>
+ <% @pages_by_date[date].each do |page| %>
+ <% if !page.private? %>
+ <% all_private = false %>
+ <% end %>
+ <% end %>
+
+ <% if !all_private %>
+ <%= format_date(date) %>
+
+ <% @pages_by_date[date].each do |page| %>
+ <% if !page.private? %>
+ - <%= link_to page.pretty_title, :action => 'show', :id => page.title, :project_id => page.project %>
+ <% elsif User.current.allowed_to?(:view_privates_wiki, @project) %>
+ - <%= link_to page.pretty_title, :action => 'show', :id => page.title, :project_id => page.project %> <%= l(:private_flag) %>
+ <% end %>
+ <% end %>
+
+ <% elsif User.current.allowed_to?(:view_privates_wiki, @project) %>
+ <%= format_date(date) %>
+
+ <% @pages_by_date[date].each do |page| %>
+ - <%= link_to page.pretty_title, :action => 'show', :id => page.title, :project_id => page.project %> <%= l(:private_flag) %>
+ <% end %>
+
+ <% end %>
+<% end %>
+
+<% content_for :sidebar do %>
+ <%= render :partial => 'sidebar' %>
+<% end %>
+
+<% unless @pages.empty? %>
+<% other_formats_links do |f| %>
+ <%= f.link_to 'Atom', :url => {:controller => 'activities', :action => 'index', :id => @project, :show_wiki_edits => 1, :key => User.current.rss_key} %>
+ <% if User.current.allowed_to?(:export_wiki_pages, @project) %>
+ <%= f.link_to('PDF', :url => {:action => 'export', :format => 'pdf'}) %>
+ <%= f.link_to('HTML', :url => {:action => 'export'}) %>
+ <% end %>
+<% end %>
+<% end %>
+
+<% content_for :header_tags do %>
+<%= auto_discovery_link_tag(:atom, :controller => 'activities', :action => 'index', :id => @project, :show_wiki_edits => 1, :format => 'atom', :key => User.current.rss_key) %>
+<% end %>
diff --git a/plugins/redmine_private_wiki/assets/images/hide.png b/plugins/redmine_private_wiki/assets/images/hide.png
new file mode 100755
index 0000000..5c9823c
Binary files /dev/null and b/plugins/redmine_private_wiki/assets/images/hide.png differ
diff --git a/plugins/redmine_private_wiki/assets/images/reveal.png b/plugins/redmine_private_wiki/assets/images/reveal.png
new file mode 100755
index 0000000..2b84fee
Binary files /dev/null and b/plugins/redmine_private_wiki/assets/images/reveal.png differ
diff --git a/plugins/redmine_private_wiki/assets/stylesheets/private_wiki.css b/plugins/redmine_private_wiki/assets/stylesheets/private_wiki.css
new file mode 100755
index 0000000..ce9d833
--- /dev/null
+++ b/plugins/redmine_private_wiki/assets/stylesheets/private_wiki.css
@@ -0,0 +1,14 @@
+.private_wiki_flag {
+ background: #D22;
+ color: white;
+ padding: 2px 2px 2px 2px;
+ border-radius: 2px;
+}
+
+.icon-setprivate{
+ background-image: url(../images/hide.png);
+}
+
+.icon-setpublic{
+ background-image: url(../images/reveal.png);
+}
diff --git a/plugins/redmine_private_wiki/config/locales/en.yml b/plugins/redmine_private_wiki/config/locales/en.yml
new file mode 100755
index 0000000..f2e4454
--- /dev/null
+++ b/plugins/redmine_private_wiki/config/locales/en.yml
@@ -0,0 +1,5 @@
+# English strings go here for Rails i18n
+en:
+ button_setprivate_wiki: Set Private
+ button_setpublic_wiki: Set Public
+ private_flag: PRIVATE
diff --git a/plugins/redmine_private_wiki/config/locales/fr.yml b/plugins/redmine_private_wiki/config/locales/fr.yml
new file mode 100755
index 0000000..3212d88
--- /dev/null
+++ b/plugins/redmine_private_wiki/config/locales/fr.yml
@@ -0,0 +1,5 @@
+# French strings go here for Rails i18n
+fr:
+ button_setprivate_wiki: Rendre Privé
+ button_setpublic_wiki: Rendre Public
+ private_flag: PRIVÉ
diff --git a/plugins/redmine_private_wiki/config/routes.rb b/plugins/redmine_private_wiki/config/routes.rb
new file mode 100755
index 0000000..827fad4
--- /dev/null
+++ b/plugins/redmine_private_wiki/config/routes.rb
@@ -0,0 +1,5 @@
+# Plugin's routes
+RedmineApp::Application.routes.draw do
+ #Allow utilisation of action 'change_privacy' in links (set route to wiki method)
+ match 'projects/:project_id/wiki/:id/change_privacy/:private', :controller => 'wiki', :action => 'change_privacy', :via => [:post]
+end
diff --git a/plugins/redmine_private_wiki/db/migrate/001_add_private_wiki_attribute.rb b/plugins/redmine_private_wiki/db/migrate/001_add_private_wiki_attribute.rb
new file mode 100755
index 0000000..5069e6f
--- /dev/null
+++ b/plugins/redmine_private_wiki/db/migrate/001_add_private_wiki_attribute.rb
@@ -0,0 +1,12 @@
+class AddPrivateWikiAttribute < ActiveRecord::Migration
+ def change
+ #Add a "Private" attribute used to identify visibility of wikis
+ add_column(:wiki_pages, "private", :boolean, :default => false)
+ end
+
+
+ def self.down
+ remove_column(:wiki_pages, "private")
+ end
+
+end
diff --git a/plugins/redmine_private_wiki/init.rb b/plugins/redmine_private_wiki/init.rb
new file mode 100755
index 0000000..ef38ba1
--- /dev/null
+++ b/plugins/redmine_private_wiki/init.rb
@@ -0,0 +1,37 @@
+require 'redmine'
+require_dependency 'wiki_patches/hook' #Apply views modifications
+
+Rails.configuration.to_prepare do
+
+ #Apply patch on wiki controller
+ require_dependency 'wiki_controller'
+ unless WikiController.included_modules.include? WikiPatches::WikiControllerPatch
+ WikiController.send(:include, WikiPatches::WikiControllerPatch)
+ end
+
+ #Apply patch on wiki page
+ require_dependency 'wiki_page'
+ unless WikiPage.included_modules.include? WikiPatches::WikiPagePatch
+ WikiPage.send(:include, WikiPatches::WikiPagePatch)
+ end
+
+ require_dependency 'application_helper'
+ unless ApplicationHelper.included_modules.include? WikiPatches::ApplicationHelperPatch
+ ApplicationHelper.send(:include, WikiPatches::ApplicationHelperPatch)
+ end
+end
+
+Redmine::Plugin.register :redmine_private_wiki do
+ name 'Private Wiki plugin'
+ author 'Alexandre BOUDINE'
+ description 'Add privatization of wiki pages'
+ version '0.2.0'
+ url ''
+ author_url ''
+
+ #Add permissions
+ project_module :wiki do
+ permission :view_privates_wiki, {:wiki => [:show, :edit]}
+ permission :manage_privates_wiki, {:wiki => :change_privacy}, :require => :member
+ end
+end
diff --git a/plugins/redmine_private_wiki/lib/wiki_patches/application_helper_patch.rb b/plugins/redmine_private_wiki/lib/wiki_patches/application_helper_patch.rb
new file mode 100755
index 0000000..9ee6403
--- /dev/null
+++ b/plugins/redmine_private_wiki/lib/wiki_patches/application_helper_patch.rb
@@ -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 << "\n"
+ pages[node].each do |page|
+ if !page.private? then
+ content << "- "
+ 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 << "
\n"
+ elsif User.current.allowed_to?(:view_privates_wiki, @project) then
+ content << "- "
+ 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 << " " + l(:private_flag) + " "
+ content << "\n" + render_page_hierarchy(pages, page.id, options) if pages[page.id]
+ content << "
\n"
+ end
+ end
+ content << "
\n"
+ end
+ content.html_safe
+ end
+
+ alias_method_chain :render_page_hierarchy, :wiki_hidding
+
+ end
+ end
+ end
+end
\ No newline at end of file
diff --git a/plugins/redmine_private_wiki/lib/wiki_patches/hook.rb b/plugins/redmine_private_wiki/lib/wiki_patches/hook.rb
new file mode 100755
index 0000000..e2ce9a9
--- /dev/null
+++ b/plugins/redmine_private_wiki/lib/wiki_patches/hook.rb
@@ -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
\ No newline at end of file
diff --git a/plugins/redmine_private_wiki/lib/wiki_patches/wiki_controller_patch.rb b/plugins/redmine_private_wiki/lib/wiki_patches/wiki_controller_patch.rb
new file mode 100755
index 0000000..45a3372
--- /dev/null
+++ b/plugins/redmine_private_wiki/lib/wiki_patches/wiki_controller_patch.rb
@@ -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
\ No newline at end of file
diff --git a/plugins/redmine_private_wiki/lib/wiki_patches/wiki_page_patch.rb b/plugins/redmine_private_wiki/lib/wiki_patches/wiki_page_patch.rb
new file mode 100755
index 0000000..0350ad8
--- /dev/null
+++ b/plugins/redmine_private_wiki/lib/wiki_patches/wiki_page_patch.rb
@@ -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
+
+
+
+
+
+
+
diff --git a/plugins/redmine_private_wiki/test/functional/wiki_controller_patch_test.rb b/plugins/redmine_private_wiki/test/functional/wiki_controller_patch_test.rb
new file mode 100755
index 0000000..de2b9dc
--- /dev/null
+++ b/plugins/redmine_private_wiki/test/functional/wiki_controller_patch_test.rb
@@ -0,0 +1,121 @@
+require File.expand_path('../../test_helper',__FILE__)
+
+
+class WikiControllerPatchTest < ActionController::TestCase
+
+ fixtures :projects, :users, :roles, :members, :member_roles, :wikis, :wiki_pages, :wiki_contents
+
+ setup do
+ @controller = WikiController.new
+
+ @project = Project.find(1)
+ @project.enable_module! :wiki
+ @role = Role.find(1)
+ User.current = nil
+ @request.session[:user_id] = 2
+ @wiki = @project.wiki
+ @page = @wiki.find_page('Another_page')
+ @page.private = true
+ @page.save!
+ end
+
+ test 'show_without_permission' do
+ #User not allowed to see the wiki page
+ get :show, :project_id => @project, :id => @page.title
+
+ assert_response 403
+ assert_select "span.private_wiki_flag", false, "There should not be a private flag"
+ end
+
+ test 'show_with_permission' do
+ #User allowed to see the wiki page
+ @role.add_permission! :view_privates_wiki
+ get :show, :project_id => @project, :id => @page.title
+
+ assert_response :success
+ assert_select "span.private_wiki_flag", true, "There should be a private flag"
+
+ #User not allowed to change privacy of wiki
+ assert_select "a.icon-setpublic", false, "There should not be a privacy button"
+
+ #User allowed to change privacy of wiki
+ @role.add_permission! :manage_privates_wiki
+ get :show, :project_id => @project, :id => @page.title
+
+ assert_select "body" do |elements|
+ elements.each do |element|
+ Rails::logger.debug("FLAG")
+ Rails::logger.debug(element)
+ end
+ end
+
+ assert_select "a.icon-setpublic", true, "There should be a privacy button"
+ end
+
+ test 'edit_without_permission' do
+ #User not allowed to edit wiki
+ get :edit, :project_id => @project, :id => @page.title
+
+ assert_response 403
+ end
+
+ test 'edit_with_permission' do
+ #User allowed to edit wiki
+ @role.add_permission! :view_privates_wiki
+ get :edit, :project_id => @project, :id => @page.title
+
+ assert_response :success
+ end
+
+ test 'post_change_privacy_without_permission' do
+ #User not allowed to change privacy of wiki
+ post :change_privacy, :project_id => @project, :id => @page.title, :private => 0
+
+ assert_response 403
+ end
+
+ test 'post_change_privacy_with_permission' do
+ #User allowed to change privacy of wiki
+ @role.add_permission! :manage_privates_wiki
+ post :change_privacy, :project_id => @project, :id => @page.title, :private => 0
+
+ assert_response :redirect
+ assert !@page.reload.private
+ end
+
+ #Next tests somehow fails, but actually works ...
+ #Probably due to the fact that elements are added directly through JS as text and not as elements.
+ test 'index_without_permission' do
+ #User not allowed to see the wiki page
+ get :index, :project_id => @project
+
+ assert_response :success
+ assert_select "li.hide_private", true, "There should be a private "
+ end
+
+ test 'index_with_permission' do
+ #User allowed to see the wiki page
+ @role.add_permission! :view_privates_wiki
+ get :index, :project_id => @project
+
+ assert_response :success
+ assert_select "span.private_wiki_flag", true, "There should be a private flag"
+ assert_select "li.hide_private", false, "There should not be a private "
+ end
+
+ test 'date_index_without_permission' do
+ #User not allowed to see the wiki page
+ get :date_index, :project_id => @project
+
+ assert_select "li.hide_private", true, "There should be a private "
+ end
+
+ test 'date_index_with_permission' do
+ #User allowed to see the wiki page
+ @role.add_permission! :view_privates_wiki
+ get :date_index, :project_id => @project
+
+ assert_select "span.private_wiki_flag", true, "There should be a private flag"
+ assert_select "li.hide_private", false, "There should not be a private "
+ end
+end
diff --git a/plugins/redmine_private_wiki/test/test_helper.rb b/plugins/redmine_private_wiki/test/test_helper.rb
new file mode 100755
index 0000000..54685d3
--- /dev/null
+++ b/plugins/redmine_private_wiki/test/test_helper.rb
@@ -0,0 +1,2 @@
+# Load the Redmine helper
+require File.expand_path(File.dirname(__FILE__) + '/../../../test/test_helper')
diff --git a/plugins/redmine_private_wiki/test/unit/wiki_page_patch_test.rb b/plugins/redmine_private_wiki/test/unit/wiki_page_patch_test.rb
new file mode 100755
index 0000000..3120da0
--- /dev/null
+++ b/plugins/redmine_private_wiki/test/unit/wiki_page_patch_test.rb
@@ -0,0 +1,29 @@
+require File.expand_path('../../test_helper',__FILE__)
+
+class WikiPagePatchTest < ActiveSupport::TestCase
+
+ fixtures :projects, :wikis, :wiki_pages
+
+ setup do
+ @controller = WikiController.new
+
+ @project = Project.find(1)
+ @project.enable_module! :wiki
+ @wiki = @project.wiki
+ @page = @wiki.find_page('Another_page')
+ @page.private = true
+ @page.save!
+ end
+
+ test 'has_private_parent_true' do
+ #A page that has a private parent
+ @page = @wiki.find_page('Child_1')
+ assert_equal true, @page.has_private_parent?
+ end
+
+ test 'has_private_parent_false' do
+ #A page that doesn't have a private parent
+ assert_equal true, !@page.has_private_parent?
+ end
+
+end
\ No newline at end of file