diff --git a/app/controllers/applied_project_controller.rb b/app/controllers/applied_project_controller.rb
index fdb45b030..3d061ef74 100644
--- a/app/controllers/applied_project_controller.rb
+++ b/app/controllers/applied_project_controller.rb
@@ -6,7 +6,8 @@ class AppliedProjectController < ApplicationController
@project = Project.find(params[:project_id])
@applieds = AppliedProject.where("user_id = ? and project_id = ?", params[:user_id],params[:project_id])
if @applieds.count == 0
- AppliedProject.create(:user_id => params[:user_id], :project_id => params[:project_id])
+ appliedproject = AppliedProject.create(:user_id => params[:user_id], :project_id => params[:project_id])
+ Mailer.applied_project(appliedproject).deliver
end
#redirect_to project_path(params[:project_id])
diff --git a/app/controllers/attachments_controller.rb b/app/controllers/attachments_controller.rb
index 0b2ae02b3..7c1c10325 100644
--- a/app/controllers/attachments_controller.rb
+++ b/app/controllers/attachments_controller.rb
@@ -23,6 +23,7 @@ class AttachmentsController < ApplicationController
before_filter :login_without_softapplication, only: [:download]
accept_api_auth :show, :download, :upload
+ require 'iconv'
def show
respond_to do |format|
@@ -75,6 +76,25 @@ class AttachmentsController < ApplicationController
end
end
+ # 更新文件密级
+ def updateFileDense
+ @attachment = Attachment.find(params[:attachmentid])
+ if @attachment != nil
+ filedense = params[:newtype].to_s
+ # d = Iconv.conv("unicodebig","utf-8",filedense)
+ if filedense == "%E5%85%AC%E5%BC%80" #l(:field_is_public)
+ @attachment.is_public = 1
+ else
+ @attachment.is_public = 0
+ end
+ @attachment.save
+ @newfiledense = filedense
+ end
+ respond_to do |format|
+ format.js
+ end
+ end
+
def thumbnail
if @attachment.thumbnailable? && thumbnail = @attachment.thumbnail(:size => params[:size])
if stale?(:etag => thumbnail)
@@ -89,6 +109,7 @@ class AttachmentsController < ApplicationController
end
end
+
def upload
# Make sure that API users get used to set this content type
# as it won't trigger Rails' automatic parsing of the request body for parameters
diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb
index 92186710c..7569ab5bb 100644
--- a/app/controllers/projects_controller.rb
+++ b/app/controllers/projects_controller.rb
@@ -746,7 +746,7 @@ class ProjectsController < ApplicationController
#Added by young
# @course_tag = params[:course]
# if @course_tag == '1'
- @course = Course.find_by_extra(@project.identifier)
+ #@course = Course.find_by_extra(@project.identifier)
# if @project.project_type == 1
# render :layout => 'base_courses'
# else
diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb
index 3b97802f5..e91f9c0a9 100644
--- a/app/controllers/repositories_controller.rb
+++ b/app/controllers/repositories_controller.rb
@@ -239,7 +239,7 @@ class RepositoriesController < ApplicationController
@repositories = @project.repositories
@course_tag = params[:course]
project_path_cut = RepositoriesHelper::PROJECT_PATH_CUT
- ip = RepositoriesHelper::REPO_IP_ADDRESS
+ ip = RepositoriesHelper::REPO_IP_ADDRESS
@repos_url = "http://"+@repository.login.to_s+"_"+@repository.identifier.to_s+"@"+ip+
@repository.url.slice(project_path_cut, @repository.url.length).to_s
if @course_tag == 1
diff --git a/app/helpers/attachments_helper.rb b/app/helpers/attachments_helper.rb
index 14105bf88..b43eb22f1 100644
--- a/app/helpers/attachments_helper.rb
+++ b/app/helpers/attachments_helper.rb
@@ -109,7 +109,7 @@ module AttachmentsHelper
domain = project.nil? ? attachAll : nobelong_attach
# 搜索到的资源
- searched_attach = domain.where("filename LIKE :like ", like:"%#{filename_condition}%").limit(limit).order('created_on desc')
+ searched_attach = domain.where("is_public=1 and filename LIKE :like ", like:"%#{filename_condition}%").limit(limit).order('created_on desc')
#searched_attach = private_filter searched_attach
searched_attach = paginateHelper(searched_attach, 10)
@@ -148,7 +148,7 @@ module AttachmentsHelper
domain = course.nil? ? attachAll : nobelong_attach
# 搜索到的资源
- searched_attach = domain.where("filename LIKE :like ", like:"%#{filename_condition}%").limit(limit).order('created_on desc')
+ searched_attach = domain.where("is_public=1 and filename LIKE :like ", like:"%#{filename_condition}%").limit(limit).order('created_on desc')
#searched_attach = private_filter searched_attach
searched_attach = paginateHelper(searched_attach, 10)
diff --git a/app/models/attachment.rb b/app/models/attachment.rb
index 116e2de9a..0eb3e7666 100644
--- a/app/models/attachment.rb
+++ b/app/models/attachment.rb
@@ -196,6 +196,21 @@ class Attachment < ActiveRecord::Base
suffix
end
+ # 文件密级的字符描述
+ def file_dense_str
+ if self.is_public == 1
+ dense = l(:field_is_public)
+ else
+ dense = l(:field_is_private)
+ end
+ dense
+ end
+
+ # 文件可设置的密级列表
+ def file_dense_list
+ denselist = [l(:field_is_public),l(:field_is_private)]
+ end
+
def suffixArr
@@SuffixArr
end
diff --git a/app/models/course.rb b/app/models/course.rb
index 5034ab0d8..b6974eed0 100644
--- a/app/models/course.rb
+++ b/app/models/course.rb
@@ -90,6 +90,18 @@ class Course < ActiveRecord::Base
false
end
+ # Returns the mail adresses of users that should be always notified on project events
+ def recipients
+ notified_users.collect {|user| user.mail}
+ end
+
+ # Returns the users that should be notified on project events
+ def notified_users
+ # TODO: User part should be extracted to User#notify_about?
+ members.select {|m| m.principal.present? && (m.mail_notification? || m.principal.mail_notification == 'all')}.collect {|m| m.principal}
+ end
+
+
# 课程的短描述信息
def short_description(length = 255)
description.gsub(/^(.{#{length}}[^\n\r]*).*$/m, '\1...').strip if description
@@ -112,6 +124,7 @@ class Course < ActiveRecord::Base
@attachmenttypes = Attachmentstype.find(:all, :conditions => ["#{Attachmentstype.table_name}.typeId= ?",self.attachmenttype ])
end
+
# 获取资源后缀名列表
def contenttypes
attachmenttypes
diff --git a/app/models/mailer.rb b/app/models/mailer.rb
index ef4996eac..131c72c8c 100644
--- a/app/models/mailer.rb
+++ b/app/models/mailer.rb
@@ -141,6 +141,19 @@ class Mailer < ActionMailer::Base
:subject => s
end
+ # 用户申请加入项目邮件通知
+ def applied_project(applied)
+ @project =applied.project
+ redmine_headers 'Project' => @project,
+ 'User' => applied.user
+ @user = applied.user
+ recipients = @project.manager_recipients
+ s = l(:text_applied_project, :id => "##{@user.show_name}", :project => @project.name)
+ @applied_url = url_for(:controller => 'projects', :action => 'settings', :id => @project.id,:tab=>'members')
+ mail :to => recipients,
+ :subject => s
+ end
+
def reminder(user, issues, days)
set_language_if_valid user.language
@issues = issues
@@ -177,25 +190,45 @@ class Mailer < ActionMailer::Base
added_to_url = ''
@author = attachments.first.author
case container.class.name
- when 'Project'
- added_to_url = url_for(:controller => 'files', :action => 'index', :project_id => container)
- added_to = "#{l(:label_project)}: #{container}"
- recipients = container.project.notified_users.select {|user| user.allowed_to?(:view_files, container.project)}.collect {|u| u.mail}
- when 'Version'
- added_to_url = url_for(:controller => 'files', :action => 'index', :project_id => container.project)
- added_to = "#{l(:label_version)}: #{container.name}"
- recipients = container.project.notified_users.select {|user| user.allowed_to?(:view_files, container.project)}.collect {|u| u.mail}
- when 'Document'
- added_to_url = url_for(:controller => 'documents', :action => 'show', :id => container.id)
- added_to = "#{l(:label_document)}: #{container.title}"
- recipients = container.recipients
+ when 'Project'
+ added_to_url = url_for(:controller => 'files', :action => 'index', :project_id => container)
+ added_to = "#{l(:label_project)}: #{container}"
+ recipients = container.notified_users.select { |user| user.allowed_to?(:view_files, container) }.collect { |u| u.mail }
+ when 'Course'
+ added_to_url = url_for(:controller => 'files', :action => 'index', :course_id => container)
+ added_to = "#{l(:label_course)}: #{container}"
+ recipients = container.notified_users.select { |user| user.allowed_to?(:view_files, container) }.collect { |u| u.mail }
+ when 'Version'
+ added_to_url = url_for(:controller => 'files', :action => 'index', :project_id => container.project)
+ added_to = "#{l(:label_version)}: #{container.name}"
+ recipients = container.project.notified_users.select { |user| user.allowed_to?(:view_files, container.project) }.collect { |u| u.mail }
+ when 'Document'
+ added_to_url = url_for(:controller => 'documents', :action => 'show', :id => container.id)
+ added_to = "#{l(:label_document)}: #{container.title}"
+ recipients = container.recipients
+ end
+ if container.class.name == 'Course'
+ redmine_headers 'Course' => container.id
+ @attachments = attachments
+ @added_to = added_to
+ @added_to_url = added_to_url
+ mail :to => recipients,
+ :subject => "[#{container.name}] #{l(:label_attachment_new)}"
+ elsif container.class.name == 'Project'
+ redmine_headers 'Project' => container.id
+ @attachments = attachments
+ @added_to = added_to
+ @added_to_url = added_to_url
+ mail :to => recipients,
+ :subject => "[#{container.name}] #{l(:label_attachment_new)}"
+ else
+ redmine_headers 'Project' => container.project.identifier
+ @attachments = attachments
+ @added_to = added_to
+ @added_to_url = added_to_url
+ mail :to => recipients,
+ :subject => "[#{container.project.name}] #{l(:label_attachment_new)}"
end
- redmine_headers 'Project' => container.project.identifier
- @attachments = attachments
- @added_to = added_to
- @added_to_url = added_to_url
- mail :to => recipients,
- :subject => "[#{container.project.name}] #{l(:label_attachment_new)}"
end
# Builds a Mail::Message object used to email recipients of a news' project when a news item is added.
diff --git a/app/models/project.rb b/app/models/project.rb
index 5efaf10ab..37ca8f20b 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -207,6 +207,12 @@ class Project < ActiveRecord::Base
end
# end
+ # 管理员的邮件列表
+ def manager_recipients
+ notified = project.project_infos.collect(&:user)
+ notified.collect(&:mail)
+ end
+
def initialize(attributes=nil, *args)
super
diff --git a/app/views/attachments/_form.html.erb b/app/views/attachments/_form.html.erb
index d568dd63c..7f1887b23 100644
--- a/app/views/attachments/_form.html.erb
+++ b/app/views/attachments/_form.html.erb
@@ -3,10 +3,10 @@
<% container.attachments.each_with_index do |attachment, i| %>
<%= text_field_tag("attachments[p#{i}][filename]", attachment.filename, :class => 'filename readonly', :readonly=>'readonly')%>
-
<%= text_field_tag("attachments[p#{i}][description]", attachment.description, :maxlength => 255, :placeholder => l(:label_optional_description), :class => 'description', :style=>"display: inline-block;") +
link_to(' '.html_safe, attachment_path(attachment, :attachment_id => "p#{i}", :format => 'js'), :method => 'delete', :remote => true, :class => 'remove-upload') %>
<%#= render :partial => 'tags/tag', :locals => {:obj => attachment, :object_flag => "6"} %>
+ <%= check_box_tag("attachments[p#{i}][is_public_checkbox]", attachment.is_public, :class => 'is_public')%>
<%= hidden_field_tag "attachments[p#{i}][token]", "#{attachment.token}" %>
<% end %>
diff --git a/app/views/attachments/updateFileDense.js.erb b/app/views/attachments/updateFileDense.js.erb
new file mode 100644
index 000000000..86fa36d4c
--- /dev/null
+++ b/app/views/attachments/updateFileDense.js.erb
@@ -0,0 +1,15 @@
+$('#edit-file-dense-form-<%= @attachment.id.to_s%>').hide();
+$('#field_file_dense_id_label<%= @attachment.id.to_s%>').show();
+$('#edit_box_dense<%= @attachment.id.to_s%>').show();
+<%if @attachment.is_public == 1%>
+$('#field_file_dense_id_label<%= @attachment.id.to_s%>').html('公开');
+<%else%>
+$('#field_file_dense_id_label<%= @attachment.id.to_s%>').html('私有');
+<%end%>
+// 下面2种写法都没起作用,暂时使用上面的非本地化模式
+// <%if @attachment.is_public == 1%>
+// $('#field_file_dense_id_label<%= @attachment.id.to_s%>').html('<%l(:field_is_public)%>');
+// <%else%>
+// $('#field_file_dense_id_label<%= @attachment.id.to_s%>').html('<%l(:field_is_private)%>');
+// <%end%>
+// $('#field_file_dense_id_label<%= @attachment.id.to_s%>').html(<%=@newfiledense%>);
diff --git a/app/views/files/_course_file_dense_edit.html.erb b/app/views/files/_course_file_dense_edit.html.erb
new file mode 100644
index 000000000..53041ef14
--- /dev/null
+++ b/app/views/files/_course_file_dense_edit.html.erb
@@ -0,0 +1,13 @@
+<% edit_allowed = User.current.allowed_to?(:manage_files, @course) %>
+<% if file_dense_list.any? %>
+
+ <%= select_tag "file_dense",
+ options_for_select(file_dense_list,attachment.file_dense_str), :onchange=>"file_dense_edit("+attachment.id.to_s + ",this.value)"%>
+
+ <%= link_to(image_tag('edit/edit.png'), 'javascript:void(0);',:style=>"white-space:nowrap;", :id=>"edit_box_dense"+attachment.id.to_s ,
+ :onclick =>"$('#edit-file-dense-form-" +attachment.id.to_s+ "').show();
+ $('#field_file_dense_id_label" +attachment.id.to_s+ "').hide();
+ $('#edit_box_dense" +attachment.id.to_s+ "').hide();") if edit_allowed %>
+
+<% end %>
+
diff --git a/app/views/files/_course_show_all_attachment.html.erb b/app/views/files/_course_show_all_attachment.html.erb
index 1a8a8ca65..a6da426c6 100644
--- a/app/views/files/_course_show_all_attachment.html.erb
+++ b/app/views/files/_course_show_all_attachment.html.erb
@@ -18,6 +18,7 @@
<%= sort_header_tag('size', :caption => l(:field_filesize), :default_order => 'desc', :scope => "col", :id => "vzebra-children") %>
<%= sort_header_tag('attach_type', :caption => l(:attachment_browse), :default_order => 'desc', :scope => "col", :id => "vzebra-attachmenttype") %>
<%= sort_header_tag('content_type', :caption => l(:attachment_sufix_browse), :default_order => 'desc', :scope => "col", :id => "vzebra-contenttype") %>
+ <%= sort_header_tag('field_file_dense', :caption => l(:field_file_dense), :default_order => 'desc', :scope => "col", :id => "vzebra-field_file_dense") %>
<%= sort_header_tag('downloads', :caption => l(:field_downloads), :default_order => 'desc', :scope => "col", :id => "vzebra-action") %>
<%= sort_header_tag('operation', :caption => "", :scope => "col", :id => "vzebra-children") %>
@@ -34,6 +35,9 @@
<% end -%>
<% container.attachments.each do |file| %>
+ <%if file.is_public == 0 && !User.current.member_of?(@project)%>
+ <%next%>
+ <%end%>
">
<%= link_to_attachment file, :download => true, :title => file.filename+"\n"+file.description.to_s, :style => "width: 230px; overflow: hidden; white-space: nowrap;text-overflow: ellipsis;" %> |
@@ -45,6 +49,14 @@
<%= file.show_suffix_type %> |
+
+ <%= file.file_dense_str %>
+
+
+ <%= render :partial => 'course_file_dense_edit', :locals => {:file_dense_list => file.file_dense_list,
+ :attachment => file} %>
+
+ |
<%= file.downloads %> |
diff --git a/app/views/files/_course_sort_by_attachtypel.html.erb b/app/views/files/_course_sort_by_attachtypel.html.erb
index f73cac072..cda832493 100644
--- a/app/views/files/_course_sort_by_attachtypel.html.erb
+++ b/app/views/files/_course_sort_by_attachtypel.html.erb
@@ -5,66 +5,78 @@
<% edit_allowed = User.current.allowed_to?(:manage_files, @course) %>
-
-
-
-
-
-
-
+
+
+
+
+
+
+
<%= sort_header_tag('filename', :caption => l(:field_filename), :scope => "col", :id => "vzebra-adventure") %>
<%#= sort_header_tag('created_on', :caption => l(:label_date), :default_order => 'desc', :scope => "col", :id => "vzebra-comedy") %>
<%= sort_header_tag('size', :caption => l(:field_filesize), :default_order => 'desc', :scope => "col", :id => "vzebra-children") %>
<%= sort_header_tag('attach_type', :caption => l(:attachment_browse), :default_order => 'desc', :scope => "col", :id => "vzebra-attachmenttype") %>
- <%= sort_header_tag('content_type', :caption => l(:attachment_sufix_browse), :default_order => 'desc', :scope =>"col", :id=> "vzebra-contenttype")%>
+ <%= sort_header_tag('content_type', :caption => l(:attachment_sufix_browse), :default_order => 'desc', :scope => "col", :id => "vzebra-contenttype") %>
+ <%= sort_header_tag('field_file_dense', :caption => l(:field_file_dense), :default_order => 'desc', :scope => "col", :id => "vzebra-field_file_dense") %>
<%= sort_header_tag('downloads', :caption => l(:field_downloads), :default_order => 'desc', :scope => "col", :id => "vzebra-action") %>
<%= sort_header_tag('operation', :caption => "", :scope => "col", :id => "vzebra-children") %>
-
-
+
+
<% @containers.each do |container| %>
- <% next if container.attachments.empty? -%>
- <% container.attachments.each do |file| %>
- <% if isTypeOk(file,selAttachType,selContentType) %>
- ">
- <%= link_to_attachment file, :download => true, :title => file.filename+"\n"+file.description.to_s, :style => "width: 230px; overflow: hidden; white-space: nowrap;text-overflow: ellipsis;" %> |
-
- <%= number_to_human_size(file.filesize) %> |
-
- <%= file.attachmentstype.typeName %>
-
+ <% next if container.attachments.empty? -%>
+ <% container.attachments.each do |file| %>
+ <% if file.is_public == 0 && !User.current.member_of?(@project) %>
+ <% next %>
+ <% end %>
+ <% if isTypeOk(file, selAttachType, selContentType) %>
+ | ">
+ <%= link_to_attachment file, :download => true, :title => file.filename+"\n"+file.description.to_s, :style => "width: 230px; overflow: hidden; white-space: nowrap;text-overflow: ellipsis;" %> |
+
+ <%= number_to_human_size(file.filesize) %> |
+
+ <%= file.attachmentstype.typeName %>
+
<%= render :partial => 'attachments/course_type_edit', :locals => {:attachmenttypes => attachmenttypes,
- :attachment => file,:contentype=>selContentType} %>
+ :attachment => file, :contentype => selContentType} %>
- |
- <%= file.show_suffix_type %> |
- <%= file.downloads %> |
-
-
- <%= link_to(image_tag('delete.png'), attachment_path(file),
- :data => {:confirm => l(:text_are_you_sure)}, :method => :delete) if delete_allowed %>
- |
-
-
-
-
-
- |
-
- <% end -%>
- <% end -%>
- <% reset_cycle %>
- <% end -%>
-
-
+
+ <%= file.show_suffix_type %> |
+
+ <%= file.file_dense_str %>
+
+
+ <%= render :partial => 'course_file_dense_edit', :locals => {:file_dense_list => file.file_dense_list,
+ :attachment => file} %>
+
+ |
+ <%= file.downloads %> |
+
+
+ <%= link_to(image_tag('delete.png'), attachment_path(file),
+ :data => {:confirm => l(:text_are_you_sure)}, :method => :delete) if delete_allowed %>
+ |
+
+
+
+
+
+ |
+
+ <% end -%>
+ <% end -%>
+ <% reset_cycle %>
+ <% end -%>
+
+
diff --git a/app/views/files/_project_file_dense_edit.html.erb b/app/views/files/_project_file_dense_edit.html.erb
new file mode 100644
index 000000000..daa4b927d
--- /dev/null
+++ b/app/views/files/_project_file_dense_edit.html.erb
@@ -0,0 +1,13 @@
+<% edit_allowed = User.current.allowed_to?(:manage_files, @project) %>
+<% if file_dense_list.any? %>
+
+ <%= select_tag "file_dense",
+ options_for_select(file_dense_list,attachment.file_dense_str), :onchange=>"file_dense_edit("+attachment.id.to_s + ",this.value)"%>
+
+ <%= link_to(image_tag('edit/edit.png'), 'javascript:void(0);',:style=>"white-space:nowrap;", :id=>"edit_box_dense"+attachment.id.to_s ,
+ :onclick =>"$('#edit-file-dense-form-" +attachment.id.to_s+ "').show();
+ $('#field_file_dense_id_label" +attachment.id.to_s+ "').hide();
+ $('#edit_box_dense" +attachment.id.to_s+ "').hide();") if edit_allowed %>
+
+<% end %>
+
diff --git a/app/views/files/_show_all_attachment.html.erb b/app/views/files/_show_all_attachment.html.erb
index 07dc6a27f..8c624d176 100644
--- a/app/views/files/_show_all_attachment.html.erb
+++ b/app/views/files/_show_all_attachment.html.erb
@@ -18,6 +18,7 @@
<%= sort_header_tag('size', :caption => l(:field_filesize), :default_order => 'desc', :scope => "col", :id => "vzebra-children") %>
<%= sort_header_tag('attach_type', :caption => l(:attachment_browse), :default_order => 'desc', :scope => "col", :id => "vzebra-attachmenttype") %>
<%= sort_header_tag('content_type', :caption => l(:attachment_sufix_browse), :default_order => 'desc', :scope => "col", :id => "vzebra-contenttype") %>
+ <%= sort_header_tag('field_file_dense', :caption => l(:field_file_dense), :default_order => 'desc', :scope => "col", :id => "vzebra-field_file_dense") %>
<%= sort_header_tag('downloads', :caption => l(:field_downloads), :default_order => 'desc', :scope => "col", :id => "vzebra-action") %>
<%= sort_header_tag('operation', :caption => "", :scope => "col", :id => "vzebra-children") %>
@@ -34,6 +35,9 @@
|
<% end -%>
<% container.attachments.each do |file| %>
+ <%if file.is_public == 0 && !User.current.member_of?(@project)%>
+ <%next%>
+ <%end%>
">
<%= link_to_attachment file, :download => true, :title => file.filename+"\n"+file.description.to_s, :style => "width: 230px; overflow: hidden; white-space: nowrap;text-overflow: ellipsis;" %> |
@@ -45,6 +49,14 @@
<%= file.show_suffix_type %> |
+
+ <%= file.file_dense_str %>
+
+
+ <%= render :partial => 'project_file_dense_edit', :locals => {:file_dense_list => file.file_dense_list,
+ :attachment => file} %>
+
+ |
<%= file.downloads %> |
diff --git a/app/views/files/_sort_by_attachtypel.html.erb b/app/views/files/_sort_by_attachtypel.html.erb
index 01c57c490..d3723c340 100644
--- a/app/views/files/_sort_by_attachtypel.html.erb
+++ b/app/views/files/_sort_by_attachtypel.html.erb
@@ -5,66 +5,78 @@
<% edit_allowed = User.current.allowed_to?(:manage_files, @project) %>
-
-
-
-
-
-
-
+
+
+
+
+
+
+
<%= sort_header_tag('filename', :caption => l(:field_filename), :scope => "col", :id => "vzebra-adventure") %>
<%#= sort_header_tag('created_on', :caption => l(:label_date), :default_order => 'desc', :scope => "col", :id => "vzebra-comedy") %>
<%= sort_header_tag('size', :caption => l(:field_filesize), :default_order => 'desc', :scope => "col", :id => "vzebra-children") %>
<%= sort_header_tag('attach_type', :caption => l(:attachment_browse), :default_order => 'desc', :scope => "col", :id => "vzebra-attachmenttype") %>
- <%= sort_header_tag('content_type', :caption => l(:attachment_sufix_browse), :default_order => 'desc', :scope =>"col", :id=> "vzebra-contenttype")%>
+ <%= sort_header_tag('content_type', :caption => l(:attachment_sufix_browse), :default_order => 'desc', :scope => "col", :id => "vzebra-contenttype") %>
+ <%= sort_header_tag('field_file_dense', :caption => l(:field_file_dense), :default_order => 'desc', :scope => "col", :id => "vzebra-field_file_dense") %>
<%= sort_header_tag('downloads', :caption => l(:field_downloads), :default_order => 'desc', :scope => "col", :id => "vzebra-action") %>
<%= sort_header_tag('operation', :caption => "", :scope => "col", :id => "vzebra-children") %>
-
-
+
+
<% @containers.each do |container| %>
- <% next if container.attachments.empty? -%>
- <% container.attachments.each do |file| %>
- <% if isTypeOk(file,selAttachType,selContentType) %>
- ">
- <%= link_to_attachment file, :download => true, :title => file.filename+"\n"+file.description.to_s, :style => "width: 230px; overflow: hidden; white-space: nowrap;text-overflow: ellipsis;" %> |
-
- <%= number_to_human_size(file.filesize) %> |
-
- <%= file.attachmentstype.typeName %>
-
+ <% next if container.attachments.empty? -%>
+ <% container.attachments.each do |file| %>
+ <% if file.is_public == 0 && !User.current.member_of?(@project) %>
+ <% next %>
+ <% end %>
+ <% if isTypeOk(file, selAttachType, selContentType) %>
+ | ">
+ <%= link_to_attachment file, :download => true, :title => file.filename+"\n"+file.description.to_s, :style => "width: 230px; overflow: hidden; white-space: nowrap;text-overflow: ellipsis;" %> |
+
+ <%= number_to_human_size(file.filesize) %> |
+
+ <%= file.attachmentstype.typeName %>
+
<%= render :partial => 'attachments/type_edit', :locals => {:attachmenttypes => attachmenttypes,
- :attachment => file,:contentype=>selContentType} %>
+ :attachment => file, :contentype => selContentType} %>
- |
- <%= file.show_suffix_type %> |
- <%= file.downloads %> |
-
-
- <%= link_to(image_tag('delete.png'), attachment_path(file),
- :data => {:confirm => l(:text_are_you_sure)}, :method => :delete) if delete_allowed %>
- |
-
-
-
-
-
- |
-
- <% end -%>
- <% end -%>
- <% reset_cycle %>
- <% end -%>
-
-
+
+ <%= file.show_suffix_type %> |
+
+ <%= file.file_dense_str %>
+
+
+ <%= render :partial => 'project_file_dense_edit', :locals => {:file_dense_list => file.file_dense_list,
+ :attachment => file} %>
+
+ |
+ <%= file.downloads %> |
+
+
+ <%= link_to(image_tag('delete.png'), attachment_path(file),
+ :data => {:confirm => l(:text_are_you_sure)}, :method => :delete) if delete_allowed %>
+ |
+
+
+
+
+
+ |
+
+ <% end -%>
+ <% end -%>
+ <% reset_cycle %>
+ <% end -%>
+
+
diff --git a/app/views/files/index.html.erb b/app/views/files/index.html.erb
index b086b90db..69b41fc28 100644
--- a/app/views/files/index.html.erb
+++ b/app/views/files/index.html.erb
@@ -207,6 +207,23 @@
<%end%>
}
+
+ // 编辑文件密级
+ function file_dense_edit(id, type) {
+ $.ajax({
+ url: '<%=updateFileDense_attachments_path%>',
+ type: "POST",
+ remote:"true",
+ data: {
+ attachmentid: encodeURIComponent(id),
+ newtype: encodeURIComponent(type)
+ }
+
+ }).complete(function (xhr, textStatus) {
+ });
+
+ }
+
diff --git a/app/views/mailer/applied_project.html.erb b/app/views/mailer/applied_project.html.erb
new file mode 100644
index 000000000..4f266e6ce
--- /dev/null
+++ b/app/views/mailer/applied_project.html.erb
@@ -0,0 +1,5 @@
+<%= l(:text_applied_project, :id => "##{@user.show_name}", :project => @project.name) %>
+
+
+<%= link_to(h(@project.name), @applied_url) %>
+
diff --git a/app/views/mailer/applied_project.text.erb b/app/views/mailer/applied_project.text.erb
new file mode 100644
index 000000000..7af8c2018
--- /dev/null
+++ b/app/views/mailer/applied_project.text.erb
@@ -0,0 +1,4 @@
+<%= l(:text_applied_project, :id => "##{@user.show_name}", :project => @project.name) %>
+
+<%= link_to(h(@project.name), @applied_url) %>
+
diff --git a/config/locales/en.yml b/config/locales/en.yml
index 4c177b58e..2231100b7 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -233,6 +233,7 @@ en:
field_mail: Email
field_job_category: Job category # added by bai
field_filename: File
+ field_file_dense: File Dense
field_filesize: Size
field_downloads: Downloads
field_author: Author
@@ -1079,6 +1080,7 @@ en:
text_session_expiration_settings: "Warning: changing these settings may expire the current sessions including yours."
text_project_closed: This project is closed and read-only.
text_turning_multiple_off: "If you disable multiple values, multiple values will be removed in order to preserve only one value per item."
+ text_applied_project: "User %{id} Apply Join Project %{project}"
default_role_manager: Manager
default_role_developer: Developer
diff --git a/config/locales/zh.yml b/config/locales/zh.yml
index dcbd1d6ec..07802e7db 100644
--- a/config/locales/zh.yml
+++ b/config/locales/zh.yml
@@ -251,6 +251,7 @@ zh:
field_lastname_eg: '(例:张三丰,请填写[张])'
field_mail: 邮件地址
field_filename: 文件
+ field_file_dense: 文件密级
field_filesize: 大小
field_downloads: 下载次数
field_author: 作者
@@ -1105,6 +1106,7 @@ zh:
text_own_membership_delete_confirmation: 你正在删除你现有的某些或全部权限,如果这样做了你可能将会再也无法编辑该项目了。你确定要继续吗?
text_zoom_in: 放大
text_zoom_out: 缩小
+ text_applied_project: "用户 %{id} 申请加入项目 %{project}"
default_role_manager: 管理人员
default_role_developer: 开发人员
diff --git a/config/routes.rb b/config/routes.rb
index f9dd53cf3..1ad026dc3 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -515,6 +515,7 @@ RedmineApp::Application.routes.draw do
resources :attachments, :only => [:show, :destroy] do
collection do
match "updateType" , via: [:get, :post]
+ match "updateFileDense" , via: [:get, :post]
match "renderTag" , via: [:get, :post]
end
end
diff --git a/db/migrate/20140710024054_add_is_public_to_attachment.rb b/db/migrate/20140710024054_add_is_public_to_attachment.rb
new file mode 100644
index 000000000..2276304c8
--- /dev/null
+++ b/db/migrate/20140710024054_add_is_public_to_attachment.rb
@@ -0,0 +1,5 @@
+class AddIsPublicToAttachment < ActiveRecord::Migration
+ def change
+ add_column :attachments, :is_public, :integer,:default => 1
+ end
+end
diff --git a/db/migrate/20140710030426_update_attachment_public_attr.rb b/db/migrate/20140710030426_update_attachment_public_attr.rb
new file mode 100644
index 000000000..339c52543
--- /dev/null
+++ b/db/migrate/20140710030426_update_attachment_public_attr.rb
@@ -0,0 +1,22 @@
+class UpdateAttachmentPublicAttr < ActiveRecord::Migration
+ def up
+ # 更新资源文件的is_public属性
+ Attachment.all.each do |res|
+ if res.is_public
+ if(res.container.nil? ||
+ (res.container.class.to_s=="Project" && res.container.is_public == false) ||
+ (res.container.has_attribute?(:project) && res.container.project && res.container.project.is_public == false) ||
+ (res.container.class.to_s=="HomeworkAttach" && res.container.bid.reward_type == 3) ||
+ (res.container.class.to_s=="Course" && res.container.is_public == false) ||
+ (res.container.has_attribute?(:course) && res.container.course && res.container.course.is_public == false)
+ )
+ res.is_public = false
+ res.save
+ end
+ end
+ end
+ end
+
+ def down
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 93aa90c44..8fa520eba 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
-ActiveRecord::Schema.define(:version => 20140707095213) do
+ActiveRecord::Schema.define(:version => 20140710030426) do
create_table "activities", :force => true do |t|
t.integer "act_id", :null => false
@@ -51,6 +51,7 @@ ActiveRecord::Schema.define(:version => 20140707095213) do
t.string "description"
t.string "disk_directory"
t.integer "attachtype", :default => 1
+ t.integer "is_public", :default => 1
end
add_index "attachments", ["author_id"], :name => "index_attachments_on_author_id"
diff --git a/lib/plugins/acts_as_attachable/lib/acts_as_attachable.rb b/lib/plugins/acts_as_attachable/lib/acts_as_attachable.rb
index 30bbaedda..1318f8afa 100644
--- a/lib/plugins/acts_as_attachable/lib/acts_as_attachable.rb
+++ b/lib/plugins/acts_as_attachable/lib/acts_as_attachable.rb
@@ -60,11 +60,28 @@ module Redmine
@unsaved_attachments ||= []
end
+ # 设置资源文件的公开属性
+ # add by nwb
+ def set_attachment_public(res)
+ # 公开的资源判断他的父级的公开属性
+ if res.is_public
+ if( (self.class.to_s=="Project" && self.is_public == false) ||
+ (self.has_attribute?(:project) && self.project && self.project.is_public == false) ||
+ (self.class.to_s=="HomeworkAttach" && self.bid.reward_type == 3) ||
+ (self.class.to_s=="Course" && self.is_public == false) ||
+ (self.has_attribute?(:course) && self.course && self.course.is_public == false)
+ )
+ res.is_public = false
+ end
+ end
+ end
+
def save_attachmentsex(attachments, author=User.current,attachment_type)
@curattachment_type = attachment_type
result = save_attachments(attachments,author)
result
end
+
def save_attachments(attachments, author=User.current)
if attachments.is_a?(Hash)
attachments = attachments.stringify_keys
@@ -94,6 +111,10 @@ module Redmine
a.filename = attachment['filename'] unless attachment['filename'].blank?
a.content_type = attachment['content_type']
end
+ if !attachment[:is_public]
+ a.is_public = false
+ end
+ set_attachment_public(a)
next unless a
a.description = attachment['description'].to_s.strip
a.attachtype = @curattachment_type;
diff --git a/public/javascripts/attachments.js b/public/javascripts/attachments.js
index 663183b9a..c60a77bd3 100644
--- a/public/javascripts/attachments.js
+++ b/public/javascripts/attachments.js
@@ -23,7 +23,9 @@ function addFile(inputEl, file, eagerUpload) {
fileSpan.append(
$('', { 'type': 'text', 'class': 'filename readonly', 'name': 'attachments[' + attachmentId + '][filename]', 'readonly': 'readonly'} ).val(file.name),
$('', { 'type': 'text', 'class': 'description', 'name': 'attachments[' + attachmentId + '][description]', 'maxlength': 255, 'placeholder': $(inputEl).data('description-placeholder') } ).toggle(!eagerUpload),
- $(' ').attr({ 'href': "#", 'class': 'remove-upload', 'data-confirm' : "您确定要删除吗?" }).click(removeFile).toggle(!eagerUpload),
+ $('公开:').attr({ 'class': 'ispublic-label' }) ,
+ $('', { 'type': 'checkbox', 'class': 'is_public_checkbox','value':1, 'name': 'attachments[' + attachmentId + '][is_public]', checked:'checked' } ).toggle(!eagerUpload),
+ $(' ').attr({ 'href': "#", 'class': 'remove-upload', 'data-confirm' : "您确定要删除吗?" }).click(removeFile).toggle(!eagerUpload),
$('', { 'class': 'div_attachments', 'name': 'div_'+'attachments_' + attachmentId} )
).appendTo('#attachments_fields');
@@ -63,6 +65,7 @@ function ajaxUpload(file, attachmentId, fileSpan, inputEl) {
.done(function(result) {
progressSpan.progressbar( 'value', 100 ).remove();
fileSpan.find('input.description, a').css('display', 'inline-block');
+ fileSpan.find('input.is_public_checkbox, a').css('display', 'inline-block');
})
.fail(function(result) {
progressSpan.text(result.statusText);
diff --git a/public/stylesheets/application.css b/public/stylesheets/application.css
index 89ee39ada..10b8fb328 100644
--- a/public/stylesheets/application.css
+++ b/public/stylesheets/application.css
@@ -1850,6 +1850,8 @@ span.required {color: #bb0000;}
#attachments_fields div.ui-progressbar { width: 100px; height:14px; margin: 2px 0 -5px 8px; display: inline-block; }
a.remove-upload {background: url(../images/delete.png) no-repeat 1px 50%; width:1px; display:inline-block; padding-left:16px;}
a.remove-upload:hover {text-decoration:none !important;}
+#attachments_fields input.is_public_checkbox {width:20px;}
+#attachments_fields span.ispublic-label {width:50px;margin-left:10px; }
/*gcm upload file count and deleteall*/
#upload_file_count #count {color:red; font-size:1.5em;}
diff --git a/public/stylesheets/nyan.css b/public/stylesheets/nyan.css
index 30496a061..b57796aa3 100644
--- a/public/stylesheets/nyan.css
+++ b/public/stylesheets/nyan.css
@@ -1081,6 +1081,11 @@ div.tags_area {
border-bottom: 1px solid #c8d4fd;
}
+#ver-zebra #vzebra-field_file_dense, #ver-zebra #vzebra-children {
+ background: #ffffff;
+ border-bottom: 1px solid #c8d4fd;
+}
+
#ver-zebra #vzebra-comedy, #ver-zebra #vzebra-action {
background: #ffffff;
border-bottom: 1px solid #d6dfff;
|