diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
index 39a467d53..0b3302fae 100644
--- a/app/controllers/users_controller.rb
+++ b/app/controllers/users_controller.rb
@@ -46,7 +46,7 @@ class UsersController < ApplicationController
:user_homeworks, :destroy_membership, :user_activities, :user_projects, :user_newfeedback, :user_comments,
:watch_contests, :info, :watch_projects, :show_score, :topic_score_index, :project_score_index,
:activity_score_index, :influence_score_index, :score_index,:show_new_score, :topic_new_score_index, :project_new_score_index,
- :activity_new_score_index, :influence_new_score_index, :score_new_index,:user_projects_index,
+ :activity_new_score_index, :influence_new_score_index, :score_new_index,:user_projects_index,:user_resource,
:user_courses4show,:user_projects4show,:user_course_activities,:user_project_activities,:user_feedback4show,:user_visitorlist]
before_filter :auth_user_extension, only: :show
#before_filter :rest_user_score, only: :show
@@ -807,6 +807,27 @@ class UsersController < ApplicationController
end
end
+ # 上传用户资源
+ def user_resource_create
+ @user = User.find(params[:id])
+ #@user.save_attachments(params[:attachments],User.current)
+ # Container_type为Principal
+ Attachment.attach_filesex(@user, params[:attachments], params[:attachment_type])
+ @attachments = Attachment.where("author_id = #{params[:id]} and container_type in('Project','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon') ").order("created_on desc")
+ respond_to do |format|
+ format.js
+ end
+ end
+
+ # 删除用户资源
+ def user_resource_delete
+ Attachment.delete(params[:resource_id])
+ @attachments = Attachment.where("author_id = #{params[:id]} and container_type in('Project','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon') ").order("created_on desc")
+ respond_to do |format|
+ format.js
+ end
+ end
+
def destroy
@user.destroy
respond_to do |format|
@@ -1008,6 +1029,55 @@ class UsersController < ApplicationController
@user = User.find(params[:id])
end
+ # 资源库 分为全部 课程资源 项目资源 附件
+ def user_resource
+ #确定container_type
+ # @user = User.find(params[:id])
+ if(params[:type].nil? || params[:type] == "1") #全部
+ if User.current.id == params[:id]
+ @attachments = Attachment.where("author_id = #{params[:id]} and container_type in('Project','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon') ").order("created_on desc")
+ else
+ @attachments = Attachment.where("author_id = #{params[:id]} and is_public = 1 and container_type in('Project','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon') ").order("created_on desc")
+ end
+ elsif params[:type] == "2" #课程资源
+ if User.current.id == params[:id]
+ @attachments = Attachment.where("author_id = #{params[:id]} and container_type = 'Course'").order("created_on desc")
+ else
+ @attachments = Attachment.where("author_id = #{params[:id]} and is_public = 1 and container_type = 'Course' ").order("created_on desc")
+ end
+ elsif params[:type] == "3" #项目资源
+ if User.current.id == params[:id]
+ @attachments = Attachment.where("author_id = #{params[:id]} and container_type = 'Project'").order("created_on desc")
+ else
+ @attachments = Attachment.where("author_id = #{params[:id]} and is_public = 1 and container_type = 'Project' ").order("created_on desc")
+ end
+ elsif params[:type] == "4" #附件
+ if User.current.id == params[:id]
+ @attachments = Attachment.where("author_id = #{params[:id]} and container_type in('Project','Issue','Document','Message','News','StudentWorkScore','HomewCommon')").order("created_on desc")
+ else
+ @attachments = Attachment.where("author_id = #{params[:id]} and is_public = 1 and container_type in('Issue','Document','Message','News','StudentWorkScore','HomewCommon')").order("created_on desc")
+ end
+ end
+ @type = params[:type]
+ respond_to do |format|
+ format.js
+ format.html {render :layout => 'base_users_new'}
+ end
+ end
+
+ # 根据资源关键字进行搜索
+ def resource_search
+ search = params[:search].to_s.strip.downcase
+ if User.current.id == params[:id]
+ @attachments = Attachment.where("author_id = #{params[:id]} and container_type not in ('Version','PhoneAppVersion','StudentWork') and (filename like '%#{search}%') ").order("created_on desc")
+ else
+ @attachments = Attachment.where("author_id = #{params[:id]} and container_type not in ('Version','PhoneAppVersion','StudentWork') and is_public = 1 and (filename like '%#{search}%') ").order("created_on desc")
+ end
+ respond_to do |format|
+ format.js
+ end
+ end
+
private
def find_user
@@ -1021,7 +1091,7 @@ class UsersController < ApplicationController
render_404
end
- def setting_layout(default_base='base_users')
+ def setting_layout(default_base='base_users_new')
User.current.admin? ? default_base : default_base
end
@@ -1071,4 +1141,7 @@ class UsersController < ApplicationController
impl.save
end
end
+
+
+
end
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index 6ac3c234a..cdcb6fc4d 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -1852,7 +1852,8 @@ module ApplicationHelper
candown = true
elsif attachment.container.class.to_s=="StudentWork"
candown = true
-
+ elsif attachment.container.class.to_s == "User"
+ candown = (attachment.is_public == 1 || attachment.is_public == true || attachment.author_id == User.current.id)
elsif attachment.container_type == "Bid" && attachment.container && attachment.container.courses
course = attachment.container.courses.first
candown = User.current.member_of_course?(attachment.container.courses.first) || (course.is_public == 1 && attachment.is_public == 1)
diff --git a/app/helpers/users_helper.rb b/app/helpers/users_helper.rb
index 49865d335..41458bc90 100644
--- a/app/helpers/users_helper.rb
+++ b/app/helpers/users_helper.rb
@@ -29,6 +29,29 @@ module UsersHelper
["#{l(:status_locked)} (#{user_count_by_status[3].to_i})", '3']], selected.to_s)
end
+ def get_resource_type type
+ case type
+ when 'Course'
+ '课程资源'
+ when 'Project'
+ '项目资源'
+ when 'Issue'
+ '缺陷附件'
+ when 'Message'
+ '讨论区附件'
+ when 'Document'
+ '文档附件'
+ when 'News'
+ '通知附件'
+ when 'HomewCommon'
+ '作业附件'
+ when 'StudentWorkScore'
+ '批改附件'
+ when 'Principal'
+ '用户资源'
+ end
+ end
+
def user_mail_notification_options(user)
user.valid_notification_options.collect {|o| [l(o.last), o.first]}
end
diff --git a/app/models/user.rb b/app/models/user.rb
index 1cd0675c8..4fae33185 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -150,7 +150,8 @@ class User < Principal
nil
}
-
+ acts_as_attachable :view_permission => :view_files,
+ :delete_permission => :manage_files
acts_as_customizable
############################added by william
acts_as_taggable
@@ -239,6 +240,12 @@ class User < Principal
self.user_extensions ||= UserExtensions.new
end
+ # User现在可以作为一个Container_type,而Attachment的Container方法会有一个Container.try(:project),
+ # 所以这里定义一个空方法,保证不报错
+ def project
+
+ end
+
def user_score_attr
self.user_score ||= UserScore.new
end
diff --git a/app/views/layouts/base_users_new.html.erb b/app/views/layouts/base_users_new.html.erb
index 09d437da4..f9f065e2a 100644
--- a/app/views/layouts/base_users_new.html.erb
+++ b/app/views/layouts/base_users_new.html.erb
@@ -146,6 +146,12 @@
(<%=@user.projects.count%>)
+
<% else%>
@@ -160,6 +166,12 @@
(<%=@user.projects.visible.count%>)
+
<% end %>
<%= link_to "留言",feedback_path(@user),:class => "f14 c_blue02"%>
diff --git a/config/routes.rb b/config/routes.rb
index cdcb1126c..79ee367bb 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -344,12 +344,18 @@ RedmineApp::Application.routes.draw do
match 'file_score_index', :to => 'projects#file_score_index', :via => [:get, :post]
match 'code_submit_score_index', :to => 'projects#code_submit_score_index', :via => [:get, :post]
match 'projects_topic_score_index', :to => 'projects#projects_topic_score_index', :via => [:get, :post]
+ get "user_resource"
+ post "resource_search"
+ post "user_resource_create"
+ post "user_resource_delete"
# end
end
end
match 'users/:id/user_newfeedback', :to => 'users#user_newfeedback', :via => :get, :as => "feedback"
match 'users/:id/user_projects', :to => 'users#user_projects', :via => :get
+
+
#end
match 'my/account', :via => [:get, :post]
match 'my/account/destroy', :to => 'my#destroy', :via => [:get, :post]
@@ -841,6 +847,7 @@ RedmineApp::Application.routes.draw do
match 'system_log/clear'
##ended by lizanle
+
resources :git_callback do
collection do
post 'post_update'
diff --git a/db/schema.rb b/db/schema.rb
index 30ca29d12..d9511818e 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -746,6 +746,16 @@ ActiveRecord::Schema.define(:version => 20150801034945) do
add_index "journal_details", ["journal_id"], :name => "journal_details_journal_id"
+ create_table "journal_details_copy", :force => true do |t|
+ t.integer "journal_id", :default => 0, :null => false
+ t.string "property", :limit => 30, :default => "", :null => false
+ t.string "prop_key", :limit => 30, :default => "", :null => false
+ t.text "old_value"
+ t.text "value"
+ end
+
+ add_index "journal_details_copy", ["journal_id"], :name => "journal_details_journal_id"
+
create_table "journal_replies", :id => false, :force => true do |t|
t.integer "journal_id"
t.integer "user_id"
diff --git a/public/stylesheets/public.css b/public/stylesheets/public.css
index 82b3f17aa..4cc859721 100644
--- a/public/stylesheets/public.css
+++ b/public/stylesheets/public.css
@@ -467,3 +467,68 @@ img,embed{max-width: 100%;}
/*.copyright{ width:390px; margin:0 auto;height:20px;line-height:20px;}*/
/*a.f_grey {color:#666666;}*/
/*a.f_grey:hover {color:#000000;}*/
+
+/*资源库*/
+.resources {width:730px; background-color:#ffffff; padding:10px;}
+.resourcesBanner {width:730px; height:40px; background-color:#eaeaea; margin-bottom:10px;}
+.bannerName {background:#64bdd9; color:#ffffff; height:40px; line-height:40px; width:90px; text-align:center; font-weight:normal; vertical-align:middle; font-size: 16px; float:left;}
+.resourcesSelect {width:40px; height:40px; float:right; position:relative;}
+.resourcesSelected {width:25px; height:20px;}
+.resourcesIcon {margin-top:15px; display:block; position:relative; background:url(../images/resource_icon_list.png) 0px 0px no-repeat; width:25px; height:20px;}
+.resourcesIcon:hover { background:url(../images/resource_icon_list.png) 0px -25px no-repeat;}
+.resourcesType {width:50px; background-color:#ffffff; float:left; list-style:none; position:absolute; border:1px solid #eaeaea; border-radius:5px; top:35px; padding:5px 10px; left:-30px; font-size:12px; color:#888888; display:none;}
+a.resourcesGrey {font-size:12px; color:#888888;}
+a.resourcesGrey:hover {font-size:12px; color:#15bccf;}
+.resourcesBanner ul li:hover ul.resourcesType {display:block;}
+ul li:hover ul {display:block;}
+.resourcesUploadBox {float:right; width:103px; height:34px; background-color:#64bdd9; line-height:34px; vertical-align:middle; text-align:center; margin-left:12px;}
+.uploadIcon {background:url(../images/resource_icon_list.png) -35px 10px no-repeat; float:left; display:block; width:30px; height:30px; margin-left:-3px;}
+a.uploadText {color:#ffffff; font-size:14px;}
+.resourcesSearchloadBox {border:1px solid #e6e6e6; width:225px; float:right; background-color:#ffffff;}
+.searchResource {border:none; outline:none; background-color:#ffffff; width:184px; height:32px; padding-left:10px; display:block; float:left;}
+.searchIcon{width:31px; height:32px; background-color:#ffffff; background:url(../images/resource_icon_list.png) -40px -15px no-repeat; display:block; float:left;}
+.resourcesSearchBanner {height:34px; margin-bottom:10px;}
+.resourcesListTab {width:730px; height:40px; background-color:#f6f6f6; border-bottom:1px solid #eaeaea; font-size:14px; color:#7a7a7a;}
+.resourcesListName {width:175px; height:40px; line-height:40px; text-align:center;}
+.resourcesListSize {width:110px; height:40px; line-height:40px; text-align:center;}
+.resourcesListType {width:150px; height:40px; line-height:40px; text-align:center;}
+.resourcesListUploader {width:130px; height:40px; line-height:40px; text-align:center;}
+.resourcesListTime {width:165px; height:40px; line-height:40px; text-align:center;}
+.resourcesList {width:730px; height:39px; background-color:#ffffff; border-bottom:1px dashed #eaeaea; color:#9a9a9a; font-size:12px;}
+a.resourcesBlack {font-size:12px; color:#4c4c4c;}
+a.resourcesBlack:hover {font-size:12px; color:#000000;}
+.dropdown-menu {
+ position: absolute;
+ top: 100%;
+ left: 0;
+ z-index: 1000;
+ display: none;
+ float: left;
+ min-width: 80px;
+ padding: 5px 0;
+ margin: 2px 0 0;
+ font-size: 12px;
+ text-align: left;
+ background-color: #fff;
+ -webkit-background-clip: padding-box;
+ background-clip: padding-box;
+ border: 1px solid #ccc;
+ border-radius: 4px;
+ -webkit-box-shadow: 0 6px 12px rgba(0, 0, 0, .175);
+ box-shadow: 0 6px 12px rgba(0, 0, 0, .175);
+}
+.dropdown-menu > li > a {
+ display: block;
+ padding: 3px 20px;
+ clear: both;
+ font-weight: normal;
+ line-height: 1.5;
+ color:#616060;
+ white-space: nowrap;
+}
+.dropdown-menu > li > a:hover{
+ color: #ffffff;
+ text-decoration: none;
+ background-color: #64bdd9;
+ outline:none;
+}
diff --git a/public/stylesheets/public_new.css b/public/stylesheets/public_new.css
index 7389dff8a..684213f20 100644
--- a/public/stylesheets/public_new.css
+++ b/public/stylesheets/public_new.css
@@ -444,4 +444,99 @@ div.ke-statusbar{height:1px; border-top:none;}
/*.copyright{ width:390px; margin:0 auto;height:20px;line-height:20px;}*/
/*a.f_grey {color:#666666;}*/
/*a.f_grey:hover {color:#000000;}*/
+/*资源库*/
+.resources {width:730px; background-color:#ffffff; padding:10px;float: right}
+.resourcesBanner {width:730px; height:40px; background-color:#eaeaea; margin-bottom:10px;}
+.bannerName {background:#64bdd9; color:#ffffff; height:40px; line-height:40px; width:90px; text-align:center; font-weight:normal; vertical-align:middle; font-size: 16px; float:left;}
+.resourcesSelect {width:40px; height:40px; float:right; position:relative;}
+.resourcesSelected {width:25px; height:20px;}
+.resourcesIcon {margin-top:15px; display:block; position:relative; background:url(images/resource_icon_list.png) 0px 0px no-repeat; width:25px; height:20px;}
+.resourcesIcon:hover { background:url(images/resource_icon_list.png) 0px -25px no-repeat;}
+.resourcesType {width:50px; background-color:#ffffff; float:left; list-style:none; position:absolute; border:1px solid #eaeaea; border-radius:5px; top:35px; padding:5px 10px; left:-30px; font-size:12px; color:#888888; display:none;}
+a.resourcesGrey {font-size:12px; color:#888888;}
+a.resourcesGrey:hover {font-size:12px; color:#15bccf;}
+.resourcesBanner ul li:hover ul.resourcesType {display:block;}
+ul li:hover ul {display:block;}
+.resourcesUploadBox {float:right; width:103px; height:34px; background-color:#64bdd9; line-height:34px; vertical-align:middle; text-align:center; margin-left:12px;}
+.uploadIcon {background:url(images/resource_icon_list.png) -35px 10px no-repeat; float:left; display:block; width:30px; height:30px; margin-left:-3px;}
+a.uploadText {color:#ffffff; font-size:14px;}
+.resourcesSearchloadBox {border:1px solid #e6e6e6; width:225px; float:right; background-color:#ffffff;}
+.searchResource {border:none; outline:none; background-color:#ffffff; width:184px; height:32px; padding-left:10px; display:block; float:left;}
+.searchIcon{width:31px; height:32px; background-color:#ffffff; background:url(images/resource_icon_list.png) -40px -15px no-repeat; display:block; float:left;}
+.resourcesSearchBanner {height:34px; margin-bottom:10px;}
+.resourcesListTab {width:730px; height:40px; background-color:#f6f6f6; border-bottom:1px solid #eaeaea; font-size:14px; color:#7a7a7a;}
+.resourcesListName {width:175px; height:40px; line-height:40px; text-align:center;}
+.resourcesListSize {width:110px; height:40px; line-height:40px; text-align:center;}
+.resourcesListType {width:150px; height:40px; line-height:40px; text-align:center;}
+.resourcesListUploader {width:130px; height:40px; line-height:40px; text-align:center;}
+.resourcesListTime {width:165px; height:40px; line-height:40px; text-align:center;}
+.resourcesList {width:730px; height:39px; background-color:#ffffff; border-bottom:1px dashed #eaeaea; color:#9a9a9a; font-size:12px;}
+a.resourcesBlack {font-size:12px; color:#4c4c4c;white-space: nowrap;text-align: left}
+a.resourcesBlack:hover {font-size:12px; color:#000000;}
+.dropdown-menu {
+ position: absolute;
+ top: 100%;
+ left: 0;
+ z-index: 1000;
+ display: none;
+ float: left;
+ min-width: 80px;
+ padding: 5px 0;
+ margin: 2px 0 0;
+ font-size: 12px;
+ text-align: left;
+ background-color: #fff;
+ -webkit-background-clip: padding-box;
+ background-clip: padding-box;
+ border: 1px solid #ccc;
+ border-radius: 4px;
+ -webkit-box-shadow: 0 6px 12px rgba(0, 0, 0, .175);
+ box-shadow: 0 6px 12px rgba(0, 0, 0, .175);
+}
+.dropdown-menu > li > a {
+ display: block;
+ padding: 3px 20px;
+ clear: both;
+ font-weight: normal;
+ line-height: 1.5;
+ color:#616060;
+ white-space: nowrap;
+}
+.dropdown-menu > li > a:hover{
+ color: #ffffff;
+ text-decoration: none;
+ background-color: #64bdd9;
+ outline:none;
+}
+
+/*上传资源弹窗*/
+.resourceUploadPopup {width:400px; height:auto; border:3px solid #15bccf; padding-left:16px; padding-bottom:16px; background-color:#ffffff; position:absolute; top:50%; left:50%; margin-left:-200px; z-index:1000;}
+.uploadDialogText {font-size:16px; color:#15bccf; line-height:16px; padding-top:20px; width:140px; display:inline-block;}
+.uploadBoxContainer {height:33px; line-height:33px; margin-top:10px; position:relative}
+.uploadBox {width:100px; height:33px; line-height:33px; text-align:center; vertical-align:middle; background-color:#64bdd9; border-radius:3px; float:left; margin-right:12px;}
+a.uploadIcon {background:url(images/resource_icon_list.png) 8px -60px no-repeat; width:100px; height:33px;}
+.chooseFile {color:#ffffff; display:block; margin-left:32px;}
+.uploadResourceIntr {width:250px; height:33px; float:left; line-height:33px; font-size:12px;}
+.uploadResourceName {width:250px; display:inline-block; line-height:15px; font-size:12px; color:#444444; margin-bottom:2px;}
+.uploadResourceIntr2 {width:250px; display:inline-block; line-height:15px; font-size:12px; color:#444444;}
+.uploadType {margin:10px 0; border:1px solid #e6e6e6; width:100px; height:30px; outline:none; font-size:12px; color:#888888;}
+.uploadKeyword {margin-bottom:10px; outline:none; border:1px solid #e6e6e6; height:30px; width:280px;}
+
+/*发送资源弹窗*/
+/*.resourceShareContainer {width:100%; height:100%; background:#666; filter:alpha(opacity=50); opacity:0.5; -moz-opacity:0.5; position:absolute; left:0; top:0; z-index:-999;}*/
+.resourceSharePopup {width:300px; height:auto; border:3px solid #15bccf; padding-left:16px; padding-bottom:16px; background-color:#ffffff; position:absolute; top:50%; left:50%; margin-left:-150px; z-index:1000;}
+.sendText {font-size:16px; color:#15bccf; line-height:16px; padding-top:20px; width:140px; display:inline-block;}
+.resourcePopupClose {width:20px; height:20px; display:inline-block; float:right;}
+.resourceClose {background:url(images/resource_icon_list.png) 0px -40px no-repeat; width:20px; height:20px; display:inline-block;}
+.resourcesSearchBox {border:1px solid #e6e6e6; width:225px; height:25px; background-color:#ffffff; margin-top:12px; margin-bottom:15px;}
+.searchResourcePopup {border:none; outline:none; background-color:#ffffff; width:184px; height:25px; padding-left:10px; display:inline-block; float:left;}
+.searchIconPopup{width:31px; height:25px; background-color:#ffffff; background:url(images/resource_icon_list.png) -40px -18px no-repeat; display:inline-block; float:left;}
+.courseSend {width:260px; height:15px; line-height:15px; margin-bottom:10px;}
+.courseSendCheckbox {padding:0px; margin:0px; width:12px; height:12px; margin-right:10px; display:inline-block; margin-top:2px;}
+.sendCourseName {font-size:12px; color:#5f6060;}
+.courseSendSubmit {width:50px; height:25px; line-height:25px; text-align:center; vertical-align:middle; background-color:#64bdd9; margin-right:25px; float:left;}
+.courseSendCancel {width:50px; height:25px; line-height:25px; text-align:center; vertical-align:middle; background-color:#c1c1c1; float:left}
+a.sendSourceText {font-size:14px; color:#ffffff;}
+input.sendSourceText {font-size:14px;color:#ffffff;background-color:#64bdd9;}
+