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
This commit is contained in:
Jean-Philippe Lang
2010-04-11 12:56:18 +00:00
parent 3979224693
commit 5879273739
8 changed files with 61 additions and 1 deletions
+6
View File
@@ -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)
+4
View File
@@ -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
+9
View File
@@ -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