Webdav R/RW functionality introduced

This commit is contained in:
Daniel Munn 2012-07-11 15:23:32 +01:00
parent 1ab1271e70
commit 04064a9c98
3 changed files with 34 additions and 5 deletions

View File

@ -91,9 +91,22 @@
(<%=l(:label_default)%>: <%=l(:select_option_activated)%>)
<br/>
<%= l(:note_webdav).html_safe %>
</p>
<% if @settings["dmsf_webdav"].nil? || !@settings["dmsf_webdav"].empty? %>
<p>
<%=content_tag(:label, l(:label_webdav_strategy) + ":") %>
<%=select_tag("settings[dmsf_webdav_strategy]",
options_for_select([
[l(:select_option_webdav_readonly), "WEBDAV_READ_ONLY"],
[l(:select_option_webdav_readwrite), "WEBDAV_READ_WRITE"]],
:selected => @settings["dmsf_webdav_strategy"])) %><br/>
(<%=l(:label_default)%>: <%=l(:select_option_webdav_readonly)%>)
<br/>
<%= l(:note_webdav_strategy).html_safe %>
</p>
<% end %>
<hr />
<% begin

View File

@ -203,4 +203,7 @@ en:
:title_unlock_folder: "Unlock to allow changes for other members"
:title_lock_folder: "Lock to prevent changes for other members"
:select_option_webdav_readonly: "Read-only"
:select_option_webdav_readwrite: "Read/Write"
:label_webdav_strategy: "Webdav strategy"
:note_webdav_strategy: "Enables the administrator to decide if webdav is a read-only or read-write platform for end users."

View File

@ -27,6 +27,21 @@ module RedmineDmsf
@folder = false
end
#Here we make sure our folder and file methods are not aliased - it should shave a few cycles off of processing
def setup
@skip_alias |= [ :folder, :file, :folder?, :file? ]
end
# Here we hook into the fact that resources can have a pre-execution routine run for them
# Our sole job here is to ensure that any write functionality is restricted to relevent configuration
before do |resource, method_name|
#If our method is not one of the following, there is no point continuing.
if [ :put, :make_collection, :move, :copy, :delete, :lock, :unlock, :set_property ].include?(method_name)
webdav_setting = Setting.plugin_redmine_dmsf["dmsf_webdav_strategy"]
webdav_setting = "WEBDAV_READ_ONLY" if webdav_setting.nil?
raise BadGateway if webdav_setting == "WEBDAV_READ_ONLY"
end
end
# Gather collection of objects that denote current entities child entities
# Used for listing directories etc, implemented basic caching because otherwise
@ -548,8 +563,6 @@ module RedmineDmsf
%w(creationdate displayname getlastmodified getetag resourcetype getcontenttype getcontentlength supportedlock lockdiscovery)
end
private
# Prepare file for download using Rack functionality:
# Download (see RedmineDmsf::Webdav::Download) extends Rack::File to allow single-file