summaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2010-04-11 12:56:18 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2010-04-11 12:56:18 +0000
commit58792737394c59ecac08db2cea0eeebb836f160a (patch)
tree20356d7c4801a53e47df1273d7c011441beee62c /app
parent3979224693c796b162e3bf815fa33265869f1b18 (diff)
downloadredmine-58792737394c59ecac08db2cea0eeebb836f160a.tar.gz
redmine-58792737394c59ecac08db2cea0eeebb836f160a.zip
Makes the wiki sidebar editable (#5208).
The content of the wiki page named 'Sidebar' is rendered in the sidebar if it exists. Permission to edit protected pages is required to create this page. git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3632 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app')
-rw-r--r--app/controllers/wiki_controller.rb2
-rw-r--r--app/models/wiki.rb6
-rw-r--r--app/models/wiki_content.rb4
-rw-r--r--app/models/wiki_page.rb9
-rw-r--r--app/views/wiki/_sidebar.rhtml4
5 files changed, 24 insertions, 1 deletions
diff --git a/app/controllers/wiki_controller.rb b/app/controllers/wiki_controller.rb
index 60b59ff5f..55194e048 100644
--- a/app/controllers/wiki_controller.rb
+++ b/app/controllers/wiki_controller.rb
@@ -33,7 +33,7 @@ class WikiController < ApplicationController
page_title = params[:page]
@page = @wiki.find_or_new_page(page_title)
if @page.new_record?
- if User.current.allowed_to?(:edit_wiki_pages, @project)
+ if User.current.allowed_to?(:edit_wiki_pages, @project) && editable?
edit
render :action => 'edit'
else
diff --git a/app/models/wiki.rb b/app/models/wiki.rb
index b9a76fb32..9bd245955 100644
--- a/app/models/wiki.rb
+++ b/app/models/wiki.rb
@@ -29,6 +29,12 @@ class Wiki < ActiveRecord::Base
!user.nil? && user.allowed_to?(:view_wiki_pages, project)
end
+ # Returns the wiki page that acts as the sidebar content
+ # or nil if no such page exists
+ def sidebar
+ @sidebar ||= find_page('Sidebar', :with_redirect => false)
+ end
+
# find the page with the given title
# if page doesn't exist, return a new page
def find_or_new_page(title)
diff --git a/app/models/wiki_content.rb b/app/models/wiki_content.rb
index f81aa9e78..1f0eb9a62 100644
--- a/app/models/wiki_content.rb
+++ b/app/models/wiki_content.rb
@@ -34,6 +34,10 @@ class WikiContent < ActiveRecord::Base
page.project
end
+ def attachments
+ page.nil? ? [] : page.attachments
+ end
+
# Returns the mail adresses of users that should be notified
def recipients
notified = project.notified_users
diff --git a/app/models/wiki_page.rb b/app/models/wiki_page.rb
index ad2d8135a..010a8532c 100644
--- a/app/models/wiki_page.rb
+++ b/app/models/wiki_page.rb
@@ -41,6 +41,15 @@ class WikiPage < ActiveRecord::Base
validates_uniqueness_of :title, :scope => :wiki_id, :case_sensitive => false
validates_associated :content
+ # Wiki pages that are protected by default
+ DEFAULT_PROTECTED_PAGES = %w(sidebar)
+
+ def after_initialize
+ if new_record? && DEFAULT_PROTECTED_PAGES.include?(title.to_s.downcase)
+ self.protected = true
+ end
+ end
+
def visible?(user=User.current)
!user.nil? && user.allowed_to?(:view_wiki_pages, project)
end
diff --git a/app/views/wiki/_sidebar.rhtml b/app/views/wiki/_sidebar.rhtml
index 20c087123..ad4b1d250 100644
--- a/app/views/wiki/_sidebar.rhtml
+++ b/app/views/wiki/_sidebar.rhtml
@@ -1,3 +1,7 @@
+<% if @wiki && @wiki.sidebar -%>
+ <%= textilizable @wiki.sidebar.content, :text %>
+<% end -%>
+
<h3><%= l(:label_wiki) %></h3>
<%= link_to l(:field_start_page), {:action => 'index', :page => nil} %><br />