Merge branch 'cxt_course' of http://git.trustie.net/jacknudt/trustieforge into cxt_course

Conflicts:
	app/helpers/application_helper.rb
This commit is contained in:
huang 2016-01-15 15:41:02 +08:00
commit 86516df88a
317 changed files with 10558 additions and 5868 deletions

View File

@ -0,0 +1,3 @@
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/

View File

@ -0,0 +1,3 @@
// Place all the styles related to the shield_activities controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/

View File

@ -7,10 +7,14 @@ class AtController < ApplicationController
@logger = Logger.new(Rails.root.join('log', 'at.log').to_s)
users = find_at_users(params[:type], params[:id])
@users = users
@users = users.uniq { |u| u.id }.delete_if { |u| u.id == User.current.id } if users
@users = users.uniq { |u| u.id }.delete_if { |u| u.id == User.current.id }.sort{|x,y| to_pinyin(x.show_name) <=> to_pinyin(y.show_name)} if users
end
private
def to_pinyin(s)
Pinyin.t(s).downcase
end
def find_at_users(type, id)
@logger.info("#{type}, #{id}")
case type

View File

@ -185,7 +185,6 @@ class AttachmentsController < ApplicationController
end
@attachment.filename = params[:filename].presence || Redmine::Utils.random_hex(16)
saved = @attachment.save
respond_to do |format|
format.js
format.api {
@ -198,12 +197,43 @@ class AttachmentsController < ApplicationController
end
end
def upload_attachment_version
@flag = false
Attachment.transaction do
@old_attachment = Attachment.find params[:old_attachment_id]
#取出当前上传的文件
@attachment = Attachment.find(params[:attachments ].first[1][:attachment_id])
#将需要修改的记录保存到历史记录
@history = AttachmentHistory.new
@history.attributes = @old_attachment.attributes.dup.except("id")
@history.attachment_id = params[:old_attachment_id]
#需要更新版本号,需要拿到原来该文件最大的历史版本号
@old_history = @old_attachment.attachment_histories.reorder('version desc').first
@history.version = @old_history.nil? ? 1 : @old_history.version + 1
@history.save #历史记录保存完毕
#将最新保存的记录 数据替换到 需要修改的文件记录
@old_attachment.attributes = @attachment.attributes.dup.except("id","container_id","container_type","is_public")
@old_attachment.save
#删除当前记录
@attachment.delete
@flag = true
end
respond_to do |format|
format.js
end
end
def destroy
if @attachment.container.respond_to?(:init_journal)
@attachment.container.init_journal(User.current)
end
if @attachment.container
@attachment.container.attachments.delete(@attachment)
if @attachment.container_type == "Issue"
@attachment.destroy
else
@attachment.container.attachments.delete(@attachment)
end
else
@attachment.destroy
end
@ -242,6 +272,8 @@ class AttachmentsController < ApplicationController
format.html { redirect_to_referer_or mobile_version_path }
elsif !@attachment.container.nil? && @attachment.container.is_a?(OrgSubfield)
format.html {redirect_to_referer_or org_subfield_files_path(@attachment.container)}
elsif !@attachment.container.nil? && @attachment.container.is_a?(OrgDocumentComment)
format.html {redirect_to_referer_or org_document_comment_path(@attachment.container)}
else
if @project.nil?
format.html { redirect_to_referer_or forum_memo_path(@attachment.container.forum, @attachment.container) }
@ -253,7 +285,7 @@ class AttachmentsController < ApplicationController
format.js
end
end
def delete_homework
@bid = @attachment.container.bid
# Make sure association callbacks are called
@ -316,13 +348,13 @@ class AttachmentsController < ApplicationController
end
respond_to do |format|
format.js
format.js
end
rescue NoMethodError
@save_flag = false
@save_message = [] << l(:error_attachment_empty)
respond_to do |format|
format.js
format.js
end
end
@ -492,6 +524,15 @@ class AttachmentsController < ApplicationController
end
end
#找到文件的所有的历史版本
def attachment_versions
@attachment = Attachment.find(params[:id])
@attachment_histories = @attachment.attachment_histories
respond_to do |format|
format.js
end
end
private
def find_project
@attachment = Attachment.find(params[:id])

View File

@ -10,7 +10,7 @@ class AvatarController < ApplicationController
unless request.content_type == 'application/octet-stream'
@source_type = params[:source_type]
@source_id = params[:source_id]
@temp_file = params[:avatar][:image]
@temp_file = params[:avatar][:image]
@image_file = @temp_file.original_filename
else
unless request.raw_post.nil?
@ -23,7 +23,7 @@ class AvatarController < ApplicationController
#image_file.force_encoding("UTF-8") if filename.respond_to?(:force_encoding)
else
@image_file=params[:filename]
end
end
@temp_file = StringIO.new(@temp_file)
end
end

View File

@ -52,7 +52,11 @@ class BlogCommentsController < ApplicationController
render_attachment_warning_if_needed(@article)
else
end
redirect_to user_blog_blog_comment_path(:user_id=>params[:user_id],:blog_id=>params[:blog_id],:id=>params[:id])
if params[:is_homepage]
redirect_to user_blogs_path(params[:user_id])
else
redirect_to user_blog_blog_comment_path(:user_id=>params[:user_id],:blog_id=>params[:blog_id],:id=>params[:id])
end
end
def destroy
@article = BlogComment.find(params[:id])

View File

@ -1,5 +1,5 @@
class BlogsController < ApplicationController
before_filter :find_blog,:except => [:index,:create,:new]
before_filter :find_blog,:except => [:index,:create,:new,:set_homepage, :cancel_homepage]
before_filter :find_user
def index
@articls = @user.blog.articles
@ -26,6 +26,18 @@ class BlogsController < ApplicationController
def edit
end
def set_homepage
@blog = Blog.find(params[:id])
@blog.update_attribute(:homepage_id, params[:article_id])
redirect_to user_blogs_path(params[:user_id])
end
def cancel_homepage
@blog = Blog.find(params[:id])
@blog.update_attribute(:homepage_id, nil)
redirect_to user_blogs_path(params[:user_id])
end
private
def find_blog
if params[:blog_id]

View File

@ -18,8 +18,8 @@
class BoardsController < ApplicationController
layout 'base_projects'#by young
default_search_scope :messages
before_filter :find_project_by_project_id, :find_board_if_available
before_filter :authorize, :except => [:new, :show, :create, :index]
before_filter :find_project_by_project_id, :find_board_if_available, :except => [:join_to_org_subfields]
before_filter :authorize, :except => [:new, :show, :create, :index, :join_to_org_subfields]
accept_rss_auth :index, :show
@ -79,13 +79,12 @@ class BoardsController < ApplicationController
end
end
end
# 更新@消息为已读
@project.boards.each do |board|
board.messages.each do |m|
User.current.at_messages.unviewed('Message', m.id).each {|x| x.viewed!}
end
end
elsif @course
query_course_messages = @board.messages
query_course_messages.each do |query_course_message|
@ -106,43 +105,19 @@ class BoardsController < ApplicationController
@is_new = params[:is_new]
@topic_count = @board ? @board.topics.count : 0
if @project
@topic_pages = Paginator.new @topic_count, per_page_option, params['page']
#现在发布帖子的时候置顶功能已经没有了。所以取消这个置顶排序 #{Message.table_name}.sticky DESC,
@topics = @board.topics.
reorder("#{Message.table_name}.created_on desc").
includes(:last_reply).
limit(@topic_pages.per_page).
offset(@topic_pages.offset).
preload(:author, {:last_reply => :author}).
all
if @board
limit = 10;
@topic_count = @board.topics.count();
@topic_pages = (params[:page] ? params[:page].to_i + 1 : 0) *10
@topics = @board.topics.reorder("#{Message.table_name}.sticky DESC, COALESCE(last_replies_messages.created_on, #{Message.table_name}.created_on) desc").
limit(limit).offset(@topic_pages).includes(:last_reply).
preload(:author, {:last_reply => :author}).all();
else
@topics = [];
end
elsif @course
#
# board_topics = @board ? @board.topics.reorder("#{Message.table_name}.sticky DESC, #{Message.table_name}.created_on desc").
# includes(:last_reply).
# # limit(@topic_pages.per_page).
# # offset(@topic_pages.offset).
#
# preload(:author, {:last_reply => :author}).
# all : []
# @topics = paginateHelper board_topics,10
if (@board)
limit = 10;
#pageno = params[:page];
#if(pageno == nil || pageno=='')
# dw_topic = nil;
# if( params[:parent_id]!=nil && params[:parent_id]!='' )
# dw_topic = @board.topics.where(id:params[:parent_id]).first();
# end
# if( dw_topic != nil )
# dw_count = @board.topics.where('(sticky>?) or (sticky=? and created_on>?)',dw_topic.sticky,dw_topic.sticky,dw_topic.created_on).count();
# dw_count = dw_count+1;
# pageno = dw_count%10==0 ? (dw_count/limit) : (dw_count/limit+1)
# end
#end
#if(pageno == nil || pageno=='')
# pageno=1;
#end
@topic_count = @board.topics.count();
@topic_pages = (params[:page] ? params[:page].to_i + 1 : 0) *10
@topics = @board.topics.reorder("#{Message.table_name}.sticky DESC, COALESCE(last_replies_messages.created_on, #{Message.table_name}.created_on) desc").
@ -225,6 +200,16 @@ class BoardsController < ApplicationController
redirect_to_settings_in_projects
end
def join_to_org_subfields
if params[:id]
@board = Board.find(params[:id])
@org_subfield_ids = params[:org_subfield_ids]
@org_subfield_ids.each do |id|
OrgSubfieldBoard.create(:org_subfield_id => id.to_i, :board_id => params[:id].to_i)
end
end
end
private
def redirect_to_settings_in_projects
redirect_to settings_project_url(@project, :tab => 'boards')

View File

@ -54,16 +54,9 @@ class CommentsController < ApplicationController
# end
# # <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ض<EFBFBD>̬<EFBFBD>ļ<EFBFBD>¼add end
#flash[:notice] = l(:label_comment_added)
course_activity = CourseActivity.where("course_act_type='News' and course_act_id =#{@news.id}").first
if course_activity
course_activity.updated_at = Time.now
course_activity.save
end
user_activity = UserActivity.where("act_type='News' and act_id =#{@news.id}").first
if user_activity
user_activity.updated_at = Time.now
user_activity.save
end
update_course_activity(@news.class,@news.id)
update_user_activity(@news.class,@news.id)
update_org_activity(@news.class,@news.id)
end
if params[:user_activity_id]

View File

@ -1,3 +1,4 @@
#encoding: utf-8
class CoursesController < ApplicationController
# layout 'base_courses'
include CoursesHelper
@ -38,15 +39,17 @@ class CoursesController < ApplicationController
end
limit = 15
course_org_ids = OrgCourse.find_by_sql("select distinct organization_id from org_courses where course_id = #{params[:id]}").map(&:organization_id)
if course_org_ids.empty?
@orgs_not_in_course = Organization.where("(is_public or creator_id =?) and name like ?",User.current.id, condition).page((params[:page].to_i || 1)).per(limit)
@org_count = Organization.where("is_public = 1 or creator_id =?", User.current.id).where("name like ?", condition).count
else
course_org_ids = "(" + course_org_ids.join(',') + ")"
@orgs_not_in_course = Organization.where("id not in #{course_org_ids} and (is_public = 1 or creator_id =?) and name like ?", User.current.id, condition).page((params[:page].to_i || 1)).per(limit)
@org_count = Organization.where("id not in #{course_org_ids} and (is_public = 1 or creator_id =?)", User.current.id).where("name like ?", condition).count
end
# @course_count = Project.course_entities.visible.like(params[:name]).page(params[:page]).count
#@orgs_not_in_course = User.current.organizations.where("organizations.id not in (#{course_org_ids.join(',')}) and organizations.name like ?", condition).page(params[:page].to_i || 1).per(limit)
#@org_count = User.current.organizations.where("organizations.id not in (#{course_org_ids.join(',')}) and organizations.name like ?", condition).count
if course_org_ids.empty?
@orgs_not_in_course = User.current.organizations.where("name like ?",condition).page((params[:page].to_i || 1)).per(limit)
@org_count = @orgs_not_in_course.count
else
course_org_ids = "(" + course_org_ids.join(',') + ")"
@orgs_not_in_course = User.current.organizations.where("organizations.id not in #{course_org_ids} and organizations.name like ?", condition).page((params[:page].to_i || 1)).per(limit)
@org_count = @orgs_not_in_course.empty? ? 0 : @orgs_not_in_course.count
end
@course_count = Project.course_entities.visible.like(params[:name]).page(params[:page]).count
@orgs_page = Paginator.new @org_count, limit,params[:page]
@hint_flag = params[:hint_flag]
#render :json => {:orgs => @orgs_not_in_course, :count => @org_count}.to_json
@ -399,6 +402,25 @@ class CoursesController < ApplicationController
end
def private_or_public
if @course.is_public == 0
@course.update_attributes(:is_public => 1)
else
@course.update_attributes(:is_public => 0)
end
if @course.is_public == 0
course_status = CourseStatus.find_by_course_id(@course.id)
course_status.destroy if course_status
elsif @course.is_public == 1
course_status = CourseStatus.find_by_course_id(@course.id)
course_status.destroy if course_status
course_status = CourseStatus.create(:course_id => @course.id, :grade => 0)
end
respond_to do |format|
format.js
end
end
def search_member
if User.current.allowed_to?(:as_teacher,@course) || User.current.admin
q = "#{params[:name].strip}"
@ -417,6 +439,73 @@ class CoursesController < ApplicationController
def create
cs = CoursesService.new
@course = cs.create_course(params,User.current)[:course]
if params[:copy_course]
copy_course = Course.find params[:copy_course].to_i
@course.update_attributes(:open_student => copy_course.open_student, :publish_resource => copy_course.publish_resource)
if params[:checkAll]
attachments = copy_course.attachments
attachments.each do |attachment|
attach_copied_obj = attachment.copy
attach_copied_obj.tag_list.add(attachment.tag_list) # tag关联
attach_copied_obj.container = @course
attach_copied_obj.created_on = Time.now
attach_copied_obj.author_id = User.current.id
attach_copied_obj.copy_from = attachment.copy_from.nil? ? attachment.id : attachment.copy_from
if attach_copied_obj.attachtype == nil
attach_copied_obj.attachtype = 4
end
attach_copied_obj.save
update_quotes attach_copied_obj
end
elsif params[:course_attachment_type]
copy_attachments = []
params[:course_attachment_type].each do |type|
case type
when "1"
tag_name = l(:label_courseware)
when "2"
tag_name = l(:label_software)
when "3"
tag_name = l(:label_media)
when "4"
tag_name = l(:label_code)
when "6"
tag_name = "论文"
else
tag_name = ""
end
if tag_name == ""
tag_attachments = copy_course.attachments.select{|attachment|
!attachment.tag_list.include?('课件') &&
!attachment.tag_list.include?('软件') &&
!attachment.tag_list.include?('媒体') &&
!attachment.tag_list.include?('代码') &&
!attachment.tag_list.include?('论文') }
else
tag_attachments = copy_course.attachments.select{|attachment| attachment.tag_list.include?(tag_name)}
end
tag_attachments.each do |attach|
next if copy_attachments.include?(attach)
copy_attachments << attach
end
end
unless copy_attachments.blank?
copy_attachments.each do |c_attach|
attach_copied_obj = c_attach.copy
attach_copied_obj.tag_list.add(c_attach.tag_list) # tag关联
attach_copied_obj.container = @course
attach_copied_obj.created_on = Time.now
attach_copied_obj.author_id = User.current.id
attach_copied_obj.copy_from = c_attach.copy_from.nil? ? c_attach.id : c_attach.copy_from
if attach_copied_obj.attachtype == nil
attach_copied_obj.attachtype = 4
end
attach_copied_obj.save
update_quotes attach_copied_obj
end
end
end
end
if @course
respond_to do |format|
flash[:notice] = l(:notice_successful_create)
@ -732,6 +821,11 @@ class CoursesController < ApplicationController
#param id:已有课程ID
def copy_course
if @course
@new_course = Course.new
respond_to do |format|
format.js
end
=begin
@new_course = Course.new @course.attributes
@new_course.tea_id = User.current.id
@new_course.created_at = DateTime.now
@ -750,6 +844,7 @@ class CoursesController < ApplicationController
@new_course.course_infos << course
redirect_to settings_course_url @new_course
end
=end
else
render_404
end
@ -810,6 +905,33 @@ class CoursesController < ApplicationController
end
private
def update_quotes attachment
if attachment.copy_from
attachments = Attachment.find_by_sql("select * from attachments where copy_from = #{attachment.copy_from} or id = #{attachment.copy_from}")
else
attachments = Attachment.find_by_sql("select * from attachments where copy_from = #{attachment.id} or id = #{attachment.copy_from}")
end
attachment.quotes = get_qute_number attachment
attachment.save
attachments.each do |att|
att.quotes = attachment.quotes
att.save
end
end
def get_qute_number attachment
if attachment.copy_from
result = Attachment.find_by_sql("select count(*) as number from attachments where copy_from = #{attachment.copy_from}")
else
result = Attachment.find_by_sql("select count(*) as number from attachments where copy_from = #{attachment.id}")
end
if result.nil? || result.count <= 0
return 0
else
return result[0].number
end
end
def allow_join course
if course_endTime_timeout? course
respond_to do |format|

File diff suppressed because it is too large Load Diff

View File

@ -24,7 +24,10 @@ class FilesController < ApplicationController
before_filter :auth_login1, :only => [:index]
before_filter :logged_user_by_apptoken,:only => [:index]
before_filter :find_project_by_project_id#, :except => [:getattachtype]
before_filter :authorize, :except => [:create,:getattachtype,:quote_resource_show,:search,:searchone4reload,:search_project,:quote_resource_show_project,:search_tag_attachment,:subfield_upload_file,:search_org_subfield_tag_attachment,:search_tag_attachment,:quote_resource_show_org_subfield,:find_org_subfield_attache,:search_files_in_subfield]
before_filter :authorize, :except => [:create,:getattachtype,:quote_resource_show,:search,:searchone4reload,:search_project,:quote_resource_show_project,
:search_tag_attachment,:subfield_upload_file,:search_org_subfield_tag_attachment,
:search_tag_attachment,:quote_resource_show_org_subfield,:find_org_subfield_attache,
:search_files_in_subfield,:upload_files_menu]
helper :sort
include SortHelper
@ -99,6 +102,7 @@ class FilesController < ApplicationController
@sort = ""
@order = ""
@is_remote = true
@q = params[:name].strip
if params[:sort]
order_by = params[:sort].split(":")
@sort = order_by[0]
@ -107,24 +111,25 @@ class FilesController < ApplicationController
end
sort = "#{@sort} #{@order}"
end
# show_attachments [@course]
begin
q = "%#{params[:name].strip}%"
#(redirect_to stores_url, :notice => l(:label_sumbit_empty);return) if params[:name].blank?
if params[:insite]
if q == "%%"
@result = []
@searched_attach = paginateHelper @result,10
@project_attachment_result = []
@searched_attach = paginateHelper @project_attachment_result, 10
else
@result = find_public_attache q,sort
@result = visable_attachemnts_insite @result,@project
@searched_attach = paginateHelper @result,10
@project_attachment_result = find_public_attache q,sort
@project_attachment_result = visable_attachemnts_insite @project_attachment_result, @project
@searched_attach = paginateHelper @project_attachment_result, 10
end
else
@result = find_project_attache q,@project,sort
@result = visable_attachemnts @result
@searched_attach = paginateHelper @result,10
@project_attachment_result = find_project_attache q, @project,sort
@project_attachment_result = visable_attachemnts @project_attachment_result
@searched_attach = paginateHelper @project_attachment_result,10
@tag_list = get_project_tag_list @project
end
#rescue Exception => e
# #render 'stores'
# redirect_to search_course_files_url
@ -200,23 +205,10 @@ class FilesController < ApplicationController
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
if ids.blank?
resultSet = Attachment.where("attachments.container_type = 'Project' And attachments.container_id = '#{project.id}' AND filename LIKE :like ", like: "%#{keywords}%").
reorder(sort)
if keywords != "%%"
resultSet = Attachment.where("attachments.container_type = 'Project' And attachments.container_id = '#{project.id}' AND filename LIKE :like ", like: "%#{keywords}%").reorder(sort)
else
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.where("attachments.container_type = 'Project' And attachments.container_id = '#{project.id}' "). reorder(sort)
end
end
@ -238,12 +230,11 @@ class FilesController < ApplicationController
@order = ""
@is_remote = false
if params[:project_id]
@page = params[:page] ? params[:page].to_i + 1 : 2
@container_type = 0
if params[:sort]
params[:sort].split(",").each do |sort_type|
order_by = sort_type.split(":")
case order_by[0]
when "filename"
attribute = "filename"
@ -281,25 +272,19 @@ class FilesController < ApplicationController
else
sort = "#{Attachment.table_name}.created_on desc"
end
# @containers = [ Project.includes(:attachments).find(@project.id)]
# @containers += @project.versions.includes(:attachments).all
@containers = [ Project.includes(:attachments).find(@project.id)]
@containers += @project.versions.includes(:attachments).all
ids = []
@containers.each do |c|
ids += c.attachments.pluck(:id)
end
@containers = [Struct.new(:attachments).new(Attachment.where('id in (?)',ids).reorder(sort))]
@containers = [ Project.includes(:attachments).reorder(sort).find(@project.id)]
show_attachments @containers
respond_to do |format|
format.html
format.js
end
@tag_list = attachment_tag_list @all_attachments
render :layout => 'base_projects'
elsif params[:course_id]
@container_type = 1
@page = params[:page] ? params[:page].to_i + 1 : 2
if params[:sort]
params[:sort].split(",").each do |sort_type|
order_by = sort_type.split(":")
@ -440,16 +425,35 @@ class FilesController < ApplicationController
if @project
@addTag=false
if params[:in_project_toolbar]
@in_project_toolbar = params[:in_project_toolbar]
@in_project_toolbar = params[:in_project_toolbar]
end
container = (params[:version_id].blank? ? @project : @project.versions.find_by_id(params[:version_id]))
attachments = Attachment.attach_filesex(container, params[:attachments], params[:attachment_type])
render_attachment_warning_if_needed(container)
# 发送邮件
attachments = Attachment.attach_filesex(@project, params[:attachments], params[:attachment_type])
if !attachments.empty? && !attachments[:files].blank? && Setting.notified_events.include?('file_added')
Mailer.run.attachments_added(attachments[:files])
end
# end
if params[:project_attachment_type] && params[:project_attachment_type].is_a?(Array)
params[:project_attachment_type].each do |type|
tag_name = get_project_tag_name_by_type_nmuber type
if !attachments.empty? && attachments[:files] && tag_name != ""
attachments[:files].each do |attachment|
attachment.tag_list.add(tag_name)
attachment.save
end
end
end
else
if params[:project_attachment_type] && params[:project_attachment_type] != "6"
tag_name = get_project_tag_name_by_type_nmuber params[:project_attachment_type]
if !attachments.empty? && attachments[:files] && tag_name != ""
attachments[:files].each do |attachment|
attachment.tag_list.add(tag_name)
attachment.save
end
end
end
end
# TODO: 临时用 nyan
sort_init 'created_on', 'desc'
sort_update 'created_on' => "#{Attachment.table_name}.created_on",
@ -457,14 +461,11 @@ class FilesController < ApplicationController
'size' => "#{Attachment.table_name}.filesize",
'downloads' => "#{Attachment.table_name}.downloads"
@containers = [Project.includes(:attachments).reorder("#{Attachment.table_name}.created_on DESC").find(@project.id)] #modify by Long Jun
@containers += @project.versions.includes(:attachments).reorder("#{Attachment.table_name}.created_on DESC").all.sort
@containers = [Project.includes(:attachments).reorder("#{Attachment.table_name}.created_on DESC").find(@project.id)]
show_attachments @containers
@tag_list = attachment_tag_list @all_attachments
@attachtype = 0
@contenttype = 0
respond_to do |format|
format.js
format.html {
@ -592,6 +593,25 @@ class FilesController < ApplicationController
end
end
def get_project_tag_name_by_type_nmuber type
case type
when "1"
tag_name = "软件版本"
when "2"
tag_name = "文档"
when "3"
tag_name = "代码"
when "4"
tag_name = "媒体"
when "5"
tag_name = "论文"
when "6"
tag_name = "其它"
else
tag_name = ""
end
end
def get_tag_name_by_type_number type
case type
when "1"
@ -743,12 +763,33 @@ class FilesController < ApplicationController
end
q = "%#{@q.strip}%"
@result = find_course_attache q,@course,sort
if @project
@result = find_project_attache q, @project,sort
else
@result = find_course_attache q,@course,sort
end
@result = visable_attachemnts @result
@result = @result.select{|attachment| attachment.tag_list.include?(@tag_name)} unless @tag_name.blank?
if params[:other]
if @project
@result = @result.select{|attachment| !attachment.tag_list.include?('软件版本') && !attachment.tag_list.include?('文档') && !attachment.tag_list.include?('代码') && !attachment.tag_list.include?('媒体') && !attachment.tag_list.include?('论文') }
else
@result = @result.select{|attachment|
!attachment.tag_list.include?('课件') &&
!attachment.tag_list.include?('软件') &&
!attachment.tag_list.include?('媒体') &&
!attachment.tag_list.include?('代码') &&
!attachment.tag_list.include?('论文') }
end
else
@result = @result.select{|attachment| attachment.tag_list.include?(@tag_name)} unless @tag_name.blank?
end
@searched_attach = paginateHelper @result,10
@tag_list = get_course_tag_list @course
if @project
@tag_list = get_project_tag_list @project
@result_search_project = @result
else
@tag_list = get_course_tag_list @course
end
respond_to do |format|
format.js
# format.html
@ -784,4 +825,8 @@ class FilesController < ApplicationController
def subfield_upload_file
@org_subfield = OrgSubfield.find(params[:org_subfield_id])
end
def upload_files_menu
end
end

View File

@ -63,6 +63,7 @@ class HomeworkCommonController < ApplicationController
end
@homework.end_time = params[:homework_common][:end_time] || Time.now
@homework.course_id = params[:course_id]
@homework.anonymous_comment = params[:homework_common][:anonymous_comment] ? params[:homework_common][:anonymous_comment] : 0
homework_detail_manual = @homework.homework_detail_manual || HomeworkDetailManual.new
if @homework.publish_time <= Date.today && homework_detail_manual.comment_status == 0

View File

@ -81,10 +81,11 @@ class IssuesController < ApplicationController
@status_id = params[:status_id]
@subject = params[:subject]
@issue_count = @query.issue_count
@issue_pages = Paginator.new @issue_count, @limit, params['page'].to_i + 1
@issue_pages = Paginator.new @issue_count, @limit, params['page']
params[:page] = (params[:page] || 1).to_i + 1 #页码需要加1
@offset ||= @issue_pages.offset
@issues = @query.issues(:include => [:assigned_to, :tracker, :priority, :category, :fixed_version],
:order => sort_clause,
:order => 'issues.updated_on desc',
:offset => @offset,
:limit => @limit)
if params[:set_filter]
@ -136,6 +137,7 @@ class IssuesController < ApplicationController
end
end
# end
@jour_reply = Journal.new
@journals = @issue.journals.includes(:user, :details).reorder("#{Journal.table_name}.id ASC").all
@journals.each_with_index {|j,i| j.indice = i+1}
@journals.reject!(&:private_notes?) unless User.current.allowed_to?(:view_private_notes, @issue.project)
@ -152,6 +154,7 @@ class IssuesController < ApplicationController
@project_base_tag = (params[:project_id] || @issue.project) ? 'base_projects':'base'#by young
@available_watchers = (@issue.project.users.sort + @issue.watcher_users).uniq
@journal = Journal.new(:journalized => @issue)
respond_to do |format|
format.html {
@ -400,14 +403,16 @@ class IssuesController < ApplicationController
jour.user_id = User.current.id
jour.notes = params[:notes]
jour.journalized = @issue
jour.save_attachments(params[:attachments])
jour.save
user_activity = UserActivity.where("act_type='Issue' and act_id =#{@issue.id}").first
user_activity.updated_at = jour.created_on
user_activity.save
update_user_activity(@issue.class,@issue.id)
update_forge_activity(@issue.class,@issue.id)
@user_activity_id = params[:user_activity_id]
if params[:issue_id]
@issue_id = params[:issue_id]
end
@priorities = IssuePriority.active
respond_to do |format|
format.js
end
@ -450,9 +455,9 @@ class IssuesController < ApplicationController
@issue = Issue.find params[:id]
jour.journalized = @issue
jour.save
user_activity = UserActivity.where("act_type='Issue' and act_id =#{@issue.id}").first
user_activity.updated_at = jour.created_on
user_activity.save
update_user_activity(@issue.class,@issue.id)
update_forge_activity(@issue.class,@issue.id)
respond_to do |format|
format.js
end

View File

@ -22,8 +22,8 @@ class MessagesController < ApplicationController
default_search_scope :messages
before_filter :find_board, :only => [:new, :preview,:edit]
before_filter :find_attachments, :only => [:preview]
before_filter :find_message, :except => [:new, :preview]
before_filter :authorize, :except => [:preview, :edit, :destroy, :new]
before_filter :find_message, :except => [:new, :preview, :join_org_subfield, :get_subfield_on_click_org, :join_org_subfields]
before_filter :authorize, :except => [:preview, :edit, :destroy, :new,:join_org_subfield, :get_subfield_on_click_org, :join_org_subfields]
helper :boards
helper :watchers
@ -75,7 +75,7 @@ class MessagesController < ApplicationController
@replies = paginateHelper messages_replies,10
@reply = Message.new(:subject => "RE: #{@message.subject}")
render :action => "show", :layout => "base_courses"#by young
else
elsif @project
@reply_pages = Paginator.new @reply_count, REPLIES_PER_PAGE, page
@replies = @topic.children.
includes(:author, :attachments, {:board => :project}).
@ -86,6 +86,18 @@ class MessagesController < ApplicationController
@reply = Message.new(:subject => "RE: #{@message.subject}")
render :action => "show", :layout => "base_projects"#by young
else
@reply_pages = Paginator.new @reply_count, REPLIES_PER_PAGE, page
@replies = @topic.children.
includes(:author, :attachments, {:board => :project}).
reorder("#{Message.table_name}.created_on DESC").
limit(@reply_pages.per_page).
offset(@reply_pages.offset).
all
@reply = Message.new(:subject => "RE: #{@message.subject}")
@organization = @org_subfield.organization
render :action => "show", :layout => "base_org"#by young
end
end
@ -164,26 +176,11 @@ class MessagesController < ApplicationController
@reply.subject = "RE: #{@topic.subject}" unless params[:reply][:subject]
# @reply.reply_id = params[:id]
@topic.children << @reply
course_activity = CourseActivity.where("course_act_type='Message' and course_act_id =#{@topic.id}").first
if course_activity
course_activity.updated_at = Time.now
course_activity.save
end
forge_activity = ForgeActivity.where("forge_act_type='Message' and forge_act_id=#{@topic.id}").first
if forge_activity
forge_activity.updated_at = Time.now
forge_activity.save
end
user_activity = UserActivity.where("act_type='Message' and act_id =#{@topic.id}").first
if user_activity
user_activity.updated_at = Time.now
user_activity.save
end
org_activity = OrgActivity.where("org_act_type='Message' and org_act_id =#{@topic.id}").first
if org_activity
org_activity.updated_at = Time.now
org_activity.save
end
update_course_activity(@topic.class,@topic.id)
update_user_activity(@topic.class,@topic.id)
update_forge_activity(@topic.class,@topic.id)
update_org_activity(@topic.class,@topic.id)
#@topic.update_attribute(:updated_on, Time.now)
if !@reply.new_record?
if params[:asset_id]
@ -199,6 +196,8 @@ class MessagesController < ApplicationController
end
if params[:user_activity_id]
@user_activity_id = params[:user_activity_id]
@is_course = params[:is_course]
@is_board = params[:is_board]
respond_to do |format|
format.js
end
@ -219,17 +218,27 @@ class MessagesController < ApplicationController
@isReply = false
if @project
(render_403; return false) unless @message.editable_by?(User.current)
else
elsif @course
(render_403; return false) unless @message.course_editable_by?(User.current)
else
(render_403; return false) unless @message.org_subfield_editable_by?(User.current)
end
@message.safe_attributes = params[:message]
if request.post? && @message.save
attachments = Attachment.attach_files(@message, params[:attachments])
render_attachment_warning_if_needed(@message)
flash[:notice] = l(:notice_successful_update)
#flash[:notice] = l(:notice_successful_update)
@message.reload
if params[:is_board]
if params[:is_course] && params[:is_course].to_i == 0
redirect_to user_activities_path(User.current.id)
elsif params[:is_course] && params[:is_course].to_i == 1 && params[:is_board] && params[:is_board].to_i == 0
if @project
redirect_to project_path(@project)
elsif @course
redirect_to course_activity_path(@course)
end
elsif params[:is_course] && params[:is_course].to_i == 1 && params[:is_board] && params[:is_board].to_i == 1
if @project
redirect_to project_boards_path(@project)
elsif @course
@ -239,19 +248,22 @@ class MessagesController < ApplicationController
redirect_to board_message_url(@message.board, @message.root, :r => (@message.parent_id && @message.id))
end
elsif request.get? || request.post?
if params[:is_board]
if @project
redirect_to project_boards_path(@project)
elsif @course
redirect_to course_boards_path(@course)
end
else
respond_to do |format|
format.html {
layout_file = @project ? 'base_projects' : 'base_courses'
render :layout => layout_file
}
end
if params[:is_course] && params[:is_board]
@is_course = params[:is_course]
@is_board = params[:is_board]
end
respond_to do |format|
format.html {
if @project
layout_file = 'base_projects'
elsif @course
layout_file = 'base_courses'
elsif @org_subfield
@organization = @org_subfield.organization
layout_file = 'base_org'
end
render :layout => layout_file
}
end
end
end
@ -260,26 +272,46 @@ class MessagesController < ApplicationController
def destroy
if @project
(render_403; return false) unless @message.destroyable_by?(User.current)
else
elsif @course
(render_403; return false) unless @message.course_destroyable_by?(User.current)
else
(render_403; return false) unless @message.org_subfield_editable_by?(User.current)
end
r = @message.to_param
@message.destroy
# modify by nwb
if @project
if params[:is_board]
redirect_to project_boards_url(@project)
if params[:is_course] && params[:is_course].to_i == 0
redirect_to user_activities_path(User.current.id)
elsif params[:is_course] && params[:is_course].to_i == 1 && params[:is_board] && params[:is_board].to_i == 0
redirect_to project_path(@project)
elsif params[:is_course] && params[:is_course].to_i == 1 && params[:is_board] && params[:is_board].to_i == 1
redirect_to project_boards_path(@project)
elsif @message.parent
redirect_to board_message_url(@board, @message.parent, :r => r)
else
redirect_to board_message_url(@board, @topic, :r => @reply)
redirect_to project_board_url(@project, @board)
end
elsif @course
if params[:is_course] && params[:is_course].to_i == 0
redirect_to user_activities_path(User.current.id)
elsif params[:is_course] && params[:is_course].to_i == 1 && params[:is_board] && params[:is_board].to_i == 0
redirect_to course_activity_path(@course)
elsif params[:is_course] && params[:is_course].to_i == 1 && params[:is_board] && params[:is_board].to_i == 1
redirect_to course_boards_path(@course)
elsif @message.parent
redirect_to board_message_url(@board, @message.parent, :r => r)
else
redirect_to course_boards_path(@course)
end
elsif @org_subfield
if params[:is_board]
redirect_to course_boards_url(@course)
redirect_to organization_path(:id => @org_subfield.organization_id, :org_subfield_id => @org_subfield.id)
else
if @message.parent
redirect_to board_message_url(@board, @message.parent, :r => r)
else
redirect_to course_board_url(@course, @board)
redirect_to organization_path(:id => @org_subfield.organization_id, :org_subfield_id => @org_subfield.id)
end
end
end
@ -301,6 +333,41 @@ class MessagesController < ApplicationController
render :partial => 'common/preview'
end
def join_org_subfield
@message = Message.find(params[:message_id])
@organizations = User.current.organizations
end
def get_subfield_on_click_org
@org = Organization.find(params[:organization_id])
end
def join_org_subfields
org_subfield_ids = params[:org_subfields]
@message = Message.find(params[:id])
# @message.update_attribute(:updated_on, Time.now)
# type = @message.board.course_id.nil? ? "Project":"Course"
org_subfield_ids.each do |field_id|
@message.quotes = @message.quotes.nil? ? 1 : (@message.quotes + 1)
@message.save
board = OrgSubfield.find(field_id).boards.first
mes = Message.create(:board_id => board.id, :subject => @message.subject, :content => @message.content, :author_id => User.current.id,
:created_on => Time.now, :updated_on => Time.now, :locked => @message.locked, :sticky => @message.sticky)
@message.attachments.each do |attach|
mes.attachments << Attachment.new(:filename => attach.filename, :disk_filename => attach.disk_filename, :filesize => attach.filesize, :content_type => attach.content_type, :digest => attach.digest,
:downloads => 0, :author_id => User.current.id, :created_on => Time.now, :description => attach.description, :disk_directory => attach.disk_directory, :attachtype => attach.attachtype,
:is_public => attach.is_public, :quotes => 0)
end
# OrgSubfieldMessage.create(:org_subfield_id => field_id.to_i, :message_id => mes.id, :message_type => type)
# org_acts = OrgActivity.where("container_type='OrgSubfield' and container_id=? and org_act_type='Message' and org_act_id=?", field_id.to_i, @message.id)
# if org_acts.all.size() > 0
# org_acts.first.update_attribute(:updated_at, Time.now)
# else
OrgActivity.create(:container_type => 'OrgSubfield', :container_id => field_id.to_i, :org_act_type=>'Message', :org_act_id => mes.id, :user_id => User.current.id)
# end
end
end
private
def find_message
return unless find_board
@ -317,6 +384,9 @@ class MessagesController < ApplicationController
@project = @board.project
elsif @board.course_id
@course = @board.course
else
@org_subfield = @board.org_subfield
@organization = @org_subfield
end
rescue ActiveRecord::RecordNotFound

View File

@ -1,16 +1,18 @@
class OrgDocumentCommentsController < ApplicationController
before_filter :find_organization, :only => [:new, :create, :show, :index]
helper :attachments
layout 'base_org'
def new
@org_document_comment = OrgDocumentComment.new
end
def create
@org_document_comment = OrgDocumentComment.new(:organization_id => @organization.id, :creator_id => User.current.id)
@org_document_comment.title = params[:org_document_comment][:title]
@org_document_comment.content = params[:org_document_comment][:content]
@org_document_comment.save_attachments(params[:attachments])
if params[:field_id]
@org_document_comment.org_subfield_id = params[:field_id].to_i
end
@ -26,6 +28,7 @@ class OrgDocumentCommentsController < ApplicationController
redirect_to new_org_document_comment_path(:organization_id => @organization.id)
end
end
def show
@document = OrgDocumentComment.find(params[:id])
end
@ -37,9 +40,12 @@ class OrgDocumentCommentsController < ApplicationController
render_403
end
end
def update
@org_document = OrgDocumentComment.find(params[:id])
@org_document.update_attributes(:title => params[:org_document_comment][:title], :content => params[:org_document_comment][:content])
Attachment.attach_files(@org_document, params[:attachments])
# @org_document.save_attachments(params[:attachments])
if @org_document.parent.nil?
act = OrgActivity.where("org_act_type='OrgDocumentComment' and org_act_id =?", @org_document.id).first
act.update_attributes(:updated_at => @org_document.updated_at)

View File

@ -1,24 +1,32 @@
class OrgSubfieldsController < ApplicationController
def create
@subfield = OrgSubfield.create(:name => params[:name])
@organization = Organization.find(params[:organization_id])
@organization.org_subfields << @subfield
@subfield.update_attributes(:priority => @subfield.id, :field_type => params[:field_type])
end
def destroy
@subfield = OrgSubfield.find(params[:id])
@organization = Organization.find(@subfield.organization_id)
@subfield.destroy
end
def update
@subfield = OrgSubfield.find(params[:id])
@organization = Organization.find(@subfield.organization_id)
@subfield.update_attributes(:name => params[:name])
end
def show
end
end
class OrgSubfieldsController < ApplicationController
def create
@subfield = OrgSubfield.create(:name => params[:name])
@organization = Organization.find(params[:organization_id])
@organization.org_subfields << @subfield
@subfield.update_attributes(:priority => @subfield.id, :field_type => params[:field_type])
end
def show
@org_subfield = OrgSubfield.find(params[:id])
@organization = @org_subfield.organization.id
@messages = []
@messages << @org_subfield.org_document_comments
@messages << @org_subfield.messages
@messages.sort{|a, b| b.updated_at <=> a.updated_at}
respond_to do |format|
format.html{render :layout => 'base_org'}
end
end
def destroy
@subfield = OrgSubfield.find(params[:id])
@organization = Organization.find(@subfield.organization_id)
@subfield.destroy
end
def update
@subfield = OrgSubfield.find(params[:id])
@organization = Organization.find(@subfield.organization_id)
@subfield.update_attributes(:name => params[:name])
end
end

View File

@ -1,284 +1,319 @@
# encoding: utf-8
class OrganizationsController < ApplicationController
helper :sort
include SortHelper
helper :custom_fields
include CustomFieldsHelper
include AvatarHelper
include WordsHelper
include GitlabHelper
include UserScoreHelper
include PollHelper
helper :user_score
helper :journals
# added by liuping 关注
helper :watchers
helper :activities
### added by william
include ActsAsTaggableOn::TagsHelper
# fq
helper :words
helper :project_score
helper :issues
include UsersHelper
before_filter :find_organization, :only => [:show, :members]
layout 'base_org'
def index
end
def new
@organization = Organization.new
render :layout => 'new_base'
end
def edit
@organization = Organization.find(params[:id])
end
def destroy
@organization = Organization.find(params[:id])
@organization.destroy
respond_to do |format|
format.html{ redirect_to admin_organization_path }
end
end
def create
@organization = Organization.new
@organization.name = params[:organization][:name]
@organization.description = params[:organization][:description]
@organization.is_public = params[:organization][:is_public]
@organization.creator_id = User.current.id
member = OrgMember.new(:user_id => User.current.id)
@organization.org_members << member
if @organization.save
OrgMemberRole.create(:org_member_id => member.id, :role_id => 11)
redirect_to organization_path(@organization)
end
end
def show
if @organization.is_public? || User.current.admin? || User.current.member_of_org?(@organization)
@organization = Organization.find(params[:id])
if params[:org_subfield_id]
@org_subfield = OrgSubfield.find(params[:org_subfield_id])
@org_subfield_ids = @org_subfield.org_document_comments.map(&:id) << 0
@org_activities = OrgActivity.where("org_act_type='OrgDocumentComment'and org_act_id in (#{@org_subfield_ids.join(",")})").order('updated_at desc').page(params[:page] || 1).per(10)
else
project_ids = @organization.projects.map(&:id) << 0
course_ids = @organization.courses.map(&:id) << 0
course_types = "('Message','News','HomeworkCommon','Poll','Course')"
case params[:type]
when nil
@org_activities = OrgActivity.where("(container_id =? and container_type =?) " +
"or (container_type ='Project' and org_act_type in ('Issue','Message','ProjectCreateInfo') and container_id in (#{project_ids.join(',')})) "+
"or (container_type ='Course' and org_act_type in #{course_types} and container_id in (#{course_ids.join(',')}))",
@organization.id, 'Organization').order('updated_at desc').page(params[:page] || 1).per(10)
when 'project_issue'
@org_activities = OrgActivity.where("container_type = 'Project' and org_act_type = 'Issue' and container_id in (#{project_ids.join(',')})").order('updated_at desc').page(params[:page] || 1).per(10)
when 'project_message'
@org_activities = OrgActivity.where("container_type = 'Project' and org_act_type = 'Message' and container_id in (#{project_ids.join(',')})").order('updated_at desc').page(params[:page] || 1).per(10)
when 'org'
@org_activities = OrgActivity.where("container_id =? and container_type =?",@organization.id, 'Organization').order('updated_at desc').page(params[:page] || 1).per(10)
when 'course_homework'
@org_activities = OrgActivity.where("container_type = 'Course' and org_act_type = 'HomeworkCommon' and container_id in (#{course_ids.join(',')})").order('updated_at desc').page(params[:page] || 1).per(10)
when 'course_news'
@org_activities = OrgActivity.where("container_type = 'Course' and org_act_type = 'News' and container_id in (#{course_ids.join(',')})").order('updated_at desc').page(params[:page] || 1).per(10)
when 'course_message'
@org_activities = OrgActivity.where("container_type = 'Course' and org_act_type = 'Message' and container_id in (#{course_ids.join(',')})").order('updated_at desc').page(params[:page] || 1).per(10)
when 'course_poll'
@org_activities = OrgActivity.where("container_type = 'Course' and org_act_type = 'Poll' and container_id in (#{course_ids.join(',')})").order('updated_at desc').page(params[:page] || 1).per(10)
end
end
@page = params[:page] || 1
respond_to do |format|
format.html
format.js
end
else
render_403
end
end
def update
@organization = Organization.find(params[:id])
@organization.name = params[:organization][:name]
@organization.description = params[:organization][:description]
@organization.domain = params[:organization][:domain]
@organization.is_public = params[:organization][:is_public] == 'on' ? 1 : 0
#@organization.name = params[:organization][:name]
@organization.save
respond_to do |format|
format.html { redirect_to setting_organization_path(@organization)}
end
end
def check_uniq
@check = false;
@org_name = params[:org_name].strip
@config_page = params[:config_page]
sameName = @config_page ? Organization.where('name = ? and id != ?',params[:org_name],params[:org_id].to_i).count == 0 : Organization.where('name = ?',params[:org_name]).count == 0
if sameName == true
@check = true
end
respond_to do |format|
format.js
end
end
def find_organization
@organization = Organization.find(params[:id])
end
def setting
@organization = Organization.find(params[:id])
if User.current.admin? || User.current.admin_of_org?(@organization)
else
render_403
end
end
def clear_org_avatar_temp
end
def set_homepage
@org = Organization.find(params[:id])
@org.home_id = params[:home_id]
@org.save
# respond_to do |format|
# format.html {redirect_to organization_path(org)}
# end
end
def cancel_homepage
@org = Organization.find(params[:id])
@org.home_id = nil
@org.save
end
def autocomplete_search
@project = Project.find(params[:project_id])
#@flag = params[:flag] || false
respond_to do |format|
format.js
end
end
def members
if @organization.is_public? || User.current.admin? || User.current.member_of_org?(@organization)
@members = OrgMember.where("organization_id =?", @organization.id)
else
render_403
end
end
def more_org_projects
@organization = Organization.find params[:id]
@page = params[:page]
@org_projects = @organization.projects.reorder('created_at').uniq.page((params[:page].to_i || 1) +1).per(5)
respond_to do |format|
format.js
end
end
def more_org_courses
@organization = Organization.find(params[:id])
@page = params[:page]
@org_courses = @organization.courses.reorder('created_at').uniq.page((params[:page].to_i || 1) + 1 ).per(5)
respond_to do |format|
format.js
end
end
def join_course_menu
@organization = Organization.find(params[:id])
respond_to do |format|
format.js
end
end
def search_courses
@organization = Organization.find(params[:id])
condition = '%%'
if !params[:name].nil?
condition = "%#{params[:name].strip}%".gsub(" ","")
end
sql = "select courses.* from courses inner join members on courses.id = members.course_id where members.user_id = #{User.current.id} and courses.name like '#{condition}'"+
"and courses.id not in (select distinct org_courses.course_id from org_courses where org_courses.organization_id = #{@organization.id})"
#user_courses = Course.find_by_sql(sql)
@courses = Course.find_by_sql(sql)
# @added_course_ids = @organization.courses.map(&:id)
# @courses = []
# user_courses.each do |course|
# if !@added_course_ids.include?(course.id)
# @courses << course
# end
# end
end
def join_courses
@organization = Organization.find(params[:id])
course_ids = params[:courseNames]
course_ids.each do |id|
OrgCourse.create(:organization_id => @organization.id, :course_id => id.to_i, :created_at => Time.now)
end
respond_to do |format|
format.js
end
end
def join_project_menu
@organization = Organization.find(params[:id])
respond_to do |format|
format.js
end
end
def logout
logout_user
respond_to do |format|
format.html {redirect_to organization_path(params[:id])}
end
end
def search_projects
@organization = Organization.find(params[:id])
condition = '%%'
if !params[:name].nil?
condition = "%#{params[:name].strip}%".gsub(" ","")
end
sql = "select projects.* from projects inner join members on projects.id = members.project_id where members.user_id = #{User.current.id} and projects.status != 9 and projects.name like '#{condition}'" +
" and projects.id not in (select org_projects.project_id from org_projects where organization_id = #{@organization.id})"
#user_projects = Course.find_by_sql(sql)
@projects = Course.find_by_sql(sql)
# @added_course_ids = @organization.projects.map(&:id)
# @projects = []
# user_projects.each do |project|
# if !@added_course_ids.include?(project.id)
# @projects << project
# end
# end
end
def join_projects
@organization = Organization.find(params[:id])
project_ids = params[:projectNames]
project_ids.each do |id|
OrgProject.create(:organization_id => @organization.id, :project_id => id.to_i, :created_at => Time.now)
end
respond_to do |format|
format.js
end
end
end
# encoding: utf-8
class OrganizationsController < ApplicationController
helper :sort
include SortHelper
helper :custom_fields
include CustomFieldsHelper
include AvatarHelper
include WordsHelper
include GitlabHelper
include UserScoreHelper
include PollHelper
helper :user_score
helper :journals
helper :attachments
# added by liuping 关注
helper :watchers
helper :activities
### added by william
include ActsAsTaggableOn::TagsHelper
# fq
helper :words
helper :project_score
helper :issues
include UsersHelper
before_filter :find_organization, :only => [:show, :members, :apply_subdomain]
layout 'base_org'
def index
end
def new
@organization = Organization.new
render :layout => 'new_base'
end
def edit
@organization = Organization.find(params[:id])
end
def destroy
@organization = Organization.find(params[:id])
@organization.destroy
respond_to do |format|
format.html{ redirect_to admin_organization_path }
end
end
def create
@organization = Organization.new
@organization.name = params[:organization][:name]
@organization.description = params[:organization][:description]
@organization.is_public = params[:organization][:is_public]
@organization.creator_id = User.current.id
member = OrgMember.new(:user_id => User.current.id)
@organization.org_members << member
if @organization.save
OrgMemberRole.create(:org_member_id => member.id, :role_id => 11)
redirect_to organization_path(@organization)
end
end
def show
if @organization.is_public? || User.current.admin? || User.current.member_of_org?(@organization)
@organization = Organization.find(params[:id])
if params[:org_subfield_id]
@org_subfield = OrgSubfield.find(params[:org_subfield_id])
@org_subfield_ids = @org_subfield.org_document_comments.map(&:id) << 0
@org_activities = OrgActivity.where("(org_act_type='OrgDocumentComment'and org_act_id in (#{@org_subfield_ids.join(",")})) || (container_type='OrgSubfield' and container_id=#{@org_subfield.id})").order('updated_at desc').page(params[:page] || 1).per(10)
else
shield_project_ids = ShieldActivity.where("container_type='Organization' and container_id=#{@organization.id} and shield_type='Project'").map(&:shield_id)
shield_course_ids = ShieldActivity.where("container_type='Organization' and container_id=#{@organization.id} and shield_type='Course'").map(&:shield_id)
project_ids = (@organization.projects.map(&:id)-shield_project_ids) << 0
course_ids = (@organization.courses.map(&:id)-shield_course_ids) << 0
course_types = "('Message','News','HomeworkCommon','Poll','Course')"
case params[:type]
when nil
@org_activities = OrgActivity.where("(container_id =? and container_type =?) " +
"or (container_type ='Project' and org_act_type in ('Issue','Message','ProjectCreateInfo') and container_id in (#{project_ids.join(',')})) "+
"or (container_type ='Course' and org_act_type in #{course_types} and container_id in (#{course_ids.join(',')}))",
@organization.id, 'Organization').order('updated_at desc').page(params[:page] || 1).per(10)
when 'project_issue'
@org_activities = OrgActivity.where("container_type = 'Project' and org_act_type = 'Issue' and container_id in (#{project_ids.join(',')})").order('updated_at desc').page(params[:page] || 1).per(10)
when 'project_message'
@org_activities = OrgActivity.where("container_type = 'Project' and org_act_type = 'Message' and container_id in (#{project_ids.join(',')})").order('updated_at desc').page(params[:page] || 1).per(10)
when 'org'
@org_activities = OrgActivity.where("container_id =? and container_type =?",@organization.id, 'Organization').order('updated_at desc').page(params[:page] || 1).per(10)
when 'course_homework'
@org_activities = OrgActivity.where("container_type = 'Course' and org_act_type = 'HomeworkCommon' and container_id in (#{course_ids.join(',')})").order('updated_at desc').page(params[:page] || 1).per(10)
when 'course_news'
@org_activities = OrgActivity.where("container_type = 'Course' and org_act_type = 'News' and container_id in (#{course_ids.join(',')})").order('updated_at desc').page(params[:page] || 1).per(10)
when 'course_message'
@org_activities = OrgActivity.where("container_type = 'Course' and org_act_type = 'Message' and container_id in (#{course_ids.join(',')})").order('updated_at desc').page(params[:page] || 1).per(10)
when 'course_poll'
@org_activities = OrgActivity.where("container_type = 'Course' and org_act_type = 'Poll' and container_id in (#{course_ids.join(',')})").order('updated_at desc').page(params[:page] || 1).per(10)
end
end
@page = params[:page] ? params[:page].to_i : 1
respond_to do |format|
format.html
format.js
end
else
render_403
end
end
def update
@organization = Organization.find(params[:id])
@organization.name = params[:organization][:name]
@organization.description = params[:organization][:description]
@organization.domain = params[:organization][:domain]
@organization.is_public = params[:organization][:is_public] == 'on' ? 1 : 0
#@organization.name = params[:organization][:name]
@organization.save
respond_to do |format|
format.html { redirect_to setting_organization_path(@organization)}
end
end
def check_uniq
@check = false;
@org_name = params[:org_name].strip
@config_page = params[:config_page]
sameName = @config_page ? Organization.where('name = ? and id != ?',params[:org_name],params[:org_id].to_i).count == 0 : Organization.where('name = ?',params[:org_name]).count == 0
if sameName == true
@check = true
end
respond_to do |format|
format.js
end
end
def find_organization
@organization = Organization.find(params[:id])
end
def setting
@organization = Organization.find(params[:id])
if User.current.admin? || User.current.admin_of_org?(@organization)
else
render_403
end
end
def clear_org_avatar_temp
end
def set_homepage
@org = Organization.find(params[:id])
@org.home_id = params[:home_id]
@org.save
# respond_to do |format|
# format.html {redirect_to organization_path(org)}
# end
end
def cancel_homepage
@org = Organization.find(params[:id])
@org.home_id = nil
@org.save
end
def autocomplete_search
@project = Project.find(params[:project_id])
#@flag = params[:flag] || false
respond_to do |format|
format.js
end
end
def members
if @organization.is_public? || User.current.admin? || User.current.member_of_org?(@organization)
@members = OrgMember.where("organization_id =?", @organization.id)
else
render_403
end
end
def more_org_projects
@organization = Organization.find params[:id]
@page = params[:page]
@org_projects = @organization.projects.reorder('created_at').uniq.page((params[:page].to_i || 1) +1).per(5)
respond_to do |format|
format.js
end
end
def more_org_courses
@organization = Organization.find(params[:id])
@page = params[:page]
@org_courses = @organization.courses.reorder('created_at').uniq.page((params[:page].to_i || 1) + 1 ).per(5)
respond_to do |format|
format.js
end
end
def join_course_menu
@organization = Organization.find(params[:id])
respond_to do |format|
format.js
end
end
def search_courses
@organization = Organization.find(params[:id])
condition = '%%'
if !params[:name].nil?
condition = "%#{params[:name].strip}%".gsub(" ","")
end
sql = "select courses.* from courses inner join members on courses.id = members.course_id where members.user_id = #{User.current.id} and courses.name like '#{condition}'"+
"and courses.id not in (select distinct org_courses.course_id from org_courses where org_courses.organization_id = #{@organization.id})"
#user_courses = Course.find_by_sql(sql)
@courses = Course.find_by_sql(sql)
# @added_course_ids = @organization.courses.map(&:id)
# @courses = []
# user_courses.each do |course|
# if !@added_course_ids.include?(course.id)
# @courses << course
# end
# end
end
def join_courses
@organization = Organization.find(params[:id])
course_ids = params[:courseNames]
course_ids.each do |id|
OrgCourse.create(:organization_id => @organization.id, :course_id => id.to_i, :created_at => Time.now)
end
respond_to do |format|
format.js
end
end
def join_project_menu
@organization = Organization.find(params[:id])
respond_to do |format|
format.js
end
end
def logout
logout_user
respond_to do |format|
format.html {redirect_to organization_path(params[:id])}
end
end
def search_projects
@organization = Organization.find(params[:id])
condition = '%%'
if !params[:name].nil?
condition = "%#{params[:name].strip}%".gsub(" ","")
end
sql = "select projects.* from projects inner join members on projects.id = members.project_id where members.user_id = #{User.current.id} and projects.status != 9 and projects.name like '#{condition}'" +
" and projects.id not in (select org_projects.project_id from org_projects where organization_id = #{@organization.id})"
#user_projects = Course.find_by_sql(sql)
@projects = Course.find_by_sql(sql)
# @added_course_ids = @organization.projects.map(&:id)
# @projects = []
# user_projects.each do |project|
# if !@added_course_ids.include?(project.id)
# @projects << project
# end
# end
end
def join_projects
@organization = Organization.find(params[:id])
project_ids = params[:projectNames]
project_ids.each do |id|
OrgProject.create(:organization_id => @organization.id, :project_id => id.to_i, :created_at => Time.now)
end
respond_to do |format|
format.js
end
end
def hide_org_subfield
@org_subfield = OrgSubfield.find(params[:org_subfield_id])
@org_subfield.update_attribute(:hide, 1)
end
def show_org_subfield
@org_subfield = OrgSubfield.find(params[:org_subfield_id])
@org_subfield.update_attribute(:hide, 0)
end
def org_resources_subfield
@org = Organization.find(params[:id])
@subfield = @org.org_subfields.where('field_type = "Resource" ')
respond_to do | format|
format.js
end
end
def apply_subdomain
@organization = Organization.find(params[:id])
admins = User.where("admin=1")
admins.each do |admin|
OrgMessage.create(:user_id => admin.id, :organization_id => @organization.id, :message_type => 'ApplySubdomain', :message_id => @organization.id, :sender_id => User.current.id, :viewed => 0, :content => params[:domain])
end
end
def agree_apply_subdomain
@organization = Organization.find(params[:organization_id])
@organization.update_attribute(:domain, params[:org_domain])
if OrgMessage.where("message_type='AgreeApplySubdomain' and organization_id=#{@organization.id} and content=?",params[:org_domain]).count == 0
OrgMessage.create(:user_id => params[:user_id], :organization_id => @organization.id, :message_type => 'AgreeApplySubdomain', :message_id => @organization.id, :sender_id => User.current.id, :viewed => 0, :content => params[:org_domain])
end
end
end

View File

@ -5,39 +5,73 @@ class PraiseTreadController < ApplicationController
def praise_plus
@obj = nil
# @is_in_list = nil
@activity = false
if request.get?
@obj_id = params[:obj_id]
@obj_type = params[:obj_type]
@horizontal = params[:horizontal].downcase == "false" ? false:true
if !params[:user_activity_id].nil? && !params[:type].nil?
@user_activity_id = params[:user_activity_id]
@type = params[:type]
@activity = true
end
# @is_in_list = nil
@obj = find_object_by_type_and_id(@obj_type,@obj_id)
unless @obj.author_id == User.current.id
pts = PraiseTread.where("praise_tread_object_id=? and praise_tread_object_type=? and user_id=?",@obj_id,@obj_type.to_s,User.current.id)
unless pts.empty?
respond_to do |format|
format.js
end
return
end
#@horizontal = params[:horizontal].downcase == "false" ? false:true
if @obj.respond_to?("author_id")
author_id = @obj.author_id
elsif @obj.respond_to?("user_id")
author_id = @obj.user_id
end
unless author_id == User.current.id
praise_tread_plus(@obj_type,@obj_id,1)
end
respond_to do |format|
format.js
end
end
end
def praise_minus
@obj = nil
@activity = false
if request.get?
@obj = params[:obj] # 传的是对象最后变成id了
#@obj = params[:obj] # 传的是对象最后变成id了
#首先更新praise_tread 表 删除关注记录
@pt = PraiseTread.find_by_user_id_and_praise_tread_object_id_and_praise_tread_object_type(User.current.id,@obj,"user")
@pt.delete
#@pt = PraiseTread.find_by_user_id_and_praise_tread_object_id_and_praise_tread_object_type(User.current.id,@obj,"user")
@obj_id = params[:obj_id]
@obj_type = params[:obj_type]
if !params[:user_activity_id].nil? && !params[:type].nil?
@user_activity_id = params[:user_activity_id]
@type = params[:type]
@activity = true
end
@obj = find_object_by_type_and_id(@obj_type,@obj_id)
@pt = PraiseTread.where("praise_tread_object_id=? and praise_tread_object_type=? and user_id=?",@obj_id,@obj_type.to_s,User.current.id).first
if @pt.nil?
respond_to do |format|
format.js
end
return
end
@pt.delete if !@pt.nil?
#再更新praise_tread_cache表 使相应的记录减1 当为0时删除
@ptc = PraiseTreadCache.find_by_object_id(@obj)
@ptc.minus(1)
@ptc = PraiseTreadCache.where("object_id=? and object_type=?",@obj_id,@obj_type.to_s).first
@ptc.minus(1) if !@ptc.nil?
if @ptc.praise_num == 0
@ptc.delete
@ptc.delete
end
end
@obj = User.find_by_id(@obj)
#@obj = User.find_by_id(@obj)
respond_to do |format|
format.html
format.js
end
end
@ -48,7 +82,7 @@ class PraiseTreadController < ApplicationController
if request.get?
@obj_id = params[:obj_id]
@obj_type = params[:obj_type]
@horizontal = params[:horizontal].downcase == "false" ? false:true
#@horizontal = params[:horizontal].downcase == "false" ? false:true
@obj = find_object_by_type_and_id(@obj_type,@obj_id)
unless @obj.author_id == User.current.id
praise_tread_plus(@obj_type,@obj_id,0)
@ -83,6 +117,16 @@ class PraiseTreadController < ApplicationController
@obj = Memo.find_by_id(id)
when 'Message'
@obj = Message.find_by_id(id)
when 'HomeworkCommon'
@obj = HomeworkCommon.find_by_id(id)
when 'JournalsForMessage'
@obj = JournalsForMessage.find_by_id(id)
when 'News'
@obj = News.find_by_id(id)
when 'Comment'
@obj = Comment.find_by_id(id)
when 'Journal'
@obj = Journal.find_by_id(id)
end
return @obj
end
@ -106,10 +150,6 @@ class PraiseTreadController < ApplicationController
@ptc.save
@ptc.plus(flag,1)
end
respond_to do |format|
format.html
format.js
end
end
end

View File

@ -76,16 +76,17 @@ class ProjectsController < ApplicationController
condition = "%#{params[:name].strip}%".gsub(" ","")
end
limit = 15
project_org_ids = OrgProject.find_by_sql("select distinct organization_id from org_projects where project_id = #{params[:id]}").map(&:organization_id)
if project_org_ids.empty?
@orgs_not_in_project = Organization.where("(is_public or creator_id =?) = 1 and name like ?",User.current.id, condition).page((params[:page].to_i || 1)).per(limit)
@org_count = Organization.where("is_public = 1 or creator_id =?", User.current.id).where("name like ?", condition).count
else
project_org_ids = "(" + project_org_ids.join(',') + ")"
@orgs_not_in_project = Organization.where("id not in #{project_org_ids} and (is_public = 1 or creator_id =?) and name like ?", User.current.id, condition).page((params[:page].to_i || 1)).per(limit)
@org_count = Organization.where("id not in #{project_org_ids} and (is_public = 1 or creator_id =?)", User.current.id).where("name like ?", condition).count
end
# @project_count = Project.project_entities.visible.like(params[:name]).page(params[:page]).count
project_org_ids = OrgProject.find_by_sql("select distinct organization_id from org_projects where project_id = #{params[:id]}").map(&:organization_id) << 0
@orgs_not_in_project = User.current.organizations.where("organizations.id not in (#{project_org_ids.join(',')}) and organizations.name like ?", condition).page(params[:page].to_i || 1).per(limit)
@org_count = User.current.organizations.where("organizations.id not in (#{project_org_ids.join(',')}) and organizations.name like '#{condition}'").count
# if project_org_ids.empty?
# @orgs_not_in_project = Organization.where("(is_public or creator_id =?) = 1 and name like ?",User.current.id, condition).page((params[:page].to_i || 1)).per(limit)
# @org_count = Organization.where("is_public = 1 or creator_id =?", User.current.id).where("name like ?", condition).count
# else
# project_org_ids = "(" + project_org_ids.join(',') + ")"
# @orgs_not_in_project = Organization.where("id not in #{project_org_ids} and (is_public = 1 or creator_id =?) and name like ?", User.current.id, condition).page((params[:page].to_i || 1)).per(limit)
# @org_count = Organization.where("id not in #{project_org_ids} and (is_public = 1 or creator_id =?)", User.current.id).where("name like ?", condition).count
# end
@orgs_page = Paginator.new @org_count, limit,params[:page]
@no_roll_hint = params[:hint_flag]
#render :json => {:orgs => @orgs_not_in_project, :count => @org_count}.to_json

View File

@ -31,8 +31,8 @@ class RepositoriesController < ApplicationController
default_search_scope :changesets
before_filter :find_project_by_project_id, :only => [:new, :create, :newrepo]
before_filter :find_repository, :only => [:edit, :update, :destroy, :committers, :forked]
before_filter :find_project_repository, :except => [:new, :create, :newcreate, :edit, :update, :destroy, :committers, :newrepo,:to_gitlab]
before_filter :find_repository, :only => [:edit, :update, :destroy, :committers]
before_filter :find_project_repository, :except => [:new, :create, :newcreate, :edit, :update, :destroy, :committers, :newrepo, :to_gitlab, :forked]
before_filter :find_changeset, :only => [:revision, :add_related_issue, :remove_related_issue]
before_filter :authorize , :except => [:newrepo,:newcreate,:fork, :to_gitlab, :forked]
accept_rss_auth :revisions
@ -64,6 +64,8 @@ class RepositoriesController < ApplicationController
end
def forked
@project = Project.find(params[:id])
@repository = Repository.where("project_id =? and type =?", @project.id, "Repository::Gitlab")
# 如果当前用户已经fork过该项目不会新fork项目则跳至已fork的项
unless has_forked?(@project, User.current)
project = project_from_current_project(@project.id, User.current.id)
@ -76,7 +78,11 @@ class RepositoriesController < ApplicationController
else
g = Gitlab.client
if User.current.gid.nil?
g.sync_user(User.current)
begin
g.sync_user(User.current)
ensure
logger.error "Synv user failed ==>#{User.current.id}"
end
end
gproject = g.fork(@project.gpid, User.current.gid)
if gproject

View File

@ -0,0 +1,43 @@
class ShieldActivitiesController < ApplicationController
def create
if params[:org_id]
if params[:project_id]
ShieldActivity.create(:container_type => 'Organization', :container_id => params[:org_id].to_i, :shield_type => 'Project', :shield_id => params[:project_id].to_i)
elsif params[:course_id]
ShieldActivity.create(:container_type => 'Organization', :container_id => params[:org_id].to_i, :shield_type => 'Course', :shield_id => params[:course_id].to_i)
end
elsif params[:user_id]
if params[:project_id]
ShieldActivity.create(:container_type => 'User', :container_id => params[:user_id].to_i, :shield_type => 'Project', :shield_id => params[:project_id].to_i)
elsif params[:course_id]
ShieldActivity.create(:container_type => 'User', :container_id => params[:user_id].to_i, :shield_type => 'Course', :shield_id => params[:course_id].to_i)
end
end
end
def show_acts
if params[:org_id]
if params[:project_id]
ShieldActivity.where("container_type='Organization' and container_id=#{params[:org_id].to_i} and shield_type='Project' and shield_id=#{params[:project_id]}").each do |act|
act.destroy
end
# ShieldActivity.create(:container_type => 'Organization', :container_id => params[:org_id].to_i, :shield_type => 'Project', :shield_id => params[:project_id].to_i)
elsif params[:course_id]
ShieldActivity.where("container_type='Organization' and container_id=#{params[:org_id].to_i} and shield_type='Course' and shield_id=#{params[:course_id]}").each do |act|
act.destroy
end
end
elsif params[:user_id]
if params[:project_id]
ShieldActivity.where("container_type='User' and container_id=#{params[:user_id].to_i} and shield_type='Project' and shield_id=#{params[:project_id]}").each do |act|
act.destroy
end
# ShieldActivity.create(:container_type => 'Organization', :container_id => params[:org_id].to_i, :shield_type => 'Project', :shield_id => params[:project_id].to_i)
elsif params[:course_id]
ShieldActivity.where("container_type='User' and container_id=#{params[:user_id].to_i} and shield_type='Course' and shield_id=#{params[:course_id]}").each do |act|
act.destroy
end
end
end
end
end

View File

@ -259,16 +259,10 @@ class StudentWorkController < ApplicationController
stu_project.save
end
end
course_activity = CourseActivity.where("course_act_type='HomeworkCommon' and course_act_id =#{@homework.id}").first
if course_activity
course_activity.updated_at = Time.now
course_activity.save
end
user_activity = UserActivity.where("act_type='HomeworkCommon' and act_id =#{@homework.id}").first
if user_activity
user_activity.updated_at = Time.now
user_activity.save
end
update_course_activity(@homework.class,@homework.id)
update_user_activity(@homework.class,@homework.id)
update_org_activity(@homework.class,@homework.id)
course_message = CourseMessage.new(:user_id =>User.current.id,:content=>"new",:course_message_id=>student_work.id,:course_id => @course.id,:course_message_type=>"StudentWork", :status => 9) #作品提交记录
course_message.save
@ -649,7 +643,8 @@ class StudentWorkController < ApplicationController
if revise_attachments.count == 2
revise_attachments.last.destroy
end
#@attachment = @work.attachments.where("attachtype = 7").order("created_on desc").first
attachment = @work.attachments.where("attachtype = 7").first
attachment.update_attributes(:description => params[:description])
respond_to do |format|
format.js
end

View File

@ -1,4 +1,5 @@
class SystemMessagesController < ApplicationController
# before_filter :message_author, :only => [:show]
#
# def message_author
@ -41,6 +42,7 @@ class SystemMessagesController < ApplicationController
@system_messages.description = params[:system_message][:description]
@system_messages.subject = params[:system_message][:subject]
@system_messages.user_id = User.current.id
# @system_messages.save_attachments(params[:attachments])
respond_to do |format|
if @system_messages.save
format.html {redirect_to user_system_messages_path(User.current)}

View File

@ -228,6 +228,12 @@ class TagsController < ApplicationController
@select_tag_name = params[:select_tag_name]
end
if @obj && @object_flag == '6' && @obj.container.kind_of?(Project)
@project = @obj.container
@tag_list = get_course_tag_list @project
@select_tag_name = params[:select_tag_name]
end
if @obj && @object_flag == '6' && @obj.container.kind_of?(OrgSubfield)
@org_subfield = @obj.container
@tag_list = get_org_subfield_tag_list @org_subfield
@ -320,6 +326,88 @@ class TagsController < ApplicationController
end
end
def update_project_tag_name
@tag_name = params[:tagName]
@rename_tag_name = params[:renameName]
@taggable_id = params[:taggableId]
@taggable_type = numbers_to_object_type(params[:taggableType])
@project_id = params[:projectId]
@rename_tag = (ActsAsTaggableOn::Tag.find_by_name(@rename_tag_name)) #查找重命名后的tag
@tag_id = (ActsAsTaggableOn::Tag.find_by_name(@tag_name)).id #重命名前的tag_id
@taggings = ActsAsTaggableOn::Tagging.find_by_tag_id_and_taggable_id_and_taggable_type(@tag_id,@taggable_id,@taggable_type) unless @taggable_id.blank?
@obj = get_object(@taggable_id,params[:taggableType]) unless @taggable_id.blank?
if @taggable_id.blank? #如果没有传tag_id那么直接更新tag_name就好了。但是要防止 重命名后的tag存在。
if @project_id
project = Project.find @project_id
if project
project.attachments.each do |attachment|
taggings = ActsAsTaggableOn::Tagging.find_by_tag_id_and_taggable_id_and_taggable_type(@tag_id,attachment.id,attachment.class)
if taggings
taggings.delete
attachment.tag_list.add(@rename_tag_name.split(","))
attachment.save
end
end
end
end
else
if(@rename_tag.nil?) #这次命名的是新的tag
# 是否还有其他记录 引用了 tag_id
@tagging = ActsAsTaggableOn::Tagging.where("tag_id = #{@tag_id}")
# 如果taggings表中记录为 1 ,那么改变@tag_id对应的tag的名字
if @tagging.count == 1
@tag = ActsAsTaggableOn::Tag.find_by_id(@tag_id)
@tag.update_attributes({:name=>@rename_tag_name})
else #如果tagging表中的记录大于1那么就要新增tag记录
unless @obj.nil?
@obj.tag_list.add(@rename_tag_name.split(","))
@obj.save
end
#删除原来的对应的taggings的记录
unless @taggings.nil?
@taggings.delete
end
end
else #这是已有的tag
# 更改taggings记录里的tag_id
unless @taggings.nil?
@taggings.update_attributes({:tag_id=>@rename_tag.id})
end
end
end
@obj_flag = params[:taggableType]
if @obj && @obj_flag == '6' && @obj.container.kind_of?(Project)
@project = @obj.container
@tag_list = @tag_list = get_course_tag_list @project
elsif @project_id
@project = Project.find(@project_id)
@tag_list = get_project_tag_list @project
#这里要引用FilesController里的逻辑了。将资源库当前的文件列表刷新一遍。
@flag = params[:flag] || false
sort = ""
@sort = ""
@order = ""
@is_remote = false
@isproject = false
sort = "#{Attachment.table_name}.created_on desc"
@containers = [ Project.includes(:attachments).reorder(sort).find(@project.id)]
show_attachments @containers
elsif @obj && @obj_flag == '5'
@forum = @obj
end
respond_to do |format|
format.js
end
end
def update_org_subfield_tag_name
@tag_name = params[:tagName]
@rename_tag_name = params[:renameName]
@ -458,6 +546,10 @@ class TagsController < ApplicationController
@course = @obj.container
@tag_list = @tag_list = get_course_tag_list @course
end
if @obj && @obj_flag == '6' && @obj.container.kind_of?(Project)
@project = @obj.container
@tag_list = @tag_list = get_project_tag_list @project
end
if @obj && @obj_flag == '6' && @obj.container.kind_of?(OrgSubfield)
@org_subfield = @obj.container
@tag_list = @tag_list = get_org_subfield_tag_list @org_subfield

View File

@ -55,6 +55,7 @@ class UsersController < ApplicationController
before_filter :recorded_visitor, :only => [:show,:user_fanslist,:user_watchlist,:user_visitorlist]
helper :sort
helper :attachments
include SortHelper
helper :custom_fields
include CustomFieldsHelper
@ -63,6 +64,7 @@ class UsersController < ApplicationController
include GitlabHelper
include UserScoreHelper
include PollHelper
helper :user_score
helper :journals
@ -497,7 +499,7 @@ class UsersController < ApplicationController
#提交作品时,计算是否迟交
if Time.parse(homework.end_time.to_s).strftime("%Y-%m-%d") < Time.parse(Time.now.to_s).strftime("%Y-%m-%d")
student_work.late_penalty = 1
student_work.late_penalty = homework.late_penalty
else
student_work.late_penalty = 0
end
@ -522,6 +524,7 @@ class UsersController < ApplicationController
else
homework.publish_time = params[:homework_common][:publish_time]
end
homework.anonymous_comment = params[:homework_common][:anonymous_comment] ? params[:homework_common][:anonymous_comment] : 0
homework.homework_type = params[:homework_type].to_i || 1
homework.late_penalty = 10
homework.teacher_priority = 1
@ -618,7 +621,7 @@ class UsersController < ApplicationController
end
if(params[:type].blank? || params[:type] == "1") #全部
user_course_ids = User.current.courses.map { |c| c.id} #我的资源库的话,那么应该是我上传的所有资源 加上 我加入的课程的所有资源
@attachments = Attachment.where("(author_id = #{params[:id]} and container_type in('Project','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) "+
@attachments = Attachment.where("(author_id = #{params[:id]} and container_type in('Project','OrgSubfield','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) "+
"or (container_type = 'Course' and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')}))").order("created_on desc")
elsif params[:type] == "2" #课程资源
user_course_ids = User.current.courses.map { |c| c.id}
@ -874,7 +877,7 @@ class UsersController < ApplicationController
#显示更多用户课程
def user_courses4show
@page = params[:page].to_i + 1
@courses = @user.courses.visible.select("courses.*,(SELECT MAX(created_at) FROM `course_activities` WHERE course_activities.course_id = courses.id) AS a").order("a desc").limit(5).offset(@page * 5)
@courses = @user.courses.visible.where("is_delete =?", 0).select("courses.*,(SELECT MAX(created_at) FROM `course_activities` WHERE course_activities.course_id = courses.id) AS a").order("a desc").limit(5).offset(@page * 5)
end
#显示更多用户项目
@ -964,9 +967,11 @@ class UsersController < ApplicationController
params[:course_id], 'JoinCourseRequest', User.current.id, @user.id, false)
join_course_messages.update_all(:viewed => true)
end
shield_project_ids = ShieldActivity.where("container_type='User' and container_id=#{@user.id} and shield_type='Project'").map(&:shield_id)
shield_course_ids = ShieldActivity.where("container_type='User' and container_id=#{@user.id} and shield_type='Course'").map(&:shield_id)
@page = params[:page] ? params[:page].to_i + 1 : 0
user_project_ids = @user.projects.visible.empty? ? "(-1)" : "(" + @user.projects.visible.map{|project| project.id}.join(",") + ")"
user_course_ids = @user.courses.visible.empty? ? "(-1)" : "(" + @user.courses.visible.map{|course| course.id}.join(",") + ")"
user_project_ids = (@user.projects.visible.map{|project| project.id}-shield_project_ids).empty? ? "(-1)" : "(" + (@user.projects.visible.map{|project| project.id}-shield_project_ids).join(",") + ")"
user_course_ids = (@user.courses.visible.map{|course| course.id}-shield_course_ids).empty? ? "(-1)" : "(" + (@user.courses.visible.map{|course| course.id}-shield_course_ids).join(",") + ")"
course_types = "('Message','News','HomeworkCommon','Poll','Course')"
project_types = "('Message','Issue','ProjectCreateInfo')"
principal_types = "JournalsForMessage"
@ -1326,12 +1331,12 @@ class UsersController < ApplicationController
if(params[:type].blank?|| params[:type] == "1") #全部
if User.current.id.to_i == params[:id].to_i
user_course_ids = User.current.courses.map { |c| c.id} #我的资源库的话,那么应该是我上传的所有资源 加上 我加入的课程的所有资源
@attachments = Attachment.where("(author_id = #{params[:id]} and container_type in('Project','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) "+
@attachments = Attachment.where("(author_id = #{params[:id]} and container_type in('Project','OrgSubfield','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) "+
"or (container_type = 'Course' and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')}))").order("created_on desc")
else
user_course_ids = User.find(params[:id]).courses.visible.map { |c| c.id} #Ta的资源库的话应该是他上传的公开资源 加上 他加入的所有我可见课程里的公开资源
@attachments = Attachment.where("(author_id = #{params[:id]} and is_public = 1 " +
"and container_type in('Project','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) " +
"and container_type in('Project','OrgSubfield','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) " +
"or (container_type = 'Course' and is_public = 1 and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')}))").order("created_on desc")
end
elsif params[:type] == "2" #课程资源
@ -1388,12 +1393,12 @@ class UsersController < ApplicationController
if(params[:type].nil? || params[:type].blank? || params[:type] == "1" || params[:type] == 'all') #全部
if User.current.id.to_i == params[:id].to_i
user_course_ids = User.current.courses.map { |c| c.id} #我的资源库的话,那么应该是我上传的所有资源 加上 我加入的课程的所有资源
@attachments = Attachment.where("(author_id = #{params[:id]} and container_type in('Project','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) "+
@attachments = Attachment.where("(author_id = #{params[:id]} and container_type in('Project','OrgSubfield','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) "+
"or (container_type = 'Course' and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')}))").order("created_on desc")
else
user_course_ids = User.find(params[:id]).courses.visible.map { |c| c.id} #Ta的资源库的话应该是他上传的公开资源 加上 他加入的所有我可见课程里的公开资源
@attachments = Attachment.where("(author_id = #{params[:id]} and is_public = 1 " +
"and container_type in('Project','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) " +
"and container_type in('Project','OrgSubfield','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) " +
"or (container_type = 'Course' and is_public = 1 and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')}))").order("created_on desc")
end
elsif params[:type] == "2" #课程资源
@ -1488,11 +1493,23 @@ class UsersController < ApplicationController
unless course_ids.nil?
course_ids.each do |id|
next if ori.blank?
@exist = false
Course.find(id).attachments.each do |att| #如果课程中包含该资源
if att.id == ori.id || (!att.copy_from.nil? && !ori.copy_from.nil? && att.copy_from == ori.copy_from) || att.copy_from == ori.id || att.id == ori.copy_from
att.created_on = Time.now
att.save
@exist = true
break
end
end
next if @exist
attach_copied_obj = ori.copy
attach_copied_obj.tag_list.add(ori.tag_list) # tag关联
attach_copied_obj.container = Course.find(id)
attach_copied_obj.created_on = Time.now
attach_copied_obj.author_id = User.current.id
attach_copied_obj.is_public = 0
attach_copied_obj.copy_from = ori.copy_from.nil? ? ori.id : ori.copy_from #发送要添加copy_from
if attach_copied_obj.attachtype == nil
attach_copied_obj.attachtype = 4
end
@ -1512,11 +1529,23 @@ class UsersController < ApplicationController
unless course_ids.nil?
course_ids.each do |id|
next if ori.blank?
@exist = false
Course.find(id).attachments.each do |att| #如果课程中包含该资源
if att.id == ori.id || (!att.copy_from.nil? && !ori.copy_from.nil? && att.copy_from == ori.copy_from) || att.copy_from == ori.id || att.id == ori.copy_from
att.created_on = Time.now
att.save
@exist = true
break
end
end
next if @exist
attach_copied_obj = ori.copy
attach_copied_obj.tag_list.add(ori.tag_list) # tag关联
attach_copied_obj.container = Course.find(id)
attach_copied_obj.created_on = Time.now
attach_copied_obj.author_id = User.current.id
attach_copied_obj.is_public = 0
attach_copied_obj.copy_from = ori.copy_from.nil? ? ori.id : ori.copy_from #发送要添加copy_from
if attach_copied_obj.attachtype == nil
attach_copied_obj.attachtype = 4
end
@ -1529,7 +1558,7 @@ class UsersController < ApplicationController
@flag = false
end
user_course_ids = User.current.courses.map { |c| c.id} #我的资源库的话,那么应该是我上传的所有资源 加上 我加入的课程的所有资源
@attachments = Attachment.where("(author_id = #{params[:id]} and container_type in('Project','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) "+
@attachments = Attachment.where("(author_id = #{params[:id]} and container_type in('Project','OrgSubfield','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) "+
"or (container_type = 'Course' and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')}))").order("created_on desc")
@type = params[:type]
@limit = 25
@ -1558,11 +1587,23 @@ class UsersController < ApplicationController
unless project_ids.nil?
project_ids.each do |project_id|
next if ori.blank?
@exist = false
Project.find(project_id).attachments.each do |att| #如果课程中包含该资源
if att.id == ori.id || (!att.copy_from.nil? && !ori.copy_from.nil? && att.copy_from == ori.copy_from) || att.copy_from == ori.id || att.id == ori.copy_from
att.created_on = Time.now
att.save
@exist = true
break
end
end
next if @exist
attach_copied_obj = ori.copy
attach_copied_obj.tag_list.add(ori.tag_list) # tag关联
attach_copied_obj.container = Project.find(project_id)
attach_copied_obj.created_on = Time.now
attach_copied_obj.author_id = User.current.id
attach_copied_obj.is_public = 0
attach_copied_obj.copy_from = ori.copy_from.nil? ? ori.id : ori.copy_from #发送要添加copy_from
if attach_copied_obj.attachtype == nil
attach_copied_obj.attachtype = 1
end
@ -1581,11 +1622,23 @@ class UsersController < ApplicationController
unless project_ids.nil?
project_ids.each do |project_id|
next if ori.blank?
@exist = false
Project.find(project_id).attachments.each do |att| #如果课程中包含该资源
if att.id == ori.id || (!att.copy_from.nil? && !ori.copy_from.nil? && att.copy_from == ori.copy_from) || att.copy_from == ori.id || att.id == ori.copy_from
att.created_on = Time.now
att.save
@exist = true
break
end
end
next if @exist
attach_copied_obj = ori.copy
attach_copied_obj.tag_list.add(ori.tag_list) # tag关联
attach_copied_obj.container = Project.find(project_id)
attach_copied_obj.created_on = Time.now
attach_copied_obj.author_id = User.current.id
attach_copied_obj.is_public = 0
attach_copied_obj.copy_from = ori.copy_from.nil? ? ori.id : ori.copy_from #发送要添加copy_from
if attach_copied_obj.attachtype == nil
attach_copied_obj.attachtype = 1
end
@ -1597,7 +1650,7 @@ class UsersController < ApplicationController
@flag=true
end
user_course_ids = User.current.courses.map { |c| c.id} #我的资源库的话,那么应该是我上传的所有资源 加上 我加入的课程的所有资源
@attachments = Attachment.where("(author_id = #{params[:id]} and container_type in('Project','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) "+
@attachments = Attachment.where("(author_id = #{params[:id]} and container_type in('Project','OrgSubfield','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) "+
"or (container_type = 'Course' and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')}))").order("created_on desc")
@type = params[:type]
@limit = 25
@ -1613,6 +1666,97 @@ class UsersController < ApplicationController
end
end
def add_exist_file_to_org
@flag = true
if params[:send_id].present?
send_id = params[:send_id]
subfield_id = params[:subfield]
if subfield_id.nil?
@flag = false
end
ori = Attachment.find_by_id(send_id)
unless subfield_id.nil?
attach_copied_obj = ori.copy
@exist = false
OrgSubfield.find(subfield_id).attachments.each do |att| #如果课程中包含该资源
if att.id == ori.id || (!att.copy_from.nil? && !ori.copy_from.nil? && att.copy_from == ori.copy_from) || att.copy_from == ori.id || att.id == ori.copy_from
att.created_on = Time.now
att.save
@exist = true
break
end
end
if @exist == false #如果不存在该资源
attach_copied_obj.tag_list.add(ori.tag_list) # tag关联
attach_copied_obj.container = OrgSubfield.find(subfield_id)
attach_copied_obj.created_on = Time.now
attach_copied_obj.author_id = User.current.id
attach_copied_obj.is_public = 0
attach_copied_obj.copy_from = ori.copy_from.nil? ? ori.id : ori.copy_from #发送要添加copy_from
if attach_copied_obj.attachtype == nil
attach_copied_obj.attachtype = 1
end
attach_copied_obj.save
end
end
elsif params[:send_ids].present?
send_ids = params[:send_ids].split(" ")
subfield_id = params[:subfield]
if subfield_id.nil?
@flag = false
end
send_ids.each do |send_id|
ori = Attachment.find_by_id(send_id)
unless subfield_id.nil?
next if ori.blank?
@exist = false
OrgSubfield.find(subfield_id).attachments.each do |att| #如果课程中包含该资源
if att.id == ori.id || (!att.copy_from.nil? && !ori.copy_from.nil? && att.copy_from == ori.copy_from) || att.copy_from == ori.id || att.id == ori.copy_from
att.created_on = Time.now
att.save
@exist = true
break
end
end
next if @exist
attach_copied_obj = ori.copy
attach_copied_obj.tag_list.add(ori.tag_list) # tag关联
attach_copied_obj.container = OrgSubfield.find(subfield_id)
attach_copied_obj.created_on = Time.now
attach_copied_obj.author_id = User.current.id
attach_copied_obj.is_public = 0
attach_copied_obj.copy_from = ori.copy_from.nil? ? ori.id : ori.copy_from #发送要添加copy_from
if attach_copied_obj.attachtype == nil
attach_copied_obj.attachtype = 1
end
attach_copied_obj.save
end
end
else
@flag=true
end
user_course_ids = User.current.courses.map { |c| c.id} #我的资源库的话,那么应该是我上传的所有资源 加上 我加入的课程的所有资源
@attachments = Attachment.where("(author_id = #{params[:id]} and container_type in('Project','OrgSubfield','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) "+
"or (container_type = 'Course' and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')}))").order("created_on desc")
@type = params[:type]
@limit = 25
@user = User.current
@is_remote = true
@atta_count = @attachments.count
@atta_pages = Paginator.new @atta_count, @limit, params['page'] || 1
@offset ||= @atta_pages.offset
#@curse_attachments_all = @all_attachments[@offset, @limit]
@attachments = paginateHelper @attachments,25
respond_to do |format|
format.js
end
end
def change_org_subfield
end
# 资源预览
def resource_preview
preview_id = params[:resource_id]
@ -1825,12 +1969,12 @@ class UsersController < ApplicationController
if(params[:type].blank? || params[:type] == "1") #全部
if User.current.id.to_i == params[:id].to_i
user_course_ids = User.current.courses.map { |c| c.id} #我的资源库的话,那么应该是我上传的所有资源 加上 我加入的课程的所有资源
@attachments = Attachment.where("(author_id = #{params[:id]} and container_type in('Project','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) "+
@attachments = Attachment.where("(author_id = #{params[:id]} and container_type in('Project','OrgSubfield','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) "+
"or (container_type = 'Course' and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')}))").order("created_on desc")
else
user_course_ids = User.find(params[:id]).courses.visible.map { |c| c.id} #Ta的资源库的话应该是他上传的公开资源 加上 他加入的所有我可见课程里的公开资源
@attachments = Attachment.where("(author_id = #{params[:id]} and is_public = 1 " +
"and container_type in('Project','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) " +
"and container_type in('Project','OrgSubfield','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) " +
"or (container_type = 'Course' and is_public = 1 and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')}))").order("created_on desc")
end
elsif params[:type] == "2" #课程资源
@ -1881,7 +2025,7 @@ class UsersController < ApplicationController
if(params[:type].nil? || params[:type].blank? || params[:type] == "1" || params[:type] == 'all') #全部
if User.current.id.to_i == params[:id].to_i
user_course_ids = User.current.courses.map { |c| c.id} #我的资源库的话,那么应该是我上传的所有资源 加上 我加入的课程的所有资源 取交集并查询
@attachments = Attachment.where("((author_id = #{params[:id]} and container_type in('Project','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) "+
@attachments = Attachment.where("((author_id = #{params[:id]} and container_type in('Project','OrgSubfield','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) "+
" or (container_type = 'Course' and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')}))) and (filename like :p) ",:p=>search).order("created_on desc")
else
user_course_ids = User.find(params[:id]).courses.visible.map { |c| c.id} #如果课程私有资源,那么要看这个资源的课程是不是在 这个user的所有我可见的课程中
@ -1954,6 +2098,23 @@ class UsersController < ApplicationController
end
end
def search_user_org
@user = User.current
if !params[:search].nil? #发送到有栏目类型为资源的组织中
search = "%#{params[:search].to_s.strip.downcase}%"
@orgs = @user.organizations.where("name like ?", search).select{|org| OrgSubfield.where("organization_id = #{org.id} and field_type='Resource'").count > 0}
else
@orgs = @user.organizations.select{|org| OrgSubfield.where("organization_id = #{org.id} and field_type='Resource'").count > 0}
end
@search = params[:search]
#这里仅仅是传递需要发送的资源id
@send_id = params[:send_id]
@send_ids = params[:checkbox1] || params[:send_ids]
respond_to do |format|
format.js
end
end
private
def find_user

View File

@ -57,21 +57,11 @@ class WordsController < ApplicationController
@jfm = add_reply_adapter options
@save_succ = true if @jfm.errors.empty?
if @save_succ
course_activity = CourseActivity.where("course_act_type='JournalsForMessage' and course_act_id =#{parent_id}").first
if course_activity
course_activity.updated_at = Time.now
course_activity.save
end
principal_activity = PrincipalActivity.where("principal_act_type='JournalsForMessage' and principal_act_id =#{parent_id}").first
if principal_activity
principal_activity.updated_at = Time.now
principal_activity.save
end
user_activity = UserActivity.where("act_type='JournalsForMessage' and act_id =#{parent_id}").first
if user_activity
user_activity.updated_at = Time.now
user_activity.save
end
update_course_activity('JournalsForMessage',parent_id)
update_user_activity('JournalsForMessage',parent_id)
update_forge_activity('JournalsForMessage',parent_id)
update_org_activity('JournalsForMessage',parent_id)
update_principal_activity('JournalsForMessage',parent_id)
end
respond_to do |format|
# format.html {
@ -236,7 +226,11 @@ class WordsController < ApplicationController
if User.current.logged?
@user = User.find(params[:id])
if params[:new_form][:user_message].size>0 && User.current.logged? && @user
@user.add_jour(User.current, params[:new_form][:user_message])
if params[:private] && params[:private] == '1'
@user.journals_for_messages << JournalsForMessage.new(:user_id => User.current.id, :notes => params[:new_form][:user_message], :reply_id => 0, :status => true, :is_readed => false, :private => 1)
else
@user.add_jour(User.current, params[:new_form][:user_message])
end
end
redirect_to feedback_path(@user)
else
@ -274,16 +268,9 @@ class WordsController < ApplicationController
update_kindeditor_assets_owner ids,feedback[:id],OwnerTypeHelper::JOURNALSFORMESSAGE
end
course_activity = CourseActivity.where("course_act_type='HomeworkCommon' and course_act_id =#{@homework_common.id}").first
if course_activity
course_activity.updated_at = Time.now
course_activity.save
end
user_activity = UserActivity.where("act_type='HomeworkCommon' and act_id =#{@homework_common.id}").first
if user_activity
user_activity.updated_at = Time.now
user_activity.save
end
update_course_activity(@homework_common.class,@homework_common.id)
update_user_activity(@homework_common.class,@homework_common.id)
update_org_activity(@homework_common.class,@homework_common.id)
respond_to do |format|
format.js{
@user_activity_id = params[:user_activity_id]

View File

@ -1,4 +1,8 @@
require 'zip'
#coding=utf-8
require "base64"
require 'zip'
class ZipdownController < ApplicationController
#查找项目(课程)
before_filter :find_project_by_bid_id, :only => [:assort]
@ -11,7 +15,13 @@ class ZipdownController < ApplicationController
def download
if User.current.logged?
begin
send_file "#{OUTPUT_FOLDER}/#{params[:file]}", :filename => filename_for_content_disposition(params[:filename]), :type => detect_content_type(params[:file])
if params[:base64file]
file = Base64.decode64(params[:base64file])
file = file.sub('*', '+')
send_file "#{OUTPUT_FOLDER}/#{file}", :filename => filename_for_content_disposition(file), :type => detect_content_type(file)
else
send_file "#{OUTPUT_FOLDER}/#{params[:file]}", :filename => filename_for_content_disposition(params[:filename]), :type => detect_content_type(params[:file])
end
rescue => e
render file: 'public/no_file_found.html'
end
@ -107,11 +117,17 @@ class ZipdownController < ApplicationController
bid_homework_path, OUTPUT_FOLDER)
}
[{files:[out_file.file_path], count: 1, index: 1,
real_file: out_file.file_path, file: File.basename(out_file.file_path),
real_file: out_file.file_path,
file: File.basename(out_file.file_path),
base64file: encode64(File.basename(out_file.file_path)),
size:(out_file.pack_size / 1024.0 / 1024.0).round(2)
}]
end
def encode64(str)
Base64.encode64(str).sub('+', '*')
end
def zip_homework_common homework_common
bid_homework_path = []
digests = []
@ -129,7 +145,9 @@ class ZipdownController < ApplicationController
bid_homework_path, OUTPUT_FOLDER)
}
[{files:[out_file.file_path], count: 1, index: 1,
real_file: out_file.file_path, file: File.basename(out_file.file_path),
real_file: out_file.file_path,
file: File.basename(out_file.file_path),
base64file: encode64(File.basename(out_file.file_path)),
size:(out_file.pack_size / 1024.0 / 1024.0).round(2)
}]
end

View File

@ -180,7 +180,7 @@ module ApiHelper
if timePassed < 0
updateAtValue = "时间有问题"
elsif timePassed < ONE_MINUTE
updateAtValue = "分钟前"
updateAtValue = "1分钟前"
elsif timePassed < ONE_HOUR
timeIntoFormat = timePassed / ONE_MINUTE
updateAtValue = timeIntoFormat.to_s + "分钟前"

View File

@ -48,6 +48,7 @@ module ApplicationHelper
end
end
end
# 获取组织成员中文名字
def get_org_member_role_name member
case member.roles[0].name
@ -58,15 +59,16 @@ module ApplicationHelper
end
end
# 获取项/课程 news最新列表
# params course: course ID or project ID
def news_act_order(course)
a = []
course.news.each do |new|
unless new.comments.blank?
new = new.comments.sort! { |a,b| a.created_on <=> b.created_on}.last.commented
# 判断组织左侧展开或者隐藏
def is_hide_org_left obj
if obj.nil?
return true
else
if obj.hide == 0
return true
else
return false
end
a << new
end
end
@ -265,8 +267,10 @@ module ApplicationHelper
subject = truncate(subject, :length => 60)
end
end
if issue.status_id == 5
if issue.status_id == 3
s = link_to text, issue_path(issue), :class => "text_line_s", :title => title
elsif issue.status_id == 5
s = link_to text, issue_path(issue), :class => "text_line_s del_line", :title => title
else
s = link_to text, issue_path(issue), :class => "c_blue", :title => title
end
@ -2442,6 +2446,16 @@ module ApplicationHelper
tag_list
end
# 获取项目资源的Tag云
def get_project_tag_list project
all_attachments = project.attachments.select{|attachment| attachment.is_public? ||
(attachment.container_type == "Project" && User.current.member_of?(project))||
attachment.author_id == User.current.id
}
tag_list = attachment_tag_list all_attachments
tag_list
end
def get_org_subfield_tag_list org_subfield
all_attachments = org_subfield.attachments.select{|attachment| attachment.is_public? ||
(attachment.container_type == "OrgSubfield" && User.current.member_of_org?(org_subfield.organization))||
@ -2598,6 +2612,12 @@ module ApplicationHelper
end
end
def file_preview_eye(file, html_options={})
if %w(pdf pptx doc docx xls xlsx).any?{|x| file.filename.downcase.end_with?(x)}
link_to '', download_named_attachment_path(file.id, file.filename, preview: true),html_options
end
end
#将文本内的/n转换为<br>
def text_format text
text.gsub("&","&amp;").gsub("<","&lt;").gsub(">","&gt;").gsub("\n","<br/>").html_safe
@ -2761,4 +2781,52 @@ int main(int argc, char** argv){
ss.html_safe
end
#代码提交数量
def changesets_num project
g = Gitlab.client
project.gpid.nil? ? 0 : g.commits_total_count(project.gpid).count
# # commits_total_count(project.gpid)
# project.changesets.count
end
#课程动态的更新
def update_course_activity type, id
course_activity = CourseActivity.where("course_act_type=? and course_act_id =?", type.to_s, id).first
if course_activity
course_activity.updated_at = Time.now
course_activity.save
end
end
#首页动态更新
def update_user_activity type, id
user_activity = UserActivity.where("act_type=? and act_id =?", type.to_s, id).first
if user_activity
user_activity.updated_at = Time.now
user_activity.save
end
end
#项目动态更新
def update_forge_activity type, id
forge_activity = ForgeActivity.where("forge_act_type=? and forge_act_id=?", type.to_s, id).first
if forge_activity
forge_activity.updated_at = Time.now
forge_activity.save
end
end
#组织动态更新
def update_org_activity type , id
org_activity = OrgActivity.where("org_act_type=? and org_act_id =?", type.to_s, id).first
if org_activity
org_activity.updated_at = Time.now
org_activity.save
end
end
#个人动态更新
def update_principal_activity type, id
principal_activity = PrincipalActivity.where("principal_act_type=? and principal_act_id =?", type.to_s, id).first
if principal_activity
principal_activity.updated_at = Time.now
principal_activity.save
end
end
end

View File

@ -96,6 +96,7 @@ module AttachmentsHelper
end
false
end
#判断项目project中是否包含课件attachmentproject中引用了attachment也算作包含
def project_contains_attachment? project,attachment
project.attachments.each do |att|

View File

@ -507,8 +507,10 @@ module CoursesHelper
#课程实践年份下拉框
def course_time_option year
type = []
month = Time.now.month
now_year = year.nil? ? Time.now.year : (Time.now.year <= year ? Time.now.year : year)
for i in (now_year..now_year + 10)
year = month < 3 ? now_year - 1 : now_year
for i in (year..year + 10)
option = []
option << i
option << i

View File

@ -1,2 +1,3 @@
module OrgSubfieldsHelper
include OrganizationsHelper
end

View File

@ -17,6 +17,15 @@ module OrganizationsHelper
s + content_tag('ul', links,:class => 'wlist',:style=>'float:left !important', :id => "org_member_pagination_links" )
end
def get_default_name field
case field.name
when 'activity' then
return '动态'
when 'course' then
return '课程'
when 'project' then
return '项目'
end
end
end

View File

@ -20,14 +20,6 @@ module ProjectScoreHelper
project.documents.count
end
#代码提交数量
def changesets_num project
g = Gitlab.client
project.gpid.nil? ? 0 : g.commits_total_count(project.gpid).count
# # commits_total_count(project.gpid)
# project.changesets.count
end
#讨论区帖子数量
def board_message_num project
board_message_count = 0

View File

@ -0,0 +1,2 @@
module ShieldActivitiesHelper
end

View File

@ -73,6 +73,16 @@ def course_contains_attachment? course,attachment
false
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 has_course? user,file
result = false

View File

@ -49,6 +49,8 @@ module UsersHelper
'批改附件'
when 'Principal'
'用户资源'
when 'OrgSubfield'
'组织资源'
end
end
@ -589,7 +591,7 @@ module UsersHelper
option << "请选择发布作业的课程"
option << -1
type << option
user.courses.visible.select("courses.*,(SELECT MAX(created_at) FROM `course_activities` WHERE course_activities.course_id = courses.id) AS a").order("a desc").select{|c| user.allowed_to?(:as_teacher,c)}.each do |course|
user.courses.visible.where("is_delete =?", 0).select("courses.*,(SELECT MAX(created_at) FROM `course_activities` WHERE course_activities.course_id = courses.id) AS a").order("a desc").select{|c| user.allowed_to?(:as_teacher,c)}.each do |course|
option = []
option << course.name+""+course.time.to_s+course.term+""
option << course.id

View File

@ -32,6 +32,7 @@ class Attachment < ActiveRecord::Base
has_many :course_acts, :class_name => 'CourseActivity',:as =>:course_act ,:dependent => :destroy
# end
include UserScoreHelper
has_many :attachment_histories
validates :filename, presence: true, length: {maximum: 254}
validates :author, presence: true
@ -348,11 +349,18 @@ class Attachment < ActiveRecord::Base
# Deletes the file from the file system if it's not referenced by other attachments
def delete_from_disk
if Attachment.where("disk_filename = ? AND id <> ?", disk_filename, id).empty?
#资源存在且历史记录为0 且 该资源没有存在任何拷贝才能删除资源
if Attachment.where("disk_filename = ? AND id <> ?", disk_filename, id).empty? && self.attachment_histories.count == 0 && Attachment.where('copy_from = ?',self.id) .count == 0
delete_from_disk!
end
end
#有了历史记录的数据记录是不能被删除的。
#true 能被删除 false 不能被删除
def destroyable
self.attachment_histories.count == 0
end
# Returns file's location on disk
def diskfile
File.join(self.class.storage_path, disk_directory.to_s, disk_filename.to_s)
@ -610,7 +618,7 @@ class Attachment < ActiveRecord::Base
end
end
def update_attachment_ealasticsearch_index
if self.is_public == 1 && ( (self.container_type == 'Project' && Project.find(self.container_id).is_public == 1) ||
if self.is_public == 1 && ( ((self.container_type == 'Project' or self.container_type == 'Version') && Project.find(self.container_id).is_public == 1) ||
( self.container_type == 'Course' && Course.find(self.container_id).is_public == 1) ||
self.container_type == 'Principal')
begin

View File

@ -0,0 +1,3 @@
class AttachmentHistory < ActiveRecord::Base
belongs_to :attachment,foreign_key: 'attachment_id'
end

View File

@ -17,6 +17,7 @@ class BlogComment < ActiveRecord::Base
safe_attributes 'title', 'content',"sticky", "locked"
after_save :add_user_activity
after_update :update_activity
before_destroy :destroy_user_activity
scope :like, lambda {|arg|
@ -28,6 +29,15 @@ class BlogComment < ActiveRecord::Base
end
}
#动态更新
def update_activity
user_activity = UserActivity.where("act_type='BlogComment' and act_id =?",self.id).first
if user_activity
user_activity.updated_at = Time.now
user_activity.save
end
end
#在个人动态里面增加当前动态
def add_user_activity
if self.parent_id.nil? #只有发博文才插入动态

View File

@ -19,6 +19,7 @@ class Board < ActiveRecord::Base
include Redmine::SafeAttributes
belongs_to :project,:touch => true
belongs_to :course,:touch=>true
belongs_to :org_subfield, :touch => true
has_many :topics, :class_name => 'Message', :conditions => "#{Message.table_name}.parent_id IS NULL", :order => "#{Message.table_name}.created_on DESC"
has_many :messages, :dependent => :destroy, :order => "#{Message.table_name}.created_on DESC"
belongs_to :last_message, :class_name => 'Message', :foreign_key => :last_message_id

View File

@ -70,7 +70,7 @@ class Course < ActiveRecord::Base
validates_length_of :description, :maximum => 10000
before_save :self_validate
# 公开课程变成私有课程,所有资源都变成私有
after_update :update_files_public,:update_course_ealasticsearch_index
after_update :update_files_public,:update_course_ealasticsearch_index,:update_activity
after_create :create_board_sync, :act_as_course_activity, :act_as_course_message,:create_course_ealasticsearch_index
before_destroy :delete_all_members,:delete_course_ealasticsearch_index
@ -428,6 +428,12 @@ class Course < ActiveRecord::Base
end
end
end
#动态的更新
def update_activity
update_course_activity(self.class, self.id)
update_user_activity(self.class, self.id)
update_org_activity(self.class, self.id)
end
# Delete the previous articles index in Elasticsearch
# Course.__elasticsearch__.client.indices.delete index: Course.index_name rescue nil

View File

@ -26,6 +26,7 @@ class HomeworkCommon < ActiveRecord::Base
:author => :author,
:url => Proc.new {|o| {:controller => 'student_work', :action => 'index', :homework => o.id}}
after_create :act_as_activity, :send_mail, :act_as_course_message
after_update :update_activity
after_save :act_as_course_activity
after_destroy :delete_kindeditor_assets
@ -60,7 +61,12 @@ class HomeworkCommon < ActiveRecord::Base
end
end
end
#动态的更新
def update_activity
update_course_activity(self.class, self.id)
update_user_activity(self.class, self.id)
update_org_activity(self.class, self.id)
end
#删除对应的图片
def delete_kindeditor_assets
delete_kindeditor_assets_from_disk self.id,OwnerTypeHelper::HOMEWORKCOMMON

View File

@ -84,7 +84,7 @@ class Issue < ActiveRecord::Base
# fq
after_create :act_as_activity,:be_user_score_new_issue,:act_as_forge_activity, :act_as_forge_message, :act_as_at_message
after_update :be_user_score
after_update :be_user_score,:update_activity
after_destroy :down_user_score
# after_create :be_user_score
# end
@ -126,7 +126,13 @@ class Issue < ActiveRecord::Base
after_save :after_create_from_copy
after_destroy :update_parent_attributes
#动态的更新
def update_activity
update_user_activity(self.class, self.id)
update_forge_activity(self.class, self.id)
update_org_activity(self.class, self.id)
end
# fq
def act_as_activity
self.acts << Activity.new(:user_id => self.author_id)

View File

@ -17,10 +17,10 @@
class Journal < ActiveRecord::Base
include UserScoreHelper
belongs_to :journalized, :polymorphic => true
belongs_to :journalized, :polymorphic => true,:touch => true
# added as a quick fix to allow eager loading of the polymorphic association
# since always associated to an issue, for now
belongs_to :issue, :foreign_key => :journalized_id
belongs_to :issue, :foreign_key => :journalized_id,:touch => true
belongs_to :user
has_many :details, :class_name => "JournalDetail", :dependent => :delete_all
@ -31,9 +31,8 @@ class Journal < ActiveRecord::Base
#has_many :forge_acts, :class_name => 'ForgeActivity',:as =>:forge_act ,:dependent => :destroy 评论不应该算入
# 被ForgeMessage虚拟关联
has_many :forge_messages, :class_name => 'ForgeMessage',:as =>:forge_message ,:dependent => :destroy
has_many :at_messages, as: :at_message, dependent: :destroy
acts_as_attachable
attr_accessor :indice
acts_as_event :title =>Proc.new {|o| status = ((s = o.new_status) ? " (#{s})" : nil); "#{o.issue.tracker} ##{o.issue.project_index}#{status}: #{o.issue.subject}" },
@ -46,8 +45,8 @@ class Journal < ActiveRecord::Base
acts_as_activity_provider :type => 'issues',
:author_key => :user_id,
:find_options => {:include => [{:issue => :project}, :details, :user],
:conditions => "#{Journal.table_name}.journalized_type = 'Issue' AND" +
" (#{JournalDetail.table_name}.prop_key = 'status_id' OR #{Journal.table_name}.notes <> '')"}
:conditions => "#{Journal.table_name}.journalized_type = 'Issue' AND" +
"(#{JournalDetail.table_name}.prop_key = 'status_id' OR #{Journal.table_name}.notes <> '')"}
before_create :split_private_notes

View File

@ -15,8 +15,9 @@ class JournalsForMessage < ActiveRecord::Base
"m_parent_id", # 留言信息的父留言id
"is_readed", # 留言是否已读
"m_reply_count", # 留言的回复数量
"m_reply_id" # 回复某留言的留言id(a留言回复了b留言这是b留言的id)
"is_comprehensive_evaluation" # 1 教师评论、2 匿评、3 留言
"m_reply_id" , # 回复某留言的留言id(a留言回复了b留言这是b留言的id)
"is_comprehensive_evaluation", # 1 教师评论、2 匿评、3 留言
"private"
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,
@ -69,12 +70,21 @@ class JournalsForMessage < ActiveRecord::Base
validates :notes, presence: true, if: :is_homework_jour?
after_create :act_as_activity, :act_as_course_activity, :act_as_course_message, :act_as_at_message, :act_as_user_feedback_message, :act_as_principal_activity, :act_as_student_score
after_create :reset_counters!
after_update :update_ativity
after_destroy :reset_counters!
after_save :be_user_score
after_destroy :down_user_score
# default_scope { where('m_parent_id IS NULL') }
#动态的更新
def update_activity
update_course_activity(self.class, self.id)
update_user_activity(self.class, self.id)
update_forge_activity(self.class, self.id)
update_org_activity(self.class, self.id)
update_principal_activity(self.class, self.id)
end
def self.create_by_user? user
if user.anonymous?
return false

View File

@ -155,8 +155,6 @@ class Mailer < ActionMailer::Base
# 发送内容: 项目【缺陷,讨论区,新闻】,课程【通知,留言,新闻】, 贴吧, 个人留言
def send_for_user_activities(user, date_to, days)
date_from = date_to - days.days
subject = "[ #{user.show_name}#{l(:label_day_mail)}]"
@subject = " #{user.show_name}#{l(:label_day_mail)}"
date_from = "#{date_from} 17:59:59"
date_to = "#{date_to} 17:59:59"
# 生成token用于直接点击登录
@ -268,10 +266,14 @@ class Mailer < ActionMailer::Base
has_content = [@issues,@issues_journals,@course_messages,@project_messages,@course_news,@course_news_comments,@project_news,@project_news_comments,@project_attachments,
@course_journal_messages,@user_journal_messages,@project_journal_messages,@forums,@memos,@attachments,@bids,@wiki_contents].any? {|o| !o.empty?}
total_count = @issues.count + @issues_journals.count + @course_messages.count + @project_messages.count + @course_news.count + @course_news_comments.count + @project_news.count + @project_news_comments.count +
@project_attachments.count + @course_journal_messages.count + @user_journal_messages.count + @project_journal_messages.count + @forums.count + @memos.count + @attachments.count +
@bids.count + @wiki_contents.count
subject = "[ #{user.show_name}#{l(:label_day_mail_first)}#{total_count}#{l(:label_day_mail_last)}]"
@subject = " #{user.show_name}#{l(:label_day_mail_first)}#{total_count}#{l(:label_day_mail_last)}"
mylogger.debug "Sent activity mail : #{user.mail} - #{has_content}"
#有内容才发,没有不发
mail :to => user.mail,:subject => subject if has_content
mail :to => user.mail,:subject => @subject if has_content
end
# 作业截止时间邮件提醒
@ -394,7 +396,7 @@ class Mailer < ActionMailer::Base
@issue = issue
user = User.find_by_mail(recipients)
@user = user
@token = Token.get_token_from_user(user, 'autologin')
# @token = Token.get_token_from_user(user, 'autologin')
@issue_url = url_for(:controller => 'issues', :action => 'show', :id => issue.id)
# edit
@ -436,15 +438,15 @@ class Mailer < ActionMailer::Base
user = User.find_by_mail(recipients)
@user = user
@token = Token.get_token_from_user(user, 'autologin')
# @token = Token.get_token_from_user(user, 'autologin')
# edit
@issue_author_url = url_for(:controller => 'users', :action => 'show', :id => issue.author_id, :token => @token.value)
@project_url = url_for(:controller => 'projects', :action => 'show', :id => issue.project_id, :token => @token.value)
@user_url = url_for(my_account_url(user,:token => @token.value))
@issue_author_url = url_for(:controller => 'users', :action => 'show', :id => issue.author_id)
@project_url = url_for(:controller => 'projects', :action => 'show', :id => issue.project_id)
@user_url = url_for(my_account_url(user))
@issue_url = url_for(:controller => 'issues', :action => 'show', :id => issue.id, :anchor => "change-#{journal.id}", :token => @token.value)
@issue_url = url_for(:controller => 'issues', :action => 'show', :id => issue.id, :anchor => "change-#{journal.id}")
s = "[#{issue.project.name} - #{issue.tracker.name} ##{issue_id}] "
s << "(#{issue.status.name}) " if journal.new_value_for('status_id')
s << issue.subject

View File

@ -23,6 +23,8 @@ class Message < ActiveRecord::Base
belongs_to :board,:touch => true
belongs_to :author, :class_name => 'User', :foreign_key => 'author_id'
has_many :praise_tread, as: :praise_tread_object, dependent: :destroy
# has_many :org_subfield_messages, :dependent => :destroy
# has_many :org_subfields, :through => :org_subfield_messages
acts_as_tree :counter_cache => :replies_count, :order => "#{Message.table_name}.created_on ASC"
acts_as_attachable
@ -34,6 +36,8 @@ class Message < ActiveRecord::Base
has_many :forge_acts, :class_name => 'ForgeActivity',:as =>:forge_act ,:dependent => :destroy
# 课程动态
has_many :course_acts, :class_name => 'CourseActivity',:as =>:course_act ,:dependent => :destroy
has_many :user_acts, :class_name => 'UserActivity',:as =>:user_act ,:dependent => :destroy
# end
# 课程/项目 消息
has_many :course_messages, :class_name =>'CourseMessage', :as => :course_message, :dependent => :destroy
@ -42,6 +46,8 @@ class Message < ActiveRecord::Base
has_many :ActivityNotifies,:as => :activity, :dependent => :destroy
after_destroy :delete_org_activities
acts_as_searchable :columns => ['subject', 'content'],
:include => {:board => :project},
:project_key => "#{Board.table_name}.project_id",
@ -71,7 +77,7 @@ class Message < ActiveRecord::Base
validate :cannot_reply_to_locked_topic, :on => :create
after_create :add_author_as_watcher, :reset_counters!
after_update :update_messages_board
after_update :update_messages_board, :update_activity
after_destroy :reset_counters!,:down_user_score,:delete_kindeditor_assets
after_create :act_as_activity,:act_as_course_activity,:be_user_score,:act_as_forge_activity, :act_as_system_message, :send_mail, :act_as_student_score, :act_as_at_message
@ -148,6 +154,10 @@ class Message < ActiveRecord::Base
usr && usr.logged? && (usr.allowed_to?(:edit_messages, course) || (self.author == usr && usr.allowed_to?(:edit_own_messages, course)))
end
def org_subfield_editable_by?(usr)
usr && usr.logged? && (usr.admin? || self.author == usr ||usr.admin_of_org?(self.board.org_subfield.organization))
end
def course_destroyable_by?(usr)
usr && usr.logged? && (usr.allowed_to?(:delete_messages, course) || (self.author == usr && usr.allowed_to?(:delete_own_messages, course)))
end
@ -172,6 +182,13 @@ class Message < ActiveRecord::Base
def get_notify_is_read()
return @notify_is_read
end
#动态的更新
def update_activity
update_course_activity(self.class, self.id)
update_user_activity(self.class, self.id)
update_forge_activity(self.class, self.id)
update_org_activity(self.class, self.id)
end
private
@ -190,9 +207,8 @@ class Message < ActiveRecord::Base
# Description
def act_as_forge_activity
# 如果project为空那么就是课程相关的消息
if !self.board.project.nil? && self.parent_id.nil?
self.forge_acts << ForgeActivity.new(:user_id => self.author_id,
:project_id => self.board.project.id)
if self.board.project_id != -1 && self.parent_id.nil?
self.forge_acts << ForgeActivity.new(:user_id => self.author_id, :project_id => self.board.project.id)
end
end
@ -225,7 +241,7 @@ class Message < ActiveRecord::Base
end
end
end
else # 项目相关
elsif self.project # 项目相关
if self.parent_id.nil? # 主贴
self.project.members.each do |m|
if m.user_id != self.author_id
@ -310,4 +326,8 @@ class Message < ActiveRecord::Base
end
end
end
def delete_org_activities
OrgActivity.where("org_act_type='Message' and org_act_id =#{self.id} and container_type='OrgSubfield'").destroy_all
end
end

View File

@ -56,7 +56,7 @@ class News < ActiveRecord::Base
acts_as_watchable
after_create :act_as_activity,:act_as_forge_activity, :act_as_course_activity,:act_as_system_message, :add_author_as_watcher, :send_mail
after_update :update_activity
after_destroy :delete_kindeditor_assets
scope :visible, lambda {|*args|
@ -68,6 +68,14 @@ class News < ActiveRecord::Base
}
safe_attributes 'title', 'summary', 'description', 'sticky'
#动态的更新
def update_activity
update_course_activity(self.class, self.id)
update_user_activity(self.class, self.id)
update_org_activity(self.class, self.id)
update_forge_activity(self.class, self.id)
end
def visible?(user=User.current)
!user.nil? && user.allowed_to?(:view_news, project)
end

View File

@ -1,20 +1,36 @@
class OrgDocumentComment < ActiveRecord::Base
attr_accessible :content, :creator_id, :organization_id, :parent_id, :reply_id, :title,:sticky,:locked
include Redmine::SafeAttributes
belongs_to :organization
belongs_to :creator, :class_name => 'User', :foreign_key => 'creator_id'
has_many :editor_of_documents, :dependent => :destroy
acts_as_tree :order => "#{OrgDocumentComment.table_name}.sticky asc, #{OrgDocumentComment.table_name}.created_at desc"
has_many :org_acts, :class_name => 'OrgActivity',:as =>:org_act ,:dependent => :destroy
after_create :document_save_as_org_activity
def document_save_as_org_activity
if(self.parent().nil?)
self.org_acts << OrgActivity.new(:user_id => User.current.id, :container_id => self.organization.id, :container_type => 'Organization')
else
act = OrgActivity.where("org_act_type='OrgDocumentComment' and org_act_id =?", self.root.id).first
act.update_attributes(:updated_at => self.updated_at)
end
end
end
class OrgDocumentComment < ActiveRecord::Base
attr_accessible :content, :creator_id, :organization_id, :parent_id, :reply_id, :title,:sticky,:locked
include Redmine::SafeAttributes
belongs_to :organization
belongs_to :creator, :class_name => 'User', :foreign_key => 'creator_id'
has_many :editor_of_documents, :dependent => :destroy
acts_as_tree :order => "#{OrgDocumentComment.table_name}.sticky asc, #{OrgDocumentComment.table_name}.created_at desc"
acts_as_attachable
has_many :org_acts, :class_name => 'OrgActivity',:as =>:org_act ,:dependent => :destroy
after_create :document_save_as_org_activity
after_update :update_activity
#动态的更新
def update_activity
org_activity = OrgActivity.where("org_act_type='OrgDocumentComment' and org_act_id =?", id).first
if org_activity
org_activity.updated_at = Time.now
org_activity.save
end
end
def document_save_as_org_activity
if(self.parent().nil?)
self.org_acts << OrgActivity.new(:user_id => User.current.id, :container_id => self.organization.id, :container_type => 'Organization')
else
act = OrgActivity.where("org_act_type='OrgDocumentComment' and org_act_id =?", self.root.id).first
act.update_attributes(:updated_at => self.updated_at)
end
end
def project
end
end

15
app/models/org_message.rb Normal file
View File

@ -0,0 +1,15 @@
class OrgMessage < ActiveRecord::Base
belongs_to :user
belongs_to :organization
has_many :message_alls, :as => :message, :dependent => :destroy
validates :message_type, :presence => true
validates :message_id, :presence => true
validates :organization_id, :presence => true
after_create :add_user_message
def add_user_message
if MessageAll.where("message_type = '#{self.class.to_s}' and message_id = '#{self.id}'").first.nil?
self.message_alls << MessageAll.new(:user_id => self.user_id)
end
end
end

View File

@ -1,9 +1,26 @@
class OrgSubfield < ActiveRecord::Base
belongs_to :organization, :foreign_key => :organization_id
has_many :org_document_comments, :dependent => :destroy
has_many :files
acts_as_attachable
def project
end
class OrgSubfield < ActiveRecord::Base
belongs_to :organization, :foreign_key => :organization_id
has_many :org_document_comments, :dependent => :destroy
has_many :files
has_many :org_subfield_messages, :dependent => :destroy
has_many :messages, :through => :org_subfield_messages
has_many :boards, :dependent => :destroy
acts_as_attachable
after_create :create_board_sync
# 创建资源栏目讨论区
def create_board_sync
@board = self.boards.build
#self.name=" #{l(:label_borad_course) }"
@board.name = " #{l(:label_borad_org_subfield) }"#self.name
@board.description = self.name.to_s
@board.project_id = -1
if @board.save
logger.debug "[OrgSubfield Model] ===> #{@board.to_json}"
else
logger.error "[OrgSubfield Model] ===> Auto create board when org_subfield saved, because #{@board.full_messages}"
end
end
def project
end
end

View File

@ -0,0 +1,3 @@
class OrgSubfieldMessage < ActiveRecord::Base
# attr_accessible :title, :body
end

View File

@ -9,9 +9,15 @@ class Organization < ActiveRecord::Base
has_many :org_subfields, :dependent => :destroy
has_many :users, :through => :org_members
validates_uniqueness_of :name
after_create :save_as_org_activity
after_create :save_as_org_activity, :add_default_subfields
def save_as_org_activity
OrgActivity.create(:user_id => User.current.id, :org_act_id => self.id, :org_act_type => 'CreateOrganization', :container_id => self.id, :container_type => 'Organization')
end
def add_default_subfields
OrgSubfield.create(:organization_id => self.id, :name => 'activity', :field_type => 'default')
OrgSubfield.create(:organization_id => self.id, :name => 'course', :field_type => 'default')
OrgSubfield.create(:organization_id => self.id, :name => 'project', :field_type => 'default')
end
end

View File

@ -14,7 +14,7 @@ class Poll < ActiveRecord::Base
# 课程消息
has_many :course_messages, :class_name =>'CourseMessage', :as => :course_message, :dependent => :destroy
after_save :act_as_course_message, :act_as_activity, :act_as_course_activity
after_update :update_activity
acts_as_event :title => Proc.new {|o| "#{l(:label_course_poll)}: #{o.polls_name}" },
:description => :polls_description,
:datetime => :published_at,
@ -32,6 +32,13 @@ class Poll < ActiveRecord::Base
self.acts << Activity.new(:user_id => self.user_id)
end
#动态的更新
def update_activity
update_course_activity(self.class, self.id)
update_user_activity(self.class, self.id)
update_org_activity(self.class, self.id)
end
#课程动态公共表记录
def act_as_course_activity
if self.polls_type == "Course"

View File

@ -0,0 +1,3 @@
class ShieldActivity < ActiveRecord::Base
end

View File

@ -7,6 +7,7 @@ class SystemMessage < ActiveRecord::Base
validates_length_of :description, maximum: 10000
has_many :message_alls, :class_name => 'MessageAll',:as =>:message, :dependent => :destroy
acts_as_attachable
# 系统消息放置总消息列表
after_create :add_system_message

View File

@ -344,7 +344,8 @@ class User < Principal
user_feedback_count = UserFeedbackMessage.where("user_id =? and viewed =? and created_at >?", User.current.id, 0, User.current.onclick_time.onclick_time).count
user_memo_count = MemoMessage.where("user_id =? and viewed =? and created_at >?", User.current.id, 0, User.current.onclick_time.onclick_time).count
system_messages_count = SystemMessage.where("created_at >?", User.current.onclick_time.onclick_time).count
messages_count = course_count + forge_count + user_feedback_count + user_memo_count + system_messages_count
at_count = AtMessage.where("user_id =? and viewed =? and created_at >?", User.current.id, 0, User.current.onclick_time.onclick_time).count
messages_count = course_count + forge_count + user_feedback_count + user_memo_count + system_messages_count + at_count
end
# 查询指派给我的缺陷记录

View File

@ -193,9 +193,12 @@ class CoursesService
@course.extra = 'course' + DateTime.parse(Time.now.to_s).strftime('%Y-%m-%d_%H-%M-%S').to_s
@course.send(:safe_attributes=, params[:course], current_user)
#@course.safe_attributes(current_user,params[:course])
@course.password = params[:course][:password]
@course.tea_id = current_user.id
@course.term = params[:term]
@course.time = params[:time]
@course.end_term = params[:end_term]
@course.end_time = params[:end_time]
#@course.school_id = params[:occupation]
@course.school_id = current_user.user_extensions.school_id
@course.setup_time = params[:setup_time]

View File

@ -19,6 +19,7 @@
<div>
<p id="content_notice_span" class="ml55"></p>
</div>
<div class="cl"></div>
<div class="actions">
<%= link_to l(:label_submit), "javascript:void(0)", :class => "btn_message_free", :onclick => "system_message_editor.sync();submit_message();" %>
</div>

View File

@ -0,0 +1,19 @@
<% if activity.attachments.any? %>
<% activity.attachments.each do |attachment| %>
<div class="break_word">
<span class="fl">
<span title="<%= attachment.filename %>" id="attachment_<%=attachment.id %>">
<%= link_to_short_attachment attachment,:length=> 58, :class => 'mw400 hidden link_file_a fl newsBlue', :download => true -%>
</span>
</span>
<span class="postAttSize">(
<%= number_to_human_size attachment.filesize %>)
</span>
<span class="author" title="<%= attachment.author%>">
<%= link_to h(truncate(attachment.author.name, length: 10, omission: '...')),user_path(attachment.author),:class => "c_orange" %>,
<%= format_time(attachment.created_on) %>
</span>
</div>
<div class="cl"></div>
<% end %>
<% end %>

View File

@ -4,10 +4,10 @@
<% container.saved_attachments.each_with_index do |attachment, i| %>
<span id="attachments_p<%= i %>" class="sub_btn">
<%= text_field_tag("attachments[p#{i}][filename]", attachment.filename, :class => 'filename readonly', :readonly=>'readonly')%>
<%= text_field_tag("attachments[p#{i}][description]", attachment.description, :maxlength => 255, :placeholder => l(:label_optional_description), :class => 'description', :style=>"display: inline-block;") %>
<span class="ispublic-label"><%= l(:field_is_public)%>:</span>
<%= check_box_tag("attachments[p#{i}][is_public_checkbox]", attachment.is_public,attachment.is_public == 1 ? true : false, :class => 'is_public_checkbox')%>
<%= text_field_tag("attachments[p#{i}][filename]", attachment.filename, :class => 'upload_filename readonly', :readonly=>'readonly')%>
<%#= text_field_tag("attachments[p#{i}][description]", attachment.description, :maxlength => 255, :placeholder => l(:label_optional_description), :class => 'description', :style=>"display: inline-block;") %>
<!--<span class="ispublic-label"><%#= l(:field_is_public)%>:</span>-->
<%#= check_box_tag("attachments[p#{i}][is_public_checkbox]", attachment.is_public,attachment.is_public == 1 ? true : false, :class => 'is_public_checkbox')%>
<%= link_to('&nbsp;'.html_safe, attachment_path(attachment, :attachment_id => "p#{i}", :format => 'js'), :method => 'delete', :remote => true, :class => 'remove-upload') %>
<%= hidden_field_tag "attachments[p#{i}][token]", "#{attachment.token}" %>
@ -17,10 +17,10 @@
<% container.attachments.each_with_index do |attachment, i| %>
<span id="attachments_p<%= i %>" class="attachment">
<%= text_field_tag("attachments[p#{i}][filename]", attachment.filename, :class => 'filename readonly', :readonly=>'readonly')%>
<%= text_field_tag("attachments[p#{i}][description]", attachment.description, :maxlength => 255, :placeholder => l(:label_optional_description), :class => 'description', :style=>"display: inline-block;") %>
<span class="ispublic-label"><%= l(:field_is_public)%>:</span>
<%= check_box_tag("attachments[p#{i}][is_public_checkbox]", attachment.is_public,attachment.is_public == 1 ? true : false, :class => 'is_public_checkbox')%>
<%= text_field_tag("attachments[p#{i}][filename]", attachment.filename, :class => 'upload_filename readonly', :readonly=>'readonly')%>
<%#= text_field_tag("attachments[p#{i}][description]", attachment.description, :maxlength => 255, :placeholder => l(:label_optional_description), :class => 'description', :style=>"display: inline-block;") %>
<!--<span class="ispublic-label"><%#= l(:field_is_public)%>:</span>-->
<%#= check_box_tag("attachments[p#{i}][is_public_checkbox]", attachment.is_public,attachment.is_public == 1 ? true : false, :class => 'is_public_checkbox')%>
<%= link_to('&nbsp;'.html_safe, attachment_path(attachment, :attachment_id => "p#{i}", :format => 'js'), :method => 'delete', :remote => true, :class => 'remove-upload') %>
<%#= render :partial => 'tags/tag', :locals => {:obj => attachment, :object_flag => "6"} %>
@ -61,8 +61,7 @@
:are_you_sure => l(:text_are_you_sure),
:file_count => l(:label_file_count),
:delete_all_files => l(:text_are_you_sure_all),
:lebel_file_uploding => l(:lebel_file_uploding),
:containerid => "#{container.id}"
:lebel_file_uploding => l(:lebel_file_uploding)
} %>
<% if container.nil? %>
<span id="upload_file_count" :class="c_grey"><%= l(:label_no_file_uploaded)%></span>

View File

@ -0,0 +1,77 @@
<span id="attachments_fields<%= container.id %>" class="attachments_fields" xmlns="http://www.w3.org/1999/html">
<% if defined?(container) && container && container.saved_attachments %>
<% if isReply %>
<% container.saved_attachments.each_with_index do |attachment, i| %>
<span id="attachments_p<%= i %>" class="sub_btn">
<%= text_field_tag("attachments[p#{i}][filename]", attachment.filename, :class => 'filename readonly', :readonly=>'readonly')%>
<%= text_field_tag("attachments[p#{i}][description]", attachment.description, :maxlength => 255, :placeholder => l(:label_optional_description), :class => 'description', :style=>"display: inline-block;") %>
<span class="ispublic-label"><%= l(:field_is_public)%>:</span>
<%= check_box_tag("attachments[p#{i}][is_public_checkbox]", attachment.is_public,attachment.is_public == 1 ? true : false, :class => 'is_public_checkbox')%>
<%= link_to('&nbsp;'.html_safe, attachment_path(attachment, :attachment_id => "p#{i}", :format => 'js'), :method => 'delete', :remote => true, :class => 'remove-upload') %>
<%= hidden_field_tag "attachments[p#{i}][token]", "#{attachment.token}" %>
</span>
<% end %>
<% else %>
<% container.attachments.each_with_index do |attachment, i| %>
<span id="attachments_p<%= i %>" class="attachment">
<%= text_field_tag("attachments[p#{i}][filename]", attachment.filename, :class => 'filename readonly', :readonly=>'readonly')%>
<%= text_field_tag("attachments[p#{i}][description]", attachment.description, :maxlength => 255, :placeholder => l(:label_optional_description), :class => 'description', :style=>"display: inline-block;") %>
<span class="ispublic-label"><%= l(:field_is_public)%>:</span>
<%= check_box_tag("attachments[p#{i}][is_public_checkbox]", attachment.is_public,attachment.is_public == 1 ? true : false, :class => 'is_public_checkbox')%>
<%= link_to('&nbsp;'.html_safe, attachment_path(attachment, :attachment_id => "p#{i}", :format => 'js'), :method => 'delete', :remote => true, :class => 'remove-upload') %>
<%#= render :partial => 'tags/tag', :locals => {:obj => attachment, :object_flag => "6"} %>
<%= hidden_field_tag "attachments[p#{i}][token]", "#{attachment.token}" %>
</span>
<% end %>
<% end %>
<% end %>
</span>
<script type='text/javascript'>
// function CompatibleSend()
// {
// var obj=document.getElementById("_file");
// var file= $(obj).clone();
// file.click();
// }
</script>
<span class="add_attachment">
<%#= button_tag "浏览", :type=>"button", :onclick=>"CompatibleSend();" %>
<!--%= link_to image_tag(),"javascript:void(0)", :onclick => "_file.click()"%-->
<%#= button_tag "#{l(:button_browse)}", :type=>"button", :onclick=>"file#{container.id}.click()",:class =>"sub_btn",:style => ie8? ? 'display:none' : '' %>
<% id ="file#{container.id}"%>
<a href="javascript:void(0);" class="AnnexBtn fl" style= "<%= ie8? ? 'display:none' : ''%>" onclick="$('#'+'<%= id %>').click();">上传附件</a>
<%= file_field_tag 'attachments[dummy][file]',
:id => "file#{container.id}",
:class => 'file_selector',
:multiple => true,
:onchange => "addInputFiles_board(this, '#{container.id}');",
:style => 'display:none',
:data => {
:max_file_size => Setting.attachment_max_size.to_i.kilobytes,
:max_file_size_message => l(:error_attachment_too_big, :max_size => number_to_human_size(Setting.attachment_max_size.to_i.kilobytes)),
:max_concurrent_uploads => Redmine::Configuration['max_concurrent_ajax_uploads'].to_i,
:upload_path => uploads_path(:format => 'js'),
:description_placeholder => l(:label_optional_description),
:field_is_public => l(:field_is_public),
:are_you_sure => l(:text_are_you_sure),
:file_count => l(:label_file_count),
:delete_all_files => l(:text_are_you_sure_all),
:lebel_file_uploding => l(:lebel_file_uploding),
:containerid => "#{container.id}"
} %>
<% if container.nil? %>
<span id="upload_file_count" :class="c_grey"><%= l(:label_no_file_uploaded)%></span>
<% end %>
<!--(<%#= l(:label_max_size) %>: <%#= number_to_human_size(Setting.attachment_max_size.to_i.kilobytes) %>)-->
</span>
<% content_for :header_tags do %>
<%= javascript_include_tag 'attachments' %>
<% end %>

View File

@ -0,0 +1,38 @@
<span id="attachments_fields<%= container.id %>" class="attachments_fields" xmlns="http://www.w3.org/1999/html">
<% if defined?(container) && container && container.saved_attachments %>
<% container.attachments.each_with_index do |attachment, i| %>
<span id="attachments_p<%= i %>" class="attachment">
<%= hidden_field_tag "attachments[p#{i}][token]", "#{attachment.token}" %>
</span>
<% end %>
<% end %>
</span>
<span class="add_attachment">
<% id ="file#{container.id}"%>
<a href="javascript:void(0);" class="AnnexBtn fl" style= "<%= ie8? ? 'display:none' : ''%>" onclick="$('#'+'<%= id %>').click();">上传附件</a>
<%= file_field_tag 'attachments[dummy][file]',
:id => "file#{container.id}",
:class => 'file_selector',
:multiple => true,
:onchange => "addInputFiles_board(this, '#{container.id}');",
:style => 'display:none',
:data => {
:max_file_size => Setting.attachment_max_size.to_i.kilobytes,
:max_file_size_message => l(:error_attachment_too_big, :max_size => number_to_human_size(Setting.attachment_max_size.to_i.kilobytes)),
:max_concurrent_uploads => Redmine::Configuration['max_concurrent_ajax_uploads'].to_i,
:upload_path => uploads_path(:format => 'js'),
:description_placeholder => l(:label_optional_description),
:field_is_public => l(:field_is_public),
:are_you_sure => l(:text_are_you_sure),
:file_count => l(:label_file_count),
:delete_all_files => l(:text_are_you_sure_all),
:lebel_file_uploding => l(:lebel_file_uploding)} %>
<% if container.nil? %>
<span id="upload_file_count" :class="c_grey"><%= l(:label_no_file_uploaded)%></span>
<% end %>
</span>
<% content_for :header_tags do %>
<%= javascript_include_tag 'attachments' %>
<% end %>

View File

@ -0,0 +1,54 @@
<!--<div class="resourceUploadPopup">-->
<span class="uploadDialogText">更新资源版本</span>
<!--<div class="resourcePopupClose"> <a href="javascript:void(0);" class="resourceClose" onclick="closeModal();"></a></div>-->
<div class="uploadBoxContainer mt0">
<div>
<div>当前版本
<span class="attachment" >
<input readonly="readonly" name="attachments[1][filename]" value="<%=@attachment.filename%>" class="upload_filename readonly" type="text">
</span>
</div>
<% unless @attachment_histories.empty? %>
<div >历史版本</div>
<div style="max-height: 95px;overflow-y:auto; background-color: #e3e3e3;" class="mb10 p10">
<% @attachment_histories.each do |history| %>
<span class="attachment">
<input readonly="readonly" name="attachments_versions_<%= history.id%>" value="<%=history.filename%>" class="upload_filename readonly" type="text">
<span>版本号:<%= history.version %></span>
</span>
<% end %>
</div>
<% end %>
</div>
<%= form_tag(upload_attachment_version_path, :multipart => true,:remote => !ie8?,:name=>"upload_form",:id=>'upload_form') do %>
<%= hidden_field_tag :old_attachment_id,@attachment.id %>
<div>
<span id="attachments_fields" xmlns="http://www.w3.org/1999/html">
</span>
</div>
<div class="uploadBox">
<input type="hidden" name="attachment_type" value="1">
<%= render :partial => 'attachments/upload_attachment_new_version' %>
<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>-->
</div>
<div class="uploadResourceIntr">
<div class="uploadResourceName fl"><span id="upload_file_count">(未选择文件)</span></div>
<div class="uploadResourceIntr2 fl">您可以上传小于<span class="c_red">50MB</span>的文件</div>
</div>
</div>
<div class="cl"></div>
<div style="margin-top: 10px" >
<div class="courseSendSubmit">
<!--<a href="javascript:void(0);" class="sendSourceText" onclick="">确定</a>-->
<%= submit_tag '确定',:onclick=>'upload_attachment_version(event);',:onfocus=>'this.blur()',:id=>'upload_files_submit_btn',:class=>'sendSourceText' %>
</div>
<div class="courseSendCancel"><a href="javascript:void(0);" id="upload_files_cancle_btn" class="sendSourceText" onclick="hideModal();">取消</a></div>
</div>
<% end %>
<div class="cl"></div>
<!--</div>-->

View File

@ -0,0 +1,23 @@
<!--<button name="button" class="sub_btn" onclick="_file.click()" onmouseover="this.focus()" style="<%#= ie8? ? 'display:none' : ''%>" type="button" ><%#= l(:label_browse) %></button>-->
<a href="javascript:void(0);" class="uploadIcon f14" name="button" onclick="_file.click()" onmouseover="" style="<%= ie8? ? 'display:none' : ''%>">
<span class="chooseFile">选择文件</span></a>
<%= file_field_tag 'attachments[dummy][file]',
:id => '_file',
:class => ie8? ? '':'file_selector',
:multiple => true,
:onchange => 'addInputFiles(this,"'+'upload_files_submit_btn'+'");',
:style => ie8? ? '': 'display:none',
:data => {
:max_file_size => Setting.attachment_max_size.to_i.kilobytes,
:max_file_size_message => l(:error_attachment_too_big, :max_size => number_to_human_size(Setting.attachment_max_size.to_i.kilobytes)),
:max_concurrent_uploads => Redmine::Configuration['max_concurrent_ajax_uploads'].to_i,
:upload_path => uploads_path(:format => 'js',:old_attachment_id=>@attachment.id),
:description_placeholder => l(:label_optional_description),
:field_is_public => l(:field_is_public),
:are_you_sure => l(:text_are_you_sure),
:file_count => l(:label_file_count),
:lebel_file_uploding => l(:lebel_file_uploding),
:delete_all_files => l(:text_are_you_sure_all)
} %>

View File

@ -0,0 +1,7 @@
$("#ajax-modal").html('<%= escape_javascript( render :partial => 'attachments/show_attachment_history' )%>');
showModal('ajax-modal', '452px');
$('#ajax-modal').siblings().remove();
$('#ajax-modal').before("<a href='javascript:void(0)' onclick='hideModal();' style='margin-left: 435px;' class='resourceClose'></a>");
$('#ajax-modal').parent().css("top","40%").css("left","46%");
$('#ajax-modal').parent().addClass("resourceUploadPopup");
$('#ajax-modal').css("padding-left","16px").css("padding-bottom","16px");

View File

@ -1,2 +1,16 @@
<% if @attachment.container_type == 'Course' %>
$("#is_public_<%= @attachment.id %>").html("<%= escape_javascript(link_to (@attachment.is_public? ? "设为私有":"设为公开"), update_file_dense_attachments_path(:attachmentid=>@attachment.id,:newtype=>(@attachment.is_public? ? 0:1)),
:remote=>true,:class=>"postOptionLink",:method => :post) %>");
<% elsif @attachment.container_type == 'Project' %>
$("#is_public_<%= @attachment.id %>").html("<%= escape_javascript(link_to (@attachment.is_public? ? "设为私有":"设为公开"), update_file_dense_attachments_path(:attachmentid => @attachment.id, :newtype => (@attachment.is_public? ? 0:1)),
:remote => true, :class => "postOptionLink", :method => :post) %>");
<% else %>
$("#is_public_<%= @attachment.id %>").html("<%= escape_javascript(link_to (@attachment.is_public? ? "公开":"私有"), update_file_dense_attachments_path(:attachmentid=>@attachment.id,:newtype=>(@attachment.is_public? ? 0:1)),
:remote=>true,:class=>"f_l re_open",:method => :post) %>");
<% end %>
<% if @attachment.is_public? %>
$("#image_private_<%= @attachment.id%>").html('')
<%else%>
$("#image_private_<%= @attachment.id%>").html('<span class="img_private ml5">私有</span>')
<% end %>

View File

@ -11,4 +11,5 @@ fileSpan.find('a.remove-upload')
})
.off('click');
$('<input>', { type: 'hidden', name: 'attachments[<%= j params[:attachment_id] %>][token]' } ).val('<%= j @attachment.token %>').appendTo(fileSpan);
$('<input>',{type:'hidden',name:'attachments[<%= j params[:attachment_id] %>][attachment_id]'}).val('<%= @attachment.id %>').appendTo(fileSpan);
<% end %>

View File

@ -0,0 +1,7 @@
<% if @flag %>
hideModal();
alert('更新成功')
$(".re_search").submit();
<%else%>
$("#upload_file_count").html('(更新失败)')
<%end %>

View File

@ -57,7 +57,7 @@
:max_file_size => Setting.attachment_max_size.to_i.kilobytes,
:max_file_size_message => l(:error_attachment_too_big, :max_size => number_to_human_size(Setting.attachment_max_size.to_i.kilobytes)),
:max_concurrent_uploads => Redmine::Configuration['max_concurrent_ajax_uploads'].to_i,
:upload_path => uploads_path(:format => 'js', :project => container),
:upload_path => uploads_path(:format => 'js'),
:description_placeholder => l(:label_optional_description),
:field_is_public => l(:field_is_public),
:are_you_sure => l(:text_are_you_sure),

View File

@ -1,5 +1,5 @@
<% if User.current.logged? && User.current.id == @user.id %>
<%= form_for @article, :url =>{:controller=>'blog_comments',:action => 'update',:user_id=>@user.id , :blog_id => @article.id},:method=>'PUT',
<%= form_for @article, :url =>{:controller=>'blog_comments',:action => 'update',:user_id=>@user.id , :blog_id => @article.id, :is_homepage => params[:is_homepage]},:method=>'PUT',
:html => {:nhname=>'form',:multipart => true, :id => 'message-form'} do |f| %>
<%= render :partial => 'blog_comments/edit', :locals => {:f => f, :article => @article, :edit_mode => true, :user => @user} %>
<% end %>

View File

@ -1,7 +1,8 @@
<% if @in_user_center%>
$("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'users/user_blog', :locals => {:activity => @article,:user_activity_id =>@user_activity_id}) %>");
init_activity_KindEditor_data(<%= @user_activity_id%>,"","87%", 'UserActivity');
// init_activity_KindEditor_data(<%#= @user_activity_id%>,"","87%", 'UserActivity');
<% else%>
$("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'blogs/article', :locals => {:activity => @article,:user_activity_id =>@user_activity_id}) %>");
init_activity_KindEditor_data(<%= @user_activity_id%>,"","87%", 'UserActivity');
<% end %>
//init_activity_KindEditor_data(<%#= @user_activity_id%>,"","87%", 'UserActivity');
<% end %>
init_activity_KindEditor_data(<%= @user_activity_id%>,"","87%", 'UserActivity');

View File

@ -58,6 +58,23 @@
:class => 'postOptionLink'
) if User.current && User.current.id == @article.author.id %>
</li>
<li>
<% if @article.id == @article.blog.homepage_id %>
<%= link_to(
l(:button_cancel_homepage),
{:controller => 'blogs',:action => 'cancel_homepage',:user_id=>@article.author_id,:id=>@article.blog_id, :article_id => @article.id},
:method => :post,
:class => 'postOptionLink'
) if User.current && User.current.id == @article.blog.author_id %>
<% else %>
<%= link_to(
l(:button_set_homepage),
{:controller => 'blogs',:action => 'set_homepage',:user_id=>@article.author_id,:id=>@article.blog_id, :article_id => @article.id},
:method => :post,
:class => 'postOptionLink'
) if User.current && User.current.id == @article.blog.author_id %>
<% end %>
</li>
</ul>
</li>
</ul>

View File

@ -25,6 +25,14 @@
:class => 'postOptionLink'
) if User.current && User.current.id == activity.author.id %>
</li>
<li>
<%= link_to(
l(:button_set_homepage),
{:controller => 'blogs',:action => 'set_homepage',:user_id=>activity.author_id,:id=>activity.blog_id, :article_id => activity.id},
:method => :post,
:class => 'postOptionLink'
) if User.current && User.current.id == activity.blog.author_id %>
</li>
</ul>
</li>
</ul>
@ -38,6 +46,9 @@
<% end %>
TO
<%= link_to activity.blog.name+" | 博客", user_blogs_path(:user_id=>activity.author_id,:host=>Setting.host_user), :class => "newsBlue ml15 mr5"%>
<% if activity.blog.homepage_id and activity.id == activity.blog.homepage_id %>
<span class="red_homework_btn_cir ml5">已设为首页</span>
<% end %>
</div>
<div class="cl"></div>
<div class="homepagePostTitle hidden m_w530 fl">
@ -54,23 +65,35 @@
<span class="locked_btn_cir ml10 fl" title="已锁定">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>
<% end%>
<div class="cl"></div>
<div class="homepagePostDate">
<div class="homepagePostDate fl">
发帖时间:<%= format_time(activity.created_on) %>
</div>
<div class="homepagePostIntro break_word upload_img list_style" id="activity_description_<%= user_activity_id%>">
<% if activity.parent_id.nil? %>
<%= activity.content.to_s.html_safe%>
<% else %>
<%= activity.parent.content.to_s.html_safe%>
<% end %>
<div class="homepagePostDate fl ml15">
更新时间:<%= format_time(UserActivity.where("act_type='#{activity.class}' and act_id =#{activity.id}").first.updated_at) %>
</div>
<div class="cl"></div>
<div class=" fl" style="width: 600px">
<% if activity.attachments.any?%>
<% options = {:author => true, :deletable => false } %>
<%= render :partial => 'blog_comments/attachments_links', :locals => {:attachments => activity.attachments, :options => options, :is_float => true} %>
<% end %>
<div class="homepagePostIntro break_word upload_img list_style maxh360 table_maxWidth" id="activity_description_<%= user_activity_id%>">
<div id="intro_content_<%= user_activity_id%>">
<% if activity.parent_id.nil? %>
<%= activity.content.to_s.html_safe%>
<% else %>
<%= activity.parent.content.to_s.html_safe%>
<% end %>
</div>
</div>
<div class="cl"></div>
<!--<div class=" fl" style="width: 600px">
<%# if activity.attachments.any?%>
<%# options = {:author => true, :deletable => false } %>
<%#= render :partial => 'blog_comments/attachments_links', :locals => {:attachments => activity.attachments, :options => options, :is_float => true} %>
<%# end %>
</div>
<div class="cl"></div>-->
<div id="intro_content_show_<%= user_activity_id%>" class="fr" style="display:none;"><a href="javascript:void(0);" class="linkBlue">[展开]</a></div>
<div id="intro_content_hide_<%= user_activity_id%>" class="fr" style="display:none;"><a href="javascript:void(0);" class="linkBlue">[收起]</a></div>
<div class="cl"></div>
<div class="mt10" style="font-weight:normal;">
<%= render :partial=>"attachments/activity_attach", :locals=>{:activity => activity} %>
</div>
<div class="homepagePostSetting" id="act-<%= user_activity_id %>" style="visibility: hidden">
<ul>
@ -170,3 +193,6 @@
<% end %>
</div>
</div>
<script type="text/javascript">
$(description_show_hide(<%=user_activity_id %>));
</script>

View File

@ -42,6 +42,12 @@
<%= @user.name%>的博客
</div>
</div>
<% if blog.homepage_id and BlogComment.where("id=?", blog.homepage_id).count > 0 %>
<% homepage = BlogComment.find(blog.homepage_id) %>
<%= render :partial => 'blogs/homepage', :locals => {:activity => homepage, :user_activity_id => homepage.id} %>
<% end %>
<% if User.current.logged? && User.current.id == @user.id %>
<%= labelled_form_for @article, :url =>{:controller=>'blog_comments',:action => 'create',:user_id=>user.id , :blog_id => blog.id},
:html => {:nhname=>'form',:multipart => true, :id => 'message-form'} do |f| %>
@ -75,16 +81,6 @@
$(function () {
init_activity_KindEditor_data(<%= topic.id%>, null, "87%", "<%=topic.class.to_s%>");
showNormalImage('activity_description_<%= topic.id %>');
/*var description_images=$("div#activity_description_<%#= topic.id %>").find("img");
if (description_images.length>0) {
for (var i=0; i<description_images.length; i++){
var image=$(description_images[i]);
var element=$("<a></a>").attr("href",image.attr('src'));
image.wrap(element);
}
}
$('#activity_description_<%#= topic.id %> a').colorbox({rel:'nofollow', close: "关闭", returnFocus: false});*/
});
</script>
<% if topic %>

View File

@ -0,0 +1,50 @@
<div class="resources mt10" id="user_activity_<%= user_activity_id%>" >
<div class="homepagePostBrief" onmouseover="$('#homepage_message_setting_<%=activity.id%>').show();" onmouseout="$('#homepage_message_setting_<%= activity.id%>').hide();">
<div class="homepagePostDes">
<% if activity.author.id == User.current.id%>
<div class="homepagePostSetting" id="homepage_message_setting_<%= activity.id%>" style="display: none">
<ul>
<li class="homepagePostSettingIcon">
<ul class="homepagePostSettiongText">
<li>
<%= link_to(
l(:button_edit_homepage),
{:controller => 'blog_comments',:action => 'edit',:user_id=>activity.author_id,:blog_id=>activity.blog_id, :id => activity.id, :is_homepage => 1},
:class => 'postOptionLink'
) if User.current && User.current.id == activity.author.id %>
</li>
<li>
<%= link_to(
l(:button_delete_homepage),
{:controller => 'blog_comments',:action => 'destroy',:user_id=>activity.author_id,:blog_id=>activity.blog_id, :id => activity.id},
:method => :delete,
:data => {:confirm => l(:text_are_you_sure)},
:class => 'postOptionLink'
) if User.current && User.current.id == activity.author.id %>
</li>
<li>
<%= link_to(
l(:button_cancel_homepage),
{:controller => 'blogs',:action => 'cancel_homepage',:user_id=>activity.author_id,:id=>activity.blog_id, :article_id => activity.id},
:method => :post,
:class => 'postOptionLink'
) if User.current && User.current.id == activity.blog.author_id %>
</li>
</ul>
</li>
</ul>
</div>
<%end%>
<div class="cl"></div>
<div class="homepagePostTitle hidden m_w530 fl">
<%= link_to activity.title.to_s.html_safe, user_blog_blog_comment_path(:user_id=>activity.author_id,
:blog_id=>activity.blog.id,:id=>activity), :class=> "postGrey", :style => 'text-align:center;' %>
</div>
<div class="homepagePostIntro break_word upload_img list_style maxh360 lh18 table_maxWidth" >
<%= activity.content.to_s.html_safe %>
</div>
<div class="cl"></div>
</div>
<div class="cl"></div>
</div>
</div>

View File

@ -41,20 +41,10 @@
$(function () {
init_activity_KindEditor_data(<%= topic.id%>, null, "87%");
showNormalImage('activity_description_<%= topic.id %>');
/*var description_images=$("div#activity_description_<%#= topic.id %>").find("img");
if (description_images.length>0) {
for (var i=0; i<description_images.length; i++){
var image=$(description_images[i]);
var element=$("<a></a>").attr("href",image.attr('src'));
image.wrap(element);
}
}
$('#activity_description_<%#= topic.id %> a').colorbox({rel:'nofollow', close: "关闭", returnFocus: false});*/
});
</script>
<% if topic %>
<%= render :partial => 'users/course_message', :locals => {:activity => topic, :user_activity_id => topic.id} %>
<%= render :partial => 'users/course_message', :locals => {:activity => topic, :user_activity_id => topic.id,:is_course=>1,:is_board=>1} %>
<% end %>
<% end %>

View File

@ -0,0 +1,16 @@
<script type="text/javascript">
$(function(){
$("#RSide").removeAttr("id");
$("#Container").css("width","1000px");
$("#message_subject").focus();
});
</script>
<div class="homepageRight mt0 ml10">
<div class="homepageRightBanner">
<div class="NewsBannerName">
编辑帖子
</div>
</div>
<%= render :partial => 'boards/org_subfield_new',
:locals => {:f => f, :edit_mode => edit_mode, :topic => topic, :org_subfield => org_subfield} %>
</div>

View File

@ -0,0 +1,74 @@
<%= content_for(:header_tags) do %>
<%= import_ke(enable_at: true, prettify: false) %>
<% end %>
<%= error_messages_for 'message' %>
<div class="resources mt10">
<div id="new_course_topic">
<div class="homepagePostBrief c_grey">
<div>
<input type="text" name="message[subject]" id="message_subject" class="InputBox w713" maxlength="255" onfocus="$('#topic_editor').show()" onkeyup="regexTopicSubject();" placeholder="发布帖子,请先输入帖子标题" value="<%= topic.subject%>" >
<p id="subjectmsg"></p>
</div>
<div id="topic_editor" style="display: none;">
<%if User.current.member_of_org?(org_subfield.organization)%>
<div class="mt10">
<%= f.check_box :sticky, :value => topic.sticky%>
<%= label_tag 'message_sticky', l(:label_board_sticky) %>
<%= f.check_box :locked, :value => topic.locked%>
<%= label_tag 'message_locked', l(:label_board_locked) %>
<div class="cl"></div>
</div>
<% end %>
<div class="mt10">
<div id="message_quote" class="wiki" style="width: 92%;word-break: break-all;word-wrap: break-word;margin-left: 40px;"></div>
<%= text_area :quote,:quote,:style => 'display:none' %>
<%= hidden_field_tag :asset_id,params[:asset_id],:required => false,:style => 'display:none' %>
<%= f.kindeditor :content, :editor_id => 'message_content_editor',
:owner_id => topic.nil? ? 0: topic.id,
:owner_type => OwnerTypeHelper::MESSAGE,
:width => '100%',
:height => 300,
:minHeight=>300,
:class => 'talk_text fl',
:input_html => { :id => 'message_content',
:class => 'talk_text fl',
:maxlength => 5000 },
at_id: topic.id, at_type: topic.class.to_s
%>
<div class="cl"></div>
<p id="message_content_span"></p>
</div>
<div class="cl"></div>
<div class="mt10">
<div class="fl" id="topic_attachments">
<%= render :partial => 'attachments/form_course', :locals => {:container => topic, :isReply => @isReply} %>
</div>
</div>
<div class="cl"></div>
<div class="mt5">
<%if !edit_mode %>
<a href="javascript:void(0);" class="BlueCirBtnMini fr" onclick="submit_topic();">确定</a>
<span class="fr mr10 mt3">或</span>
<a href="javascript:void(0);" class="fr mr10 mt3" onclick="reset_topic();">取消</a>
<% else %>
<a href="javascript:void(0);" class="BlueCirBtnMini fr" onclick="submit_topic();">确定</a>
<span class="fr mr10 mt3">或</span>
<%= link_to "取消",board_message_url(topic.board, topic.root, :r => (topic.parent_id && topic.id)), :class => "fr mr10 mt3"%>
<% end %>
</div>
<div class="cl"></div>
</div>
</div>
<%#= render :partial => 'course_new_topic', :locals => {:f => f, :topic => @message} %>
<!--<li>
<div class="ml55 fl" nhname="toolbar_container"></div>
<a href="javascript:void(0);" nhname="cancelbtn" class="grey_btn fr ml10"><%#= l(:button_cancel) %></a>
<a href="javascript:void(0);" nhname="submitbtn" class="blue_btn fr " style="margin-left: 55px">
<%#= l(:button_submit)%>
</a>
<div class="cl"></div>
</li>-->
</div>
</div>

View File

@ -0,0 +1,16 @@
<script type="text/javascript">
$(function(){
$("#RSide").removeAttr("id");
$("#Container").css("width","1000px");
$("#message_subject").focus();
});
</script>
<div class="homepageRight mt0 ml10">
<div class="homepageRightBanner">
<div class="NewsBannerName">
编辑帖子
</div>
</div>
<%= render :partial => 'boards/project_new_topic',
:locals => {:f => f, :edit_mode => edit_mode, :topic => topic, :project => project} %>
</div>

View File

@ -0,0 +1,65 @@
<%= content_for(:header_tags) do %>
<%= import_ke(enable_at: true, prettify: false) %>
<% end %>
<%= error_messages_for 'message' %>
<div class="resources mt10">
<div id="new_course_topic">
<div class="homepagePostBrief c_grey">
<div>
<input type="text" name="message[subject]" id="message_subject" class="InputBox w713" maxlength="255" onfocus="$('#topic_editor').show()" onkeyup="regexTopicSubject();" placeholder="发布帖子,请先输入帖子标题" value="<%= topic.subject%>" >
<p id="subjectmsg"></p>
</div>
<div id="topic_editor" style="display: none;">
<%if User.current.member_of?(project)%>
<div class="mt10">
<%= f.check_box :sticky, :value => topic.sticky%>
<%= label_tag 'message_sticky', l(:label_board_sticky) %>
<%= f.check_box :locked, :value => topic.locked%>
<%= label_tag 'message_locked', l(:label_board_locked) %>
<div class="cl"></div>
</div>
<% end %>
<div class="mt10">
<div id="message_quote" class="wiki" style="width: 92%;word-break: break-all;word-wrap: break-word;margin-left: 40px;"></div>
<%= text_area :quote,:quote,:style => 'display:none' %>
<%= hidden_field_tag :asset_id,params[:asset_id],:required => false,:style => 'display:none' %>
<%= f.kindeditor :content, :editor_id => 'message_content_editor',
:owner_id => topic.nil? ? 0: topic.id,
:owner_type => OwnerTypeHelper::MESSAGE,
:width => '100%',
:height => 300,
:minHeight=>300,
:class => 'talk_text fl',
:input_html => { :id => 'message_content',
:class => 'talk_text fl',
:maxlength => 5000 },
at_id: topic.id, at_type: topic.class.to_s
%>
<div class="cl"></div>
<p id="message_content_span"></p>
</div>
<div class="cl"></div>
<div class="mt10">
<div class="fl" id="topic_attachments">
<%= render :partial => 'attachments/form_project_new', :locals => {:container => topic, :isReply => @isReply} %>
</div>
</div>
<div class="cl"></div>
<div class="mt5">
<%if !edit_mode %>
<a href="javascript:void(0);" class="BlueCirBtnMini fr" onclick="submit_topic_project();">确定</a>
<span class="fr mr10 mt3">或</span>
<a href="javascript:void(0);" class="fr mr10 mt3" onclick="reset_topic();">取消</a>
<% else %>
<a href="javascript:void(0);" class="BlueCirBtnMini fr" onclick="submit_topic_project();">确定</a>
<span class="fr mr10 mt3">或</span>
<%= link_to "取消",board_message_url(topic.board, topic.root, :r => (topic.parent_id && topic.id)), :class => "fr mr10 mt3"%>
<% end %>
</div>
<div class="cl"></div>
</div>
</div>
</div>
</div>

View File

@ -1,11 +1,65 @@
<%= form_for @message, :url =>{:controller=>'messages',:action => 'new', :board_id => @board.id, :is_board => 'true'},:html => {:nhname=>'form', :multipart => true, :id => 'message-form', :name=>'message-form'} do |f| %>
<%= render :partial => 'form_project', :locals => {:f => f, :topic => @message} %>
<li>
<div class="ml55 fl" nhname="toolbar_container"></div>
<a href="javascript:void(0)" nhname="cancelbtn" class="grey_btn fr ml10"><%= l(:button_cancel) %></a>
<a href="javascript:void(0)" nhname="submitbtn" class="blue_btn fr " style="margin-left: 55px"><%= l(:button_submit)%></a>
<div class="cl"></div>
</li>
<% end %>
<%= content_for(:header_tags) do %>
<%= import_ke(enable_at: true, prettify: false) %>
<% end %>
<%= error_messages_for 'message' %>
<div class="resources mt10">
<div id="new_course_topic">
<div class="homepagePostBrief c_grey">
<div>
<input type="text" name="message[subject]" id="message_subject" class="InputBox w713" maxlength="255" onfocus="$('#topic_editor').show()" onkeyup="regexTopicSubject();" placeholder="发布帖子,请先输入帖子标题" value="<%= topic.subject%>" >
<p id="subjectmsg"></p>
</div>
<div id="topic_editor" style="display: none;">
<%if User.current.member_of?(project)%>
<div class="mt10">
<%= f.check_box :sticky, :value => topic.sticky%>
<%= label_tag 'message_sticky', l(:label_board_sticky) %>
<%= f.check_box :locked, :value => topic.locked%>
<%= label_tag 'message_locked', l(:label_board_locked) %>
<div class="cl"></div>
</div>
<% end %>
<div class="mt10">
<div id="message_quote" class="wiki" style="width: 92%;word-break: break-all;word-wrap: break-word;margin-left: 40px;"></div>
<%= text_area :quote,:quote,:style => 'display:none' %>
<%= hidden_field_tag :asset_id,params[:asset_id],:required => false,:style => 'display:none' %>
<%= f.kindeditor :content, :editor_id => 'message_content_editor',
:owner_id => topic.nil? ? 0: topic.id,
:owner_type => OwnerTypeHelper::MESSAGE,
:width => '100%',
:height => 300,
:minHeight=>300,
:class => 'talk_text fl',
:input_html => { :id => 'message_content',
:class => 'talk_text fl',
:maxlength => 5000 },
at_id: topic.id, at_type: topic.class.to_s
%>
<div class="cl"></div>
<p id="message_content_span"></p>
</div>
<div class="cl"></div>
<div class="mt10">
<div class="fl" id="topic_attachments">
<%= render :partial => 'attachments/form_course', :locals => {:container => topic, :isReply => @isReply} %>
</div>
</div>
<div class="cl"></div>
<div class="mt5">
<%if !edit_mode %>
<a href="javascript:void(0);" class="BlueCirBtnMini fr" onclick="message_content_editor.sync();$('#message-form').submit();">确定</a>
<span class="fr mr10 mt3">或</span>
<a href="javascript:void(0);" class="fr mr10 mt3" onclick="reset_topic();">取消</a>
<% else %>
<a href="javascript:void(0);" class="BlueCirBtnMini fr" onclick="message_content_editor.sync();$('#message-form').submit();">确定</a>
<span class="fr mr10 mt3">或</span>
<%= link_to "取消",board_message_url(topic.board, topic.root, :r => (topic.parent_id && topic.id)), :class => "fr mr10 mt3"%>
<% end %>
</div>
<div class="cl"></div>
</div>
</div>
</div>
</div>

View File

@ -1,278 +1,33 @@
<div nhname="container_board">
<div class="project_r_h" xmlns="http://www.w3.org/1999/html">
<h2 class="project_h2 fl">
<% if User.current.language == "zh"%>
<%= h @board.name %>
<% else %>
<%= l(:project_module_boards) %>
<% end %>
</h2>
<% if User.current.logged? %>
<a href="javascript:void(0)" class="green_btn fr newtalk " id="new_topic_btn" nhname="showbtn"><%= l(:label_message_new) %></a>
<% end %>
<div class="cl"></div>
</div>
<% if !User.current.logged? %>
<div class="c_grey f14">
<%= l(:label_user_login_project_board) %>
<%= link_to l(:label_user_login_new), signin_path, :class => "c_blue ml5" %>
</div>
<% end %>
<div class="cl"></div>
<div class=" talklist_box" >
<div class="talk_new ml15 mb10" nhname="about_talk" data-at-id="<%= project.id %>" data-at-type="Project" style="display:none;">
<ul>
<%= render :partial => 'project_new_topic' %>
</ul>
</div><!--talknew end-->
</div>
</div>
<div class=" talklist_box" >
<p class="c_dark mb5 f14">讨论区共有<span class="c_orange"><%= @topic_count %></span>个帖子</p>
<% if @topics.any? %>
<% @topics.each do |topic| %>
<div class="talkmain_box" id="topic<%= topic.id %>" nhname="container_board" mhname="container_board_reply" style="border:none; margin-bottom:0; border-bottom: 1px dashed #d9d9d9;">
<%= link_to image_tag(url_to_avatar(topic.author), :width=>"42",:height=>"42"), user_path(topic.author),:class =>'talkmain_pic fl' %>
<div class="talkmain_txt fl mt5 f14">
<% author = topic.author.to_s %>
<div style="max-width:80px;white-space:nowrap;overflow:hidden;float:left;text-overflow:ellipsis;">
<%= link_to author, user_path(topic.author), :class =>"talkmain_name fl f14",:title=>author,
:style=>'max-width:80px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;' %>
</div>
<p style="float:left;color:#ff5722;">&nbsp;&nbsp;:</p>
<p class="talkmain_tit fl fb break_word f14" title="<%= h(topic.subject) %>" style="width:auto;float:left;max-width:390px;white-space:nowrap;overflow:hidden;float:left;text-overflow:ellipsis;">&nbsp;&nbsp;<%= h(topic.subject) %></p>
<% if topic.editable_by?(User.current) %>
<a href="javascript:void(0)" nhname="showbtn" style="color: #426e9a;float: right;margin-right: 10px;"><%= l(:button_edit) %></a>
<% end %>
<%= link_to(l(:button_delete), {:controller =>'messages',:action => 'destroy', :id => topic.id, :board_id => topic.board_id, :is_board=>'true'},
:method => :post,
:data => {:confirm => l(:text_are_you_sure)},
:class => 'talk_edit fr',
:style => ' margin-right: 10px;') if topic.destroyable_by?(User.current) %>
<% if topic.sticky? %>
<a href="javascript:void(0)" class="talk_up fr c_red" style="margin-right: 10px;"><%= l(:label_board_sticky)%></a>
<% end %>
<script>
//$(function(){if($("#contentmessage<%#=topic.id %>").height()>182){$("#project_show_<%#= topic.id%>").show();}});
//解决由于图片加载慢造成div高度不够 以至于展开按钮不显示的bug
$(function(){
function nh_show_btn(){
if($("#project_show_<%= topic.id%>").is(':hidden')){
if($("#contentmessage<%=topic.id %>").height()>182){
$("#project_show_<%= topic.id%>").show();
}
}
}
var div = $("#contentmessage<%=topic.id %>");
var imgs = $('img',div);
var lens = imgs.length;
function nh_load_img_end(){
nh_show_btn();
// lens--;
// if(lens <= 0){
// nh_show_btn();
// }
}
if(lens > 0){
$('img',div).load(function(){
nh_load_img_end();
});
}
nh_show_btn();
// if(lens <= 0){
// nh_show_btn();
// }else{
// $('img',div).load(function(){
// nh_load_img_end();
// });
// }
});
</script>
<div class="cl"></div>
<div class="project_board_content break_word f14 list_style" id="content_<%=topic.id%>">
<div id="contentmessage<%=topic.id %>" class="upload_img">
<%= topic.content.html_safe %>
<!-- -->
</div>
</div>
<p style="display: none;" id="project_show_<%= topic.id%>">
<a id="expend_more_information<%= topic.id%>" style="color: #0781b4;" href="javascript:void(0)" onclick="show_more_reply('#content_<%=topic.id%>','#expend_more_information<%= topic.id%>','#arrow<%=topic.id%>');" value="show_more">[展开]</a>
<span class="g-arr-down">
<img id="arrow<%=topic.id%>" src="/images/jiantou.jpg" width="12" height="6" />
</span>
</p>
<%= link_to_attachments_course topic, :author => false %>
<%= l(:label_activity_time)%>&nbsp;&nbsp;<%= format_time topic.created_on %>
</div>
<% if User.current.logged? %>
<a href="javascript:void(0)" nhname="showbtn_reply" class="c_dblue fr f14" style="margin-right:10px;"><%= l(:button_reply) %></a>
<% end %>
<div class="cl"></div>
<div class="talk_new ml15 mb10" nhname='about_talk' id="about_newtalk<%=topic.id%>" data-at-id="<%= topic.id %>" data-at-type="<%= topic.class.name %>" style="display: none;border-top: 1px dashed #d9d9d9;padding-top:5px;margin-left:0px;padding-left:15px;">
<ul>
<%= render :partial => 'edit',locals: {:topic => topic} %>
</ul>
</div>
<div class="cl"></div>
<div class="talkWrapBox">
<% reply = Message.new(:subject => "RE: #{topic.subject}")%>
<% if !topic.locked? && authorize_for('messages', 'reply') %>
<div class="talkWrapMsg" nhname="about_talk_reply" data-at-id="<%= topic.id %>" data-at-type="<%= topic.class.name %>" style="display: none;">
<em class="talkWrapArrow"></em>
<div class="cl"></div>
<div class="talkConIpt ml15 mb10" style="margin-left:30px;" id="reply<%= topic.id %>">
<%= form_for reply, :as => :reply, :url => {:controller=>'messages',:action => 'reply', :id => topic.id, :board_id => topic.board_id, :is_board => 'true'},
:html => {:nhname=>"form",:multipart => true, :id => 'message_form' + topic.id.to_s, :name=>'message-form'} do |f| %>
<%= render :partial => 'form_project', :locals => {:f => f, :replying => true} %>
<div class="fl" style="padding-top:5px;" nhname="toolbar_container"></div>
<div style="padding-top:5px;" class="fr">
<a href="javascript:void(0)" nhname="cancelbtn" class="grey_btn fr ml10" style=""><%= l(:button_cancel)%></a>
<a href="javascript:void(0)" nhname="submitbtn" class="blue_btn fr " style=""><%= l(:button_submit)%></a>
</div>
<% end %>
<div class="cl"></div>
</div>
</div>
<% end %>
<div class="cl"></div>
<% replies_all = topic.children.includes(:author, :attachments, {:board => :project}).reorder("#{Message.table_name}.id desc").all %>
<% unless replies_all.empty? %>
<div class="talkWrapMsg" nhname="nh_reply_div" id="nh_reply_div_<%= topic.id %>">
<ul>
<% replies_all_i = 0 %>
<% replies_all.each do |message| %>
<% replies_all_i=replies_all_i+1 %>
<li nhname="reply_rec" style="display:<%= replies_all_i>2?'none':'' %>">
<%= link_to image_tag(url_to_avatar(message.author), :width => '34',:height => '34'), user_path(message.author), :class =>'Msg_pic' %>
<div class="Msg_txt">
<%= link_to_user_header message.author,false,:class => 'fl c_orange f14 ' %>
<br/>
<div class="fl break_word f14 list_style">
<%= textAreailizable message,:content,:attachments => message.attachments %>
<!-- -->
</div>
<input nhname="nh_content_val" type="hidden" value="<%= message.content %>"/>
<br/><div class="cl"></div>
<span class=" c_grey fl f14"><%= format_time(message.created_on) %></span>
<%= link_to(l(:button_delete),{:controller => 'messages', :action => 'destroy', :id => message.id, :board_id => message.board_id, :is_board => 'true'},
:method => :post,
:data => {:confirm => l(:text_are_you_sure)},
:title => l(:button_delete),
:class => ' c_dblue fr f14') if message.course_destroyable_by?(User.current) %>
<%= link_to(l(:button_reply), 'javascript:;',
:nhname =>'showbtn_child_reply',
:class => ' c_dblue fr f14',
:style => 'margin-right: 10px;',
:title => l(:button_reply)) if !topic.locked? && authorize_for('messages', 'reply') %>
</div>
<div class="cl"></div>
</li>
<% end %>
</ul>
</div>
<%if topic.replies_count>2 %>
<div class="talkWrapMsg">
<a nhname="reply_ex_btn" data-count="<%= topic.replies_count %>" data-init="0" href="javascript:void(0)" class="ml258 c_dblue lh23">展开回复(<%= topic.replies_count.to_s%>)</a>
</div>
<% end %>
<% end %>
</div>
</div>
<% end %>
<% else %>
<p class="nodata"><%= l(:label_no_data) %></p>
<% end %>
<ul class="wlist">
<%= pagination_links_full @topic_pages, @topic_count, :per_page_links => false, :remote => false, :flag => true %>
</ul>
<!--讨论主类容 end-->
<%# other_formats_links do |f| %>
<%#= f.link_to 'Atom', :url => {:key => User.current.rss_key} %>
<%# end %>
<% html_title @board.name %>
<% content_for :header_tags do %>
<%= auto_discovery_link_tag(:atom, {:format => 'atom', :key => User.current.rss_key}, :title => "#{@project}: #{@board}") %>
<% end %>
</div>
<div style="display:none;"><a href="#" id="nhjump"></a></div>
<script type="text/javascript">
$(function(){
$(".talkmain_box").each(function(){
var target = $("li[nhname='reply_rec']",$(this));
var btn = $("a[nhname='reply_ex_btn']",$(this));
var jumpobj = $("div[nhname='nh_reply_div']",$(this));
btn.click(function(){
if($(this).data('init')=='0'){
$(this).data('init',1);
$(this).html('收起回复');
target.show();
}else{
$(this).data('init',0);
$(this).html('展开回复'+$(this).data('count')+')');
target.hide();
target.eq(0).show();
target.eq(1).show();
$("#nhjump").attr('href','#'+jumpobj.attr('id'));
$("#nhjump")[0].click();
}
});
});
KindEditor.ready(function(K){
$("div[nhname='container_board']").each(function(){
var container = $(this);
var about_talk = $("div[nhname='about_talk']",container);
var params = ({
kindutil:K,
showbtn:$("a[nhname='showbtn']",container),
about_talk:about_talk,
inputsubject:$("input[nhname='inputsubject']",about_talk),
subjectmsg:$("p[nhname='subjectmsg']",about_talk),
textarea:$("textarea[nhname='textarea']",about_talk),
contentmsg:$("p[nhname='contentmsg']",about_talk),
submitbtn:$("a[nhname='submitbtn']",about_talk),
cancelbtn:$("a[nhname='cancelbtn']",about_talk),
form:$("form[nhname='form']",about_talk),
toolbar_container:$("div[nhname='toolbar_container']",about_talk),
init_content_val:$("input[nhname='init_content_val']",about_talk)
});
nh_init_board(params);
});
$("div[mhname='container_board_reply']").each(function(){
var container = $(this);
var about_talk = $("div[nhname='about_talk_reply']",container);
var params = {
type:'reply',
kindutil:K,
showbtn:$("a[nhname='showbtn_reply']",container),
showbtn_child:$("a[nhname='showbtn_child_reply']",container),
about_talk:about_talk,
inputsubject:$("input[nhname='inputsubject']",about_talk),
subjectmsg:$("p[nhname='subjectmsg']",about_talk),
textarea:$("textarea[nhname='textarea']",about_talk),
contentmsg:$("p[nhname='contentmsg']",about_talk),
submitbtn:$("a[nhname='submitbtn']",about_talk),
cancelbtn:$("a[nhname='cancelbtn']",about_talk),
form:$("form[nhname='form']",about_talk),
quote_show:$("div[nhname='quote_show']",about_talk),
quote_input:$("textarea[nhname='quote_input']",about_talk),
toolbar_container:$("div[nhname='toolbar_container']",about_talk),
jumphref:$("#nhjump")
};
params.get_ref_str_call=function(btn){
var div = btn.parent('div');
var str = '<blockquote>'+$('a',div).filter(':first').html()+' 写到: <br/>'+$("input[nhname='nh_content_val']",div).val()+'<div class="cl"></div></blockquote>';
return str;
}
nh_init_board(params);
});
<% if(!@flag.nil? && @flag=='true') %>
if($("#new_topic_btn")!=undefined)$("#new_topic_btn").click();
<% end %>
});
$("#RSide").removeAttr("id");
$("#Container").css("width","1000px");
});
</script>
function reset_topic(){
$("#message_subject").val("");
$("#subjectmsg").text("");
document.getElementById("message_sticky").checked=false;
document.getElementById("message_locked").checked=false;
$("#topic_attachments").html("<%= escape_javascript(render :partial => 'attachments/form_project_new', :locals => {:container => Message.new, :isReply => @isReply})%>");
message_content_editor.html("");
$("#topic_editor").toggle();
}
<% if @is_new%>
$(function(){
$("#message_subject").focus();
});
<%end%>
</script>
<div class="homepageRight mt0 ml10">
<div class="homepageRightBanner">
<div class="NewsBannerName"><%= l(:label_borad_project) %></div>
</div>
<% if User.current.logged? %>
<%= labelled_form_for @message, :url =>{:controller=>'messages',:action => 'new', :board_id => @board.id, :is_board => 'true'},
:html => {:nhname=>'form',:multipart => true, :id => 'message-form-project'} do |f| %>
<%= render :partial => 'project_new', :locals => {:f => f, :topic => @message, :edit_mode => false, :project => @board.project} %>
<% end %>
<% end %>
<%= render :partial=> 'project_show_detail',:locals =>{:topics => @topics, :page => 0} %>
</div>

View File

@ -0,0 +1,61 @@
<%= content_for(:header_tags) do %>
<%= import_ke(enable_at: false, prettify: false) %>
<%= javascript_include_tag "init_activity_KindEditor" %>
<% end %>
<style type="text/css">
/*回复框*/
.homepagePostReplyInputContainer .ke-toolbar {display: none; width: 400px; border: none; background: none; padding: 0px 0px;}
.homepagePostReplyInputContainer .ke-toolbar-icon {line-height: 26px; font-size: 14px; padding-left: 26px;}
.homepagePostReplyInputContainer .ke-toolbar-icon-url {background-image: url(/images/public_icon.png)}
.homepagePostReplyInputContainer .ke-outline {padding: 0px 0px; line-height: 26px; font-size: 14px;}
.homepagePostReplyInputContainer .ke-icon-emoticons {background-position: 0px -671px; width: 50px; height: 26px;}
.homepagePostReplyInputContainer .ke-icon-emoticons:hover {background-position: -79px -671px; width: 50px; height: 26px;}
.homepagePostReplyInputContainer .ke-outline {border: none;}
.homepagePostReplyInputContainer .ke-inline-block {display: none;}
.homepagePostReplyInputContainer .ke-container {float: left;}
</style>
<% if topics%>
<% topics.each do |topic| %>
<script>
function expand_reply(container, btnid) {
var target = $(container);
var btn = $(btnid);
if (btn.data('init') == '0') {
btn.data('init', 1);
btn.html('收起回复');
target.show();
} else {
btn.data('init', 0);
btn.html('展开更多');
target.hide();
target.eq(0).show();
target.eq(1).show();
target.eq(2).show();
}
}
function expand_reply_input(id) {
$(id).toggle();
}
$(function () {
init_activity_KindEditor_data(<%= topic.id%>, null, "87%");
});
</script>
<% if topic %>
<%= render :partial => 'users/project_message', :locals => {:activity => topic, :user_activity_id => topic.id,:is_course=>1,:is_board=>1} %>
<% end %>
<% end %>
<% if topics.count == 10 %>
<!--<div id="show_more_course_topic" class="loadMore mt10 f_grey">展开更多<%#= link_to "", boards_topic_path(@board, :course_id => @board.course.id ,:page => page), :id => "more_topic_link", :remote => "true", :class => "none" %></div>-->
<%= link_to "点击展开更多", boards_topic_path(@board, :project_id => @board.project.id ,:page => page), :id => "show_more_project_topic",:remote => "true",:class => "loadMore mt10 f_grey"%>
<% end %>
<% end%>
<!--
<script type="text/javascript">
$("#show_more_course_topic").mouseover(function () {
$("#more_topic_link").click();
});
</script>-->

View File

@ -1,3 +1,4 @@
<style type="text/css">
div.talk_new .ke-container{margin-left:2px;}
.break_word {width:100%;}
@ -32,12 +33,11 @@
<% end %>
<% if @project %>
<%= render :partial => 'project_show', locals: {project: @project} %>
<% elsif @course %>
<%= render :partial => 'course_show', :locals => {:topics => @topics, :page => 0, :course => @course} %>
<% end %>
<% if @project %>
<%= render :partial => 'project_show', locals: {:topics => @topics, :page => 0, project: @project} %>
<% elsif @course %>
<%= render :partial => 'course_show', :locals => {:topics => @topics, :page => 0, :course => @course} %>
<% end %>
<script type="text/javascript">//侧导航

View File

@ -1 +1,5 @@
$("#show_more_course_topic").replaceWith("<%= escape_javascript( render :partial => 'boards/course_show_detail',:locals => {:topics => @topics, :page => @page} )%>");
<% if @course %>
$("#show_more_course_topic").replaceWith("<%= escape_javascript( render :partial => 'boards/course_show_detail',:locals => {:topics => @topics, :page => @page} )%>");
<% else %>
$("#show_more_project_topic").replaceWith("<%= escape_javascript( render :partial => 'boards/project_show_detail',:locals => {:topics => @topics, :page => @page} )%>");
<% end %>

View File

@ -0,0 +1,145 @@
<script type="text/javascript">
$(document).ready(function(){
$("#time").change(function(){
document.getElementById("end_time").options[document.getElementById("time").selectedIndex].selected = true;
});
$("#term").change(function(){
document.getElementById("end_term").options[document.getElementById("term").selectedIndex].selected = true;
});
var popupHeight = $(".referenceResourcesPopup").outerHeight(true);
$(".referenceResourcesPopup").css("marginTop",-popupHeight/2);
$(".resourcePopupClose").click(function(){
hideModal();
});
$("#copyResource").click(function(){
if ($("#allResource").is(":checked")){
$("input[name='course_attachment_type[]']").attr("checked",true);
}
else{
$("input[name='course_attachment_type[]']").attr("checked",false);
}
});
$("#copyResource2").click(function(){
if ($("input[name='course_attachment_type[]']:checked").length == 6){
$("#allResource").attr("checked",true);
}
else{
$("#allResource").attr("checked",false);
}
});
});
</script>
<div>
<div class="referenceText">信息配置</div>
</div>
<ul class="mt10">
<%=labelled_form_for @new_course do |f| %>
<input name="copy_course" value="<%=@course.id %>" style="display: none"/>
<li class="ml45 mb10">
<a href="javascript:void(0)" class="upimg fl">
<%= image_tag(url_to_avatar(@new_course), id: "avatar_image", :width =>"60", :height =>"60",:alt=>"上传图片")%>
</a> <!--<a href="javascript:void(0)" class="upbtn fl ml30" onclick="$('#upload_course_logo').click();">上传图片</a>-->
<!--</span>-->
<div class="cl"></div>
</li>
<li class="ml45">
<input type="text" style="display: none"/> <!--阻止表单自动填充 -->
<input type="password" style="display: none"/> <!--阻止表单自动填充 -->
<label><span class="c_red">*</span>&nbsp;<%= l(:label_tags_course_name)%>&nbsp;&nbsp;</label>
<input type="text" name="course[name]" id="course_name" class="courses_input grey_border" maxlength="100" onkeyup="regex_course_name();" value="<%=@course.name %>">
<span class="c_red" id="course_name_notice" style="display: none;">课程名称不能为空</span>
<div class="cl"></div>
<li class="ml45">
<label><span class="c_red">*</span>&nbsp;<%= l(:label_class_period)%>&nbsp;&nbsp;</label>
<input type="text" name="class_period" id="class_period" class="hwork_input02 grey_border" onkeyup="regex_course_class_period();" maxlength="6" value="<%=@course.class_period %>">
<span class="c_red" id="course_class_period_notice" style="display: none;"></span>
</li>
<div class="cl"></div>
<li class="ml45 mb10">
<label><span class="c_red">*</span>&nbsp;<%= l(:label_course_term)%>&nbsp;&nbsp;</label>
<%= select_tag :time,options_for_select(course_time_option(@new_course.time),@new_course.time), {} %>
<%= select_tag :term,options_for_select(course_term_option,@new_course.term || cur_course_term),{} %>
<span class="c_red" id="course_time_term_notice"></span>
</li>
<div class="cl"></div>
<li class="ml45 mb10">
<label><span class="c_red">*</span>&nbsp;结束学期&nbsp;&nbsp;</label>
<%= select_tag :end_time,options_for_select(course_time_option(@new_course.end_time),@new_course.end_time), {} %>
<%= select_tag :end_term,options_for_select(course_term_option,@new_course.end_term || cur_course_term),{} %>
<span class="mr15 c_red">仅针对跨越多个学期的班级,否则不用修改。</span>
</li>
<div class="cl"></div>
<li class="ml45 mb10">
<label><span class="c_red">*</span>&nbsp;<%= l(:label_new_course_password)%>&nbsp;&nbsp;</label>
<input type="text" style="display: none;">
<input type="text" name="course[password]" id="course_course_password" class="hwork_input02 grey_border" onkeyup="regex_course_password();" value="<%=@course.password %>">
<!--<a id="psw_btn" href="javascript:void(0)">显示明码</a>-->
<span class="c_red" id="course_course_password_notice"></span>
<div class="cl"></div>
<span class="ml95 c_red">学生或其他成员申请加入课程时候需要使用该口令,该口令可以由老师在课堂上公布。</span>
</li>
<li class="ml50">
<label class="fl" >&nbsp;&nbsp;<%= l(:label_new_course_description)%>&nbsp;&nbsp;</label>
<textarea name="course[description]" placeholder="最多3000个汉字(或6000个英文字符)" class="courses_text fl grey_border" ><%= @course.description.nil? ? "" : @course.description %></textarea>
<div class="cl"></div>
</li>
<li class=" mb5 ml85">
<label >公开&nbsp;&nbsp;</label>
<input <%= @course.is_public == 1 ? 'checked' : ''%> id="course_is_public" name="course[is_public]" type="checkbox" value="<%=@course.is_public.to_i %>">
<span class="c_grey">(选中后课外用户可见该课程,否则仅对课内成员可见)</span>
<div class="cl"></div>
</li>
<li class="ml58">
<label class="fl">复制资源&nbsp;&nbsp;</label>
<ul class="fl" id="copyResource">
<li class="sendCourseName fl mr15 ml5">
<label>
<input name="checkAll" type="checkbox" id="allResource" value="0" class="resourceCopy"/>
全部</label>
</li>
</ul>
<ul class="fl" id="copyResource2">
<li class="sendCourseName fl mr15">
<label>
<input name="course_attachment_type[]" type="checkbox" value="1" class="resourceCopy"/>
课件</label>
</li>
<li class="sendCourseName fl mr15">
<label>
<input name="course_attachment_type[]" type="checkbox" value="2" class="resourceCopy"/>
软件</label>
</li>
<li class="sendCourseName fl mr15">
<label>
<input name="course_attachment_type[]" type="checkbox" value="3" class="resourceCopy"/>
媒体</label>
</li>
<li class="sendCourseName fl mr15">
<label>
<input name="course_attachment_type[]" type="checkbox" value="4" class="resourceCopy"/>
代码</label>
</li>
<li class="sendCourseName fl mr15">
<label>
<input name="course_attachment_type[]" type="checkbox" value="6" class="resourceCopy"/>
论文</label>
</li>
<li class="sendCourseName fl mr15">
<label>
<input name="course_attachment_type[]" type="checkbox" value="5" class="resourceCopy"/>
其它</label>
</li>
<div class="cl"></div>
</ul>
<span class="c_red ml5 fl mb10">您可以通过选择资源类型,将对应资源复制到新课程中。</span>
<div class="cl"></div>
</li>
<% end %>
</ul>
<div>
<a href="javascript:void(0);" class="greyBtn fr mr40 f12" onclick="submit_new_course();">完成</a>
<a href="javascript:void(0);" class="greyBtn fr mr10 f12" onclick="hideResource();">取消</a>
</div>
<div class="cl"></div>

View File

@ -1,7 +1,42 @@
<%= content_for(:header_tags) do %>
<%= import_ke(enable_at: true, prettify: false, init_activity: true) %>
<% end %>
<script>
$(document).ready(function(){
$("#relateProject,.relatePInfo").mouseover(function(){
$(".relatePInfo").css("display","block");
})
$("#relateProject,.relatePInfo").mouseout(function(){
$(".relatePInfo").css("display","none");
})
$(".homepagePostPortrait").mouseover(function(){
$(this).children(".userCard").css("display","block");
})
$(".homepagePostPortrait").mouseout(function(){
$(this).children(".userCard").css("display","none");
})
$(".userCard").mouseover(function(){
$(this).css("display","block");
})
$(".userCard").mouseout(function(){
$(this).css("display","none");
})
$(".coursesLineGrey").mouseover(function(){
$(this).css("color","#ffffff");
})
$(".coursesLineGrey").mouseout(function(){
$(this).css("color","#808080");
})
$(".homepagePostSetting,.coursesLineGrey").mouseover(function(){
$(this).prev().css("color","#ffffff");
$(this).css("z-index", "9999");
})
$(".homepagePostSetting").mouseout(function(){
$(this).prev().css("color","#808080");
$(this).css("z-index", "1");
})
})
</script>
<style type="text/css">
/*回复框*/
div.ke-toolbar {
@ -73,22 +108,6 @@
$(function () {
init_activity_KindEditor_data(<%= activity.id%>, null, "87%", "<%= activity.class.to_s %>");
showNormalImage('activity_description_<%= activity.id %>');
if($("#intro_content_<%= activity.id %>").height() > 360) {
$("#intro_content_show_<%= activity.id %>").show();
}
$("#intro_content_show_<%= activity.id %>").click(function(){
$("#activity_description_<%= activity.id %>").toggleClass("maxh360");
$("#activity_description_<%= activity.id%>").toggleClass("lh18");
$("#intro_content_show_<%= activity.id %>").hide();
$("#intro_content_hide_<%= activity.id %>").show();
});
$("#intro_content_hide_<%= activity.id %>").click(function(){
$("#activity_description_<%= activity.id %>").toggleClass("maxh360");
$("#activity_description_<%= activity.id%>").toggleClass("lh18");
$("#intro_content_hide_<%= activity.id %>").hide();
$("#intro_content_show_<%= activity.id %>").show();
});
});
</script>
<% if activity && activity.course_act%>
@ -99,7 +118,7 @@
<% when 'News' %>
<%= render :partial => 'users/course_news', :locals => {:activity => act, :user_activity_id => activity.id} %>
<% when 'Message' %>
<%= render :partial => 'users/course_message', :locals => {:activity => act, :user_activity_id => activity.id} %>
<%= render :partial => 'users/course_message', :locals => {:activity => act, :user_activity_id => activity.id,:is_course=>1,:is_board=>0} %>
<% when 'Poll' %>
<%= render :partial => 'users/course_poll', :locals => {:activity => act, :user_activity_id => activity.id} %>
<% when 'JournalsForMessage' %>

View File

@ -12,13 +12,14 @@
</div>
<div class="cl"></div>
<div class="mt15 grey_c lh22">
<%= link_to "复制学期", copy_course_course_path(@course.id),:remote=>true, :class => "term_btn fl" %>
<!--<a href="javascript:" class="term_btn fl" onclick="copyTerm();">
复制学期
</a>-->
<div class="disable_btn fl">
<!--<div class="disable_btn fl">
<span style="display: inline-block">复制学期</span>
<span style="display: inline-block">(开发中...)</span>
</div>
</div>-->
复制学期将为您创建一个新的课程学期,新学期将继承本学期的相关资源,具体您稍后可以选择。
</div>
<div class="cl"></div>

View File

@ -2,19 +2,19 @@
<% is_teacher = User.current.logged? && (User.current.admin? || User.current.allowed_to?(:as_teacher,@course)) %>
<% if show_nav?(@course.homework_commons.count) %>
<div class="subNav">
<%= link_to l(:label_homework), homework_common_index_path(:course => @course.id), :class => "f14 c_blue02 ml10"%>
<%= link_to l(:label_homework), homework_common_index_path(:course => @course.id), :class => "f14 c_blue02 ml10 fn"%>
<%= link_to( "", homework_common_index_path(:course => @course.id,:is_new => 1), :class => 'courseMenuSetting', :title =>"#{l(:label_course_homework_new)}") if is_teacher %>
</div>
<% end %>
<% if show_nav?(@course.news.count) %>
<div class="subNav">
<%= link_to l(:label_course_news), course_news_index_path(@course), :class => "f14 c_blue02 ml10" %>
<%= link_to l(:label_course_news), course_news_index_path(@course), :class => "f14 c_blue02 ml10 fn" %>
<%= link_to( "", new_course_news_path(@course), :class => 'courseMenuSetting', :title =>"#{l(:label_course_news_new)}") if is_teacher %>
</div>
<% end %>
<% if show_nav?(course_file_num) %>
<div class="subNav">
<%= link_to l(:label_course_file), course_files_path(@course), :class => "f14 c_blue02 ml10" %>
<%= link_to l(:label_course_file), course_files_path(@course), :class => "f14 c_blue02 ml10 fn" %>
<% if is_teacher || (@course.publish_resource == 1 && User.current.member_of_course?(@course)) %>
<!--link_to( "+#{l(:label_upload_files)}", course_files_path(@course), :class => 'subnav_green ml95 c_white')-->
<a class="courseMenuSetting" title="上传资源" href="javascript:void(0);" onclick="course_files_upload();"> </a>
@ -23,25 +23,25 @@
<% end %>
<% if show_nav?(@course.boards.first ? @course.boards.first.topics.count : 0) %>
<div class="subNav">
<%= link_to l(:label_course_board), course_boards_path(@course), :class => "f14 c_blue02 ml10" %>
<%= link_to l(:label_course_board), course_boards_path(@course), :class => "f14 c_blue02 ml10 fn" %>
<%= link_to( "",course_boards_path(@course, :flag => true, :is_new => 1), :class => 'courseMenuSetting', :title =>"#{l(:label_message_new)}") if User.current.member_of_course?(@course) && @course.boards.first %>
</div>
<% end %>
<% if show_nav?(course_feedback_count) %>
<div class="subNav">
<%= link_to l(:label_course_feedback), course_feedback_path(@course), :class => "f14 c_blue02 ml10" %>
<%= link_to l(:label_course_feedback), course_feedback_path(@course), :class => "f14 c_blue02 ml10 fn" %>
<%= link_to "", course_feedback_path(@course), :class => 'courseMenuSetting', :title =>"#{l(:label_course_feedback)}", :id => "course_jour_count"%>
</div>
<% end %>
<% if show_nav?(course_poll_count) %>
<div class="subNav">
<%= link_to l(:label_poll), poll_index_path(:polls_type => "Course", :polls_group_id => @course.id), :class => " f14 c_blue02 ml10"%>
<%= link_to l(:label_poll), poll_index_path(:polls_type => "Course", :polls_group_id => @course.id), :class => " f14 c_blue02 ml10 fn"%>
<%= link_to( "", new_poll_path(:polls_type => "Course",:polls_group_id => @course.id), :class => 'courseMenuSetting', :title =>"#{l(:label_new_poll)}") if is_teacher %>
</div>
<% end %>
<% if show_nav?(User.current.allowed_to?(:as_teacher,@course)? @course.exercises.count : @course.exercises.where("exercise_status=2").count) %>
<div class="subNav">
<%= link_to "在线测验", exercise_index_path(:course_id => @course.id), :class => " f14 c_blue02 ml10"%>
<%= link_to "在线测验", exercise_index_path(:course_id => @course.id), :class => " f14 c_blue02 ml10 fn"%>
<%= link_to( "", new_exercise_path(:course_id => @course.id), :class => 'courseMenuSetting', :title =>"新建试卷") if is_teacher %>
</div>
<% end %>

View File

@ -0,0 +1,13 @@
if(document.getElementById("popbox02")) {
hideModal("#popbox02");
}
$('#ajax-modal').html('<%= escape_javascript(render :partial => 'copy_course') %>');
showModal('ajax-modal', '730px');
$('#ajax-modal').css('height','530px').css('width','730px');
$('#ajax-modal').siblings().remove();
$('#ajax-modal').before("<div class='resourcePopupClose mt5 mr-5'>" +
"<a href='javascript:void(0)' class='resourceClose' onclick='hideResource();'></a></div>");
$('#ajax-modal').parent().css("top","30%").css("left","").css("position","fixed");
$('#ajax-modal').parent().addClass("popbox").addClass("copyCoursePopup");

View File

@ -4,64 +4,82 @@
<div class="hwork_new">
<ul>
<%= labelled_form_for @course do |f| %>
<li class="ml45">
<input type="text" style="display: none"/> <!--阻止表单自动填充 -->
<input type="password" style="display: none"/> <!--阻止表单自动填充 -->
<label><span class="c_red">*</span>&nbsp;<%= l(:label_tags_course_name)%>&nbsp;&nbsp;</label>
<input type="text" name="course[name]" id="course_name" class="courses_input" maxlength="100" onkeyup="regex_course_name();">
<span class="c_red" id="course_name_notice" style="display: none;">课程名称不能为空</span>
</li>
<div class="cl"></div>
<li class="ml45">
<label><span class="c_red">*</span>&nbsp;<%= l(:label_class_period)%>&nbsp;&nbsp;</label>
<input type="text" name="class_period" id="class_period" class="hwork_input02" onkeyup="regex_course_class_period();" maxlength="6">
<span class="c_red" id="course_class_period_notice" style="display: none;"></span>
</li>
<div class="cl"></div>
<li class="ml45 mb10">
<label><span class="c_red">*</span>&nbsp;<%= l(:label_course_term)%>&nbsp;&nbsp;</label>
<%= select_tag :time,options_for_select(course_time_option(@course.time),@course.time), {} %>
<%= select_tag :term,options_for_select(course_term_option,@course.term || cur_course_term),{} %>
</li>
<div class="cl"></div>
<li class="ml45 mb10">
<label><span class="c_red">*</span>&nbsp;<%= l(:label_new_course_password)%>&nbsp;&nbsp;</label>
<input type="text" style="display: none;">
<input type="password" name="course[password]" id="course_course_password" class="hwork_input02" onkeyup="regex_course_password();">
<a id="psw_btn" href="javascript:void(0)">显示明码</a>
<span class="c_red" id="course_course_password_notice"></span>
<li class="ml45">
<input type="text" style="display: none"/> <!--阻止表单自动填充 -->
<input type="password" style="display: none"/> <!--阻止表单自动填充 -->
<label><span class="c_red">*</span>&nbsp;<%= l(:label_tags_course_name)%>&nbsp;&nbsp;</label>
<input type="text" name="course[name]" id="course_name" class="courses_input" maxlength="100" onkeyup="regex_course_name();">
<span class="c_red" id="course_name_notice" style="display: none;">课程名称不能为空</span>
</li>
<div class="cl"></div>
<span class=" ml80 c_orange">学生或其他成员申请加入课程时候需要使用该口令,该口令可以由老师在课堂上公布。</span>
</li>
<li class="ml45">
<label class="fl" >&nbsp;&nbsp;<%= l(:label_new_course_description)%>&nbsp;&nbsp;</label>
<textarea name="course[description]" placeholder="最多3000个汉字(或6000个英文字符)" class="courses_text fl" ></textarea>
<li class="ml45">
<label><span class="c_red">*</span>&nbsp;<%= l(:label_class_period)%>&nbsp;&nbsp;</label>
<input type="text" name="class_period" id="class_period" class="hwork_input02" onkeyup="regex_course_class_period();" maxlength="6">
<span class="c_red" id="course_class_period_notice" style="display: none;"></span>
</li>
<div class="cl"></div>
</li>
<li class=" mb5 ml80">
<label >公开&nbsp;&nbsp;</label>
<input id="course_is_public" name="course[is_public]" type="checkbox" value="1">
<span class="c_grey">(打钩为公开,不打钩则不公开,若不公开,仅课程成员可见该课程。)</span>
<li class="ml45 mb10">
<label><span class="c_red">*</span>&nbsp;<%= l(:label_course_term)%>&nbsp;&nbsp;</label>
<%= select_tag :time,options_for_select(course_time_option(@course.time),@course.time), {} %>
<%= select_tag :term,options_for_select(course_term_option,@course.term || cur_course_term),{} %>
<span class="c_red" id="course_time_term_notice"></span>
</li>
<div class="cl"></div>
</li>
<li class=" mb5 ml30">
<label >学生列表公开&nbsp;&nbsp;</label>
<input id="course_open_student" name="course[open_student]" type="checkbox" value="1">
<span class="c_grey">(打钩为"学生列表公开",不打钩为不公开,若不公开,则课程外部人员看不到学生列表)</span>
<li class="ml45 mb10">
<label><span class="c_red">*</span>&nbsp;结束学期&nbsp;&nbsp;</label>
<%= select_tag :end_time,options_for_select(course_time_option(@course.end_time),@course.end_time), {} %>
<%= select_tag :end_term,options_for_select(course_term_option,@course.end_term || cur_course_term),{} %>
<span class="mr15 c_red">仅针对跨越多个学期的班级,否则不用修改。</span>
</li>
<div class="cl"></div>
</li>
<li class=" mb5 ml30">
<li class="ml45 mb10">
<label><span class="c_red">*</span>&nbsp;<%= l(:label_new_course_password)%>&nbsp;&nbsp;</label>
<input type="text" style="display: none;">
<input type="password" name="course[password]" id="course_course_password" class="hwork_input02" onkeyup="regex_course_password();">
<a id="psw_btn" href="javascript:void(0)">显示明码</a>
<span class="c_red" id="course_course_password_notice"></span>
<div class="cl"></div>
<span class="ml80 c_red">学生或其他成员申请加入课程时候需要使用该口令,该口令可以由老师在课堂上公布。</span>
</li>
<li class="ml45">
<label class="fl" >&nbsp;&nbsp;<%= l(:label_new_course_description)%>&nbsp;&nbsp;</label>
<textarea name="course[description]" placeholder="最多3000个汉字(或6000个英文字符)" class="courses_text fl" ></textarea>
<div class="cl"></div>
</li>
<li class=" mb5 ml80">
<label >公开&nbsp;&nbsp;</label>
<input id="course_is_public" name="course[is_public]" type="checkbox" value="1">
<span class="c_grey">(选中后课外用户可见该课程,否则仅对课内成员可见)</span>
<div class="cl"></div>
</li>
<li class=" mb5 ml30">
<label >学生列表公开&nbsp;&nbsp;</label>
<input id="course_open_student" name="course[open_student]" type="checkbox" value="1">
<span class="c_grey">(选中后课外用户可见学生列表,否则仅对课内成员可见)</span>
<div class="cl"></div>
</li>
<li class=" mb5 ml30">
<label >学生上传资源&nbsp;&nbsp;</label>
<input <%= @course.publish_resource == 1 ? 'checked' : ''%> id="course_publish_resource" name="course[publish_resource]" type="checkbox" />
<span class="c_grey">(打钩为"允许学生上传资源",不打钩为"不允许学生上传资源"</span>
<span class="c_grey">选中后允许学生上传课程资源,否则不允许</span>
<div class="cl"></div>
</li>
<li class=" ml90" >
<a href="javascript:void(0)" class="blue_btn fl c_white" onclick="submit_new_course();" >提交</a>
<%= link_to "取消",user_activities_path(User.current.id),:class => "blue_btn grey_btn fl c_white"%>
<div class="cl"></div>
</li>
</li>
<li class=" ml90" >
<a href="javascript:void(0)" class="blue_btn fl c_white" onclick="submit_new_course();" >提交</a>
<%= link_to "取消",user_activities_path(User.current.id),:class => "blue_btn grey_btn fl c_white"%>
<div class="cl"></div>
</li>
<% end%>
</ul>
</div><!--talknew end-->
<div class="cl"></div>
<div class="cl"></div>
<script>
$(function(){
$("#time").change(function(){
document.getElementById("end_time").options[document.getElementById("time").selectedIndex].selected = true;
});
$("#term").change(function(){
document.getElementById("end_term").options[document.getElementById("term").selectedIndex].selected = true;
});
});
</script>

View File

@ -0,0 +1,8 @@
$("#project_info_<%=@course.id %>").html('<%=escape_javascript(render :partial=>'layouts/project_info') %>');
if(document.getElementById("course_is_public")) {
<% if @course.is_public == 0%>
$("#course_is_public").attr("checked",false);
<% elsif @course.is_public == 1 %>
$("#course_is_public").attr("checked",true);
<% end %>
}

View File

@ -2,11 +2,11 @@
<h2 class="project_h2"><%= l(:label_course_modify_settings)%></h2>
</div>
<script>
$(function(){
<% if @select_tab == 'member'%>
$("#tb_2").click();
<% end %>
})
$(function(){
<% if @select_tab == 'member'%>
$("#tb_2").click();
<% end %>
})
</script>
<div class="hwork_new">
<div id="tb_" class="hwork_tb_">
@ -50,6 +50,12 @@
<%= select_tag :term,options_for_select(course_term_option,@course.term || cur_course_term),{:id=>"term_selected"} %>
</li>
<div class="cl"></div>
<li class="ml45 mb10">
<label><span class="c_red">*</span>&nbsp;结束学期&nbsp;&nbsp;</label>
<%= select_tag :end_time,options_for_select(course_time_option(@course.end_time),@course.end_time), {:id=>"end_time_selected"} %>
<%= select_tag :end_term,options_for_select(course_term_option,@course.end_term || cur_course_term),{:id=>"end_term_selected"} %>
</li>
<div class="cl"></div>
<li class="ml45 mb10">
<label><span class="c_red">*</span>&nbsp;<%= l(:label_new_course_password)%>&nbsp;&nbsp;</label>
<input type="password" name="course[password]" id="course_course_password" class="hwork_input02" value="<%= @course.password%>" onkeyup="regex_course_password();">
@ -66,19 +72,19 @@
<li class=" mb5 ml80">
<label >公开&nbsp;&nbsp;</label>
<input <%= @course.is_public == 1 ? 'checked' : ''%> id="course_is_public" name="course[is_public]" type="checkbox">
<span class="c_grey">打钩为公开,不打钩则不公开,若不公开,仅课程成员可见该课程。</span>
<span class="c_grey">选中后课外用户可见该课程,否则仅对课内成员可见</span>
<div class="cl"></div>
</li>
<li class=" mb5 ml30">
<label >学生列表公开&nbsp;&nbsp;</label>
<input <%= @course.open_student == 1 ? 'checked' : ''%> id="course_open_student" name="course[open_student]" type="checkbox" style="margin-left: 1px;"/>
<span class="c_grey">打钩为"学生列表公开",不打钩为不公开,若不公开,则课程外部人员看不到学生列表</span>
<span class="c_grey">选中后课外用户可见学生列表,否则仅对课内成员可见</span>
<div class="cl"></div>
</li>
<li class=" mb5 ml30">
<label >学生上传资源&nbsp;&nbsp;</label>
<input <%= @course.publish_resource == 1 ? 'checked' : ''%> id="course_publish_resource" name="course[publish_resource]" type="checkbox" style="margin-left: 1px;"/>
<span class="c_grey">打钩为"允许学生上传资源",不打钩为"不允许学生上传资源"</span>
<span class="c_grey">选中后允许学生上传课程资源,否则不允许</span>
<div class="cl"></div>
</li>
<li class=" ml90" >
@ -123,15 +129,17 @@
</div><!--talknew end-->
<div class="cl"></div>
<script type="text/javascript">
function select() {
$('#ajax-modal').html('<%= escape_javascript(render :partial => 'courses/term_select') %>');
showModal('ajax-modal', '500px');
$('#ajax-modal').siblings().remove();
$('#ajax-modal').before("<span style='float: right;cursor:pointer;'>" +
"<a href='javascript:' onclick='clickCanel();'><img src='/images/bid/close.png' width='26px' height='26px' /></a></span>");
$('#ajax-modal').parent().css("top","").css("left","");
$('#ajax-modal').parent().addClass("anonymos");
}
$("#time_selected").click(select);
$("#term_selected").click(select);
function select() {
$('#ajax-modal').html('<%= escape_javascript(render :partial => 'courses/term_select') %>');
showModal('ajax-modal', '500px');
$('#ajax-modal').siblings().remove();
$('#ajax-modal').before("<span style='float: right;cursor:pointer;'>" +
"<a href='javascript:' onclick='clickCanel();'><img src='/images/bid/close.png' width='26px' height='26px' /></a></span>");
$('#ajax-modal').parent().css("top","").css("left","");
$('#ajax-modal').parent().addClass("anonymos");
}
$("#time_selected").click(select);
$("#term_selected").click(select);
$("#end_time_selected").click(select);
$("#end_term_selected").click(select);
</script>

View File

@ -100,6 +100,9 @@
{
obj.checked = false;
}
},
error: function () {
alert("网络异常,答题失败,请确认网络正常连接后再答题。");
}
});
}
@ -154,6 +157,9 @@
{
obj.checked = false;
}
},
error: function () {
alert("网络异常,答题失败,请确认网络正常连接后再答题。");
}
});
}
@ -196,6 +202,9 @@
success: function (data) {
var dataObj = eval(data);
obj.value = dataObj.text;
},
error: function () {
alert("网络异常,答题失败,请确认网络正常连接后再答题。");
}
});

View File

@ -5,29 +5,6 @@
$("#Container").css("width","1000px");
});
// 匿评弹框提示
<%# if @is_evaluation && !@stundet_works.empty?%>
// $(function(){
// $('#ajax-modal').html('<%#= escape_javascript(render :partial => 'student_work/praise_alert') %>');
// showModal('ajax-modal', '500px');
// $('#ajax-modal').siblings().remove();
// $('#ajax-modal').before("<span style='float: right;cursor:pointer;'>" +
// "<a href='javascript:' onclick='clickCanel();'><img src='/images/bid/close.png' width='26px' height='26px' /></a></span>");
// $('#ajax-modal').parent().css("top","").css("left","");
// $('#ajax-modal').parent().addClass("anonymos");
// });
<%# end%>
//设置评分规则
function set_score_rule(){
$('#ajax-modal').html('<%#= escape_javascript(render :partial => 'student_work/set_score_rule',:locals => {:homework => @homework,:student_path => true}) %>');
showModal('ajax-modal', '350px');
$('#ajax-modal').siblings().remove();
$('#ajax-modal').before("<span style='float: right;cursor:pointer;'>" +
"<a href='javascript:' onclick='clickCanel();'><img src='/images/bid/close.png' width='26px' height='26px' /></a></span>");
$('#ajax-modal').parent().css("top","25%").css("left","35%").css("position","fixed");
}
$(function(){
$("#homework_info_hidden").click(function(){
$("#homeworkInformation").hide();
@ -84,6 +61,20 @@
<!---menu_r end--->
</div>
<!--div class="hworkInfor"><a href="javascript:void(0);" class="linkBlue">作业信息</a></div-->
<% if @is_teacher%>
<div class="fr mt5">
<ul class="resourcesSelect">
<li class="resourcesSelected">
<a href="javascript:void(0);" class="resourcesIcon"></a>
<ul class="hworkMenu">
<li>
<%= link_to "导出测验成绩", student_exercise_list_exercise_path(@exercise.id,:course_id => @course.id, :format => 'xls'),:class=>'hworkExport postTypeGrey', :id => "export_student_work"%>
</li>
</ul>
</li>
</ul>
</div>
<% end%>
<div class="cl"></div>
</div>

View File

@ -1,4 +1,9 @@
<script>
$(function(){
$("#RSide").removeAttr("id")
$("#container").css('width',"1000px")
});
function searchone4reload(fileid){
var url = "<%= searchone4reload_course_files_path(@course)%>";
var data = {};data.fileid=fileid;
@ -64,33 +69,61 @@
}
</script>
<div class="container">
<div class="resource"><!--资源库内容开始--->
<div class="re_top">
<%= form_tag( search_course_files_path(@course), 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()" %>
<div class="homepageRight mt0 ml10">
<div class="homepageRightBanner">
<div class="NewsBannerName">资源库</div>
<ul class="resourcesSelect">
<li class="resourcesSelected"><a href="javascript:void(0);" class="resourcesIcon"></a>
<ul class="resourcesType">
<li><a href="javascript:void(0);" onclick="search_tag_attachment('<%= search_tag_attachment_course_files_path(@course)%>','','<%= @q%>','<%= @course.id%>');" class="resourcesTypeAll resourcesGrey">全部</a></li>
<li><a href="javascript:void(0);" onclick="search_tag_attachment('<%= search_tag_attachment_course_files_path(@course)%>','课件','<%= @q%>','<%= @course.id%>');" class="homepagePostTypeAssignment postTypeGrey">课件</a></li>
<li><a href="javascript:void(0);" onclick="search_tag_attachment('<%= search_tag_attachment_course_files_path(@course)%>','软件','<%= @q%>','<%= @course.id%>');" class="softwareIcon postTypeGrey">软件</a></li>
<li><a href="javascript:void(0);" onclick="search_tag_attachment('<%= search_tag_attachment_course_files_path(@course)%>','媒体','<%= @q%>','<%= @course.id%>');" class="mediaIcon resourcesGrey">媒体</a></li>
<li><a href="javascript:void(0);" onclick="search_tag_attachment('<%= search_tag_attachment_course_files_path(@course)%>','代码','<%= @q%>','<%= @course.id%>');" class="codeIcon resourcesGrey">代码</a></li>
<li><a href="javascript:void(0);" onclick="search_tag_attachment('<%= search_tag_attachment_course_files_path(@course)%>','论文','<%= @q%>','<%= @course.id%>');" class="thesisIcon resourcesGrey">论文</a></li>
<li><a href="javascript:void(0);" onclick="search_tag_attachment('<%= search_tag_attachment_course_files_path(@course,:other=>true)%>','其他','<%= @q%>','<%= @course.id%>');" class="othersIcon resourcesGrey">其它</a></li>
</ul>
</li>
</ul>
</div>
<div class="resources mt10" style="padding-bottom:5px;">
<div class="reTop mb5">
<%= form_tag( search_course_files_path(@course), method: 'get',:class => "re_search",:remote=>true) do %>
<%= text_field_tag 'name', params[:name], name: "name", :class => 'researchBox fl',:style=>"padding: 0px"%>
<%= submit_tag "课内搜索", :class => "blueBtn mr5 fl",:name => "incourse",:id => "incourse" %>
<%= submit_tag "全站搜索", :class => "blueBtn mr5 fl",:name => "insite",:id => "insite" %>
<% if is_course_teacher(User.current,@course) || (@course.publish_resource==1 && User.current.member_of_course?(@course) ) %>
<input class="blueBtn fr mr5" value="上传资源" onclick="course_files_upload();">
<% end %>
<% end %>
<% if is_course_teacher(User.current,@course) || (@course.publish_resource==1 && User.current.member_of_course?(@course) ) %> <!-- show_window('light','fade','20%','35%')-->
<!--<a href="javascript:void(0)" class="re_fabu f_r b_lblue" onclick="show_upload();">上传资源</a>-->
<p class="c_grey fr mt10 mr5">
上传:
<a href="javascript:void(0);" class=" c_dblue font_bold" onclick="show_upload(1);">课件</a>&nbsp;|&nbsp;
<a href="javascript:void(0);" class=" c_dblue font_bold" onclick="show_upload(2);">软件</a>&nbsp;|&nbsp;
<a href="javascript:void(0);" class=" c_dblue font_bold" onclick="show_upload(3);">媒体</a>&nbsp;|&nbsp;
<a href="javascript:void(0);" class=" c_dblue font_bold" onclick="show_upload(4);">代码</a>&nbsp;|&nbsp;
<a href="javascript:void(0);" class=" c_dblue font_bold" onclick="show_upload(6);">论文</a>&nbsp;|&nbsp;
<a href="javascript:void(0);" class=" c_dblue font_bold" onclick="show_upload(5);">其他</a>
<!-- show_window('light','fade','20%','35%')-->
<!--<a href="javascript:void(0)" class="re_fabu f_r b_lblue" onclick="show_upload();">上传资源</a>-->
</div>
<div>
<div class="fileTagWrap" id="files_tag">
<%= render :partial => "files/tag_yun", :locals => {:tag_list => @tag_list,:course => @course,:tag_name => @tag_name}%>
</div>
<div class="cl"></div>
<div class="re_con_top">
<p class="f_l fontBlue f_b f_14">共有&nbsp;<span id="attachment_count"><%= @all_attachments.count%></span>&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: 'files/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: 'files/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: 'files/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: 'files/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: 'files/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: 'files/arrow_show',locals: { sort: @sort,order:@order,current:"quotes"} %>&nbsp;排序
<% end %>
</p>
<% end %>
</div><!---re_top end-->
</div>
</div>
<div class="cl"></div>
<div class="re_con" id="course_list">
<%= render :partial => 'course_list',:locals => {course: @course,all_attachments: @all_attachments,sort:@sort,order:@order,curse_attachments:@obj_attachments} %>
</div><!---re_con end-->
</div>
<div id="course_list">
<%= render :partial => 'course_list',:locals => {course: @course,all_attachments: @all_attachments,sort:@sort,order:@order,curse_attachments:@obj_attachments} %>
</div>
</div>
<% html_title(l(:label_attachment_plural)) -%>

View File

@ -1,79 +1,90 @@
<% delete_allowed = User.current.allowed_to?(:manage_files, course) %>
<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: 'files/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: 'files/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: 'files/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: 'files/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: 'files/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: 'files/arrow_show',locals: { sort: sort,order:order,current:"quotes"} %>&nbsp;排序
<% end %>
</p>
</div>
<div class="cl"></div>
<div class="files_tag" id="files_tag">
<%= render :partial => "files/tag_yun", :locals => {:tag_list => @tag_list,:course => course,:tag_name => @tag_name}%>
</div>
<div class="cl"></div>
<div class="for_img_thumbnails">
<% curse_attachments.each do |file| %>
<% if file.is_public? || User.current.member_of_course?(course) || User.current.admin? %>
<div class="re_con_box" id="container_files_<%= file.id %>">
<div class="">
<%= link_to truncate(file.filename,length: 35, omission: '...'),
download_named_attachment_path(file.id, file.filename),
: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 (is_course_teacher(User.current,@course) || file.author_id == User.current.id) && course_contains_attachment?(@course,file) %>
<%= link_to("选入我的其他课程",quote_resource_show_course_file_path(@course,file),:class => "f_l re_select c_lorange",:remote => true) if has_course?(User.current,file) %>
<div class="resources mt10"><!--资源库内容开始--->
<div class="homepagePostBrief">
<div class="homepagePostPortrait">
<%= link_to image_tag(url_to_avatar(file.author), :width => 50, :height => 50), user_path(file.author) %>
</div>
<div class="homepagePostDes">
<div class="homepagePostTitle break_word mt-4">
<%= link_to truncate(file.filename,length: 35, omission: '...'),
download_named_attachment_path(file.id, file.filename),
:title => file.filename+"\n"+file.description.to_s, :style => "overflow: hidden; white-space: nowrap;text-overflow: ellipsis;",:class => "linkBlue f_14 f_b" %>
<%= file_preview_eye(file, class: 'preview') %>
<span id="image_private_<%= file.id%>">
<% if file.is_public? == false%>
<span class="img_private ml5">私有</span>
<%end %>
</span>
</div>
<div class="mt5">
<span class="fontGrey2 mr15 fl">上传时间:<%= format_time(file.created_on)%></span>
<% if file.tag_list.length > 0%>
<span class="fontGrey2 fl mr15">上传类型:<%= file.tag_list[0] %></span>
<% end %>
<p class="f_l mb5 fontGrey2">文件大小:<%= number_to_human_size(file.filesize) %></p>
<p class="fl ml15 fontGrey2">下载<%= file.downloads%>&nbsp;&nbsp;|&nbsp;&nbsp;引用<%= file.quotes.nil? ? 0:file.quotes %> </p>
</div>
<div class="cl"></div>
<div class="tag_h">
<!-- container_type = 1 代表是课程里的资源 -->
<%= render :partial => 'tags/tag_new', :locals => {:obj => file, :object_flag => "6",:tag_name => @tag_name} %>
<%= render :partial => 'tags/tag_add', :locals => {:obj => file, :object_flag => "6",:tag_name => @tag_name} %>
</div>
<div class="homepagePostSetting">
<% if delete_allowed && file.container_id == @course.id && file.container_type == "Course" %>
<% if @course.is_public? %>
<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 c_blue",:method => :post %>
</span>
<% else %>
<span id="is_public_<%= file.id %>">
<span class="f_l re_open c_blue">私有</span>
</span>
<% end %>
<ul>
<li class="homepagePostSettingIcon">
<% if User.current.logged? %>
<% else %>
<!-- <#%= link_to (file.is_public? ? "公开":"私有"),"javascript:void(0)",:class=>"f_l re_open" %> -->
<% end %>
<% else %>
<%= link_to("选入我的课程",quote_resource_show_course_file_path(@course,file),:class => "f_l re_select c_lorange",:remote => true) if has_course?(User.current,file) %>
<% end %>
<%= file_preview_tag(file, class: 'f_l re_open') %>
<% else %>
<% end %>
</div>
<div class="cl"></div>
<div class="mt5">
<p class="f_l mb5 c_grey02">文件大小:<%= 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 (delete_allowed || User.current.id == file.author_id) && file.container_id == @course.id && file.container_type == "Course"%>
<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">
<!-- container_type = 1 代表是课程里的资源 -->
<%= render :partial => 'tags/tag_new', :locals => {:obj => file, :object_flag => "6",:tag_name => @tag_name} %>
<%= render :partial => 'tags/tag_add', :locals => {:obj => file, :object_flag => "6",:tag_name => @tag_name} %>
</div>
<div class="cl"></div>
</div><!---re_con_box end-->
<% if (is_course_teacher(User.current,@course) || file.author_id == User.current.id) && course_contains_attachment?(@course,file) %>
<% if (delete_allowed || User.current.id == file.author_id) && file.container_id == @course.id && file.container_type == "Course" %>
<ul class="homepagePostSettiongText">
<li><%= link_to("发&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;送".html_safe, 'javascript:void(0)',:class => "postOptionLink",:onclick=>"show_send('#{file.id}')") %></li>
<li><%= link_to '更新版本',attachments_versions_path(file),:class => "postOptionLink",:remote=>true %></li>
<% if @course.is_public? %>
<li>
<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=>"postOptionLink",:method => :post %>
</span>
</li>
<%end%>
<li>
<%= link_to( '删除资源', attachment_path(file),
:data => {:confirm => l(:text_are_you_sure)}, :method => :delete,:class => "postOptionLink") if (delete_allowed || User.current.id == file.author_id) && file.container_id == @course.id && file.container_type == "Course" && file.destroyable %>
</li>
</ul>
<% end %>
<%else%>
<ul class="resourceSendO">
<li><%= link_to("发&nbsp;&nbsp;送".html_safe, 'javascript:void(0)',:class => "postOptionLink2",:onclick=>"show_send('#{file.id}')") %></li>
</ul>
<% end %>
<% end %>
</li>
</ul>
</div>
<div class="cl"></div>
</div>
<div class="cl"></div>
</div>
</div>
<% else %>
<div class="re_con_box"><span class='fr mr10 pr_join_span '><%= file.filename %>是私有资源</span></div>
<% 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>
<% if curse_attachments.count == 10%>
<% if params[:action] == 'search' %>
<%=link_to "点击展开更多", search_course_files_path({:course_id => course.id,:page => @obj_pages.nil? ? @feedback_pages.page + 1 : @obj_pages.page + 1}.merge(params)),:id => "show_more_attachments",:remote => "true",:class => "loadMore mt10 f_grey" %>
<% else %>
<!-- 全站搜索的时候 返回的页码对象是obj_pages,而站内搜索返回的页码对象是feedback_pages -->
<%=link_to "点击展开更多", course_files_path(:course_id => course.id, :page => @page), :id => "show_more_attachments",:remote => "true",:class => "loadMore mt10 f_grey" %>
<%end%>
<% end%>

Some files were not shown because too many files have changed in this diff Show More