diff --git a/BrainPortal/app/controllers/userfiles_controller.rb b/BrainPortal/app/controllers/userfiles_controller.rb
index 49ec78f2f..2d7c397ec 100644
--- a/BrainPortal/app/controllers/userfiles_controller.rb
+++ b/BrainPortal/app/controllers/userfiles_controller.rb
@@ -440,6 +440,36 @@ def show #:nodoc:
end
end
+ # establishes trust in all the files of a creator of this file for the duration of the session
+ # This method is used to render html userfiles or collection elements
+ def trust_creator
+ @userfile = Userfile.find_accessible_by_user(params[:id], current_user, :access_requested => :read)
+ cbrain_session[:trust_user_files] ||= []
+ unless cbrain_session[:trust_user_files].include?(@userfile.user_id)
+ ids = cbrain_session[:trust_user_files] # in place modification does not work well within a session
+ ids.shift if ids.length > 99 # cap to 100 ids, session storage is limited
+ cbrain_session[:trust_userfiles] = ids << @userfile.user_id
+ end
+ respond_to do |format|
+ format.js { render js: "" } # no need to do anything as of now
+ end
+ end
+
+ # establishes trust in a file or all the other files of a collection for the duration of the session
+ # This method is used to render html userfiles or collection elements
+ def trust
+ @userfile = Userfile.find_accessible_by_user(params[:id], current_user, :access_requested => :read)
+ cbrain_session[:trust_userfiles] ||= []
+ unless cbrain_session[:trust_userfiles].include?(@userfile.id)
+ ids = cbrain_session[:trust_userfiles] # in place modification does not work well within a session
+ ids.shift if ids.length > 199 # limit to 200 file ids, session size is limited
+ cbrain_session[:trust_userfiles] = ids << @userfile.id
+ end
+ respond_to do |format|
+ format.js { render js: "" } # no need to do anything as of now
+ end
+ end
+
# Triggers the mass synchronization of several userfiles
# or mass 'desynchronization' (ProvNewer) of several userfiles.
def sync_multiple #:nodoc:
diff --git a/BrainPortal/cbrain_plugins/cbrain-plugins-base/userfiles/html_file/html_file.rb b/BrainPortal/cbrain_plugins/cbrain-plugins-base/userfiles/html_file/html_file.rb
index 2a556bd66..ca029c678 100644
--- a/BrainPortal/cbrain_plugins/cbrain-plugins-base/userfiles/html_file/html_file.rb
+++ b/BrainPortal/cbrain_plugins/cbrain-plugins-base/userfiles/html_file/html_file.rb
@@ -33,6 +33,6 @@ def self.file_name_pattern #:nodoc:
def self.pretty_type #:nodoc:
"HTML File"
- end
+ end
end
diff --git a/BrainPortal/cbrain_plugins/cbrain-plugins-base/userfiles/html_file/views/_html.html.erb b/BrainPortal/cbrain_plugins/cbrain-plugins-base/userfiles/html_file/views/_html.html.erb
index 37a386454..4224ebffb 100644
--- a/BrainPortal/cbrain_plugins/cbrain-plugins-base/userfiles/html_file/views/_html.html.erb
+++ b/BrainPortal/cbrain_plugins/cbrain-plugins-base/userfiles/html_file/views/_html.html.erb
@@ -1,4 +1,3 @@
-
<%
#
# CBRAIN Project
@@ -22,29 +21,68 @@
#
%>
-<% if params[:new_tab].blank? # show only on userfile page %>
+This HTML document is not part of CBRAIN. You should not view or
+ interact with it unless you fully trust it. (Forms and external links are disabled.)
+
+
+<% if params[:new_tab].blank?
+ # show only on userfile page %>
<%= link_to(
- "Open in a separate tab",
- display_userfile_url(@userfile,
- :viewer => :html,
- :content_viewer => "on",
- :file_name => @userfile.name,
- :viewer_userfile_class => "HtmlFile",
- :new_tab => "yes"
- ),
- :target => "_blank"
- ) %>
+ "Open in a separate tab",
+ display_userfile_url(@userfile,
+ :viewer => :html,
+ :content_viewer => "on",
+ :file_name => @userfile.name,
+ :viewer_userfile_class => "HtmlFile",
+ :new_tab => "yes"
+ ),
+ :target => "_blank"
+ )
+ %>
<% end %>
-The HTML document previewed in the frame below is not part of CBRAIN. You should not open it or
-interact with it unless you fully trust it. Forms and external links are disabled.
+
+<%# -- for other user's files ask confirmation, unless user of files is marked as trusted %>
+<% hide_frame = params[:new_tab].blank? && current_user.id != @userfile.user_id %>
+<% hide_frame &&= !cbrain_session[:trust_user_files]&.include?(@userfile.user_id) %>
+<% hide_frame &&= !cbrain_session[:trust_userfiles]&.include?(@userfile.id) %>
+<% if hide_frame %>
+