memcached_alan
whimlex 10 years ago
commit 2ef224556e

@ -41,7 +41,7 @@ module Mobile
mount Apis::Comments mount Apis::Comments
#add_swagger_documentation ({api_version: 'v1', base_path: 'http://u06.shellinfo.cn/trustie/api'}) #add_swagger_documentation ({api_version: 'v1', base_path: 'http://u06.shellinfo.cn/trustie/api'})
#add_swagger_documentation ({api_version: 'v1', base_path: '/api'}) if Rails.env.development? add_swagger_documentation ({api_version: 'v1', base_path: '/api'}) if Rails.env.development?
end end
end end

@ -27,7 +27,7 @@ class AttachmentsController < ApplicationController
accept_api_auth :show, :download, :upload accept_api_auth :show, :download, :upload
require 'iconv' require 'iconv'
include AttachmentsHelper include AttachmentsHelper
include ApplicationHelper
def show def show
respond_to do |format| respond_to do |format|
@ -65,36 +65,7 @@ class AttachmentsController < ApplicationController
def download def download
# modify by nwb # modify by nwb
# 下载添加权限设置 # 下载添加权限设置
candown = false candown = attachment_candown @attachment
if @attachment.container.class.to_s != "HomeworkAttach" && (@attachment.container.has_attribute?(:project) || @attachment.container.has_attribute?(:project_id)) && @attachment.container.project
project = @attachment.container.project
candown= User.current.member_of?(project) || (project.is_public && @attachment.is_public == 1)
elsif @attachment.container.is_a?(Project)
project = @attachment.container
candown= User.current.member_of?(project) || (project.is_public && @attachment.is_public == 1)
elsif (@attachment.container.has_attribute?(:board) || @attachment.container.has_attribute?(:board_id)) && @attachment.container.board &&
@attachment.container.board.project
project = @attachment.container.board.project
candown = User.current.member_of?(project) || (project.is_public && @attachment.is_public == 1)
elsif (@attachment.container.has_attribute?(:course) ||@attachment.container.has_attribute?(:course_id) ) && @attachment.container.course
course = @attachment.container.course
candown = User.current.member_of_course?(course) || (course.is_public==1 && @attachment.is_public == 1)
elsif @attachment.container.is_a?(Course)
course = @attachment.container
candown= User.current.member_of_course?(course) || (course.is_public==1 && @attachment.is_public == 1)
elsif (@attachment.container.has_attribute?(:board) || @attachment.container.has_attribute?(:board_id)) && @attachment.container.board &&
@attachment.container.board.course
course = @attachment.container.board.course
candown= User.current.member_of_course?(course) || (course.is_public==1 && @attachment.is_public == 1)
elsif @attachment.container.class.to_s=="HomeworkAttach" && @attachment.container.bid.reward_type == 3
candown = true
elsif @attachment.container_type == "Bid" && @attachment.container && @attachment.container.courses.first
course = @attachment.container.courses.first
candown = User.current.member_of_course?(course) || (course.is_public == 1 && @attachment.is_public == 1)
else
candown = @attachment.is_public == 1
end
if candown || User.current.admin? || User.current.id == @attachment.author_id if candown || User.current.admin? || User.current.id == @attachment.author_id
@attachment.increment_download @attachment.increment_download
if stale?(:etag => @attachment.digest) if stale?(:etag => @attachment.digest)
@ -349,6 +320,46 @@ class AttachmentsController < ApplicationController
end end
end end
def add_exist_file_to_projects
file = Attachment.find(params[:file_id])
projects = params[:projects][:project]
@message = ""
projects.each do |project|
c = Project.find(project);
if project_contains_attachment?(c,file)
if @message && @message == ""
@message += l(:label_project_prompt) + c.name + l(:label_contain_resource) + file.filename + l(:label_quote_resource_failed)
next
else
@message += "<br/>" + l(:label_project_prompt) + c.name + l(:label_contain_resource) + file.filename + l(:label_quote_resource_failed)
next
end
end
attach_copied_obj = file.copy
attach_copied_obj.tag_list.add(file.tag_list) # tag关联
attach_copied_obj.container = c
attach_copied_obj.created_on = Time.now
attach_copied_obj.author_id = User.current.id
attach_copied_obj.copy_from = file.copy_from.nil? ? file.id : file.copy_from
if attach_copied_obj.attachtype == nil
attach_copied_obj.attachtype = 4
end
@obj = c
@save_flag = attach_copied_obj.save
@save_message = attach_copied_obj.errors.full_messages
update_quotes attach_copied_obj
end
respond_to do |format|
format.js
end
rescue NoMethodError
@save_flag = false
@save_message = [] << l(:label_course_empty_select)
respond_to do |format|
format.js
end
end
def add_exist_file_to_courses def add_exist_file_to_courses
file = Attachment.find(params[:file_id]) file = Attachment.find(params[:file_id])
courses = params[:courses][:course] courses = params[:courses][:course]

@ -17,6 +17,7 @@
class CommentsController < ApplicationController class CommentsController < ApplicationController
default_search_scope :news default_search_scope :news
include ApplicationHelper
model_object News model_object News
before_filter :find_model_object before_filter :find_model_object
before_filter :find_project_from_association before_filter :find_project_from_association
@ -26,9 +27,11 @@ class CommentsController < ApplicationController
raise Unauthorized unless @news.commentable? raise Unauthorized unless @news.commentable?
@comment = Comment.new @comment = Comment.new
@comment.safe_attributes = params[:comment] @comment.comments = params[:comment]
@comment.author = User.current @comment.author = User.current
if @news.comments << @comment if @news.comments << @comment
ids = params[:asset_id].split(',')
update_kindeditor_assets_owner ids,@comment.id,OwnerTypeHelper::COMMENT
flash[:notice] = l(:label_comment_added) flash[:notice] = l(:label_comment_added)
end end

@ -23,13 +23,14 @@ class FilesController < ApplicationController
before_filter :auth_login1, :only => [:index] before_filter :auth_login1, :only => [:index]
before_filter :logged_user_by_apptoken,:only => [:index] before_filter :logged_user_by_apptoken,:only => [:index]
before_filter :find_project_by_project_id#, :except => [:getattachtype] before_filter :find_project_by_project_id#, :except => [:getattachtype]
before_filter :authorize, :except => [:getattachtype,:quote_resource_show,:search] before_filter :authorize, :except => [:getattachtype,:quote_resource_show,:search,:search_project,:quote_resource_show_project]
helper :sort helper :sort
include SortHelper include SortHelper
include FilesHelper include FilesHelper
helper :project_score helper :project_score
include CoursesHelper include CoursesHelper
include ApplicationHelper
def show_attachments obj def show_attachments obj
@attachments = [] @attachments = []
@ -41,8 +42,8 @@ class FilesController < ApplicationController
@feedback_count = @all_attachments.count @feedback_count = @all_attachments.count
@feedback_pages = Paginator.new @feedback_count, @limit, params['page'] @feedback_pages = Paginator.new @feedback_count, @limit, params['page']
@offset ||= @feedback_pages.offset @offset ||= @feedback_pages.offset
@curse_attachments_all = @all_attachments[@offset, @limit] #@curse_attachments_all = @all_attachments[@offset, @limit]
@curse_attachments = paginateHelper @all_attachments,10 @obj_attachments = paginateHelper @all_attachments,10
end end
def search def search
@ -78,6 +79,39 @@ class FilesController < ApplicationController
end end
end end
def search_project
sort = ""
@sort = ""
@order = ""
@is_remote = true
if params[:sort]
order_by = params[:sort].split(":")
@sort = order_by[0]
if order_by.count > 1
@order = order_by[1]
end
sort = "#{@sort} #{@order}"
end
begin
q = "%#{params[:name].strip}%"
#(redirect_to stores_url, :notice => l(:label_sumbit_empty);return) if params[:name].blank?
if params[:insite]
@result = find_public_attache q,sort
@result = visable_attachemnts_insite @result,@project
@searched_attach = paginateHelper @result,10
else
@result = find_project_attache q,@project,sort
@result = visable_attachemnts @result
@searched_attach = paginateHelper @result,10
end
#rescue Exception => e
# #render 'stores'
# redirect_to search_course_files_url
end
end
def find_course_attache keywords,course,sort = "" def find_course_attache keywords,course,sort = ""
if sort == "" if sort == ""
sort = "created_on DESC" sort = "created_on DESC"
@ -87,6 +121,26 @@ class FilesController < ApplicationController
#resultSet = Attachment.find_by_sql("SELECT `attachments`.* FROM `attachments` LEFT OUTER JOIN `homework_attaches` ON `attachments`.container_type = 'HomeworkAttach' AND `attachments`.container_id = `homework_attaches`.id LEFT OUTER JOIN `homework_for_courses` ON `homework_attaches`.bid_id = `homework_for_courses`.bid_id LEFT OUTER JOIN `homework_for_courses` AS H_C ON `attachments`.container_type = 'Bid' AND `attachments`.container_id = H_C.bid_id WHERE (`homework_for_courses`.course_id = 117 OR H_C.course_id = 117 OR (`attachments`.container_type = 'Course' AND `attachments`.container_id = 117)) AND `attachments`.filename LIKE '%#{keywords}%'").reorder("created_on DESC") #resultSet = Attachment.find_by_sql("SELECT `attachments`.* FROM `attachments` LEFT OUTER JOIN `homework_attaches` ON `attachments`.container_type = 'HomeworkAttach' AND `attachments`.container_id = `homework_attaches`.id LEFT OUTER JOIN `homework_for_courses` ON `homework_attaches`.bid_id = `homework_for_courses`.bid_id LEFT OUTER JOIN `homework_for_courses` AS H_C ON `attachments`.container_type = 'Bid' AND `attachments`.container_id = H_C.bid_id WHERE (`homework_for_courses`.course_id = 117 OR H_C.course_id = 117 OR (`attachments`.container_type = 'Course' AND `attachments`.container_id = 117)) AND `attachments`.filename LIKE '%#{keywords}%'").reorder("created_on DESC")
end end
def find_project_attache keywords,project,sort = ""
if sort == ""
sort = "created_on DESC"
end
ids = ""
len = 0
count = project.versions.count
project.versions.each do |version|
len = len + 1
if len != count
ids += version.id.to_s + ','
else
ids += version.id.to_s
end
end
resultSet = Attachment.where("((attachments.container_type = 'Project' And attachments.container_id = '#{project.id}') OR (container_type = 'Version' AND container_id IN (#{ids}))) AND filename LIKE :like ", like: "%#{keywords}%").
reorder(sort)
#resultSet = Attachment.find_by_sql("SELECT `attachments`.* FROM `attachments` LEFT OUTER JOIN `homework_attaches` ON `attachments`.container_type = 'HomeworkAttach' AND `attachments`.container_id = `homework_attaches`.id LEFT OUTER JOIN `homework_for_courses` ON `homework_attaches`.bid_id = `homework_for_courses`.bid_id LEFT OUTER JOIN `homework_for_courses` AS H_C ON `attachments`.container_type = 'Bid' AND `attachments`.container_id = H_C.bid_id WHERE (`homework_for_courses`.course_id = 117 OR H_C.course_id = 117 OR (`attachments`.container_type = 'Course' AND `attachments`.container_id = 117)) AND `attachments`.filename LIKE '%#{keywords}%'").reorder("created_on DESC")
end
def find_public_attache keywords,sort = "" def find_public_attache keywords,sort = ""
# StoresController#search 将每条文件都查出来,再次进行判断过滤。---> resultSet.to_a.map # StoresController#search 将每条文件都查出来,再次进行判断过滤。---> resultSet.to_a.map
# 此时内容不多速度还可但文件增长每条判断多则进行3-4次表连接。 # 此时内容不多速度还可但文件增长每条判断多则进行3-4次表连接。
@ -132,18 +186,28 @@ class FilesController < ApplicationController
attribute = "downloads" attribute = "downloads"
when "created_on" when "created_on"
attribute = "created_on" attribute = "created_on"
when "quotes"
attribute = "quotes"
else
attribute = "created_on"
end end
@sort = order_by[0]
if order_by.count == 1 @order = order_by[1]
sort += "#{Attachment.table_name}.#{attribute} asc " if attribute if order_by.count == 1 && attribute
elsif order_by.count == 2 sort += "#{Attachment.table_name}.#{attribute} asc "
sort += "#{Attachment.table_name}.#{attribute} #{order_by[1]} " if attribute && order_by[1] if sort_type != params[:sort].split(",").last
sort += ","
end end
elsif order_by.count == 2 && order_by[1]
sort += "#{Attachment.table_name}.#{attribute} #{order_by[1]} "
if sort_type != params[:sort].split(",").last if sort_type != params[:sort].split(",").last
sort += "," sort += ","
end end
end end
end end
else
sort = "#{Attachment.table_name}.created_on desc"
end
@containers = [ Project.includes(:attachments).find(@project.id)] @containers = [ Project.includes(:attachments).find(@project.id)]
@containers += @project.versions.includes(:attachments).all @containers += @project.versions.includes(:attachments).all
@ -184,6 +248,8 @@ class FilesController < ApplicationController
attribute = "created_on" attribute = "created_on"
when "quotes" when "quotes"
attribute = "quotes" attribute = "quotes"
else
attribute = "created_on"
end end
@sort = order_by[0] @sort = order_by[0]
@order = order_by[1] @order = order_by[1]
@ -199,6 +265,8 @@ class FilesController < ApplicationController
end end
end end
end end
else
sort = "#{Attachment.table_name}.created_on desc"
end end
@containers = [ Course.includes(:attachments).reorder(sort).find(@course.id)] @containers = [ Course.includes(:attachments).reorder(sort).find(@course.id)]
@ -215,6 +283,11 @@ class FilesController < ApplicationController
@can_quote = attachment_candown @file @can_quote = attachment_candown @file
end end
def quote_resource_show_project
@file = Attachment.find(params[:id])
@can_quote = attachment_candown @file
end
def new def new
@versions = @project.versions.sort @versions = @project.versions.sort
@course_tag = @project.project_type @course_tag = @project.project_type

@ -64,7 +64,7 @@ class ForumsController < ApplicationController
respond_to do |format| respond_to do |format|
if @memo.save if @memo.save
ids = params[:asset_id].split(',') ids = params[:asset_id].split(',')
update_kindeditor_assets_owner ids ,@memo.id,1 update_kindeditor_assets_owner ids ,@memo.id,OwnerTypeHelper::MEMO
#end #end
format.html { redirect_to (forum_memo_url(@forum, (@memo.parent_id.nil? ? @memo : @memo.parent_id))), notice: "#{l :label_memo_create_succ}" } format.html { redirect_to (forum_memo_url(@forum, (@memo.parent_id.nil? ? @memo : @memo.parent_id))), notice: "#{l :label_memo_create_succ}" }
format.json { render json: @memo, status: :created, location: @memo } format.json { render json: @memo, status: :created, location: @memo }
@ -171,7 +171,7 @@ class ForumsController < ApplicationController
# Description after save后需要进行资源记录的更新 # Description after save后需要进行资源记录的更新
# owner_type = 2 对应的是 forum # owner_type = 2 对应的是 forum
ids = params[:asset_id].split(',') ids = params[:asset_id].split(',')
update_kindeditor_assets_owner ids ,@forum.id,2 update_kindeditor_assets_owner ids ,@forum.id,OwnerTypeHelper::FORUM
#end #end
respond_to do |format| respond_to do |format|

@ -86,6 +86,10 @@ class MessagesController < ApplicationController
if request.post? if request.post?
@message.save_attachments(params[:attachments]) @message.save_attachments(params[:attachments])
if @message.save if @message.save
# 更新kindeditor上传的图片资源所有者
ids = params[:asset_id].split(',')
update_kindeditor_assets_owner ids,@message.id,OwnerTypeHelper::MESSAGE
call_hook(:controller_messages_new_after_save, { :params => params, :message => @message}) call_hook(:controller_messages_new_after_save, { :params => params, :message => @message})
render_attachment_warning_if_needed(@message) render_attachment_warning_if_needed(@message)
redirect_to board_message_url(@board, @message) redirect_to board_message_url(@board, @message)
@ -117,6 +121,8 @@ class MessagesController < ApplicationController
@topic.children << @reply @topic.children << @reply
#@topic.update_attribute(:updated_on, Time.now) #@topic.update_attribute(:updated_on, Time.now)
if !@reply.new_record? if !@reply.new_record?
ids = params[:asset_id].split(',')
update_kindeditor_assets_owner ids,@reply.id,OwnerTypeHelper::MESSAGE
call_hook(:controller_messages_reply_after_save, { :params => params, :message => @reply}) call_hook(:controller_messages_reply_after_save, { :params => params, :message => @reply})
attachments = Attachment.attach_files(@reply, params[:attachments]) attachments = Attachment.attach_files(@reply, params[:attachments])
render_attachment_warning_if_needed(@reply) render_attachment_warning_if_needed(@reply)

@ -17,6 +17,7 @@
class NewsController < ApplicationController class NewsController < ApplicationController
layout 'base_projects'# by young layout 'base_projects'# by young
include ApplicationHelper
before_filter :authorize1, :only => [:show] before_filter :authorize1, :only => [:show]
default_search_scope :news default_search_scope :news
model_object News model_object News
@ -136,6 +137,8 @@ class NewsController < ApplicationController
@news.safe_attributes = params[:news] @news.safe_attributes = params[:news]
@news.save_attachments(params[:attachments]) @news.save_attachments(params[:attachments])
if @news.save if @news.save
ids = params[:asset_id].split(',')
update_kindeditor_assets_owner ids,@news.id,OwnerTypeHelper::NEWS
render_attachment_warning_if_needed(@news) render_attachment_warning_if_needed(@news)
flash[:notice] = l(:notice_successful_create) flash[:notice] = l(:notice_successful_create)
redirect_to course_news_index_url(@course) redirect_to course_news_index_url(@course)

@ -1,7 +1,7 @@
# encoding: utf-8 # encoding: utf-8
#####leave message fq #####leave message fq
class WordsController < ApplicationController class WordsController < ApplicationController
include ApplicationHelper
before_filter :find_user, :only => [:new, :create, :destroy, :more, :back] before_filter :find_user, :only => [:new, :create, :destroy, :more, :back]
def create def create
if params[:new_form][:user_message].size>0 if params[:new_form][:user_message].size>0
@ -209,6 +209,8 @@ class WordsController < ApplicationController
message = params[:new_form][:course_message] message = params[:new_form][:course_message]
feedback = Course.add_new_jour(user, message, params[:id]) feedback = Course.add_new_jour(user, message, params[:id])
if(feedback.errors.empty?) if(feedback.errors.empty?)
ids = params[:asset_id].split(',')
update_kindeditor_assets_owner ids,feedback[:id],OwnerTypeHelper::JOURNALSFORMESSAGE
redirect_to course_feedback_url(params[:id]), notice: l(:label_feedback_success) redirect_to course_feedback_url(params[:id]), notice: l(:label_feedback_success)
else else
flash[:error] = feedback.errors.full_messages[0] flash[:error] = feedback.errors.full_messages[0]

@ -53,6 +53,10 @@ module ApplicationHelper
# Author lizanle # Author lizanle
# Description after save后需要进行资源记录的更新 # Description after save后需要进行资源记录的更新
# owner_type = 1 对应的是 memo # owner_type = 1 对应的是 memo
# owner_type = 2 对应的是forum
# owner_type = 3 对应的是message
# owner_type = 4 对应的是news
# owner_type = 5 对应的是comment
def update_kindeditor_assets_owner ids,owner_id,owner_type def update_kindeditor_assets_owner ids,owner_id,owner_type
ids.each do |id| ids.each do |id|
asset = Kindeditor::Asset.find(id.to_i) asset = Kindeditor::Asset.find(id.to_i)
@ -1676,6 +1680,42 @@ module ApplicationHelper
courses_doing courses_doing
end end
def attachment_candown attachment
candown = false
if attachment.container
if attachment.container.class.to_s != "HomeworkAttach" && (attachment.container.has_attribute?(:project) || attachment.container.has_attribute?(:project_id)) && attachment.container.project
project = attachment.container.project
candown= User.current.member_of?(project) || (project.is_public && attachment.is_public == 1)
elsif attachment.container.is_a?(Project)
project = attachment.container
candown= User.current.member_of?(project) || (project.is_public && attachment.is_public == 1)
elsif (attachment.container.has_attribute?(:board) || attachment.container.has_attribute?(:board_id)) && attachment.container.board &&
attachment.container.board.project
project = attachment.container.board.project
candown = User.current.member_of?(project) || (project.is_public && attachment.is_public == 1)
elsif (attachment.container.has_attribute?(:course) ||attachment.container.has_attribute?(:course_id) ) && attachment.container.course
course = attachment.container.course
candown = User.current.member_of_course?(course) || (course.is_public==1 && attachment.is_public == 1)
elsif attachment.container.is_a?(Course)
course = attachment.container
candown= User.current.member_of_course?(course) || (course.is_public==1 && attachment.is_public == 1)
elsif (attachment.container.has_attribute?(:board) || attachment.container.has_attribute?(:board_id)) && attachment.container.board &&
attachment.container.board.course
course = attachment.container.board.course
candown= User.current.member_of_course?(course) || (course.is_public==1 && attachment.is_public == 1)
elsif attachment.container.class.to_s=="HomeworkAttach" && attachment.container.bid.reward_type == 3
candown = true
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)
else
candown = (attachment.is_public == 1 || attachment.is_public == true)
end
end
candown
end
private private
def wiki_helper def wiki_helper

@ -77,6 +77,7 @@ module AttachmentsHelper
end end
end end
#判断课程course中是否包含课件attachmentcourse中引用了attachment也算作包含
def course_contains_attachment? course,attachment def course_contains_attachment? course,attachment
course.attachments.each do |att| course.attachments.each do |att|
if att.id == attachment.id || (!att.copy_from.nil? && !attachment.copy_from.nil? && att.copy_from == attachment.copy_from) || att.copy_from == attachment.id || att.id == attachment.copy_from if att.id == attachment.id || (!att.copy_from.nil? && !attachment.copy_from.nil? && att.copy_from == attachment.copy_from) || att.copy_from == attachment.id || att.id == attachment.copy_from
@ -85,6 +86,15 @@ module AttachmentsHelper
end end
false false
end end
#判断项目project中是否包含课件attachmentproject中引用了attachment也算作包含
def project_contains_attachment? project,attachment
project.attachments.each do |att|
if att.id == attachment.id || (!att.copy_from.nil? && !attachment.copy_from.nil? && att.copy_from == attachment.copy_from) || att.copy_from == attachment.id || att.id == attachment.copy_from
return true
end
end
false
end
def get_qute_number attachment def get_qute_number attachment
if attachment.copy_from if attachment.copy_from

@ -45,6 +45,7 @@ module FilesHelper
File.new(zipfile_name,'w+') File.new(zipfile_name,'w+')
end end
#带勾选框的课程列表
def courses_check_box_tags(name,courses,current_course,attachment) def courses_check_box_tags(name,courses,current_course,attachment)
s = '' s = ''
courses.each do |course| courses.each do |course|
@ -55,6 +56,17 @@ module FilesHelper
s.html_safe s.html_safe
end end
#带勾选框的项目列表
def projects_check_box_tags(name,projects,current_project,attachment)
s = ''
projects.each do |project|
if !project_contains_attachment?(project,attachment) && User.current.allowed_to?(:manage_files, project)
s << "<label>#{ check_box_tag name, project.id, false, :id => nil } #{h project.name}</label>"
end
end
s.html_safe
end
#判断用户是否拥有不包含当前资源的课程,需用户在该课程中角色为教师且该课程属于当前学期或下一学期 #判断用户是否拥有不包含当前资源的课程,需用户在该课程中角色为教师且该课程属于当前学期或下一学期
def has_course? user,file def has_course? user,file
result = false result = false
@ -66,6 +78,17 @@ module FilesHelper
result result
end end
#判断用户是否拥有不包含当前资源的项目,需用户在该项目中有资源管理相关资源
def has_project? user,file
result = false
user.projects.each do |project|
if !project_contains_attachment?(project,file) && User.current.allowed_to?(:manage_files, project)
return true
end
end
result
end
# 判断指定的资源时候符合类型 # 判断指定的资源时候符合类型
def isTypeOk(attachment, type, contentType) def isTypeOk(attachment, type, contentType)
result = false result = false
@ -97,49 +120,23 @@ module FilesHelper
result result
end end
def visable_attachemnts_insite attachments,course def visable_attachemnts_insite attachments,obj
result = [] result = []
if obj.is_a?(Course)
attachments.each do |attachment| attachments.each do |attachment|
if attachment.is_public? || (attachment.container_type == "Course" && attachment.container_id == course.id && User.current.member_of_course?(Course.find(attachment.container_id)))|| attachment.author_id == User.current.id if attachment.is_public? || (attachment.container_type == "Course" && attachment.container_id == obj.id && User.current.member_of_course?(Course.find(attachment.container_id)))|| attachment.author_id == User.current.id
result << attachment result << attachment
end end
end end
result else if obj.is_a?(Project)
attachments.each do |attachment|
if attachment.is_public? || (attachment.container_type == "Project" && attachment.container_id == obj.id && User.current.member_of_course?(Project.find(attachment.container_id)))|| attachment.author_id == User.current.id
result << attachment
end end
def attachment_candown attachment
candown = false
if attachment.container
if attachment.container.class.to_s != "HomeworkAttach" && (attachment.container.has_attribute?(:project) || attachment.container.has_attribute?(:project_id)) && attachment.container.project
project = attachment.container.project
candown= User.current.member_of?(project) || (project.is_public && attachment.is_public == 1)
elsif attachment.container.is_a?(Project)
project = attachment.container
candown= User.current.member_of?(project) || (project.is_public && attachment.is_public == 1)
elsif (attachment.container.has_attribute?(:board) || attachment.container.has_attribute?(:board_id)) && attachment.container.board &&
attachment.container.board.project
project = attachment.container.board.project
candown = User.current.member_of?(project) || (project.is_public && attachment.is_public == 1)
elsif (attachment.container.has_attribute?(:course) ||attachment.container.has_attribute?(:course_id) ) && attachment.container.course
course = attachment.container.course
candown = User.current.member_of_course?(course) || (course.is_public==1 && attachment.is_public == 1)
elsif attachment.container.is_a?(Course)
course = attachment.container
candown= User.current.member_of_course?(course) || (course.is_public==1 && attachment.is_public == 1)
elsif (attachment.container.has_attribute?(:board) || attachment.container.has_attribute?(:board_id)) && attachment.container.board &&
attachment.container.board.course
course = attachment.container.board.course
candown= User.current.member_of_course?(course) || (course.is_public==1 && attachment.is_public == 1)
elsif attachment.container.class.to_s=="HomeworkAttach" && attachment.container.bid.reward_type == 3
candown = true
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)
else
candown = (attachment.is_public == 1 || attachment.is_public == true)
end end
end end
candown end
result
end end

@ -17,7 +17,8 @@ class Bid < ActiveRecord::Base
HomeworkProject = 2 HomeworkProject = 2
attr_accessible :author_id, :budget, :deadline, :name, :description, :homework_type, :password attr_accessible :author_id, :budget, :deadline, :name, :description, :homework_type, :password
include Redmine::SafeAttributes include Redmine::SafeAttributes
include ApplicationHelper
has_many_kindeditor_assets :assets, :dependent => :destroy
belongs_to :author, :class_name => 'User', :foreign_key => :author_id belongs_to :author, :class_name => 'User', :foreign_key => :author_id
belongs_to :course belongs_to :course
has_many :biding_projects, :dependent => :destroy has_many :biding_projects, :dependent => :destroy
@ -47,7 +48,7 @@ class Bid < ActiveRecord::Base
validate :validate_user validate :validate_user
validate :validate_reward_type validate :validate_reward_type
after_create :act_as_activity after_create :act_as_activity
after_destroy :delete_kindeditor_assets
scope :visible, lambda {|*args| scope :visible, lambda {|*args|
nil nil
} }
@ -157,5 +158,10 @@ class Bid < ActiveRecord::Base
end end
end end
# Time 2015-04-01 14:19:06
# Author lizanle
# Description 删除对应课程通知的图片资源
def delete_kindeditor_assets
delete_kindeditor_assets_from_disk self.id,OwnerTypeHelper::BID
end
end end

@ -17,8 +17,18 @@
class Comment < ActiveRecord::Base class Comment < ActiveRecord::Base
include Redmine::SafeAttributes include Redmine::SafeAttributes
include ApplicationHelper
has_many_kindeditor_assets :assets, :dependent => :destroy
belongs_to :commented, :polymorphic => true, :counter_cache => true belongs_to :commented, :polymorphic => true, :counter_cache => true
belongs_to :author, :class_name => 'User', :foreign_key => 'author_id' belongs_to :author, :class_name => 'User', :foreign_key => 'author_id'
validates_presence_of :commented, :author, :comments validates_presence_of :commented, :author, :comments
safe_attributes 'comments' safe_attributes 'comments'
after_destroy :delete_kindeditor_assets
# Time 2015-03-31 09:15:06
# Author lizanle
# Description 删除对应评论的图片资源
def delete_kindeditor_assets
delete_kindeditor_assets_from_disk self.id,OwnerTypeHelper::COMMENT
end
end end

@ -53,7 +53,7 @@ class Forum < ActiveRecord::Base
# Author lizanle # Author lizanle
# Description 删除论坛后删除对应的资源 # Description 删除论坛后删除对应的资源
def delete_kindeditor_assets def delete_kindeditor_assets
delete_kindeditor_assets_from_disk self.id,2 delete_kindeditor_assets_from_disk self.id,OwnerTypeHelper::FORUM
end end
end end

@ -4,6 +4,8 @@
class JournalsForMessage < ActiveRecord::Base class JournalsForMessage < ActiveRecord::Base
include Redmine::SafeAttributes include Redmine::SafeAttributes
include UserScoreHelper include UserScoreHelper
include ApplicationHelper
has_many_kindeditor_assets :assets, :dependent => :destroy
safe_attributes "jour_type", # 留言所属类型 safe_attributes "jour_type", # 留言所属类型
"jour_id", # 留言所属类型的id "jour_id", # 留言所属类型的id
"notes", # 留言内容 "notes", # 留言内容
@ -16,7 +18,7 @@ class JournalsForMessage < ActiveRecord::Base
"m_reply_id" # 回复某留言的留言id(a留言回复了b留言这是b留言的id) "m_reply_id" # 回复某留言的留言id(a留言回复了b留言这是b留言的id)
"is_comprehensive_evaluation" # 1 教师评论、2 匿评、3 留言 "is_comprehensive_evaluation" # 1 教师评论、2 匿评、3 留言
acts_as_tree :foreign_key => 'm_parent_id', :counter_cache => :m_reply_count, :order => "#{JournalsForMessage.table_name}.created_on ASC" acts_as_tree :foreign_key => 'm_parent_id', :counter_cache => :m_reply_count, :order => "#{JournalsForMessage.table_name}.created_on ASC"
after_destroy :delete_kindeditor_assets
belongs_to :project, belongs_to :project,
:foreign_key => 'jour_id', :foreign_key => 'jour_id',
:conditions => "#{self.table_name}.jour_type = 'Project' " :conditions => "#{self.table_name}.jour_type = 'Project' "
@ -163,5 +165,10 @@ class JournalsForMessage < ActiveRecord::Base
end end
end end
# Time 2015-04-01 14:15:06
# Author lizanle
# Description 删除对应课程留言的图片资源
def delete_kindeditor_assets
delete_kindeditor_assets_from_disk self.id,7
end
end end

@ -176,6 +176,6 @@ class Memo < ActiveRecord::Base
# Author lizanle # Author lizanle
# Description 从硬盘上删除资源 # Description 从硬盘上删除资源
def delete_kindeditor_assets def delete_kindeditor_assets
delete_kindeditor_assets_from_disk self.id,1 delete_kindeditor_assets_from_disk self.id,OwnerTypeHelper::MEMO
end end
end end

@ -18,6 +18,8 @@
class Message < ActiveRecord::Base class Message < ActiveRecord::Base
include Redmine::SafeAttributes include Redmine::SafeAttributes
include UserScoreHelper include UserScoreHelper
include ApplicationHelper
has_many_kindeditor_assets :assets, :dependent => :destroy
belongs_to :board belongs_to :board
belongs_to :author, :class_name => 'User', :foreign_key => 'author_id' belongs_to :author, :class_name => 'User', :foreign_key => 'author_id'
has_many :praise_tread, as: :praise_tread_object, dependent: :destroy has_many :praise_tread, as: :praise_tread_object, dependent: :destroy
@ -62,7 +64,7 @@ class Message < ActiveRecord::Base
after_create :add_author_as_watcher, :reset_counters! after_create :add_author_as_watcher, :reset_counters!
after_update :update_messages_board after_update :update_messages_board
after_destroy :reset_counters!,:down_user_score after_destroy :reset_counters!,:down_user_score,:delete_kindeditor_assets
# fq # fq
after_create :act_as_activity,:be_user_score,:act_as_forge_activity after_create :act_as_activity,:be_user_score,:act_as_forge_activity
@ -208,5 +210,10 @@ class Message < ActiveRecord::Base
end end
end end
# Time 2015-03-31 09:15:06
# Author lizanle
# Description 删除对应消息的图片资源
def delete_kindeditor_assets
delete_kindeditor_assets_from_disk self.id,OwnerTypeHelper::MESSAGE
end
end end

@ -18,6 +18,8 @@
class News < ActiveRecord::Base class News < ActiveRecord::Base
include Redmine::SafeAttributes include Redmine::SafeAttributes
belongs_to :project belongs_to :project
include ApplicationHelper
has_many_kindeditor_assets :assets, :dependent => :destroy
#added by nwb #added by nwb
belongs_to :course belongs_to :course
belongs_to :author, :class_name => 'User', :foreign_key => 'author_id' belongs_to :author, :class_name => 'User', :foreign_key => 'author_id'
@ -49,6 +51,7 @@ class News < ActiveRecord::Base
# fq # fq
after_create :act_as_activity,:act_as_forge_activity after_create :act_as_activity,:act_as_forge_activity
# end # end
after_destroy :delete_kindeditor_assets
scope :visible, lambda {|*args| scope :visible, lambda {|*args|
includes(:project).where(Project.allowed_to_condition(args.shift || User.current, :view_news, *args)) includes(:project).where(Project.allowed_to_condition(args.shift || User.current, :view_news, *args))
@ -105,4 +108,11 @@ class News < ActiveRecord::Base
end end
end end
# Time 2015-03-31 13:50:54
# Author lizanle
# Description 删除news后删除对应的资源
def delete_kindeditor_assets
delete_kindeditor_assets_from_disk self.id,OwnerTypeHelper::NEWS
end
end end

@ -20,7 +20,7 @@ class HomeworkService
many_times = course.homeworks.index(@bid) + 1 many_times = course.homeworks.index(@bid) + 1
name = @bid.name name = @bid.name
homework_count = @bid.homeworks.count #已提交的作业数量 homework_count = @bid.homeworks.count #已提交的作业数量
student_questions_count = @bid.commit.nil? ? 0 : @bid.commit student_questions_count = @bid.journals_for_messages.where('m_parent_id IS NULL').count
description = @bid.description description = @bid.description
#if is_course_teacher(User.current, course) && @bid.open_anonymous_evaluation == 1 && @bid.homeworks.count >= 2 #if is_course_teacher(User.current, course) && @bid.open_anonymous_evaluation == 1 && @bid.homeworks.count >= 2
state = @bid.comment_status state = @bid.comment_status
@ -282,7 +282,7 @@ class HomeworkService
many_times = course.homeworks.index(@bid) + 1 many_times = course.homeworks.index(@bid) + 1
name = @bid.name name = @bid.name
homework_count = @bid.homeworks.count #已提交的作业数量 homework_count = @bid.homeworks.count #已提交的作业数量
student_questions_count = @bid.commit.nil? ? 0 : @bid.commit student_questions_count = @bid.journals_for_messages.where('m_parent_id IS NULL').count
description = @bid.description description = @bid.description
#if is_course_teacher(User.current, course) && @bid.open_anonymous_evaluation == 1 && @bid.homeworks.count >= 2 #if is_course_teacher(User.current, course) && @bid.open_anonymous_evaluation == 1 && @bid.homeworks.count >= 2
state = @bid.comment_status state = @bid.comment_status

@ -0,0 +1,7 @@
<% if !@save_flag && @save_message %>
$("#error_show").html("<%= @save_message.join(', ') %>");
<% elsif @message && @message != "" %>
$("#error_show").html("<%= @message.html_safe %>");
<% else %>
closeModal();
<% end %>

@ -13,7 +13,13 @@
</li> </li>
<li class="ml45"> <li class="ml45">
<label class="fl" >&nbsp;&nbsp;<%= l(:field_quote)%>&nbsp;&nbsp;</label> <label class="fl" >&nbsp;&nbsp;<%= l(:field_quote)%>&nbsp;&nbsp;</label>
<textarea name="bid[description]" placeholder="最多3000个汉字(或6000个英文字符)" class="hwork_text fl"><%= bid.description%></textarea> <!--<textarea name="bid[description]" placeholder="最多3000个汉字(或6000个英文字符)" class="hwork_text fl"></textarea>-->
<% if edit_mode %>
<%= f.kindeditor :description,:width=>'91%',:editor_id => 'bid_description_editor',:owner_id => bid.id,:owner_type =>OwnerTypeHelper::BID %>
<% else %>
<%= hidden_field_tag :asset_id,params[:asset_id],:required => false,:style => 'display:none' %>
<%= f.kindeditor :description,:width=>'91%',:editor_id => 'bid_description_editor' %>
<% end %>
</li> </li>
<div class="cl"></div> <div class="cl"></div>
<li class="ml21"> <li class="ml21">

@ -1,3 +1,4 @@
<%= javascript_include_tag "/assets/kindeditor/kindeditor" %>
<%= labelled_form_for @bid do |f| %> <%= labelled_form_for @bid do |f| %>
<%= render :partial => 'new_homework_form', :locals => { :bid => @bid, :bid_id => "edit_bid_#{@bid.id}"} %> <%= render :partial => 'new_homework_form', :locals => { :bid => @bid, :bid_id => "edit_bid_#{@bid.id}",:f=>f,:edit_mode => true} %>
<% end %> <% end %>

@ -1,3 +1,4 @@
<% if @project %> <% if @project %>
<%= render :partial => 'project_show', locals: {project: @project} %> <%= render :partial => 'project_show', locals: {project: @project} %>
<% elsif @course %> <% elsif @course %>

@ -1,4 +1,4 @@
<%= javascript_include_tag "/assets/kindeditor/kindeditor" %>
<div class="msg_box" id='leave-message'> <div class="msg_box" id='leave-message'>
<%# reply_allow = JournalsForMessage.create_by_user? User.current %> <%# reply_allow = JournalsForMessage.create_by_user? User.current %>
<h4><%= l(:label_leave_message) %></h4> <h4><%= l(:label_leave_message) %></h4>
@ -11,11 +11,12 @@
</div> </div>
<% else %> <% else %>
<%= form_for('new_form', :method => :post, <%= form_for('new_form', :method => :post,
:url => {:controller => 'words', :action => 'leave_course_message'}) do |f|%> :url => {:controller => 'words', :action => 'leave_course_message'},:html => {:id=>'leave_message_form'}) do |f|%>
<%= f.text_area 'course_message',:id => "leave_meassge",:style => "resize: none;", <%= hidden_field_tag :asset_id,params[:asset_id],:required => false,:style => 'display:none' %>
:placeholder => "#{l(:label_welcome_my_respond)}",:maxlength => 250%> <%= f.kindeditor 'course_message',:editor_id => 'leave_message_editor',:input_html=>{:id => "leave_meassge",:style => "resize: none;",
:placeholder => "#{l(:label_welcome_my_respond)}",:maxlength => 250}%>
<a href="#" class="grey_btn fr ml10">取&nbsp;&nbsp;消</a> <a href="#" class="grey_btn fr ml10">取&nbsp;&nbsp;消</a>
<a href="#" onclick='$("#leave_meassge").parent().submit();' class="blue_btn fr"> <%= l(:button_leave_meassge)%></a> <a href="#" onclick='leave_message_editor.sync();$("#leave_message_form").submit();' class="blue_btn fr"> <%= l(:button_leave_meassge)%></a>
<% end %> <% end %>
<% end %> <% end %>
</div> </div>

@ -32,7 +32,7 @@
</script> </script>
<div id="bid_description_<%= bid.id%>" class="news_description mt5"> <div id="bid_description_<%= bid.id%>" class="news_description mt5">
<div id="bid_description_<%= bid.id%>_content"> <div id="bid_description_<%= bid.id%>_content">
<%= textilizable bid, :description %> <%= textAreailizable bid, :description %>
</div> </div>
</div> </div>
<div class="news_foot c_red" id="bid_show_more_des_button<%= bid.id%>" onclick="bid_show_more_des(<%= bid.id%>);" style="cursor:pointer;display: none;"> <div class="news_foot c_red" id="bid_show_more_des_button<%= bid.id%>" onclick="bid_show_more_des(<%= bid.id%>);" style="cursor:pointer;display: none;">

@ -1,3 +1,4 @@
<%= javascript_include_tag "/assets/kindeditor/kindeditor" %>
<%= labelled_form_for @homework, :url => {:controller => 'bids', :action => 'create_homework',:course_id => "#{params[:id] || params[:course_id]}"} do |f| %> <%= labelled_form_for @homework, :url => {:controller => 'bids', :action => 'create_homework',:course_id => "#{params[:id] || params[:course_id]}"} do |f| %>
<%= render :partial => 'bids/new_homework_form', :locals => { :bid => @homework,:bid_id => "new_bid" } %> <%= render :partial => 'bids/new_homework_form', :locals => { :bid => @homework,:bid_id => "new_bid",:f => f,:edit_mode => false } %>
<% end %> <% end %>

@ -55,7 +55,7 @@
<div class="cl"></div> <div class="cl"></div>
<div class="re_con" id="course_list"> <div class="re_con" id="course_list">
<%= render :partial => 'course_list',:locals => {course: @course,all_attachments: @all_attachments,sort:@sort,order:@order,curse_attachments:@curse_attachments} %> <%= render :partial => 'course_list',:locals => {course: @course,all_attachments: @all_attachments,sort:@sort,order:@order,curse_attachments:@obj_attachments} %>
</div><!---re_con end--> </div><!---re_con end-->
</div> </div>

@ -0,0 +1,58 @@
<div class="re_con_top">
<p class="f_l c_blue f_b f_14">共有&nbsp;<%= all_attachments.count%>&nbsp;个资源</p>
<p class="f_r" style="color: #808080">
<% if order == "asc" %>
按&nbsp;<%= link_to "时间",params.merge(:sort=>"created_on:desc"),:class => "f_b c_grey",:remote => @is_remote %><%= render partial: 'arrow_show',locals: { sort: sort,order:order,current:"created_on"} %>&nbsp;/&nbsp;
<%= link_to "下载次数",params.merge(:sort=>"downloads:desc"),:class => "f_b c_grey",:remote => @is_remote %><%= render partial: 'arrow_show',locals: { sort: sort,order:order,current:"downloads"} %>&nbsp;/&nbsp;
<%= link_to "引用次数",params.merge(:sort=>"quotes:desc"),:class => "f_b c_grey",:remote => @is_remote %><%= render partial: 'arrow_show',locals: { sort: sort,order:order,current:"quotes"} %>&nbsp;排序
<% else %>
按&nbsp;<%= link_to "时间",params.merge(:sort=>"created_on:asc"),:class => "f_b c_grey" ,:remote => @is_remote %><%= render partial: 'arrow_show',locals: { sort: sort,order:order,current:"created_on"} %>&nbsp;/&nbsp;
<%= link_to "下载次数",params.merge(:sort=>"downloads:asc"),:class => "f_b c_grey",:remote => @is_remote %><%= render partial: 'arrow_show',locals: { sort: sort,order:order,current:"downloads"} %>&nbsp; /&nbsp;
<%= link_to "引用次数",params.merge(:sort=>"quotes:asc"),:class => "f_b c_grey",:remote => @is_remote %><%= render partial: 'arrow_show',locals: { sort: sort,order:order,current:"quotes"} %>&nbsp;排序
<% end %>
</p>
</div>
<div class="cl"></div>
<div class="for_img_thumbnails">
<% project_attachments.each do |file| %>
<div class="re_con_box">
<div class="">
<%= link_to_attachment file, :download => true,:text => truncate(file.filename,length: 35, omission: '...'), :title => file.filename+"\n"+file.description.to_s, :style => "overflow: hidden; white-space: nowrap;text-overflow: ellipsis;",:class => "c_dblue f_14 f_b f_l" %>
<% if User.current.logged? %>
<% if (manage_allowed || file.author_id == User.current.id) && project_contains_attachment?(project,file) %>
<%= link_to(l(:label_slected_to_other_project),quote_resource_show_project_project_file_path(project,file),:class => "f_l re_select",:remote => true) if has_project?(User.current,file) %>
<% if manage_allowed && file.container_id == project.id && file.container_type == "Project" %>
<span id="is_public_<%= file.id %>">
<%= link_to (file.is_public? ? "公开":"私有"), update_file_dense_attachments_path(:attachmentid=>file.id,:newtype=>(file.is_public? ? 0:1)),:remote=>true,:class=>"f_l re_open",:method => :post %>
</span>
<% else %>
<!-- <#%= link_to (file.is_public? ? "公开":"私有"),"javascript:void(0)",:class=>"f_l re_open" %> -->
<% end %>
<% else %>
<%= link_to(l(:label_slected_to_project),quote_resource_show_project_project_file_path(project,file),:class => "f_l re_select",:remote => true) if has_project?(User.current,file) %>
<% end %>
<% else %>
<% end %>
</div>
<div class="cl"></div>
<div class="">
<p class="f_l c_grey02 font">文件大小:<%= number_to_human_size(file.filesize) %></p>
<%= link_to( l(:button_delete), attachment_path(file),
:data => {:confirm => l(:text_are_you_sure)}, :method => :delete,:class => "f_r re_de") if manage_allowed && file.container_id == project.id && file.container_type == "Project"%>
<p class="f_r c_grey02" ><%= time_tag(file.created_on).html_safe %><%= l(:label_bids_published_ago) %>&nbsp;&nbsp;|&nbsp;&nbsp;下载<%= file.downloads %>&nbsp;&nbsp;|&nbsp;&nbsp;引用<%= file.quotes.nil? ? 0:file.quotes %> </p>
</div>
<div class="cl"></div>
<div class="tag_h">
<%= render :partial => 'tags/tag_new', :locals => {:obj => file, :object_flag => "10"} %>
<%= render :partial => 'tags/tag_add', :locals => {:obj => file, :object_flag => "10"} %>
</div>
<div class="cl"></div>
</div><!---re_con_box end-->
<% end %>
</div>
<ul class="wlist">
<%= pagination_links_full @obj_pages, @obj_count, :per_page_links => false, :remote => @is_remote, :flag => true%>
</ul>
<div class="cl"></div>

@ -0,0 +1,65 @@
<div class="project_r_h">
<h2 class="project_h2"><%= l(:lable_file_sharingarea) %></h2>
</div>
<!--<%#= stylesheet_link_tag 'resource', :media => 'all' %> -->
<script>
function show_upload()
{
$('#ajax-modal').html('<%= escape_javascript(render :partial => 'upload_show_project',:locals => {:project => project}) %>');
showModal('ajax-modal', '513px');
$('#ajax-modal').siblings().remove();
$('#ajax-modal').before("<span style='float: right;cursor:pointer;padding-left: 513px;'><a href='javascript:void(0)' onclick='closeModal()'><img src='/images/bid/close.png' width='26px' height='26px' /></a></span>")
$('#ajax-modal').parent().css("top","").css("left","");
$('#ajax-modal').parent().addClass("popbox_polls");
}
function closeModal()
{
hideModal($("#popbox_upload"));
}
function presscss(id)
{
if(id == "incourse")
{
$('#incourse').attr("class", "re_schbtn b_dblue");
$('#insite').attr("class", "re_schbtn b_lblue");
}
else
{
$('#incourse').attr("class", "re_schbtn b_lblue");
$('#insite').attr("class", "re_schbtn b_dblue");
}
}
function buttoncss()
{
$('#incourse').attr("class", "re_schbtn b_lblue");
$('#insite').attr("class", "re_schbtn b_lblue");
}
</script>
<div class="container">
<div class="resource"><!--资源库内容开始--->
<div class="re_top">
<%= form_tag( search_project_project_files_path(@project), method: 'get',:class => "re_search f_l",:remote=>true) do %>
<%= text_field_tag 'name', params[:name], name: "name", :class => 're_schbox',:style=>"padding: 0px"%>
<%= submit_tag "课内搜索", :class => "re_schbtn b_lblue",:name => "incourse",:id => "incourse", :onmouseover => "presscss('incourse')",:onmouseout =>"buttoncss()" %>
<%= submit_tag "全站搜索", :class => "re_schbtn b_lblue",:name => "insite",:id => "insite",:onmouseover => "presscss('insite')",:onmouseout =>"buttoncss()" %>
<% end %>
<% manage_allowed = User.current.allowed_to?(:manage_files, @project) %>
<% if manage_allowed %> <!-- show_window('light','fade','20%','35%')-->
<a href="javascript:void(0)" class="re_fabu f_r b_lblue" onclick="show_upload();">上传资源</a>
<% end %>
</div><!---re_top end-->
<div class="cl"></div>
<div class="re_con" id="course_list">
<%= render :partial => 'project_file_list',:locals => {project: @project,all_attachments: @all_attachments,sort:@sort,order:@order,project_attachments:@obj_attachments,:manage_allowed => manage_allowed} %>
</div><!---re_con end-->
</div>
</div>
<% html_title(l(:label_attachment_plural)) -%>

@ -24,8 +24,8 @@
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<% if @curse_attachments != nil %> <% if @obj_attachments != nil %>
<% @curse_attachments.each do |file| %> <% @obj_attachments.each do |file| %>
<%if file.is_public == 0 && !User.current.member_of?(@project)%> <%if file.is_public == 0 && !User.current.member_of?(@project)%>
<%next%> <%next%>
<%end%> <%end%>

@ -0,0 +1,31 @@
<div id="popbox_upload" style="margin-top: -30px;margin-left: -20px;margin-right: -10px;">
<div class="upload_con">
<h2>将此课件引入我的资源库</h2>
<% if error == '403' %>
<div class="upload_box">
<div style="color: red;">您没有权限引用此资源</div>
</div>
<% else %>
<div class="upload_box">
<div id="error_show" style="color: red;"></div>
<%= form_tag attach_relations_path,
method: :post,
remote: true,
id: "relation_file_form" do %>
<%= hidden_field_tag(:file_id, file.id) %>
<%= content_tag('div', projects_check_box_tags('projects[project][]', User.current.projects,project,file), :id => 'projects')%>
<a id="submit_quote" href="javascript:void(0)" class="blue_btn fl c_white" onclick="submit_quote();">引&nbsp;&nbsp;用</a><a href="javascript:void(0)" class="blue_btn grey_btn fl c_white" onclick="closeModal();">取&nbsp;&nbsp;消</a>
<% end -%>
</div>
<% end %>
</div>
</div>
<script>
function submit_quote()
{
$('#submit_quote').parent().submit();
}
</script>

@ -0,0 +1,29 @@
<div id="popbox_upload" class="box_h3 mb10" style="margin-top: -30px">
<div class="upload_con">
<h2><%= l(:label_upload_files)%></h2>
<div class="upload_box">
<%= error_messages_for 'attachment' %>
<div id="network_issue" style="color: red; display: none;"><%= l(:label_file_upload_error_messages)%></div>
<%= form_tag(project_files_path(project), :multipart => true,:remote => !ie8?,:name=>"upload_form") do %>
<!-- <label style="margin-top:3px;"><#%= l(:label_file_upload)%></label> -->
<%= render :partial => 'attachement_list',:locals => {:project => project} %>
<div class="cl"></div>
<a href="javascript:void(0);" class=" fr grey_btn mr40" onclick="closeModal();"><%= l(:button_cancel)%></a>
<a id="submit_resource" href="javascript:void(0);" class="blue_btn fr" onclick="submit_resource();"><%= l(:button_confirm)%></a>
<% end %>
</div>
</div>
<% content_for :header_tags do %>
<%= javascript_include_tag 'attachments' %>
<% end %>
</div>
<script>
function submit_resource()
{
$('#submit_resource').parent().submit();
}
</script>

@ -1,35 +1,33 @@
<%if @addTag%> <% if @addTag%>
<% if @obj_flag == '3'%> <% if @obj_flag == '3'%>
$('#tags_show_issue').html('<%= escape_javascript(render :partial => 'tags/tag_name',
$('#tags_show_issue').html('<%= escape_javascript(render :partial => 'tags/tag_name',
:locals => {:obj => @obj,:non_list_all => false,:object_flag => @obj_flag}) %>'); :locals => {:obj => @obj,:non_list_all => false,:object_flag => @obj_flag}) %>');
//$('#put-tag-form-issue').hide(); //$('#put-tag-form-issue').hide();
$('#name-issue').val(""); $('#name-issue').val("");
<% elsif @obj_flag == '6'%> <% elsif @obj_flag == '6'%>
$("#tags_show-<%=@obj.class%>-<%=@obj.id%>").empty(); $("#tags_show-<%=@obj.class%>-<%=@obj.id%>").empty();
$("#tags_show-<%=@obj.class%>-<%=@obj.id%>").html('<%= escape_javascript(render :partial => 'tags/tag_name', $("#tags_show-<%=@obj.class%>-<%=@obj.id%>").html('<%= escape_javascript(render :partial => 'tags/tag_name',
:locals => {:obj => @obj,:non_list_all => false,:object_flag => @obj_flag}) %>'); :locals => {:obj => @obj,:non_list_all => false,:object_flag => @obj_flag}) %>');
$("#put-tag-form- <%=@obj.class%>- <%=@obj.id%>").hide(); $("#put-tag-form- <%=@obj.class%>- <%=@obj.id%>").hide();
$("#put-tag-form-<%=@obj.class%>-<%=@obj.id%> #name").val(""); $("#put-tag-form-<%=@obj.class%>-<%=@obj.id%> #name").val("");
<% else %> <% else %>
$('#tags_show').html('<%= escape_javascript(render :partial => 'tags/tag_name',
$('#tags_show').html('<%= escape_javascript(render :partial => 'tags/tag_name',
:locals => {:obj => @obj,:non_list_all => false,:object_flag => @obj_flag}) %>'); :locals => {:obj => @obj,:non_list_all => false,:object_flag => @obj_flag}) %>');
$('#tags_show').html('<%=render_attachments_tag_save(@project, nil)%>'); $('#tags_show').html('<%=render_attachments_tag_save(@project, nil)%>');
$('#put-tag-form #name').val(""); $('#put-tag-form #name').val("");
//$('#put-tag-form').hide(); //$('#put-tag-form').hide();
<% end %> <% end %>
<%else%> <% else %>
$("#attachments_fields").children().remove(); $("#attachments_fields").children().remove();
$("#upload_file_count").text("未上传文件"); $("#upload_file_count").text("未上传文件");
$('#upload_file_div').slideToggle('slow'); $('#upload_file_div').slideToggle('slow');
<%if @project%> <% if @project%>
$("#all_browse_div").html('<%= j(render partial: "show_all_attachment")%>'); closeModal();
<%elsif @course%> $("#resource_list").html('<%= j(render partial: "project_file_new" ,locals: {project: @project}) %>');
$("#all_browse_div").html('<%= j(render partial: "course_show_all_attachment")%>'); <%elsif @course%>
closeModal(); closeModal();
$("#resource_list").html('<%= j(render partial: "course_file" ,locals: {course: @course}) %>'); $("#resource_list").html('<%= j(render partial: "course_file" ,locals: {course: @course}) %>');
<%end%> <% end %>
<% end %> <% end %>
$(document).ready(img_thumbnails); $(document).ready(img_thumbnails);

@ -0,0 +1,11 @@
<% if @can_quote %>
$('#ajax-modal').html('<%= escape_javascript(render :partial => 'show_quote_resource_project',:locals => {:project => @project,:file => @file,:error => ''}) %>');
<% else %>
$('#ajax-modal').html('<%= escape_javascript(render :partial => 'show_quote_resource_project',:locals => {:project => @project,:file => @file,:error => '403'}) %>');
<% end %>
showModal('ajax-modal', '513px');
$('#ajax-modal').siblings().remove();
$('#ajax-modal').before("<span style='float: right;cursor:pointer;padding-left: 513px;'><a href='javascript:void(0)' onclick='closeModal()'><img src='/images/bid/close.png' width='26px' height='26px' /></a></span>");
$('#ajax-modal').parent().css("top","").css("left","");
$('#ajax-modal').parent().addClass("popbox_polls");

@ -0,0 +1 @@
$("#course_list").html("<%= escape_javascript(render :partial => 'project_file_list',:locals => {project: @project,all_attachments: @result,sort:@sort,order:@order,project_attachments:@searched_attach,:manage_allowed => User.current.allowed_to?(:manage_files, @project)})%>");

@ -1,3 +1,34 @@
<script type="text/javascript">
// var flag = false;
// jQuery(document).ready(function($) {
// transpotUrl('#content');
// });
// function submit_message_replay()
// {
// regexContent();//onkeyup传给kindeditor用不上了所以只能放在这里
// if(flag)
// {
// message_content_editor.sync();//提交内容之前要sync不然服务器端取不到值
// $("#message_form").submit();
// }
// }
// function regexContent()
// {
// var content = message_content_editor.html();//$.trim($("#message_content").val());
// if(content.length ==0)
// {
// $("#message_content_span").text("<%= l(:label_reply_empty) %>");
// $("#message_content_span").css('color','#ff0000');
// flag = false;
// }
// else
// {
// $("#message_content_span").text("<%= l(:label_field_correct) %>");
// $("#message_content_span").css('color','#008000');
// flag = true;
// }
// }
</script>
<div class="project_r_h"> <div class="project_r_h">
<h2 class="project_h2"><%= l(:label_board) %></h2> <h2 class="project_h2"><%= l(:label_board) %></h2>
</div> </div>
@ -24,7 +55,7 @@
:class => 'talk_edit fr' :class => 'talk_edit fr'
) if @message.course_destroyable_by?(User.current) %> ) if @message.course_destroyable_by?(User.current) %>
<div class="cl"></div> <div class="cl"></div>
<div class="talk_info mb10"><%= textilizable(@topic, :content) %></div> <div class="talk_info mb10"><%= textAreailizable(@topic, :content) %></div>
<div class="talk_info mb10"><%= link_to_attachments_course @topic, :author => false %></div> <div class="talk_info mb10"><%= link_to_attachments_course @topic, :author => false %></div>
<!-- <a href="#" class=" link_file ml60">附件爱覅俄方if.zip(27.5kB)</a>--> <!-- <a href="#" class=" link_file ml60">附件爱覅俄方if.zip(27.5kB)</a>-->
<div class="cl"></div> <div class="cl"></div>
@ -52,7 +83,7 @@
<%= link_to_user_header message.author,false,:class => 'c_blue fb fl mb10 ' %> <%= link_to_user_header message.author,false,:class => 'c_blue fb fl mb10 ' %>
<span class="c_grey fr"><%= format_time(message.created_on) %></span> <span class="c_grey fr"><%= format_time(message.created_on) %></span>
<div class="cl"></div> <div class="cl"></div>
<p><%= textilizable message,:content,:attachments => message.attachments %></p> <p><%= textAreailizable message,:content,:attachments => message.attachments %></p>
<%= link_to_attachments_course message, :author => false %> <%= link_to_attachments_course message, :author => false %>
</div> </div>
<div class="ping_disfoot"> <div class="ping_disfoot">
@ -87,7 +118,7 @@
<div id="reply" style="display:none;"> <div id="reply" style="display:none;">
<%= form_for @reply, :as => :reply, :url => {:action => 'reply', :id => @topic}, :html => {:multipart => true, :id => 'message_form'} do |f| %> <%= form_for @reply, :as => :reply, :url => {:action => 'reply', :id => @topic}, :html => {:multipart => true, :id => 'message_form'} do |f| %>
<%= render :partial => 'form_course', :locals => {:f => f, :replying => true} %> <%= render :partial => 'form_course', :locals => {:f => f, :replying => true} %>
<a href="#" onclick="submit_message_replay();"class="blue_btn fl c_white" style="margin-left: 50px;"><%= l(:button_submit)%></a> <%= link_to l(:button_submit),"#",:onclick => 'course_board_submit_message_replay();' ,:class => "blue_btn fl c_white" ,:style=>"margin-left: 50px;"%>
<% end %> <% end %>
<div id="preview" class="wiki"></div> <div id="preview" class="wiki"></div>
</div> </div>
@ -97,32 +128,3 @@
</ul> </ul>
<% html_title @topic.subject %> <% html_title @topic.subject %>
<script type="text/javascript">
var flag = false;
jQuery(document).ready(function($) {
transpotUrl('#content');
});
function submit_message_replay()
{
if(flag)
{
$("#message_form").submit();
}
}
function regexContent()
{
var content = $.trim($("#message_content").val());
if(content.length ==0)
{
$("#message_content_span").text("<%= l(:label_reply_empty) %>");
$("#message_content_span").css('color','#ff0000');
flag = false;
}
else
{
$("#message_content_span").text("<%= l(:label_field_correct) %>");
$("#message_content_span").css('color','#008000');
flag = true;
}
}
</script>

@ -1,3 +1,4 @@
<%= javascript_include_tag "/assets/kindeditor/kindeditor" %>
<%= error_messages_for 'message' %> <%= error_messages_for 'message' %>
<% replying ||= false %> <% replying ||= false %>
<% extra_option = replying ? { readonly: true} : { maxlength: 200 } %> <% extra_option = replying ? { readonly: true} : { maxlength: 200 } %>
@ -28,7 +29,25 @@
<div id="message_quote" class="wiki" style="width: 100%;word-break: break-all;word-wrap: break-word;"></div> <div id="message_quote" class="wiki" style="width: 100%;word-break: break-all;word-wrap: break-word;"></div>
<label class="fl" ><span class="c_red">*</span>&nbsp;<%= l(:field_description) %>&nbsp;&nbsp;</label> <label class="fl" ><span class="c_red">*</span>&nbsp;<%= l(:field_description) %>&nbsp;&nbsp;</label>
<%= text_area :quote,:quote,:style => 'display:none' %> <%= text_area :quote,:quote,:style => 'display:none' %>
<%= f.text_area :content, :class => 'talk_text fl', :id => 'message_content', :onkeyup => "regexContent();", :maxlength => 5000,:placeholder => "最多3000个汉字(或6000个英文字符)" %> <%= hidden_field_tag :asset_id,params[:asset_id],:required => false,:style => 'display:none' %>
<% if replying %>
<%= f.kindeditor :content, :editor_id => 'message_content_editor',
:width => '89%',
:height => 300,
:input_html => { :id => 'message_content',
:class => 'talk_text fl',
:maxlength => 5000 }%>
<% else %>
<%= f.kindeditor :content, :editor_id => 'message_content_editor',
:owner_id => @message.nil? ? 0: @message.id,
:owner_type => OwnerTypeHelper::MESSAGE,
:width => '91%',
:height => 300,
:class => 'talk_text fl',
:input_html => { :id => 'message_content',
:class => 'talk_text fl',
:maxlength => 5000 }%>
<% end %>
<div class="cl"></div> <div class="cl"></div>
<p id="message_content_span" class="ml55"></p> <p id="message_content_span" class="ml55"></p>
</li> </li>

@ -1,12 +1,21 @@
<%= javascript_include_tag "/assets/kindeditor/kindeditor" %>
<li class="ml45"> <li class="ml45">
<label><span class="c_red">*</span>&nbsp;<%= l(:field_title) %>&nbsp;&nbsp;</label> <label><span class="c_red">*</span>&nbsp;<%= l(:field_title) %>&nbsp;&nbsp;</label>
<input type="text" name="news[title]" class="hwork_input" id="news_title" size="60" onkeyup="regexTitle();" maxlength="60" placeholder="60个字符以内" value="<%= is_new ? '' : @news.title %>"> <input type="text" name="news[title]" class="hwork_input" id="news_title" size="60" onkeyup="regexTitle();" maxlength="60" placeholder="60个字符以内" value="<%= is_new ? '' : @news.title %>">
<p id="title_notice_span" class="ml55"></p> <p id="title_notice_span" class="ml55"></p>
</li> </li>
<li class="ml45"> <li class="ml45">
<% if is_new %>
<%= hidden_field_tag :asset_id,params[:asset_id],:required => false,:style => 'display:none' %>
<label class="fl" ><span class="c_red">*</span>&nbsp;<%= l(:field_description) %>&nbsp;&nbsp;</label> <label class="fl" ><span class="c_red">*</span>&nbsp;<%= l(:field_description) %>&nbsp;&nbsp;</label>
<textarea id="news_description" name="news[description]" placeholder="最多3000个汉字(或6000个英文字符)" class="hwork_text fl" onkeyup="regexDescription();" maxlength="6000"><%= is_new ? '' : @news.description %></textarea> <%= f.kindeditor :description,:width=>'91%',:editor_id=>'news_description_editor' %>
<p id="description_notice_span" class="ml55"></p> <p id="description_notice_span" class="ml55"></p>
<% else %>
<label class="fl" ><span class="c_red">*</span>&nbsp;<%= l(:field_description) %>&nbsp;&nbsp;</label>
<%= f.kindeditor :description,:width=>'91%',:editor_id=>'news_description_editor',:owner_id => @news.id,:owner_type => OwnerTypeHelper::NEWS %>
<p id="description_notice_span" class="ml55"></p>
<% end %>
</li> </li>
<div class="cl"></div> <div class="cl"></div>
<li class="ml45"> <li class="ml45">
@ -19,7 +28,7 @@
<%= link_to l(:button_create), "#", :onclick => 'submitNews();', :onmouseover => 'submitFocus(this);', :class => 'blue_btn fl c_white' %> <%= link_to l(:button_create), "#", :onclick => 'submitNews();', :onmouseover => 'submitFocus(this);', :class => 'blue_btn fl c_white' %>
<%= link_to l(:button_cancel), course_news_index_path(@course), :onclick => '$("#add-news").hide()', :class => 'blue_btn grey_btn fl c_white' %> <%= link_to l(:button_cancel), course_news_index_path(@course), :onclick => '$("#add-news").hide()', :class => 'blue_btn grey_btn fl c_white' %>
<% else %> <% else %>
<%= link_to l(:button_save), "#", :onclick => 'submitNews();',:onmouseover => 'this.focus()',:class => 'blue_btn fl c_white' %> <%= link_to l(:button_save), "#", :onclick => "submitNews();",:onmouseover => 'this.focus()',:class => 'blue_btn fl c_white' %>
<%= link_to l(:button_cancel), "#", :onclick => '$("#edit-news").hide(); return false;',:class => 'blue_btn grey_btn fl c_white' %> <%= link_to l(:button_cancel), "#", :onclick => '$("#edit-news").hide(); return false;',:class => 'blue_btn grey_btn fl c_white' %>
<% end %> <% end %>
<div class="cl"></div> <div class="cl"></div>

@ -51,7 +51,7 @@
<%= link_to_user_header(news.author,false,{:class=> 'problem_name c_orange fl'}) if news.respond_to?(:author) %> <%= link_to_user_header(news.author,false,{:class=> 'problem_name c_orange fl'}) if news.respond_to?(:author) %>
<span class="fl"> <%= l(:label_release_news) %></span><%= link_to h(news.title), news_path(news),:class => 'problem_tit fl fb c_dblue' %><br /> <span class="fl"> <%= l(:label_release_news) %></span><%= link_to h(news.title), news_path(news),:class => 'problem_tit fl fb c_dblue' %><br />
<div class="cl mb5"></div> <div class="cl mb5"></div>
<p id="news_description_<%= news.id %>" class="news_description mt5"><%= news.description %><br /> <%= l(:label_create_time) %> <%= format_time(news.created_on) %></p> <p id="news_description_<%= news.id %>" class="news_description mt5"><%= textAreailizable news.description %><br /> <%= l(:label_create_time) %> <%= format_time(news.created_on) %></p>
<div class="news_foot" style="display: none;" onclick="news_show_more_des(<%= news.id %>);" id="news_foot_<%= news.id %>"><%= l(:label_expend_information) %> <span class="g-arr-down"><img src="/images/jiantou.jpg" width="12" height="6" /></span></div> <div class="news_foot" style="display: none;" onclick="news_show_more_des(<%= news.id %>);" id="news_foot_<%= news.id %>"><%= l(:label_expend_information) %> <span class="g-arr-down"><img src="/images/jiantou.jpg" width="12" height="6" /></span></div>
</div> </div>
<div class="cl"></div> <div class="cl"></div>

@ -44,6 +44,7 @@
function submitNews() function submitNews()
{ {
news_description_editor.sync();
if(regexTitle() && regexDescription()) if(regexTitle() && regexDescription())
{ {
$("#news-form").submit(); $("#news-form").submit();
@ -51,6 +52,7 @@
} }
function submitComment() function submitComment()
{ {
comment_editor.sync();
$("#add_comment_form").submit(); $("#add_comment_form").submit();
} }
function clearMessage() function clearMessage()
@ -58,7 +60,7 @@
$("#comment_comments").val(""); $("#comment_comments").val("");
} }
</script> </script>
<%= javascript_include_tag "/assets/kindeditor/kindeditor" %>
<div class="project_r_h"> <div class="project_r_h">
<h2 class="project_h2"><%= l(:label_course_news) %></h2> <h2 class="project_h2"><%= l(:label_course_news) %></h2>
</div> </div>
@ -84,7 +86,7 @@
:onclick => '$("#edit-news").show(); return false;') if User.current.allowed_to?(:manage_news, @course) %> :onclick => '$("#edit-news").show(); return false;') if User.current.allowed_to?(:manage_news, @course) %>
<%= delete_link(news_path(@news),:class => 'talk_edit fr') if User.current.allowed_to?(:manage_news, @course) %> <%= delete_link(news_path(@news),:class => 'talk_edit fr') if User.current.allowed_to?(:manage_news, @course) %>
<div class="cl"></div> <div class="cl"></div>
<div class="mb5"><%= textilizable(@news, :description) %><br /> <%= l(:label_create_time) %> <%= format_time(@news.created_on) %></div> <div class="mb5"><%= textAreailizable(@news, :description) %><br /> <%= l(:label_create_time) %> <%= format_time(@news.created_on) %></div>
<%= link_to_attachments_course @news %> <%= link_to_attachments_course @news %>
<!--<a href="#" class=" link_file">附件爱覅俄方if.zip(27.5kB)</a> --> <!--<a href="#" class=" link_file">附件爱覅俄方if.zip(27.5kB)</a> -->
</div> </div>
@ -95,8 +97,9 @@
<div class="msg_box"> <div class="msg_box">
<h4><%= l(:label_comment_add) %></h4> <h4><%= l(:label_comment_add) %></h4>
<%= form_tag({:controller => 'comments', :action => 'create', :id => @news}, :id => "add_comment_form") do %> <%= form_tag({:controller => 'comments', :action => 'create', :id => @news}, :id => "add_comment_form") do %>
<div class="box"> <div class="box" >
<%= text_area 'comment', 'comments', :placeholder=>"最多250个字"%> <%= hidden_field_tag :asset_id,params[:asset_id],:required => false,:style => 'display:none' %>
<%= kindeditor_tag :comment, '',:height=>'100',:editor_id =>'comment_editor', :placeholder=>"最多250个字"%>
</div> </div>
<p> <p>
<a href="#" class="grey_btn fr ml10" onclick="clearMessage();"><%= l(:label_cancel_with_space) %></a> <a href="#" class="grey_btn fr ml10" onclick="clearMessage();"><%= l(:label_cancel_with_space) %></a>
@ -106,6 +109,7 @@
<% end %> <% end %>
</div> </div>
<% end %> <% end %>
<% comments = @comments.reverse %> <% comments = @comments.reverse %>
<% comments.each do |comment| %> <% comments.each do |comment| %>
<% next if comment.new_record? %> <% next if comment.new_record? %>
@ -115,7 +119,7 @@
<div class="ping_distop"> <div class="ping_distop">
<%= link_to_user_header(comment.author,false,:class => 'c_blue fb fl mb10 ') if comment.respond_to?(:author) %><span class="c_grey fr"><%= format_time(comment.created_on) %></span> <%= link_to_user_header(comment.author,false,:class => 'c_blue fb fl mb10 ') if comment.respond_to?(:author) %><span class="c_grey fr"><%= format_time(comment.created_on) %></span>
<div class="cl"></div> <div class="cl"></div>
<p><%= textilizable(comment.comments) %></p> <p><%= textAreailizable(comment.comments) %></p>
</div> </div>
<div class="ping_disfoot"><%= link_to_if_authorized_course image_tag('delete.png'), {:controller => 'comments', :action => 'destroy', :id => @news, :comment_id => comment}, <div class="ping_disfoot"><%= link_to_if_authorized_course image_tag('delete.png'), {:controller => 'comments', :action => 'destroy', :id => @news, :comment_id => comment},
:data => {:confirm => l(:text_are_you_sure)}, :method => :delete, :title => l(:button_delete) %> :data => {:confirm => l(:text_are_you_sure)}, :method => :delete, :title => l(:button_delete) %>

@ -106,7 +106,8 @@ zh:
lable_file_sharingarea: 资源共享区 lable_file_sharingarea: 资源共享区
label_upload_files: 上传文件 label_upload_files: 上传文件
label_slected_to_other_project: 选入我的其他项目
label_slected_to_project: 选入我的项目
# 资源库(附件)公用 > 关联资源 # 资源库(附件)公用 > 关联资源
label_relation_files: 关联已有资源 label_relation_files: 关联已有资源

@ -1964,6 +1964,7 @@ zh:
field_open_anonymous_evaluation: 是否使用匿评 field_open_anonymous_evaluation: 是否使用匿评
label_course_empty_select: 尚未选择课程! label_course_empty_select: 尚未选择课程!
label_course_prompt: 课程: label_course_prompt: 课程:
label_project_prompt: 项目:
label_contain_resource: 已包含资源: label_contain_resource: 已包含资源:
label_quote_resource_failed: ",此资源引用失败! " label_quote_resource_failed: ",此资源引用失败! "
label_file_lost: 以下无法成功下载,请联系相关人员重新上传: label_file_lost: 以下无法成功下载,请联系相关人员重新上传:

@ -431,8 +431,12 @@ RedmineApp::Application.routes.draw do
match 'issues/update_form', :to => 'issues#update_form', :via => [:put, :post], :as => 'issue_form' match 'issues/update_form', :to => 'issues#update_form', :via => [:put, :post], :as => 'issue_form'
resources :files, :only => [:index, :new, :create] do resources :files, :only => [:index, :new, :create] do
member do
match "quote_resource_show_project",:via => [:get]
end
collection do collection do
match "getattachtype" , :via => [:get, :post] match "getattachtype" , :via => [:get, :post]
match "search_project",:via => [:post,:get]
#match 'getattachtype/:attachtype', :to => 'files#getattachtype', :via => [:get, :post] #match 'getattachtype/:attachtype', :to => 'files#getattachtype', :via => [:get, :post]
end end
end end
@ -590,6 +594,7 @@ RedmineApp::Application.routes.draw do
get 'attachments/autocomplete' get 'attachments/autocomplete'
match 'attachments/autocomplete', :to => 'attachments#autocomplete', :via => [:post] match 'attachments/autocomplete', :to => 'attachments#autocomplete', :via => [:post]
post 'attachments/relationfile', to: 'attachments#add_exist_file_to_project', as: 'attach_relation' post 'attachments/relationfile', to: 'attachments#add_exist_file_to_project', as: 'attach_relation'
post 'attachments/relationfiles', to: 'attachments#add_exist_file_to_projects', as: 'attach_relations'
post 'attachments/courserelationfile', to: 'attachments#add_exist_file_to_course', as: 'course_attach_relation' post 'attachments/courserelationfile', to: 'attachments#add_exist_file_to_course', as: 'course_attach_relation'
post 'attachments/courserelationfiles', to: 'attachments#add_exist_file_to_courses', as: 'course_attach_relations' post 'attachments/courserelationfiles', to: 'attachments#add_exist_file_to_courses', as: 'course_attach_relations'
get 'attachments/renderTag/:attchmentId', :to => 'attachments#renderTag', :attchmentId => /\d+/ get 'attachments/renderTag/:attchmentId', :to => 'attachments#renderTag', :attchmentId => /\d+/

@ -11,7 +11,7 @@
# #
# It's strongly recommended to check this file into your version control system. # It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20150309090143) do ActiveRecord::Schema.define(:version => 20150324021043) do
create_table "activities", :force => true do |t| create_table "activities", :force => true do |t|
t.integer "act_id", :null => false t.integer "act_id", :null => false
@ -638,16 +638,6 @@ ActiveRecord::Schema.define(:version => 20150309090143) do
add_index "journal_details", ["journal_id"], :name => "journal_details_journal_id" 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| create_table "journal_replies", :id => false, :force => true do |t|
t.integer "journal_id" t.integer "journal_id"
t.integer "user_id" t.integer "user_id"
@ -1069,12 +1059,12 @@ ActiveRecord::Schema.define(:version => 20150309090143) do
end end
create_table "roles", :force => true do |t| create_table "roles", :force => true do |t|
t.string "name", :limit => 90 t.string "name", :limit => 30, :default => "", :null => false
t.integer "position" t.integer "position", :default => 1
t.boolean "assignable" t.boolean "assignable", :default => true
t.integer "builtin" t.integer "builtin", :default => 0, :null => false
t.text "permissions" t.text "permissions"
t.string "issues_visibility", :limit => 90 t.string "issues_visibility", :limit => 30, :default => "default", :null => false
end end
create_table "schools", :force => true do |t| create_table "schools", :force => true do |t|

@ -3,9 +3,17 @@ if defined?(ActiveRecord)
def self.has_many_kindeditor_assets(*args) def self.has_many_kindeditor_assets(*args)
options = args.extract_options! options = args.extract_options!
asset_name = args[0] ? args[0].to_s : 'assets' asset_name = args[0] ? args[0].to_s : 'assets'
has_many asset_name.to_sym, :class_name => 'Kindeditor::Asset', :foreign_key => 'owner_id', :dependent => options[:dependent]
class_name = self.name class_name = self.name
# Time 2015-04-01 14:20:32
# Author lizanle
# Description 对象类型对应的数值kindeditor_assets表里owner_type的值
has_many asset_name.to_sym,
:class_name => 'Kindeditor::Asset',
:conditions => "owner_type = #{('OwnerTypeHelper::'+class_name.upcase).constantize}",
:foreign_key => 'owner_id', :dependent => options[:dependent]
Kindeditor::Asset.class_eval do Kindeditor::Asset.class_eval do
belongs_to :owner, :class_name => class_name, :foreign_key => 'owner_id' belongs_to :owner, :class_name => class_name, :foreign_key => 'owner_id'
end end

@ -20,7 +20,11 @@ module RailsKindeditor
def kindeditor_upload_json_path(*args) def kindeditor_upload_json_path(*args)
options = args.extract_options! options = args.extract_options!
owner_id_query_string = options[:owner_id] ? "?owner_id=#{options[:owner_id]}" : '' owner_id_query_string = options[:owner_id] ? "?owner_id=#{options[:owner_id]}" : ''
if owner_id_query_string.blank?
owner_type_query_string = options[:owner_type] ? "?owner_type=#{options[:owner_type]}" : ""
else
owner_type_query_string = options[:owner_type] ? owner_id_query_string + "&owner_type=#{options[:owner_type]}" : owner_id_query_string owner_type_query_string = options[:owner_type] ? owner_id_query_string + "&owner_type=#{options[:owner_type]}" : owner_id_query_string
end
"#{main_app_root_url}kindeditor/upload#{owner_type_query_string}" "#{main_app_root_url}kindeditor/upload#{owner_type_query_string}"
end end

@ -257,14 +257,10 @@ K.options = {
minHeight : 100, minHeight : 100,
minChangeSize : 50, minChangeSize : 50,
zIndex : 811213, zIndex : 811213,
items : [ items : ['emoticons',
'source', '|', 'undo', 'redo', '|', 'preview', 'print', 'template', 'code', 'source','plainpaste', 'wordpaste', '|', 'justifyleft', 'justifycenter', 'justifyright', 'insertorderedlist', '|',
'plainpaste', 'wordpaste', '|', 'justifyleft', 'justifycenter', 'justifyright', 'formatblock', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold',
'justifyfull', 'insertorderedlist', 'insertunorderedlist', 'indent', 'outdent', 'subscript', 'italic', 'underline', 'removeformat', '|', 'image', 'table', 'link', '|', 'fullscreen'
'superscript', 'quickformat', 'fullscreen','|', '/',
'formatblock', 'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold',
'italic', 'underline', 'strikethrough', 'lineheight', 'removeformat', '|', 'image', 'table', 'hr', 'emoticons', 'baidumap', 'pagebreak',
'anchor', 'link', '|'
], ],
noDisableItems : ['source', 'fullscreen'], noDisableItems : ['source', 'fullscreen'],
colorTable : [ colorTable : [

@ -129,7 +129,7 @@ function regexSubject()
} }
function regexContent() function regexContent()
{ {
var content = $.trim($("#message_content").val()); var content = message_content_editor.html();
if(content.length ==0) if(content.length ==0)
{ {
$("#message_content_span").text("描述不能为空"); $("#message_content_span").text("描述不能为空");
@ -146,6 +146,7 @@ function regexContent()
} }
function submitCoursesBoard() function submitCoursesBoard()
{ {
message_content_editor.sync();
if(regexSubject()&&regexContent()){$("#message-form").submit();} if(regexSubject()&&regexContent()){$("#message-form").submit();}
} }
/////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////
@ -177,7 +178,7 @@ function regexTitle()
function regexDescription() function regexDescription()
{ {
var name = $("#news_description").val(); var name = news_description_editor.html();
if(name.length ==0) if(name.length ==0)
{ {
$("#description_notice_span").text("描述不能为空"); $("#description_notice_span").text("描述不能为空");
@ -185,6 +186,12 @@ function regexDescription()
$("#description_notice_span").focus(); $("#description_notice_span").focus();
return false; return false;
} }
else if(name.length >=6000){
$("#description_notice_span").text("描述最多3000个汉字(或6000个英文字符)");
$("#description_notice_span").css('color','#ff0000');
$("#description_notice_span").focus();
return false;
}
else else
{ {
$("#description_notice_span").text("填写正确"); $("#description_notice_span").text("填写正确");
@ -193,10 +200,12 @@ function regexDescription()
} }
} }
function submitNews() function submitNews(is_new)
{ {
alert(is_new)
if(regexTitle() && regexDescription()) if(regexTitle() && regexDescription())
{ {
news_description_editor.sync();
$("#news-form").submit(); $("#news-form").submit();
} }
} }
@ -205,6 +214,31 @@ function submitFocus(obj)
{ {
$(obj).focus(); $(obj).focus();
} }
/////////////////////////////////////////////////课程讨论区
function course_board_submit_message_replay()
{
if(MessageReplayVevify())
{
message_content_editor.sync();//提交内容之前要sync不然服务器端取不到值
$("#message_form").submit();
}
}
function MessageReplayVevify() {
var content = message_content_editor.html();//$.trim($("#message_content").val());
if (content.length == 0) {
$("#message_content_span").text("<%= l(:label_reply_empty) %>");
$("#message_content_span").css('color', '#ff0000');
return false;
}
else {
$("#message_content_span").text("<%= l(:label_field_correct) %>");
$("#message_content_span").css('color', '#008000');
return true;
}
}
//////////////////////////////////////////////////
/////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////
//验证搜索时输入名字 //验证搜索时输入名字
@ -336,6 +370,7 @@ function submit_new_bid(id)
{ {
if(regex_bid_name()&&regex_evaluation_num()) if(regex_bid_name()&&regex_evaluation_num())
{ {
bid_description_editor.sync();
$("#"+id).submit(); $("#"+id).submit();
} }
} }

Loading…
Cancel
Save