end
return
end
+ if params[:version] && !User.current.allowed_to?(:view_wiki_edits, @project)
+ # Redirects user to the current version if he's not allowed to view previous versions
+ redirect_to :version => nil
+ return
+ end
@content = @page.content_for_version(params[:version])
if params[:export] == 'html'
export = render_to_string :action => 'export', :layout => false
save!
end
+ # Returns true if the role has the given permission
+ def has_permission?(perm)
+ !permissions.nil? && permissions.include?(perm.to_sym)
+ end
+
def <=>(role)
position <=> role.position
end
:type => 'wiki-page',
:url => Proc.new {|o| {:controller => 'wiki', :id => o.page.wiki.project_id, :page => o.page.title, :version => o.version}}
- acts_as_activity_provider :type => 'wiki_pages',
+ acts_as_activity_provider :type => 'wiki_edits',
:timestamp => "#{WikiContent.versioned_table_name}.updated_on",
- :permission => :view_wiki_pages,
+ :permission => :view_wiki_edits,
:find_options => {:select => "#{WikiContent.versioned_table_name}.updated_on, #{WikiContent.versioned_table_name}.comments, " +
"#{WikiContent.versioned_table_name}.#{WikiContent.version_column}, #{WikiPage.table_name}.title, " +
"#{WikiContent.versioned_table_name}.page_id, #{WikiContent.versioned_table_name}.author_id, " +
<%= link_to_if_authorized(l(:button_delete), {:action => 'destroy', :page => @page.title}, :method => :post, :confirm => l(:text_are_you_sure), :class => 'icon icon-del') %>
<%= link_to_if_authorized(l(:button_rollback), {:action => 'edit', :page => @page.title, :version => @content.version }, :class => 'icon icon-cancel') if @content.version < @page.content.version %>
<% end %>
-<%= link_to(l(:label_history), {:action => 'history', :page => @page.title}, :class => 'icon icon-history') %>
+<%= link_to_if_authorized(l(:label_history), {:action => 'history', :page => @page.title}, :class => 'icon icon-history') %>
</div>
<%= breadcrumb(@page.ancestors.reverse.collect {|parent| link_to h(parent.pretty_title), {:page => parent.title}}) %>
--- /dev/null
+class AddWiewWikiEditsPermission < ActiveRecord::Migration
+ def self.up
+ Role.find(:all).each do |r|
+ r.add_permission!(:view_wiki_edits) if r.has_permission?(:view_wiki_pages)
+ end
+ end
+
+ def self.down
+ Role.find(:all).each do |r|
+ r.remove_permission!(:view_wiki_edits)
+ end
+ end
+end
map.permission :manage_wiki, {:wikis => [:edit, :destroy]}, :require => :member
map.permission :rename_wiki_pages, {:wiki => :rename}, :require => :member
map.permission :delete_wiki_pages, {:wiki => :destroy}, :require => :member
- map.permission :view_wiki_pages, :wiki => [:index, :history, :diff, :annotate, :special]
+ map.permission :view_wiki_pages, :wiki => [:index, :special]
+ map.permission :view_wiki_edits, :wiki => [:history, :diff, :annotate]
map.permission :edit_wiki_pages, :wiki => [:edit, :preview, :add_attachment, :destroy_attachment]
map.permission :protect_wiki_pages, {:wiki => :protect}, :require => :member
end
activity.register :news
activity.register :documents, :class_name => %w(Document Attachment)
activity.register :files, :class_name => 'Attachment'
- activity.register :wiki_pages, :class_name => 'WikiContent::Version', :default => false
+ activity.register :wiki_edits, :class_name => 'WikiContent::Version', :default => false
activity.register :messages, :default => false
end
- :view_documents\r
- :manage_documents\r
- :view_wiki_pages\r
+ - :view_wiki_edits\r
- :edit_wiki_pages\r
- :protect_wiki_pages\r
- :delete_wiki_pages\r
- :view_documents\r
- :manage_documents\r
- :view_wiki_pages\r
+ - :view_wiki_edits\r
- :edit_wiki_pages\r
- :protect_wiki_pages\r
- :delete_wiki_pages\r
- :view_documents\r
- :manage_documents\r
- :view_wiki_pages\r
+ - :view_wiki_edits\r
- :edit_wiki_pages\r
- :delete_wiki_pages\r
- :add_messages\r
- :view_documents\r
- :manage_documents\r
- :view_wiki_pages\r
+ - :view_wiki_edits\r
- :edit_wiki_pages\r
- :add_messages\r
- :view_files\r
- :view_time_entries\r
- :view_documents\r
- :view_wiki_pages\r
+ - :view_wiki_edits\r
- :view_files\r
- :browse_repository\r
- :view_changesets\r