* work on Issue 145: Direct links for sensitive oprations

git-svn-id: http://redmine-dmsf.googlecode.com/svn/trunk/redmine_dmsf@237 5e329b0b-a2ee-ea63-e329-299493fc886d
This commit is contained in:
vit.jonas@gmail.com 2011-09-25 08:11:28 +00:00
parent 354d83dc70
commit bce512c1ad
4 changed files with 28 additions and 32 deletions

View File

@ -25,6 +25,9 @@ class DmsfFilesController < ApplicationController
before_filter :find_revision, :only => [:delete_revision]
before_filter :authorize
verify :method => :post, :only => [:create_revision, :delete_revision, :delete, :lock, :unlock, :notify_activate, :notify_deactivate],
:render => { :nothing => true, :status => :method_not_allowed }
def show
# download is put here to provide more clear and usable links
if params.has_key?(:download)

View File

@ -88,10 +88,9 @@ form_tag({:action => "entries_operation", :id => @project, :folder_id => @folder
</div>
<% end %>
<div style="float: right">
<%= link_to(image_tag("delete.png", :plugin => "redmine_dmsf"),
{:action => "delete", :id => @project,
:folder_id => @folder, :delete_folder_id => subfolder}, :class => "delete-link",
:title => l(:title_delete)) if User.current.allowed_to?(:folder_manipulation, @project) %>
<%= link_to_function(image_tag("delete.png", :plugin => "redmine_dmsf"),
"confirmation_link('#{url_for(:action => 'delete', :id => @project, :folder_id => @folder, :delete_folder_id => subfolder)}')",
:title => l(:title_delete))%>
</div>
</div>
<br class="clear" />
@ -139,12 +138,12 @@ form_tag({:action => "entries_operation", :id => @project, :folder_id => @folder
<% if User.current.allowed_to?(:file_approval, @project) %>
<div class="right_icon_box">
<% if file.notification %>
<%= link_to(image_tag("notify.png", :plugin => "redmine_dmsf"),
{:controller => "dmsf_files", :action => "notify_deactivate", :id => file},
<%= link_to_function(image_tag("notify.png", :plugin => "redmine_dmsf"),
"manipulation_link('#{url_for(:controller => "dmsf_files", :action => 'notify_deactivate', :id => file)}')",
:title => l(:title_notifications_active_deactivate)) %>
<% else %>
<%= link_to(image_tag("notifynot.png", :plugin => "redmine_dmsf"),
{:controller => "dmsf_files", :action => "notify_activate", :id => file},
<%= link_to_function(image_tag("notifynot.png", :plugin => "redmine_dmsf"),
"manipulation_link('#{url_for(:controller => "dmsf_files", :action => 'notify_activate', :id => file)}')",
:title => l(:title_notifications_not_active_activate)) %>
<% end %>
</div>
@ -158,20 +157,20 @@ form_tag({:action => "entries_operation", :id => @project, :folder_id => @folder
<div style="float: right; width: 44px;">
<% unless file.locked_for_user? && !User.current.allowed_to?(:force_file_unlock, @project)%>
<% if file.locked? %>
<%= link_to(image_tag("unlock.png", :plugin => "redmine_dmsf"),
{:controller => "dmsf_files", :action => "unlock", :id => file },
<%= link_to_function(image_tag("unlock.png", :plugin => "redmine_dmsf"),
"manipulation_link('#{url_for(:controller => "dmsf_files", :action => 'unlock', :id => file)}')",
:title => l(:title_unlock_file)) %>
<% else %>
<%= link_to(image_tag("lock.png", :plugin => "redmine_dmsf"),
{:controller => "dmsf_files", :action => "lock", :id => file },
<%= link_to_function(image_tag("lock.png", :plugin => "redmine_dmsf"),
"manipulation_link('#{url_for(:controller => "dmsf_files", :action => 'lock', :id => file)}')",
:title => l(:title_lock_file)) %>
<% end %>
&nbsp;
<% end %>
<% if User.current.allowed_to?(:file_manipulation, @project) && !file.locked_for_user? %>
<%= link_to(image_tag("delete.png", :plugin => "redmine_dmsf"),
{:controller => "dmsf_files", :action => "delete", :id => file},
:class => "delete-link", :title => l(:title_delete)) %>
<%= link_to_function(image_tag("delete.png", :plugin => "redmine_dmsf"),
"confirmation_link('#{url_for(:controller => "dmsf_files", :action => 'delete', :id => file)}')",
:title => l(:title_delete)) %>
<% end %>
</div>
</div>
@ -187,13 +186,6 @@ form_tag({:action => "entries_operation", :id => @project, :folder_id => @folder
<% end %>
<script type="text/javascript">
jQuery("a.delete-link").click(function(event) {
event.preventDefault();
if(!window.confirm("<%= l(:question_do_you_really_want_to_delete_this_entry) %>")) return;
jQuery("#entries_form").attr("action", jQuery(this).attr("href"));
jQuery("#entries_form").submit();
})
jQuery("#entries_delete_button").click(function(event) {
if(window.confirm("<%= l(:question_do_you_really_want_to_delete_entries) %>")) {
jQuery("#entries_form").attr("action", "<%= url_for(:action => 'delete_entries', :id => @project, :folder_id => @folder) %>");

View File

@ -19,7 +19,7 @@ else
end
form_for(:dmsf_file_revision, @revision, :url => {:action => "create_revision", :id => @file},
:html => {:method=>:post, :multipart => true}) do |f|
:html => {:method=>:post, :multipart => true, :id => "new_revision_form"}) do |f|
%>
<div class="clear">
<div class="splitcontentleft">

View File

@ -4,7 +4,7 @@
<% if User.current.allowed_to?(:file_manipulation, @project) %>
<% unless @file.locked_for_user? && !User.current.allowed_to?(:force_file_unlock, @project)%>
<% if @file.locked? %>
<%= link_to(image_tag("unlock.png", :plugin => "redmine_dmsf"),
<%= link_to_function(image_tag("unlock.png", :plugin => "redmine_dmsf"),
{:action => "unlock", :id => @file, :current => request.url },
:title => l(:title_unlock_file)) %>
<% else %>
@ -175,14 +175,15 @@ sUrl = "jquery.dataTables/#{I18n.locale.to_s.downcase}.json" if I18n.locale && !
<script type="text/javascript">
jQuery.noConflict();
function copyFile() {
var $copyDialog = jQuery('#copyDialog');
$copyDialog.dialog({
autoOpen: false,
title: "Copy file"
});
$copyDialog.dialog('open')
}
function manipulation_link(action) {
jQuery("#new_revision_form").attr("action", action);
jQuery("#new_revision_form").submit();
};
function confirmation_link(action, question) {
if(!window.confirm(question)) return;
jQuery("#new_revision_form").attr("action", action);
jQuery("#new_revision_form").submit();
};
</script>
<% end %>