This commit is contained in:
cxt 2015-09-01 16:37:43 +08:00
parent 735c374f73
commit 21565b74fe
20 changed files with 1064 additions and 1246 deletions

View File

@ -19,7 +19,7 @@ class CommentsController < ApplicationController
default_search_scope :news default_search_scope :news
include ApplicationHelper include ApplicationHelper
model_object News model_object News
before_filter :find_model_object before_filter :find_model_object
before_filter :find_project_from_association before_filter :find_project_from_association
before_filter :authorize before_filter :authorize
@ -34,7 +34,7 @@ class CommentsController < ApplicationController
ids = params[:asset_id].split(',') ids = params[:asset_id].split(',')
update_kindeditor_assets_owner ids,@comment.id,OwnerTypeHelper::COMMENT update_kindeditor_assets_owner ids,@comment.id,OwnerTypeHelper::COMMENT
end end
# 与我相关动态的记录add start # <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ض<EFBFBD>̬<EFBFBD>ļ<EFBFBD>¼add start
if( @comment.id && @news.course ) if( @comment.id && @news.course )
if(@news.author_id != User.current.id) if(@news.author_id != User.current.id)
notify = ActivityNotify.new() notify = ActivityNotify.new()
@ -47,11 +47,18 @@ class CommentsController < ApplicationController
notify.save() notify.save()
end end
end end
# 与我相关动态的记录add end # <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ض<EFBFBD>̬<EFBFBD>ļ<EFBFBD>¼add end
flash[:notice] = l(:label_comment_added) flash[:notice] = l(:label_comment_added)
end end
redirect_to news_url(@news) if params[:user_activity_id]
@user_activity_id = params[:user_activity_id]
respond_to do |format|
format.js
end
else
redirect_to news_url(@news)
end
end end
def destroy def destroy
@ -69,6 +76,6 @@ class CommentsController < ApplicationController
@comment = nil @comment = nil
@news @news
end end
end end

View File

@ -20,11 +20,11 @@ class IssuesController < ApplicationController
default_search_scope :issues default_search_scope :issues
before_filter :authorize1, :only => [:show] before_filter :authorize1, :only => [:show]
before_filter :find_issue, :only => [:show, :edit, :update] before_filter :find_issue, :only => [:show, :edit, :update,:add_journal]
before_filter :find_issues, :only => [:bulk_edit, :bulk_update, :destroy] before_filter :find_issues, :only => [:bulk_edit, :bulk_update, :destroy]
before_filter :find_project, :only => [:new, :create, :update_form] before_filter :find_project, :only => [:new, :create, :update_form]
#before_filter :authorize, :except => [:index, :show] #before_filter :authorize, :except => [:index, :show]
before_filter :authorize, :except => [:index] before_filter :authorize, :except => [:index,:add_journal]
before_filter :find_optional_project, :only => [:index] before_filter :find_optional_project, :only => [:index]
before_filter :check_for_default_issue_status, :only => [:new, :create] before_filter :check_for_default_issue_status, :only => [:new, :create]
@ -66,14 +66,14 @@ class IssuesController < ApplicationController
if @query.valid? if @query.valid?
case params[:format] case params[:format]
when 'csv', 'pdf' when 'csv', 'pdf'
@limit = 10#Setting.issues_export_limit.to_i @limit = 10#Setting.issues_export_limit.to_i
when 'atom' when 'atom'
@limit = 10#Setting.feeds_limit.to_i @limit = 10#Setting.feeds_limit.to_i
when 'xml', 'json' when 'xml', 'json'
@offset, @limit = api_offset_and_limit({:limit => 10}) @offset, @limit = api_offset_and_limit({:limit => 10})
else else
@limit = 10#per_page_option @limit = 10#per_page_option
end end
@assign_to_id = params[:assigned_to_id] @assign_to_id = params[:assigned_to_id]
@author_id = params[:author_id] @author_id = params[:author_id]
@ -84,9 +84,9 @@ class IssuesController < ApplicationController
@issue_pages = Paginator.new @issue_count, @limit, params['page'] @issue_pages = Paginator.new @issue_count, @limit, params['page']
@offset ||= @issue_pages.offset @offset ||= @issue_pages.offset
@issues = @query.issues(:include => [:assigned_to, :tracker, :priority, :category, :fixed_version], @issues = @query.issues(:include => [:assigned_to, :tracker, :priority, :category, :fixed_version],
:order => sort_clause, :order => sort_clause,
:offset => @offset, :offset => @offset,
:limit => @limit) :limit => @limit)
@issue_count_by_group = @query.issue_count_by_group @issue_count_by_group = @query.issue_count_by_group
respond_to do |format| respond_to do |format|
format.js format.js
@ -143,16 +143,16 @@ class IssuesController < ApplicationController
@available_watchers = (@issue.project.users.sort + @issue.watcher_users).uniq @available_watchers = (@issue.project.users.sort + @issue.watcher_users).uniq
respond_to do |format|`` respond_to do |format|``
format.html { format.html {
retrieve_previous_and_next_issue_ids retrieve_previous_and_next_issue_ids
render :template => 'issues/show', :layout => @project_base_tag#by young render :template => 'issues/show', :layout => @project_base_tag#by young
} }
format.api format.api
format.atom { render :template => 'journals/index', :layout => false, :content_type => 'application/atom+xml' } format.atom { render :template => 'journals/index', :layout => false, :content_type => 'application/atom+xml' }
format.pdf { format.pdf {
pdf = issue_to_pdf(@issue, :journals => @journals) pdf = issue_to_pdf(@issue, :journals => @journals)
send_data(pdf, :type => 'application/pdf', :filename => "#{@project.identifier}-#{@issue.id}.pdf") send_data(pdf, :type => 'application/pdf', :filename => "#{@project.identifier}-#{@issue.id}.pdf")
} }
end end
end end
@ -322,8 +322,8 @@ class IssuesController < ApplicationController
issue.reload issue.reload
if @copy if @copy
issue = issue.copy({}, issue = issue.copy({},
:attachments => params[:copy_attachments].present?, :attachments => params[:copy_attachments].present?,
:subtasks => params[:copy_subtasks].present? :subtasks => params[:copy_subtasks].present?
) )
end end
journal = issue.init_journal(User.current, params[:notes]) journal = issue.init_journal(User.current, params[:notes])
@ -353,21 +353,21 @@ class IssuesController < ApplicationController
@hours = TimeEntry.sum(:hours, :conditions => ['issue_id IN (?)', @issues]).to_f @hours = TimeEntry.sum(:hours, :conditions => ['issue_id IN (?)', @issues]).to_f
if @hours > 0 if @hours > 0
case params[:todo] case params[:todo]
when 'destroy' when 'destroy'
# nothing to do # nothing to do
when 'nullify' when 'nullify'
TimeEntry.update_all('issue_id = NULL', ['issue_id IN (?)', @issues]) TimeEntry.update_all('issue_id = NULL', ['issue_id IN (?)', @issues])
when 'reassign' when 'reassign'
reassign_to = @project.issues.find_by_id(params[:reassign_to_id]) reassign_to = @project.issues.find_by_id(params[:reassign_to_id])
if reassign_to.nil? if reassign_to.nil?
flash.now[:error] = l(:error_issue_not_found_in_project) flash.now[:error] = l(:error_issue_not_found_in_project)
return return
else
TimeEntry.update_all("issue_id = #{reassign_to.id}", ['issue_id IN (?)', @issues])
end
else else
TimeEntry.update_all("issue_id = #{reassign_to.id}", ['issue_id IN (?)', @issues]) # display the destroy form if it's a user request
end return unless api_request?
else
# display the destroy form if it's a user request
return unless api_request?
end end
end end
@issues.each do |issue| @issues.each do |issue|
@ -383,6 +383,18 @@ class IssuesController < ApplicationController
end end
end end
def add_journal
jour = Journal.new
jour.user_id = User.current.id
jour.notes = params[:notes]
jour.journalized = @issue
jour.save
@user_activity_id = params[:user_activity_id]
respond_to do |format|
format.js
end
end
private private
def find_project def find_project
@ -423,14 +435,14 @@ class IssuesController < ApplicationController
issue_attributes = params[:issue] issue_attributes = params[:issue]
if issue_attributes && params[:conflict_resolution] if issue_attributes && params[:conflict_resolution]
case params[:conflict_resolution] case params[:conflict_resolution]
when 'overwrite' when 'overwrite'
issue_attributes = issue_attributes.dup issue_attributes = issue_attributes.dup
issue_attributes.delete(:lock_version) issue_attributes.delete(:lock_version)
when 'add_notes' when 'add_notes'
issue_attributes = issue_attributes.slice(:notes) issue_attributes = issue_attributes.slice(:notes)
when 'cancel' when 'cancel'
redirect_to issue_url(@issue) redirect_to issue_url(@issue)
return false return false
end end
end end
@issue.safe_attributes = issue_attributes @issue.safe_attributes = issue_attributes

View File

@ -177,6 +177,7 @@ class MessagesController < ApplicationController
@reply.board = @board @reply.board = @board
@reply.safe_attributes = params[:reply] @reply.safe_attributes = params[:reply]
@reply.content = @quote + @reply.content @reply.content = @quote + @reply.content
@reply.subject = "RE: #{@topic.subject}" unless params[:reply][:subject]
@topic.children << @reply @topic.children << @reply
#@topic.update_attribute(:updated_on, Time.now) #@topic.update_attribute(:updated_on, Time.now)
if !@reply.new_record? if !@reply.new_record?
@ -185,41 +186,18 @@ class MessagesController < ApplicationController
update_kindeditor_assets_owner ids,@reply.id,OwnerTypeHelper::MESSAGE update_kindeditor_assets_owner ids,@reply.id,OwnerTypeHelper::MESSAGE
end end
# 与我相关动态的记录add start
if(@board && @board.course) #项目的先不管
notifyto_arr = {}
notifyto_arr[@topic.author_id] = @topic.author_id
if( params[:parent_topic] != nil && params[:parent_topic] != '')
parent_topic = Message.find(params[:parent_topic])
notifyto_arr[parent_topic.author_id] = parent_topic.author_id
end
notifyto_arr.each do |k,user_id|
if(user_id != User.current.id)
notify = ActivityNotify.new()
if(@board.course)
notify.activity_container_id = @board.course_id
notify.activity_container_type = 'Course'
else
notify.activity_container_id = @board.project_id
notify.activity_container_type = 'Project'
end
notify.activity_id = @reply.id
notify.activity_type = 'Message'
notify.notify_to = user_id
notify.is_read = 0
notify.save()
end
end
end
# 与我相关动态的记录add end
call_hook(:controller_messages_reply_after_save, { :params => params, :message => @reply}) call_hook(:controller_messages_reply_after_save, { :params => params, :message => @reply})
attachments = Attachment.attach_files(@reply, params[:attachments]) attachments = Attachment.attach_files(@reply, params[:attachments])
render_attachment_warning_if_needed(@reply) render_attachment_warning_if_needed(@reply)
else else
#render file: 'messages#show', layout: 'base_courses' #render file: 'messages#show', layout: 'base_courses'
end end
if params[:is_board] if params[:user_activity_id]
@user_activity_id = params[:user_activity_id]
respond_to do |format|
format.js
end
elsif params[:is_board]
if @project if @project
redirect_to project_boards_path(@project) redirect_to project_boards_path(@project)
elsif @course elsif @course

View File

@ -41,12 +41,12 @@ class UsersController < ApplicationController
before_filter :can_show_course, :only => [:user_courses,:user_homeworks] before_filter :can_show_course, :only => [:user_courses,:user_homeworks]
#edit has been deleted by huang, 2013-9-23 #edit has been deleted by huang, 2013-9-23
before_filter :find_user, :only => [:user_fanslist, :user_watchlist, :show, :edit, :update, :destroy, :edit_membership, :user_courses, before_filter :find_user, :only => [:user_fanslist, :user_watchlist, :show, :edit, :update, :destroy, :edit_membership, :user_courses,
:user_homeworks, :destroy_membership, :user_activities, :user_projects, :user_newfeedback, :user_comments, :user_homeworks, :destroy_membership, :user_activities, :user_projects, :user_newfeedback, :user_comments,
:watch_contests, :info, :watch_projects, :show_score, :topic_score_index, :project_score_index, :watch_contests, :info, :watch_projects, :show_score, :topic_score_index, :project_score_index,
:activity_score_index, :influence_score_index, :score_index,:show_new_score, :topic_new_score_index, :project_new_score_index, :activity_score_index, :influence_score_index, :score_index,:show_new_score, :topic_new_score_index, :project_new_score_index,
:activity_new_score_index, :influence_new_score_index, :score_new_index,:user_projects_index,:user_resource, :activity_new_score_index, :influence_new_score_index, :score_new_index,:user_projects_index,:user_resource,
:user_courses4show,:user_projects4show,:user_course_activities,:user_project_activities,:user_feedback4show,:user_visitorlist,:user_messages,:edit_brief_introduction, :user_courses4show,:user_projects4show,:user_course_activities,:user_project_activities,:user_feedback4show,:user_visitorlist,:user_messages,:edit_brief_introduction,
:user_import_homeworks,:user_search_homeworks,:user_import_resource] :user_import_homeworks,:user_search_homeworks,:user_import_resource]
before_filter :auth_user_extension, only: :show before_filter :auth_user_extension, only: :show
#before_filter :rest_user_score, only: :show #before_filter :rest_user_score, only: :show
#before_filter :select_entry, only: :user_projects #before_filter :select_entry, only: :user_projects
@ -223,7 +223,7 @@ class UsersController < ApplicationController
end end
# end # end
##added by fq ##added by fq
def watch_bids def watch_bids
# cond = 'bids.reward_type <> 1' # cond = 'bids.reward_type <> 1'
# @bids = Bid.watched_by(@user).where('reward_type = ?', 1) # added by huang # @bids = Bid.watched_by(@user).where('reward_type = ?', 1) # added by huang
@ -286,7 +286,7 @@ class UsersController < ApplicationController
unless User.current.admin? unless User.current.admin?
if !@user.active? || (@user != User.current && @memberships.empty? && events.empty?) if !@user.active? || (@user != User.current && @memberships.empty? && events.empty?)
render_404 render_404
return return
end end
end end
@ -405,19 +405,19 @@ class UsersController < ApplicationController
render_403 render_403
return return
end end
if(params[:type].nil? || params[:type] == "1") #全部 if(params[:type].blank? || params[:type] == "1") #全部
user_course_ids = User.current.courses.map { |c| c.id} #我的资源库的话,那么应该是我上传的所有资源 加上 我加入的课程的所有资源 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','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") "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" #课程资源 elsif params[:type] == "2" #课程资源
user_course_ids = User.current.courses.map { |c| c.id} user_course_ids = User.current.courses.map { |c| c.id}
@attachments = Attachment.where("(author_id = #{params[:id]} and container_type = 'Course') or (container_type = 'Course' and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')})) ").order("created_on desc") @attachments = Attachment.where("(author_id = #{params[:id]} and container_type = 'Course') or (container_type = 'Course' and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')})) ").order("created_on desc")
elsif params[:type] == "3" #项目资源 elsif params[:type] == "3" #项目资源
@attachments = Attachment.where("author_id = #{params[:id]} and container_type = 'Project'").order("created_on desc") @attachments = Attachment.where("author_id = #{params[:id]} and container_type = 'Project'").order("created_on desc")
elsif params[:type] == "4" #附件 elsif params[:type] == "4" #附件
@attachments = Attachment.where("author_id = #{params[:id]} and container_type in('Issue','Document','Message','News','StudentWorkScore','HomewCommon')").order("created_on desc") @attachments = Attachment.where("author_id = #{params[:id]} and container_type in('Issue','Document','Message','News','StudentWorkScore','HomewCommon')").order("created_on desc")
elsif params[:type] == "5" #用户资源 elsif params[:type] == "5" #用户资源
@attachments = Attachment.where("author_id = #{params[:id]} and container_type = 'Principal'").order("created_on desc") @attachments = Attachment.where("author_id = #{params[:id]} and container_type = 'Principal'").order("created_on desc")
end end
@type = params[:type] @type = params[:type]
@limit = 7 @limit = 7
@ -436,19 +436,19 @@ class UsersController < ApplicationController
#引入资源列表根据关键词过滤 #引入资源列表根据关键词过滤
def user_ref_resource_search def user_ref_resource_search
search = params[:search].to_s.strip.downcase search = params[:search].to_s.strip.downcase
if(params[:type].nil? || params[:type] == "1") #全部 if(params[:type].blank? || params[:type] == "1") #全部
user_course_ids = User.current.courses.map { |c| c.id} #我的资源库的话,那么应该是我上传的所有资源 加上 我加入的课程的所有资源 取交集并查询 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','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 '%#{search}%') ").order("created_on desc") " or (container_type = 'Course' and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')}))) and (filename like '%#{search}%') ").order("created_on desc")
elsif params[:type] == "2" #课程资源 elsif params[:type] == "2" #课程资源
user_course_ids = User.current.courses.map { |c| c.id} user_course_ids = User.current.courses.map { |c| c.id}
@attachments = Attachment.where("(author_id = #{params[:id]} and container_type = 'Course') or (container_type = 'Course' and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')})) and (filename like '%#{search}%') ").order("created_on desc") @attachments = Attachment.where("(author_id = #{params[:id]} and container_type = 'Course') or (container_type = 'Course' and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')})) and (filename like '%#{search}%') ").order("created_on desc")
elsif params[:type] == "3" #项目资源 elsif params[:type] == "3" #项目资源
@attachments = Attachment.where("author_id = #{params[:id]} and container_type = 'Project' and (filename like '%#{search}%')").order("created_on desc") @attachments = Attachment.where("author_id = #{params[:id]} and container_type = 'Project' and (filename like '%#{search}%')").order("created_on desc")
elsif params[:type] == "4" #附件 elsif params[:type] == "4" #附件
@attachments = Attachment.where("author_id = #{params[:id]} and container_type in('Project','Issue','Document','Message','News','StudentWorkScore','HomewCommon') and (filename like '%#{search}%')").order("created_on desc") @attachments = Attachment.where("author_id = #{params[:id]} and container_type in('Project','Issue','Document','Message','News','StudentWorkScore','HomewCommon') and (filename like '%#{search}%')").order("created_on desc")
elsif params[:type] == "5" #用户资源 elsif params[:type] == "5" #用户资源
@attachments = Attachment.where("author_id = #{params[:id]} and container_type = 'Principal' and (filename like '%#{search}%')").order("created_on desc") @attachments = Attachment.where("author_id = #{params[:id]} and container_type = 'Principal' and (filename like '%#{search}%')").order("created_on desc")
end end
@type = params[:type] @type = params[:type]
@limit = 7 @limit = 7
@ -466,20 +466,20 @@ class UsersController < ApplicationController
#将资源批量引入 #将资源批量引入
def import_resources_to_homework def import_resources_to_homework
@attachments = [] @attachments = []
unless params[:checkbox1].nil? || params[:checkbox1].blank? unless params[:checkbox1].nil? || params[:checkbox1].blank?
params[:checkbox1].each do |id| params[:checkbox1].each do |id|
atta = Attachment.find(id) atta = Attachment.find(id)
att_copy = atta.copy att_copy = atta.copy
att_copy.container_id = nil att_copy.container_id = nil
att_copy.container_type = nil att_copy.container_type = nil
att_copy.copy_from = atta.id att_copy.copy_from = atta.id
att_copy.save att_copy.save
@attachments << att_copy @attachments << att_copy
end
end
respond_to do |format|
format.js
end end
end
respond_to do |format|
format.js
end
end end
@ -529,16 +529,16 @@ class UsersController < ApplicationController
sort_update %w(login firstname lastname mail admin created_on last_login_on) sort_update %w(login firstname lastname mail admin created_on last_login_on)
case params[:format] case params[:format]
when 'xml', 'json' when 'xml', 'json'
@offset, @limit = api_offset_and_limit({:limit => 15}) @offset, @limit = api_offset_and_limit({:limit => 15})
else else
@limit = 15 @limit = 15
end end
# retrieve all users # retrieve all users
# 先内连一下statuses 保证排序之后数量一致 # 先内连一下statuses 保证排序之后数量一致
scope = User.visible. scope = User.visible.
joins("INNER JOIN user_statuses ON users.id = user_statuses.user_id") joins("INNER JOIN user_statuses ON users.id = user_statuses.user_id")
# unknow # unknow
scope = scope.in_group(params[:group_id]) if params[:group_id].present? scope = scope.in_group(params[:group_id]) if params[:group_id].present?
@ -549,29 +549,29 @@ class UsersController < ApplicationController
# users classify # users classify
case params[:user_sort_type] case params[:user_sort_type]
when '0' when '0'
# 创建时间排序 # 创建时间排序
@s_type = 0 @s_type = 0
@users = scope.reorder('users.created_on DESC') @users = scope.reorder('users.created_on DESC')
when '1' when '1'
# 活跃度排序, 就是所谓的得分情况 # 活跃度排序, 就是所谓的得分情况
@s_type = 1 @s_type = 1
@users = scope. @users = scope.
joins("LEFT JOIN option_numbers ON users.id = option_numbers.user_id and option_numbers.score_type = 1"). joins("LEFT JOIN option_numbers ON users.id = option_numbers.user_id and option_numbers.score_type = 1").
reorder('option_numbers.total_score DESC') reorder('option_numbers.total_score DESC')
when '2' when '2'
# 粉丝数排序 # 粉丝数排序
@s_type = 2 @s_type = 2
@users = scope. @users = scope.
#joins("INNER JOIN user_statuses ON users.id = user_statuses.user_id"). #joins("INNER JOIN user_statuses ON users.id = user_statuses.user_id").
reorder('user_statuses.watchers_count DESC') reorder('user_statuses.watchers_count DESC')
else else
# 默认活跃度排序 # 默认活跃度排序
@s_type = 1 @s_type = 1
@users = scope. @users = scope.
joins("LEFT JOIN option_numbers ON users.id = option_numbers.user_id and option_numbers.score_type = 1"). joins("LEFT JOIN option_numbers ON users.id = option_numbers.user_id and option_numbers.score_type = 1").
reorder('option_numbers.total_score DESC') reorder('option_numbers.total_score DESC')
end end
# limit and offset # limit and offset
@ -591,20 +591,20 @@ class UsersController < ApplicationController
sort_init 'login', 'asc' sort_init 'login', 'asc'
sort_update %w(login firstname lastname mail admin created_on last_login_on) sort_update %w(login firstname lastname mail admin created_on last_login_on)
(redirect_to user_url, :notice => l(:label_sumbit_empty);return) if params[:name].blank? (redirect_to user_url, :notice => l(:label_sumbit_empty);return) if params[:name].blank?
case params[:format] case params[:format]
when 'xml', 'json' when 'xml', 'json'
@offset, @limit = api_offset_and_limit({:limit => 15}) @offset, @limit = api_offset_and_limit({:limit => 15})
else else
@limit = 15#per_page_option @limit = 15#per_page_option
end end
# #
#@status = params[:status] || 1 #@status = params[:status] || 1
#has = { #has = {
# "show_changesets" => true # "show_changesets" => true
#} #}
# scope = User.logged.status(@status) # scope = User.logged.status(@status)
# @search_by = params[:search_by] ? params[:search_by][:id] : 0 # @search_by = params[:search_by] ? params[:search_by][:id] : 0
# scope = scope.like(params[:name],@search_by) if params[:name].present? # scope = scope.like(params[:name],@search_by) if params[:name].present?
@search_by = params[:search_by] ? params[:search_by] : 0 @search_by = params[:search_by] ? params[:search_by] : 0
us = UsersService.new us = UsersService.new
@ -637,13 +637,13 @@ class UsersController < ApplicationController
def user_courses4show def user_courses4show
@page = params[:page].to_i + 1 @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.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 end
#显示更多用户项目 #显示更多用户项目
def user_projects4show def user_projects4show
@page = params[:page].to_i + 1 @page = params[:page].to_i + 1
@projects = @user.projects.visible.select("projects.*,(SELECT MAX(created_at) FROM `forge_activities` WHERE forge_activities.project_id = projects.id) AS a").order("a desc").limit(5).offset(@page * 5) @projects = @user.projects.visible.select("projects.*,(SELECT MAX(created_at) FROM `forge_activities` WHERE forge_activities.project_id = projects.id) AS a").order("a desc").limit(5).offset(@page * 5)
end end
def user_course_activities def user_course_activities
lastid = nil lastid = nil
@ -720,9 +720,7 @@ class UsersController < ApplicationController
end end
def show def show
@page = params[:page] ? params[:page].to_i + 1 : 0 @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_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_course_ids = @user.courses.visible.empty? ? "(-1)" : "(" + @user.courses.visible.map{|course| course.id}.join(",") + ")"
course_types = "('Message','News','HomeworkCommon','poll')" course_types = "('Message','News','HomeworkCommon','poll')"
@ -743,7 +741,7 @@ class UsersController < ApplicationController
@user_activities = UserActivity.where("container_type = 'Project' and container_id in #{user_project_ids} and act_type = 'Message'").order('created_at desc').limit(10).offset(@page * 10) @user_activities = UserActivity.where("container_type = 'Project' and container_id in #{user_project_ids} and act_type = 'Message'").order('created_at desc').limit(10).offset(@page * 10)
else else
@user_activities = UserActivity.where("(container_type = 'Project' and container_id in #{user_project_ids} and act_type in #{project_types}) or (container_type = 'Course' and container_id in #{user_course_ids}) and act_type in #{course_types}").order('created_at desc').limit(10).offset(@page * 10) @user_activities = UserActivity.where("(container_type = 'Project' and container_id in #{user_project_ids} and act_type in #{project_types}) or (container_type = 'Course' and container_id in #{user_course_ids}) and act_type in #{course_types}").order('created_at desc').limit(10).offset(@page * 10)
end end
else else
@user_activities = UserActivity.where("(container_type = 'Project' and container_id in #{user_project_ids} and act_type in #{project_types}) or (container_type = 'Course' and container_id in #{user_course_ids}) and act_type in #{course_types}").order('created_at desc').limit(10).offset(@page * 10) @user_activities = UserActivity.where("(container_type = 'Project' and container_id in #{user_project_ids} and act_type in #{project_types}) or (container_type = 'Course' and container_id in #{user_course_ids}) and act_type in #{course_types}").order('created_at desc').limit(10).offset(@page * 10)
end end
@ -761,124 +759,124 @@ class UsersController < ApplicationController
# Author lizanle # Author lizanle
# Description type 1 :所有动态包括我关注的人 type 2:我的动态 type 3:关于我的回复 # Description type 1 :所有动态包括我关注的人 type 2:我的动态 type 3:关于我的回复
case params[:type] case params[:type]
when "1" when "1"
if @user == User.current if @user == User.current
activity = Activity.where('user_id = ?', User.current.id).order('id desc') activity = Activity.where('user_id = ?', User.current.id).order('id desc')
@activity_count = activity.count @activity_count = activity.count
@activity_pages = Paginator.new @activity_count, pre_count, params['page'] @activity_pages = Paginator.new @activity_count, pre_count, params['page']
@activity = activity.offset(@activity_pages.offset).limit(@activity_pages.per_page).all @activity = activity.offset(@activity_pages.offset).limit(@activity_pages.per_page).all
@state = 1 @state = 1
end end
when "2" when "2"
message = [] message = []
if @user == User.current if @user == User.current
message = JournalsForMessage.reference_message(@user.id) message = JournalsForMessage.reference_message(@user.id)
message += Journal.reference_message(@user.id) message += Journal.reference_message(@user.id)
end end
@activity_count = message.size @activity_count = message.size
@info_pages = Paginator.new @activity_count, pre_count, params['page'] @info_pages = Paginator.new @activity_count, pre_count, params['page']
messages = message.sort {|x,y| y.created_on <=> x.created_on } messages = message.sort {|x,y| y.created_on <=> x.created_on }
@message = messages[@info_pages.offset, @info_pages.per_page] @message = messages[@info_pages.offset, @info_pages.per_page]
@state = 2 @state = 2
else else
# Time 2015-02-04 10:50:49 # Time 2015-02-04 10:50:49
# Author lizanle # Author lizanle
# Description 所有动态 # Description 所有动态
where_condition = nil; where_condition = nil;
# where_condition = "act_type <> 'JournalsForMessage'" # where_condition = "act_type <> 'JournalsForMessage'"
user_ids = [] user_ids = []
if @user == User.current if @user == User.current
watcher = User.watched_by(@user) watcher = User.watched_by(@user)
watcher.push(User.current) watcher.push(User.current)
user_ids = watcher.map{|x| x.id} user_ids = watcher.map{|x| x.id}
else else
user_ids << @user.id user_ids << @user.id
end
activity = Activity.where(where_condition).where(user_id: user_ids).order('id desc')
permission = !User.current.admin?
if permission
#Issue
act_ids = activity.where(act_type: 'Issue').select('act_id').map{|x| x.act_id}
project_ids = Issue.where(id: act_ids).select('distinct project_id').map{|x| x.project_id}
p_ids = []
Project.where(id: project_ids).each do |x|
p_ids << x.id unless x.visible?(User.current)
end end
ids = [] activity = Activity.where(where_condition).where(user_id: user_ids).order('id desc')
ids << Issue.where(id: act_ids, project_id: p_ids).map{|x| x.id}
#HomeworkCommon permission = !User.current.admin?
act_ids = activity.where(act_type: 'HomeworkCommon').select('act_id').map{|x| x.act_id} if permission
course_ids = HomeworkCommon.where(id: act_ids).select('distinct course_id').map{|x| x.course_id} #Issue
c_ids = [] act_ids = activity.where(act_type: 'Issue').select('act_id').map{|x| x.act_id}
Course.where(id: course_ids).each do |x| project_ids = Issue.where(id: act_ids).select('distinct project_id').map{|x| x.project_id}
c_ids << x.id unless x.is_public !=0 && User.current.member_of_course?(x) p_ids = []
Project.where(id: project_ids).each do |x|
p_ids << x.id unless x.visible?(User.current)
end
ids = []
ids << Issue.where(id: act_ids, project_id: p_ids).map{|x| x.id}
#HomeworkCommon
act_ids = activity.where(act_type: 'HomeworkCommon').select('act_id').map{|x| x.act_id}
course_ids = HomeworkCommon.where(id: act_ids).select('distinct course_id').map{|x| x.course_id}
c_ids = []
Course.where(id: course_ids).each do |x|
c_ids << x.id unless x.is_public !=0 && User.current.member_of_course?(x)
end
ids << HomeworkCommon.where(id: act_ids, course_id: c_ids).map{|x| x.id}
#Journal
act_ids = activity.where(act_type: 'Journal').select('act_id').map{|x| x.act_id}
project_ids = Journal.where(id:act_ids, journalized_type: 'Project').select('distinct journalized_id').map{|x| x.journalized_id}
p_ids = []
Project.where(id: project_ids).each do |x|
p_ids << x.id unless x.visible?(User.current)
end
ids << Journal.where(id: act_ids, journalized_id: p_ids, journalized_type: 'Project').map{|x| x.id}
#News
act_ids = activity.where(act_type: 'News').select('act_id').map{|x| x.act_id}
project_ids = News.where(id: act_ids).select('distinct project_id').map{|x| x.project_id}
p_ids = []
Project.where(id: project_ids).each do |x|
p_ids << x.id unless x.visible?(User.current)
end
ids << News.where(id: act_ids, project_id: p_ids).map{|x| x.id}
project_ids = News.where(id: act_ids).select('distinct course_id').map{|x| x.course_id}
c_ids = []
Course.where(id: project_ids).each do |x|
c_ids << x.id unless x.is_public !=0 && User.current.member_of_course?(x)
end
ids << News.where(id: act_ids, course_id: p_ids).map{|x| x.id}
#Message
act_ids = activity.where(act_type: 'Message').select('act_id').map{|x| x.act_id}
board_ids = Message.where(id: act_ids).select('distinct board_id').map{|x| x.board_id}
project_ids = Board.where(id: board_ids).select('distinct project_id').map{|x| x.project_id}
p_ids = []
Project.where(id: project_ids).each do |x|
p_ids << x.id unless x.visible?(User.current)
end
ids << Message.where(id: act_ids, board_id: p_ids).map{|x| x.id}
project_ids = Board.where(id: board_ids).select('distinct course_id').map{|x| x.course_id}
c_ids = []
Course.where(id: project_ids).each do |x|
c_ids << x.id unless x.is_public !=0 && User.current.member_of_course?(x)
end
ids << Message.where(id: act_ids, board_id: c_ids).map{|x| x.id}
logger.debug "filter ids #{ids}"
activity = activity.where('act_id not in (?)', ids.flatten ).order('id desc') unless ids.flatten.empty?
end end
ids << HomeworkCommon.where(id: act_ids, course_id: c_ids).map{|x| x.id}
#Journal # activity = activity.reject { |e|
act_ids = activity.where(act_type: 'Journal').select('act_id').map{|x| x.act_id} # e.act.nil? ||
project_ids = Journal.where(id:act_ids, journalized_type: 'Project').select('distinct journalized_id').map{|x| x.journalized_id} # (!User.current.admin? && !e.act.nil?
p_ids = [] # (((e.act_type == "Issue") && !e.act.project.visible?(User.current)) ||
Project.where(id: project_ids).each do |x| # (e.act_type == "Bid" && !e.act.courses.first.nil? && e.act.courses.first.is_public == 0 && !User.current.member_of_course?(e.act.courses.first)) ||
p_ids << x.id unless x.visible?(User.current) # (e.act_type == "Journal" && e.act.respond_to?("Project") && !e.act.project.visible?(User.current)) ||
end # (e.act_type == "News" && ((!e.act.project.nil? && !e.act.project.visible?(User.current)) || (!e.act.course.nil? && e.act.course.is_public == 0 && !User.current.member_of_course?(e.act.course)))) ||
ids << Journal.where(id: act_ids, journalized_id: p_ids, journalized_type: 'Project').map{|x| x.id} # (e.act_type == "Message" && !e.act.board.nil? && ((!e.act.board.project.nil? && !e.act.board.project.visible?(User.current)) || (!e.act.board.course.nil? && e.act.board.course.is_public == 0 && !User.current.member_of_course?(e.act.board.course))))))
# }
#
#News @activity_count = activity.count
act_ids = activity.where(act_type: 'News').select('act_id').map{|x| x.act_id} @activity_pages = Paginator.new @activity_count, pre_count, params['page']
project_ids = News.where(id: act_ids).select('distinct project_id').map{|x| x.project_id} @activity = activity.slice(@activity_pages.offset,@activity_pages.per_page)
p_ids = [] @state = 0
Project.where(id: project_ids).each do |x|
p_ids << x.id unless x.visible?(User.current)
end
ids << News.where(id: act_ids, project_id: p_ids).map{|x| x.id}
project_ids = News.where(id: act_ids).select('distinct course_id').map{|x| x.course_id}
c_ids = []
Course.where(id: project_ids).each do |x|
c_ids << x.id unless x.is_public !=0 && User.current.member_of_course?(x)
end
ids << News.where(id: act_ids, course_id: p_ids).map{|x| x.id}
#Message
act_ids = activity.where(act_type: 'Message').select('act_id').map{|x| x.act_id}
board_ids = Message.where(id: act_ids).select('distinct board_id').map{|x| x.board_id}
project_ids = Board.where(id: board_ids).select('distinct project_id').map{|x| x.project_id}
p_ids = []
Project.where(id: project_ids).each do |x|
p_ids << x.id unless x.visible?(User.current)
end
ids << Message.where(id: act_ids, board_id: p_ids).map{|x| x.id}
project_ids = Board.where(id: board_ids).select('distinct course_id').map{|x| x.course_id}
c_ids = []
Course.where(id: project_ids).each do |x|
c_ids << x.id unless x.is_public !=0 && User.current.member_of_course?(x)
end
ids << Message.where(id: act_ids, board_id: c_ids).map{|x| x.id}
logger.debug "filter ids #{ids}"
activity = activity.where('act_id not in (?)', ids.flatten ).order('id desc') unless ids.flatten.empty?
end
# activity = activity.reject { |e|
# e.act.nil? ||
# (!User.current.admin? && !e.act.nil?
# (((e.act_type == "Issue") && !e.act.project.visible?(User.current)) ||
# (e.act_type == "Bid" && !e.act.courses.first.nil? && e.act.courses.first.is_public == 0 && !User.current.member_of_course?(e.act.courses.first)) ||
# (e.act_type == "Journal" && e.act.respond_to?("Project") && !e.act.project.visible?(User.current)) ||
# (e.act_type == "News" && ((!e.act.project.nil? && !e.act.project.visible?(User.current)) || (!e.act.course.nil? && e.act.course.is_public == 0 && !User.current.member_of_course?(e.act.course)))) ||
# (e.act_type == "Message" && !e.act.board.nil? && ((!e.act.board.project.nil? && !e.act.board.project.visible?(User.current)) || (!e.act.board.course.nil? && e.act.board.course.is_public == 0 && !User.current.member_of_course?(e.act.board.course))))))
# }
#
@activity_count = activity.count
@activity_pages = Paginator.new @activity_count, pre_count, params['page']
@activity = activity.slice(@activity_pages.offset,@activity_pages.per_page)
@state = 0
end end
if params[:user].present? if params[:user].present?
@ -906,7 +904,7 @@ class UsersController < ApplicationController
if !@user.active? #|| (@user != User.current && @memberships.empty? && events.empty?) if !@user.active? #|| (@user != User.current && @memberships.empty? && events.empty?)
# redirect_to home_path # redirect_to home_path
render_404 render_404
return return
end end
end end
@ -938,7 +936,7 @@ class UsersController < ApplicationController
unless User.current.admin? unless User.current.admin?
if !@user.active? if !@user.active?
render_404 render_404
return return
end end
end end
@ -996,7 +994,7 @@ class UsersController < ApplicationController
unless @user.id.nil? unless @user.id.nil?
#后台注册的用户默认权限为男性开发员 #后台注册的用户默认权限为男性开发员
ue = UserExtensions.create(:identity => 3, ue = UserExtensions.create(:identity => 3,
:gender => 0, :gender => 0,
:user_id => @user.id) :user_id => @user.id)
ue.save ue.save
end end
@ -1066,8 +1064,8 @@ class UsersController < ApplicationController
@user = User.find(params[:id]) @user = User.find(params[:id])
#@user.save_attachments(params[:attachments],User.current) #@user.save_attachments(params[:attachments],User.current)
# Container_type为Principal # Container_type为Principal
Attachment.attach_filesex(@user, params[:attachments], params[:attachment_type]) Attachment.attach_filesex(@user, params[:attachments], params[:attachment_type])
if(params[:type].nil? || params[:type] == "1") #全部 if(params[:type].blank?|| params[:type] == "1") #全部
if User.current.id.to_i == params[:id].to_i if User.current.id.to_i == params[:id].to_i
user_course_ids = User.current.courses.map { |c| c.id} #我的资源库的话,那么应该是我上传的所有资源 加上 我加入的课程的所有资源 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','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) "+
@ -1122,14 +1120,14 @@ class UsersController < ApplicationController
# 删除用户资源,分为批量删除 和 单个删除,只能删除自己上传的资源 # 删除用户资源,分为批量删除 和 单个删除,只能删除自己上传的资源
def user_resource_delete def user_resource_delete
if params[:resource_id].present? if params[:resource_id].present?
Attachment.where("author_id = #{User.current.id}").delete(params[:resource_id]) Attachment.where("author_id = #{User.current.id}").delete(params[:resource_id])
elsif params[:checkbox1].present? elsif params[:checkbox1].present?
params[:checkbox1].each do |id| params[:checkbox1].each do |id|
Attachment.where("author_id = #{User.current.id}").delete(id) Attachment.where("author_id = #{User.current.id}").delete(id)
end end
end end
if(params[:type].nil? || params[:type] == "1") #全部 if(params[:type].blank? || params[:type] == "1") #全部
if User.current.id.to_i == params[:id].to_i if User.current.id.to_i == params[:id].to_i
user_course_ids = User.current.courses.map { |c| c.id} #我的资源库的话,那么应该是我上传的所有资源 加上 我加入的课程的所有资源 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','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) "+
@ -1176,17 +1174,17 @@ class UsersController < ApplicationController
@offset ||= @atta_pages.offset @offset ||= @atta_pages.offset
#@curse_attachments_all = @all_attachments[@offset, @limit] #@curse_attachments_all = @all_attachments[@offset, @limit]
@attachments = paginateHelper @attachments,25 @attachments = paginateHelper @attachments,25
respond_to do |format| respond_to do |format|
format.js format.js
end end
end end
#根据id或者名称搜索教师或者助教为当前用户的课程 #根据id或者名称搜索教师或者助教为当前用户的课程
def search_user_course def search_user_course
@user = User.current @user = User.current
if !params[:search].nil? if !params[:search].nil?
@course = @user.courses.where(" #{Course.table_name}.id = #{params[:search].to_i } or #{Course.table_name}.name like '%#{params[:search.to_s]}%'") @course = @user.courses.where(" #{Course.table_name}.id = #{params[:search].to_i } or #{Course.table_name}.name like '%#{params[:search.to_s]}%'")
.select { |course| @user.allowed_to?(:as_teacher,course)} .select { |course| @user.allowed_to?(:as_teacher,course)}
else else
@course = @user.courses @course = @user.courses
.select { |course| @user.allowed_to?(:as_teacher,course)} .select { |course| @user.allowed_to?(:as_teacher,course)}
@ -1218,28 +1216,28 @@ class UsersController < ApplicationController
# 将资源发送到对应的课程,分为发送单个,或者批量发送 # 将资源发送到对应的课程,分为发送单个,或者批量发送
def add_exist_file_to_course def add_exist_file_to_course
@flag = true @flag = true
if params[:send_id].present? if params[:send_id].present?
send_id = params[:send_id] send_id = params[:send_id]
ori = Attachment.find_by_id(send_id) ori = Attachment.find_by_id(send_id)
course_ids = params[:course_ids] course_ids = params[:course_ids]
if course_ids.nil? if course_ids.nil?
@flag = false @flag = false
end end
unless course_ids.nil? unless course_ids.nil?
course_ids.each do |id| course_ids.each do |id|
next if ori.blank? next if ori.blank?
attach_copied_obj = ori.copy attach_copied_obj = ori.copy
attach_copied_obj.tag_list.add(ori.tag_list) # tag关联 attach_copied_obj.tag_list.add(ori.tag_list) # tag关联
attach_copied_obj.container = Course.find(id) attach_copied_obj.container = Course.find(id)
attach_copied_obj.created_on = Time.now attach_copied_obj.created_on = Time.now
attach_copied_obj.author_id = User.current.id attach_copied_obj.author_id = User.current.id
if attach_copied_obj.attachtype == nil if attach_copied_obj.attachtype == nil
attach_copied_obj.attachtype = 4 attach_copied_obj.attachtype = 4
end end
attach_copied_obj.save attach_copied_obj.save
@save_message = attach_copied_obj.errors.full_messages @save_message = attach_copied_obj.errors.full_messages
end
end end
end
elsif params[:send_ids].present? elsif params[:send_ids].present?
send_ids = params[:send_ids].split(" ") send_ids = params[:send_ids].split(" ")
course_ids = params[:course_ids] course_ids = params[:course_ids]
@ -1266,8 +1264,20 @@ class UsersController < ApplicationController
end end
end end
else else
@flag = false @flag = false
end 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')) "+
"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| respond_to do |format|
format.js format.js
end end
@ -1324,7 +1334,18 @@ class UsersController < ApplicationController
else else
@flag=true @flag=true
end 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')) "+
"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| respond_to do |format|
format.js format.js
end end
@ -1332,15 +1353,15 @@ class UsersController < ApplicationController
# 资源预览 # 资源预览
def resource_preview def resource_preview
preview_id = params[:resource_id] preview_id = params[:resource_id]
@file = Attachment.find(preview_id) @file = Attachment.find(preview_id)
@preview_able = false; @preview_able = false;
if %w(pdf pptx doc docx xls xlsx).any?{|x| @file.filename.downcase.end_with?(x)} if %w(pdf pptx doc docx xls xlsx).any?{|x| @file.filename.downcase.end_with?(x)}
@preview_able = true; @preview_able = true;
end end
respond_to do |format| respond_to do |format|
format.js format.js
end end
end end
# 重命名资源 # 重命名资源
@ -1380,7 +1401,7 @@ class UsersController < ApplicationController
def destroy_membership def destroy_membership
@membership = Member.find(params[:membership_id]) @membership = Member.find(params[:membership_id])
if @membership.deletable? if @membership.deletable?
@membership.destroy @membership.destroy
end end
respond_to do |format| respond_to do |format|
format.html { redirect_to edit_user_url(@user, :tab => 'memberships') } format.html { redirect_to edit_user_url(@user, :tab => 'memberships') }
@ -1395,31 +1416,31 @@ class UsersController < ApplicationController
@obj_flag = params[:tag_for_save][:object_flag] @obj_flag = params[:tag_for_save][:object_flag]
case @obj_flag case @obj_flag
when '1' then when '1' then
@obj = User.find_by_id(@obj_id) @obj = User.find_by_id(@obj_id)
when '2' then when '2' then
@obj = Project.find_by_id(@obj_id) @obj = Project.find_by_id(@obj_id)
when '3' then when '3' then
@obj = Issue.find_by_id(@obj_id) @obj = Issue.find_by_id(@obj_id)
when '4' then when '4' then
# @obj = Bid.find_by_id(@obj_id) # @obj = Bid.find_by_id(@obj_id)
when '5' then when '5' then
@obj = Forum.find_by_id(@obj_id) @obj = Forum.find_by_id(@obj_id)
when '6' when '6'
@obj = Attachment.find_by_id(@obj_id) @obj = Attachment.find_by_id(@obj_id)
when '7' then when '7' then
@obj = Contest.find_by_id(@obj_id) @obj = Contest.find_by_id(@obj_id)
when '8' when '8'
@obj = OpenSourceProject.find_by_id(@obj_id) @obj = OpenSourceProject.find_by_id(@obj_id)
when '9' when '9'
@obj = Course.find_by_id(@obj_id) @obj = Course.find_by_id(@obj_id)
else else
@obj = nil @obj = nil
end end
unless @obj.nil? unless @obj.nil?
@obj.tag_list.add(@tags.split(",")) @obj.tag_list.add(@tags.split(","))
else else
return return
end end
if @obj.save if @obj.save
logger.debug "#{__FILE__}:#{__LINE__} ===> #{@obj.to_json}" logger.debug "#{__FILE__}:#{__LINE__} ===> #{@obj.to_json}"
@ -1510,9 +1531,9 @@ class UsersController < ApplicationController
def update_extensions(user_extensions) def update_extensions(user_extensions)
user_extensions = params[:user_extensions] user_extensions = params[:user_extensions]
unless user_extensions.nil? unless user_extensions.nil?
user_extensions = UserExtensions.find_by_id(user_extensions.user_id) user_extensions = UserExtensions.find_by_id(user_extensions.user_id)
# user_extensions. # user_extensions.
end end
end end
@ -1539,7 +1560,7 @@ class UsersController < ApplicationController
render_403 render_403
return return
end end
if(params[:type].nil? || params[:type] == "1") #全部 if(params[:type].blank? || params[:type] == "1") #全部
if User.current.id.to_i == params[:id].to_i if User.current.id.to_i == params[:id].to_i
user_course_ids = User.current.courses.map { |c| c.id} #我的资源库的话,那么应该是我上传的所有资源 加上 我加入的课程的所有资源 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','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) "+
@ -1603,9 +1624,9 @@ class UsersController < ApplicationController
else else
user_course_ids = User.find(params[:id]).courses.visible.map { |c| c.id} #如果课程私有资源,那么要看这个资源的课程是不是在 这个user的所有我可见的课程中 user_course_ids = User.find(params[:id]).courses.visible.map { |c| c.id} #如果课程私有资源,那么要看这个资源的课程是不是在 这个user的所有我可见的课程中
@attachments = Attachment.where("((author_id = #{params[:id]} and is_public = 1 and container_type in" + @attachments = Attachment.where("((author_id = #{params[:id]} and is_public = 1 and container_type in" +
" ('Project','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon'))"+ " ('Project','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(',')})) )" + " or (container_type = 'Course' and is_public = 1 and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')})) )" +
" and (filename like '%#{search}%') ").order("created_on desc") " and (filename like '%#{search}%') ").order("created_on desc")
end end
elsif params[:type] == "2" #课程资源 elsif params[:type] == "2" #课程资源
if User.current.id.to_i == params[:id].to_i if User.current.id.to_i == params[:id].to_i
@ -1614,7 +1635,7 @@ class UsersController < ApplicationController
else else
user_course_ids = User.find(params[:id]).courses.visible.map { |c| c.id} #如果课程私有资源,那么要看这个资源的课程是不是在 这个user的所有我可见的课程中 user_course_ids = User.find(params[:id]).courses.visible.map { |c| c.id} #如果课程私有资源,那么要看这个资源的课程是不是在 这个user的所有我可见的课程中
@attachments = Attachment.where("((author_id = #{params[:id]} and is_public = 1 and container_type = 'Course') "+ @attachments = Attachment.where("((author_id = #{params[:id]} and is_public = 1 and container_type = 'Course') "+
"or (container_type = 'Course' and is_public = 1 and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')})) )"+ "or (container_type = 'Course' and is_public = 1 and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')})) )"+
" and (filename like '%#{search}%') ").order("created_on desc") " and (filename like '%#{search}%') ").order("created_on desc")
end end
elsif params[:type] == "3" #项目资源 elsif params[:type] == "3" #项目资源

View File

@ -71,7 +71,7 @@ module UsersHelper
def user_settings_tabs def user_settings_tabs
tabs = [{:name => 'general', :partial => 'users/general', :label => :label_general}, tabs = [{:name => 'general', :partial => 'users/general', :label => :label_general},
{:name => 'memberships', :partial => 'users/memberships', :label => :label_project_plural} {:name => 'memberships', :partial => 'users/memberships', :label => :label_project_plural}
] ]
if Group.all.any? if Group.all.any?
tabs.insert 1, {:name => 'groups', :partial => 'users/groups', :label => :label_group_plural} tabs.insert 1, {:name => 'groups', :partial => 'users/groups', :label => :label_group_plural}
end end
@ -83,7 +83,7 @@ module UsersHelper
def get_users_by_tag(tag_name) def get_users_by_tag(tag_name)
User.tagged_with(tag_name).order('updated_on desc') User.tagged_with(tag_name).order('updated_on desc')
end end
# added by fq # added by fq
# <div class="pagination" > # <div class="pagination" >
# <ul> # <ul>
@ -91,7 +91,7 @@ module UsersHelper
# <li><%= link_to("只看自己", {:controller => 'users', :action => 'show', :type => 1}) %></li> # <li><%= link_to("只看自己", {:controller => 'users', :action => 'show', :type => 1}) %></li>
# <li><%= link_to("所有反馈", {:controller => 'users', :action => 'show', :type => 2}) %></li> # <li><%= link_to("所有反馈", {:controller => 'users', :action => 'show', :type => 2}) %></li>
# </ul></div> # </ul></div>
# TODO: 待删 # TODO: 待删
# def show_activity(state) # def show_activity(state)
# content = ''.html_safe # content = ''.html_safe
@ -114,19 +114,19 @@ module UsersHelper
# end # end
# content_tag('div', content, :class => "pagination") # content_tag('div', content, :class => "pagination")
# end # end
#TODO: 待删 #TODO: 待删
def watch_projects(state) def watch_projects(state)
content = ''.html_safe content = ''.html_safe
case state case state
when 0 when 0
s = content_tag('span', l(:label_project_take), :class => "current-page") s = content_tag('span', l(:label_project_take), :class => "current-page")
content << content_tag('li', s) content << content_tag('li', s)
content << content_tag('li', link_to(l(:label_has_watched_project), {:controller => 'users', :action => 'watch_projects', :type => 1})) content << content_tag('li', link_to(l(:label_has_watched_project), {:controller => 'users', :action => 'watch_projects', :type => 1}))
when 1 when 1
s = content_tag('span', l(:label_has_watched_project), :class => "current-page") s = content_tag('span', l(:label_has_watched_project), :class => "current-page")
content << content_tag('li', link_to(l(:label_project_take), {:controller => 'users', :action => 'user_projects'})) content << content_tag('li', link_to(l(:label_project_take), {:controller => 'users', :action => 'user_projects'}))
content << content_tag('li', s, :class => "current-page") content << content_tag('li', s, :class => "current-page")
end end
content_tag('div', content, :class => "pagination") content_tag('div', content, :class => "pagination")
end end
@ -134,59 +134,59 @@ module UsersHelper
def user_course(state) def user_course(state)
content = ''.html_safe content = ''.html_safe
if @user != User.current if @user != User.current
if @user.user_extensions.identity == 0 if @user.user_extensions.identity == 0
case state case state
when 0 when 0
s = content_tag('span', '他执教的课程', :class => "current-page") s = content_tag('span', '他执教的课程', :class => "current-page")
content << content_tag('li', s) content << content_tag('li', s)
content << content_tag('li', link_to('他发布的作业', {:controller => 'users', :action => 'user_courses', :type => 1})) content << content_tag('li', link_to('他发布的作业', {:controller => 'users', :action => 'user_courses', :type => 1}))
content_tag('div', content, :class => "pagination") content_tag('div', content, :class => "pagination")
when 1 when 1
s = content_tag('span', '他发布的作业', :class => "current-page") s = content_tag('span', '他发布的作业', :class => "current-page")
content << content_tag('li', link_to('他执教的课程', {:controller => 'users', :action => 'user_courses'})) content << content_tag('li', link_to('他执教的课程', {:controller => 'users', :action => 'user_courses'}))
content << content_tag('li', s, :class => "current-page") content << content_tag('li', s, :class => "current-page")
content_tag('div', content, :class => "pagination") content_tag('div', content, :class => "pagination")
end end
else else
case state case state
when 0 when 0
s = content_tag('span', '他的课程', :class => "current-page") s = content_tag('span', '他的课程', :class => "current-page")
content << content_tag('li', s) content << content_tag('li', s)
content << content_tag('li', link_to('他的作业', {:controller => 'users', :action => 'user_courses', :type => 1})) content << content_tag('li', link_to('他的作业', {:controller => 'users', :action => 'user_courses', :type => 1}))
content_tag('div', content, :class => "pagination") content_tag('div', content, :class => "pagination")
when 1 when 1
s = content_tag('span', '他的作业', :class => "current-page") s = content_tag('span', '他的作业', :class => "current-page")
content << content_tag('li', link_to('他的课程', {:controller => 'users', :action => 'user_courses', :type => 0})) content << content_tag('li', link_to('他的课程', {:controller => 'users', :action => 'user_courses', :type => 0}))
content << content_tag('li', s, :class => "current-page") content << content_tag('li', s, :class => "current-page")
content_tag('div', content, :class => "pagination") content_tag('div', content, :class => "pagination")
end end
end end
else else
if @user.user_extensions.identity == 0 if @user.user_extensions.identity == 0
case state case state
when 0 when 0
s = content_tag('span', l(:label_teaching_course), :class => "current-page") s = content_tag('span', l(:label_teaching_course), :class => "current-page")
content << content_tag('li', s) content << content_tag('li', s)
content << content_tag('li', link_to(l(:label_release_homework), {:controller => 'users', :action => 'user_courses', :type => 1})) content << content_tag('li', link_to(l(:label_release_homework), {:controller => 'users', :action => 'user_courses', :type => 1}))
content_tag('div', content, :class => "pagination") content_tag('div', content, :class => "pagination")
when 1 when 1
s = content_tag('span', l(:label_release_homework), :class => "current-page") s = content_tag('span', l(:label_release_homework), :class => "current-page")
content << content_tag('li', link_to(l(:label_teaching_course), {:controller => 'users', :action => 'user_courses'})) content << content_tag('li', link_to(l(:label_teaching_course), {:controller => 'users', :action => 'user_courses'}))
content << content_tag('li', s, :class => "current-page") content << content_tag('li', s, :class => "current-page")
content_tag('div', content, :class => "pagination") content_tag('div', content, :class => "pagination")
end end
else else
case state case state
when 0 when 0
s = content_tag('span', l(:label_my_course), :class => "current-page") s = content_tag('span', l(:label_my_course), :class => "current-page")
content << content_tag('li', s) content << content_tag('li', s)
content << content_tag('li', link_to('我的作业', {:controller => 'users', :action => 'user_courses', :type => 1})) content << content_tag('li', link_to('我的作业', {:controller => 'users', :action => 'user_courses', :type => 1}))
content_tag('div', content, :class => "pagination") content_tag('div', content, :class => "pagination")
when 1 when 1
s = content_tag('span', '我的作业', :class => "current-page") s = content_tag('span', '我的作业', :class => "current-page")
content << content_tag('li', link_to(l(:label_my_course), {:controller => 'users', :action => 'user_courses', :type => 0})) content << content_tag('li', link_to(l(:label_my_course), {:controller => 'users', :action => 'user_courses', :type => 0}))
content << content_tag('li', s, :class => "current-page") content << content_tag('li', s, :class => "current-page")
content_tag('div', content, :class => "pagination") content_tag('div', content, :class => "pagination")
end end
end end
end end
@ -196,42 +196,42 @@ module UsersHelper
def sort_user(state, project_type) def sort_user(state, project_type)
content = ''.html_safe content = ''.html_safe
case state case state
when 0 when 0
content << content_tag('li', link_to(l(:label_sort_by_active), users_path(params.merge({:user_sort_type => '1', :project_type => project_type}) ))) content << content_tag('li', link_to(l(:label_sort_by_active), users_path(params.merge({:user_sort_type => '1', :project_type => project_type}) )))
content << content_tag('li', link_to(l(:label_sort_by_influence), users_path(params.merge({:user_sort_type => '2', :project_type => project_type}) ))) content << content_tag('li', link_to(l(:label_sort_by_influence), users_path(params.merge({:user_sort_type => '2', :project_type => project_type}) )))
content << content_tag('li', link_to(l(:label_sort_by_time), users_path(params.merge({:user_sort_type => '0', :project_type => project_type}) ), :class=>"selected") ) content << content_tag('li', link_to(l(:label_sort_by_time), users_path(params.merge({:user_sort_type => '0', :project_type => project_type}) ), :class=>"selected") )
when 1 when 1
content << content_tag('li', link_to(l(:label_sort_by_active), users_path(params.merge({:user_sort_type => '1', :project_type => project_type}) ), :class=>"selected") ) content << content_tag('li', link_to(l(:label_sort_by_active), users_path(params.merge({:user_sort_type => '1', :project_type => project_type}) ), :class=>"selected") )
content << content_tag('li', link_to(l(:label_sort_by_influence), users_path(params.merge({:user_sort_type => '2', :project_type => project_type}) ))) content << content_tag('li', link_to(l(:label_sort_by_influence), users_path(params.merge({:user_sort_type => '2', :project_type => project_type}) )))
content << content_tag('li', link_to(l(:label_sort_by_time), users_path(params.merge({:user_sort_type => '0', :project_type => project_type}) ))) content << content_tag('li', link_to(l(:label_sort_by_time), users_path(params.merge({:user_sort_type => '0', :project_type => project_type}) )))
when 2 when 2
content << content_tag('li', link_to(l(:label_sort_by_active), users_path(params.merge({:user_sort_type => '1', :project_type => project_type}) ))) content << content_tag('li', link_to(l(:label_sort_by_active), users_path(params.merge({:user_sort_type => '1', :project_type => project_type}) )))
content << content_tag('li', link_to(l(:label_sort_by_influence), users_path(params.merge({:user_sort_type => '2', :project_type => project_type}) ), :class=>"selected") ) content << content_tag('li', link_to(l(:label_sort_by_influence), users_path(params.merge({:user_sort_type => '2', :project_type => project_type}) ), :class=>"selected") )
content << content_tag('li', link_to(l(:label_sort_by_time), users_path(params.merge({:user_sort_type => '0', :project_type => project_type}) ))) content << content_tag('li', link_to(l(:label_sort_by_time), users_path(params.merge({:user_sort_type => '0', :project_type => project_type}) )))
end end
content = content_tag('ul', content) content = content_tag('ul', content)
content_tag('div', content, :class => "tabs") content_tag('div', content, :class => "tabs")
end end
def sort_user_enterprise(state, project_type) def sort_user_enterprise(state, project_type)
content = ''.html_safe content = ''.html_safe
case state case state
when 0 when 0
content << content_tag('li', link_to(l(:label_sort_by_active), users_path(:user_sort_type => '1', :project_type => project_type))) content << content_tag('li', link_to(l(:label_sort_by_active), users_path(:user_sort_type => '1', :project_type => project_type)))
content << content_tag('li', link_to(l(:label_sort_by_influence), users_path(:user_sort_type => '2', :project_type => project_type))) content << content_tag('li', link_to(l(:label_sort_by_influence), users_path(:user_sort_type => '2', :project_type => project_type)))
content << content_tag('li', link_to(l(:label_sort_by_time), users_path(:user_sort_type => '0', :project_type => project_type), :class=>"selected"), :class=>"selected") content << content_tag('li', link_to(l(:label_sort_by_time), users_path(:user_sort_type => '0', :project_type => project_type), :class=>"selected"), :class=>"selected")
when 1 when 1
content << content_tag('li', link_to(l(:label_sort_by_active), users_path(:user_sort_type => '1', :project_type => project_type), :class=>"selected"), :class=>"selected") content << content_tag('li', link_to(l(:label_sort_by_active), users_path(:user_sort_type => '1', :project_type => project_type), :class=>"selected"), :class=>"selected")
content << content_tag('li', link_to(l(:label_sort_by_influence), users_path(:user_sort_type => '2', :project_type => project_type))) content << content_tag('li', link_to(l(:label_sort_by_influence), users_path(:user_sort_type => '2', :project_type => project_type)))
content << content_tag('li', link_to(l(:label_sort_by_time), users_path(:user_sort_type => '0', :project_type => project_type))) content << content_tag('li', link_to(l(:label_sort_by_time), users_path(:user_sort_type => '0', :project_type => project_type)))
when 2 when 2
content << content_tag('li', link_to(l(:label_sort_by_active), users_path(:user_sort_type => '1', :project_type => project_type))) content << content_tag('li', link_to(l(:label_sort_by_active), users_path(:user_sort_type => '1', :project_type => project_type)))
content << content_tag('li', link_to(l(:label_sort_by_influence), users_path(:user_sort_type => '2', :project_type => project_type), :class=>"selected"), :class=>"selected") content << content_tag('li', link_to(l(:label_sort_by_influence), users_path(:user_sort_type => '2', :project_type => project_type), :class=>"selected"), :class=>"selected")
content << content_tag('li', link_to(l(:label_sort_by_time), users_path(:user_sort_type => '0', :project_type => project_type))) content << content_tag('li', link_to(l(:label_sort_by_time), users_path(:user_sort_type => '0', :project_type => project_type)))
end end
content = content_tag('ul', content) content = content_tag('ul', content)
content_tag('div', content, :class => "tabs_enterprise") content_tag('div', content, :class => "tabs_enterprise")
end end
def gender_avatar_uri user def gender_avatar_uri user
img_uri = '/images/sidebar/female.png' img_uri = '/images/sidebar/female.png'
@ -256,7 +256,7 @@ module UsersHelper
# people_ids += (members_to_user_ids(tmp)) unless tmp.nil? # people_ids += (members_to_user_ids(tmp)) unless tmp.nil?
# end # end
# people_ids.include?(login_user.id) or (login_user == user) or login_user.admin? # people_ids.include?(login_user.id) or (login_user == user) or login_user.admin?
false false
end end
@ -290,7 +290,7 @@ module UsersHelper
membership.collect { |e| membership.collect { |e|
memberships.push(e) memberships.push(e)
} }
## 判断课程是否过期 [需封装] ## 判断课程是否过期 [需封装]
memberships_doing = [] memberships_doing = []
memberships_done = [] memberships_done = []
memberships.map { |e| memberships.map { |e|
@ -541,7 +541,7 @@ module UsersHelper
end end
end end
=begin #获取指定用户作为老师的课程
def get_as_teacher_courses user def get_as_teacher_courses user
type = [] type = []
user.courses.select{|c| user.allowed_to?(:as_teacher,c)}.each do |course| user.courses.select{|c| user.allowed_to?(:as_teacher,c)}.each do |course|
@ -552,18 +552,5 @@ module UsersHelper
end end
type type
end end
=end
#获取指定用户作为老师的课程
def get_as_teacher_courses_terms user
type = []
user.courses.select{|c| user.allowed_to?(:as_teacher,c)}.each do |course|
option = []
option << course.name+""+course.time.to_s+course.term+""
option << course.id
type << option
end
type
end
end end

View File

@ -21,17 +21,10 @@
</div> </div>
<div class="homepagePostDeadline">截止时间:<%= format_date(activity.end_time) %></div> <div class="homepagePostDeadline">截止时间:<%= format_date(activity.end_time) %></div>
</div> </div>
<div class="homepagePostIntro break_word upload_img" id="activity_description_<%= user_activity.id%>"> <div class="homepagePostIntro break_word upload_img" id="activity_description_<%= user_activity_id%>">
作业描述:<%= activity.description.html_safe %> 作业描述:<%= activity.description.html_safe %>
</div> </div>
<!--<p style="display: none" id="activity_message_<%#= user_activity.id%>"> <div class="homepagePostSetting" style="visibility: hidden" id="act-<%=user_activity_id %>">
<a id="expend_more_information<%#= user_activity.id%>" href="javascript:void(0)" style="color: #0781b4;" onclick="show_more_reply('#activity_description_<%#=user_activity.id%>','#expend_more_information<%#= user_activity.id%>','#arrow<%#=user_activity.id%>');" value="show_more">[展开]</a>
<span class="g-arr-down">
<img id="arrow<%#=user_activity.id%>" src="/images/jiantou.jpg" width="12" height="6" />
</span>
</p>-->
<div class="homepagePostSetting" style="visibility: hidden" id="act-<%=user_activity.id %>">
<ul> <ul>
<li class="homepagePostSettingIcon"> <li class="homepagePostSettingIcon">
<ul class="homepagePostSettiongText"> <ul class="homepagePostSettiongText">

View File

@ -1,102 +1,108 @@
<div class="resources mt10"> <div class="resources mt10" id="user_activity_<%= user_activity_id%>">
<div class="homepagePostBrief"> <!-- onmouseover="$('#act-<%=user_activity.id %>').css('visibility','visible')" onmouseout="$('.homepagePostSetting').css('visibility','hidden')"--> <div class="homepagePostBrief">
<div class="homepagePostPortrait"> <div class="homepagePostPortrait">
<%= link_to image_tag(url_to_avatar(activity.author), :width => "50", :height => "50"), user_path(activity.author_id), :alt => "用户头像" %> <%= link_to image_tag(url_to_avatar(activity.author), :width => "50", :height => "50"), user_path(activity.author_id), :alt => "用户头像" %>
</div> </div>
<div class="homepagePostDes"> <div class="homepagePostDes">
<div class="homepagePostTo break_word"> <div class="homepagePostTo break_word">
<% if activity.try(:author).try(:realname) == ' ' %> <% if activity.try(:author).try(:realname) == ' ' %>
<%= link_to activity.try(:author), user_path(activity.author_id), :class => "newsBlue mr15" %> <%= link_to activity.try(:author), user_path(activity.author_id), :class => "newsBlue mr15" %>
<% else %> <% else %>
<%= link_to activity.try(:author).try(:realname), user_path(activity.author_id), :class => "newsBlue mr15" %> <%= link_to activity.try(:author).try(:realname), user_path(activity.author_id), :class => "newsBlue mr15" %>
<% end %> <% end %>
TO TO
<%= link_to activity.course.name.to_s+" | 课程讨论区", course_boards_path(activity.course), :class => "newsBlue ml15 mr5"%> <%= link_to activity.course.name.to_s+" | 课程讨论区", course_boards_path(activity.course), :class => "newsBlue ml15 mr5"%>
<%#= link_to activity.course.name.to_s+"(课程讨论区)", course_path(activity.course), :class => "newsBlue ml15 mr5"%>
</div>
<div class="homepagePostTitle break_word">
<% if activity.parent_id.nil? %> <!--+"(帖子标题)"-->
<%= link_to activity.subject.to_s.html_safe, course_boards_path(activity.course,:parent_id =>activity.id, :topic_id => activity.id), :class=> "postGrey" %>
<% else %>
<%= link_to activity.parent.subject.to_s.html_safe, course_boards_path(activity.course,:parent_id =>activity.parent_id, :topic_id => activity.id), :class=> "postGrey"%>
<% end %>
</div>
<div class="homepagePostDate">
发帖时间:<%= format_date(activity.created_on) %>
</div>
<div class="homepagePostIntro break_word upload_img" 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>
<div class="homepagePostSetting" id="act-<%= user_activity.id %>" style="visibility: hidden">
<ul>
<li class="homepagePostSettingIcon">
<ul class="homepagePostSettiongText">
<li><a href="javascript:void(0);" class="postOptionLink">编辑</a></li>
<li><a href="javascript:void(0);" class="postOptionLink">复制</a></li>
<li><a href="javascript:void(0);" class="postOptionLink">删除</a></li>
</ul>
</li>
</ul>
</div>
</div>
<div class="cl"></div>
</div> </div>
<div class="homepagePostReply"> <div class="homepagePostTitle break_word">
<div class="homepagePostReplyBanner"> <% if activity.parent_id.nil? %> <!--+"(帖子标题)"-->
<% count=0 %> <%= link_to activity.subject.to_s.html_safe, course_boards_path(activity.course,:parent_id =>activity.id, :topic_id => activity.id), :class=> "postGrey" %>
<div class="homepagePostReplyBannerCount">回复( <% else %>
<% if activity.parent_id.nil? %> <%= link_to activity.parent.subject.to_s.html_safe, course_boards_path(activity.course,:parent_id =>activity.parent_id, :topic_id => activity.id), :class=> "postGrey"%>
<% count=activity.replies_count%> <% end %>
<%=count %> </div>
<% else %> <div class="homepagePostDate">
<% count=activity.parent.replies_count%> 发帖时间:<%= format_date(activity.created_on) %>
<%=count %> </div>
<% end %>
)</div>
<div class="homepagePostReplyBannerTime"><%#=format_date(activity.updated_on)%></div> <div class="homepagePostIntro break_word upload_img" id="activity_description_<%= user_activity_id%>">帖子描述:
<%if count>2 %> <% if activity.parent_id.nil? %>
<div class="homepagePostReplyBannerMore"><a id="reply_btn_<%=user_activity.id%>" onclick="expand_reply('#reply_div_<%= user_activity.id %> li','#reply_btn_<%=user_activity.id%>')" data-count="<%= count %>" data-init="0" class=" replyGrey" href="javascript:void(0)" value="show_help" >点击展开更多回复(<%= count.to_s%>)</a></div> <%= activity.content.to_s.html_safe%>
<% end %> <% else %>
<!--<div class="homepagePostReplyBannerMore"><a href="javascript:void(0);" nhname='reply_ex_btn' class="replyGrey">点击展开更多回复</a> <%= activity.parent.content.to_s.html_safe%>
</div>--> <% end %>
</div> </div>
<!--<div class="homepagePostReplyInputContainer"> <div class="homepagePostSetting" id="act-<%= user_activity_id %>" style="visibility: hidden">
<textarea class="homepagePostReplyInput" placeholder="请输入回复"></textarea> <ul>
</div> <li class="homepagePostSettingIcon">
<div class="homepagePostReplyInputContainer"> <ul class="homepagePostSettiongText">
<div class="homepagePostReplyEmotion"><a href="javascript:void(0);" class="replyGrey">表情</a></div> <li><a href="javascript:void(0);" class="postOptionLink">编辑</a></li>
<div class="homepagePostReplyCancel"><a href="javascript:void(0);" class="postReplyCancel">取消</a> <li><a href="javascript:void(0);" class="postOptionLink">复制</a></li>
<li><a href="javascript:void(0);" class="postOptionLink">删除</a></li>
</ul>
</li>
</ul>
</div>
</div>
<div class="cl"></div>
</div>
<div class="homepagePostReply">
<div class="homepagePostReplyBanner">
<% count=0 %>
<div class="homepagePostReplyBannerCount">回复(
<% if activity.parent_id.nil? %>
<% count=activity.replies_count%>
<%=count %>
<% else %>
<% count=activity.parent.replies_count%>
<%=count %>
<% end %>
)</div>
<div class="homepagePostReplyBannerTime"><%#=format_date(activity.updated_on)%></div>
<%if count>2 %>
<div class="homepagePostReplyBannerMore">
<a id="reply_btn_<%=user_activity_id%>" onclick="expand_reply('#reply_div_<%= user_activity_id %> li','#reply_btn_<%=user_activity_id%>')" data-count="<%= count %>" data-init="0" class=" replyGrey" href="javascript:void(0)" value="show_help" >
点击展开更多回复(<%= count.to_s%>)
</a>
</div> </div>
<div class="homepagePostReplySubmit"><a href="javascript:void(0);" class="postReplySubmit">发送</a> <% end %>
</div> </div>
<div class="cl"></div>
</div>--> <div class="homepagePostReplyInputContainer">
<% activity= activity.parent_id.nil? ? activity:activity.parent%> <div nhname='new_message_<%= user_activity_id%>' style="display:none;">
<% replies_all_i = 0 %> <%= form_for('new_form',:url => {:controller=>'messages',:action => 'reply', :id => activity.id, :board_id => activity.board_id, :is_board => 'true'},:method => "post", :remote => true) do |f|%>
<% unless activity.children.empty? %> <input type="hidden" name="quote[quote]" value="">
<div id="reply_div_<%= user_activity.id %>"> <input type="hidden" name="user_activity_id" value="<%=user_activity_id%>">
<ul> <textarea placeholder="有问题或有建议,请直接给我留言吧!" nhname='new_message_textarea_<%= user_activity_id%>' name="reply[content]"></textarea>
<% activity.children.reorder("created_on desc").each do |reply|%> <p nhname='contentmsg_<%= user_activity_id%>'></p>
<% replies_all_i=replies_all_i+1 %> <div nhname='toolbar_container_<%= user_activity_id%>' style="float:left;padding-top:3px;"></div>
<li class="homepagePostReplyContainer" nhname="reply_rec" style="display:<%= replies_all_i>2 ? 'none' : '' %>"> <a id="new_message_cancel_btn_<%= user_activity_id%>" href="javascript:void(0)" class="grey_n_btn fr " style="margin-top:3px;">取消</a>
<div class="homepagePostReplyPortrait"> <a id="new_message_submit_btn_<%= user_activity_id%>" href="javascript:void(0)" class="blue_n_btn fr mr5 " style="margin-top:3px;">发送</a>
<%= link_to image_tag(url_to_avatar(reply.author), :width => "45", :height => "45"), user_path(reply.author_id), :alt => "用户头像" %> <% end%>
</div> </div>
<div class="homepagePostReplyDes"> <div class="cl"></div>
<div class="homepagePostReplyPublisher"> </div>
<% if reply.try(:author).try(:realname) == ' ' %>
<%= link_to reply.try(:author), user_path(reply.author_id), :class => "newsBlue mr10 f14" %> <% activity= activity.parent_id.nil? ? activity:activity.parent%>
<% else %> <% replies_all_i = 0 %>
<%= link_to reply.try(:author).try(:realname), user_path(reply.author_id), :class => "newsBlue mr10 f14" %> <% unless activity.children.empty? %>
<% end %> <div class="homepagePostReplyContainer" id="reply_div_<%= user_activity_id %>">
<%= format_date(reply.created_on) %> <ul>
<%#= link_to( <% activity.children.reorder("created_on desc").each do |reply|%>
<% replies_all_i=replies_all_i+1 %>
<li class="homepagePostReplyContainer" nhname="reply_rec" style="display:<%= replies_all_i>2 ? 'none' : '' %>">
<div class="homepagePostReplyPortrait">
<%= link_to image_tag(url_to_avatar(reply.author), :width => "45", :height => "45"), user_path(reply.author_id), :alt => "用户头像" %>
</div>
<div class="homepagePostReplyDes">
<div class="homepagePostReplyPublisher">
<% if reply.try(:author).try(:realname) == ' ' %>
<%= link_to reply.try(:author), user_path(reply.author_id), :class => "newsBlue mr10 f14" %>
<% else %>
<%= link_to reply.try(:author).try(:realname), user_path(reply.author_id), :class => "newsBlue mr10 f14" %>
<% end %>
<%= format_date(reply.created_on) %>
<%#= link_to(
l(:button_delete), l(:button_delete),
{:controller => 'messages', :action => 'destroy', :id => reply.id, :board_id => reply.board_id, :is_board => 'false'}, {:controller => 'messages', :action => 'destroy', :id => reply.id, :board_id => reply.board_id, :is_board => 'false'},
:method => :post, :method => :post,
@ -104,15 +110,15 @@
:title => l(:button_delete), :title => l(:button_delete),
:class => 'replyGrey fr ml10' :class => 'replyGrey fr ml10'
) if reply.course_destroyable_by?(User.current) %> ) if reply.course_destroyable_by?(User.current) %>
<!--<a href="javascript:void(0);" class="replyGrey fr ml10">删除</a>--> <!--<a href="javascript:void(0);" class="replyGrey fr ml10">删除</a>-->
</div> </div>
<div class="homepagePostReplyContent break_word"><%= reply.content.html_safe %></div> <div class="homepagePostReplyContent break_word"><%= reply.content.html_safe %></div>
</div> </div>
<div class="cl"></div> <div class="cl"></div>
</li> </li>
<% end %> <% end %>
</ul> </ul>
</div> </div>
<% end %> <% end %>
</div> </div>
</div> </div>

View File

@ -1,4 +1,4 @@
<div class="resources mt10"> <div class="resources mt10" id="user_activity_<%= user_activity_id%>">
<div class="homepagePostBrief"> <div class="homepagePostBrief">
<div class="homepagePostPortrait"> <div class="homepagePostPortrait">
<%= link_to image_tag(url_to_avatar(activity.author), :width => "50", :height => "50"), user_path(activity.author_id), :alt => "用户头像" %> <%= link_to image_tag(url_to_avatar(activity.author), :width => "50", :height => "50"), user_path(activity.author_id), :alt => "用户头像" %>
@ -18,9 +18,9 @@
<div class="homepagePostDate"> <div class="homepagePostDate">
发布时间:<%= format_date(activity.created_on) %> 发布时间:<%= format_date(activity.created_on) %>
</div> </div>
<div class="homepagePostIntro break_word upload_img" id="activity_description_<%= user_activity.id %>">通知描述:<%= activity.description.html_safe %></div> <div class="homepagePostIntro break_word upload_img" id="activity_description_<%= user_activity_id %>">通知描述:<%= activity.description.html_safe %></div>
<div class="homepagePostSetting" id="act-<%= user_activity.id %>" style="visibility: hidden"> <div class="homepagePostSetting none" id="act-<%= user_activity_id %>">
<ul> <ul>
<li class="homepagePostSettingIcon"> <li class="homepagePostSettingIcon">
<ul class="homepagePostSettiongText"> <ul class="homepagePostSettiongText">
@ -40,30 +40,27 @@
<div class="homepagePostReplyBannerCount">回复(<%= count %></div> <div class="homepagePostReplyBannerCount">回复(<%= count %></div>
<div class="homepagePostReplyBannerTime"><%#= format_date(activity.updated_on) %></div> <div class="homepagePostReplyBannerTime"><%#= format_date(activity.updated_on) %></div>
<%if count>2 %> <%if count>2 %>
<div class="homepagePostReplyBannerMore"><a id="reply_btn_<%=user_activity.id%>" onclick="expand_reply('#reply_div_<%= user_activity.id %> li','#reply_btn_<%=user_activity.id%>')" data-count="<%= count %>" data-init="0" class=" replyGrey" href="javascript:void(0)" value="show_help" >点击展开更多回复(<%= count.to_s%>)</a></div> <div class="homepagePostReplyBannerMore"><a id="reply_btn_<%=user_activity_id%>" onclick="expand_reply('#reply_div_<%= user_activity_id %> li','#reply_btn_<%=user_activity_id%>')" data-count="<%= count %>" data-init="0" class=" replyGrey" href="javascript:void(0)" value="show_help" >点击展开更多回复(<%= count.to_s%>)</a></div>
<% end %> <% end %>
<!--
<div class="homepagePostReplyBannerMore"><a href="javascript:void(0);" class="replyGrey">点击展开更多回复</a>
</div>-->
</div> </div>
<%#= render :partial => 'course_news_reply',:locals => { :contest => @contest, :journals => @jour, :state => false}%>
<!--<div class="homepagePostReplyInputContainer"> <div class="homepagePostReplyInputContainer">
<%= form_tag({:controller => 'comments', :action => 'create', :id => activity}, :id => "add_reply_form") do %> <div nhname='new_message_<%= user_activity_id%>' style="display:none;">
<textarea id="new_reply" class="homepagePostReplyInput" placeholder="请输入回复"></textarea> <%= form_for('new_form',:url => {:controller => 'comments', :action => 'create', :id => activity},:method => "post", :remote => true) do |f|%>
<input type="hidden" name="user_activity_id" value="<%=user_activity_id%>">
<textarea placeholder="有问题或有建议,请直接给我留言吧!" nhname='new_message_textarea_<%= user_activity_id%>' name="comment"></textarea>
<p nhname='contentmsg_<%= user_activity_id%>'></p>
<div nhname='toolbar_container_<%= user_activity_id%>' style="float:left;padding-top:3px;"></div>
<a id="new_message_cancel_btn_<%= user_activity_id%>" href="javascript:void(0)" class="grey_n_btn fr " style="margin-top:3px;">取消</a>
<a id="new_message_submit_btn_<%= user_activity_id%>" href="javascript:void(0)" class="blue_n_btn fr mr5 " style="margin-top:3px;">发送</a>
<% end%>
</div>
<div class="cl"></div>
</div>
<div class="homepagePostReplyCancel">
<a href="javascript:void(0);" class="postReplyCancel" onclick="$('#new_reply').value('');">取消</a>
</div>
<div class="homepagePostReplySubmit">
<a href="javascript:void(0);" class="postReplySubmit" onclick="$('#add_reply_form').submit();">发送</a>
</div>
<div class="cl"></div>
<% end %>
</div>-->
<% replies_all_i = 0 %> <% replies_all_i = 0 %>
<% unless activity.comments.empty? %> <% unless activity.comments.empty? %>
<div id="reply_div_<%= user_activity.id %>"> <div class="homepagePostReplyContainer" id="reply_div_<%= user_activity_id %>">
<ul> <ul>
<% activity.comments.reorder("created_on desc").each do |comment| %> <% activity.comments.reorder("created_on desc").each do |comment| %>
<% replies_all_i=replies_all_i+1 %> <% replies_all_i=replies_all_i+1 %>
@ -79,9 +76,6 @@
<%= link_to comment.try(:author).try(:realname), user_path(comment.author_id), :class => "newsBlue mr10 f14" %> <%= link_to comment.try(:author).try(:realname), user_path(comment.author_id), :class => "newsBlue mr10 f14" %>
<% end %> <% end %>
<%= format_date(comment.created_on) %> <%= format_date(comment.created_on) %>
<%#= link_to_if_authorized_course l(:button_delete), {:controller => 'comments', :action => 'destroy', :id => activity, :comment_id => comment},
:data => {:confirm => l(:text_are_you_sure)}, :method => :delete, :title => l(:button_delete) %>
<!--<a href="javascript:void(0);" class="replyGrey fr ml10">删除</a>-->
</div> </div>
<div class="homepagePostReplyContent break_word"><%= comment.comments.html_safe %></div> <div class="homepagePostReplyContent break_word"><%= comment.comments.html_safe %></div>
</div> </div>
@ -90,6 +84,6 @@
<% end %> <% end %>
</ul> </ul>
</div> </div>
<% end %> <% end %>
</div> </div>
</div> </div>

View File

@ -28,8 +28,8 @@
<div class="homepagePostDate"> <div class="homepagePostDate">
发布时间:<%= format_date(activity.published_at) %> 发布时间:<%= format_date(activity.published_at) %>
</div> </div>
<div class="homepagePostIntro break_word upload_img" id="activity_description_<%= user_activity.id%>">问卷描述:<%=activity.polls_description.html_safe.to_s%></div> <div class="homepagePostIntro break_word upload_img" id="activity_description_<%= user_activity_id%>">问卷描述:<%=activity.polls_description.html_safe.to_s%></div>
<div class="homepagePostSetting" id="act-<%= user_activity.id %>" style="visibility: hidden"> <div class="homepagePostSetting" id="act-<%= user_activity_id %>" style="visibility: hidden">
<ul> <ul>
<li class="homepagePostSettingIcon"> <li class="homepagePostSettingIcon">
<ul class="homepagePostSettiongText"> <ul class="homepagePostSettiongText">

View File

@ -1,4 +1,4 @@
<div class="resources mt10"> <div class="resources mt10" id="user_activity_<%= user_activity_id%>">
<div class="homepagePostBrief"> <div class="homepagePostBrief">
<div class="homepagePostPortrait"> <div class="homepagePostPortrait">
<%= link_to image_tag(url_to_avatar(activity.author), :width => "50", :height => "50"), user_path(activity.author_id), :alt => "用户头像" %> <%= link_to image_tag(url_to_avatar(activity.author), :width => "50", :height => "50"), user_path(activity.author_id), :alt => "用户头像" %>
@ -11,7 +11,7 @@
<%= link_to activity.try(:author).try(:realname), user_path(activity.author_id), :class => "newsBlue mr15" %> <%= link_to activity.try(:author).try(:realname), user_path(activity.author_id), :class => "newsBlue mr15" %>
<% end %> TO <% end %> TO
<%= link_to activity.project.name.to_s+" | 项目缺陷", project_issues_path(activity.project), :class => "newsBlue ml15"%> <%= link_to activity.project.name.to_s+" | 项目缺陷", project_issues_path(activity.project), :class => "newsBlue ml15"%>
</div> </div>
<div class="homepagePostTitle break_word"> <div class="homepagePostTitle break_word">
<%= link_to activity.subject.to_s, issue_path(activity), :class => "postGrey" %> <%= link_to activity.subject.to_s, issue_path(activity), :class => "postGrey" %>
<span class='<%= get_issue_priority(activity.priority_id)[0] %>'><%= get_issue_priority(activity.priority_id)[1] %></span> <span class='<%= get_issue_priority(activity.priority_id)[0] %>'><%= get_issue_priority(activity.priority_id)[1] %></span>
@ -19,16 +19,16 @@
<div class="homepagePostSubmitContainer"> <div class="homepagePostSubmitContainer">
<div class="homepagePostAssignTo">指派给&nbsp;&nbsp; <div class="homepagePostAssignTo">指派给&nbsp;&nbsp;
<% unless activity.assigned_to_id.nil? %> <% unless activity.assigned_to_id.nil? %>
<% if activity.try(:assigned_to).try(:realname) == ' ' %> <% if activity.try(:assigned_to).try(:realname) == ' ' %>
<%= link_to activity.try(:assigned_to), user_path(activity.assigned_to_id), :class => "newsBlue mr15" %> <%= link_to activity.try(:assigned_to), user_path(activity.assigned_to_id), :class => "newsBlue mr15" %>
<% else %> <% else %>
<%= link_to activity.try(:assigned_to).try(:realname), user_path(activity.assigned_to_id), :class => "newsBlue mr15" %> <%= link_to activity.try(:assigned_to).try(:realname), user_path(activity.assigned_to_id), :class => "newsBlue mr15" %>
<% end %> <% end %>
<% end %> <% end %>
</div> </div>
<div class="homepagePostDeadline">时间:<%=format_date(activity.created_on) %></div> <div class="homepagePostDeadline">时间:<%=format_date(activity.created_on) %></div>
</div> </div>
<div class="homepagePostIntro break_word upload_img" id="activity_description_<%= user_activity.id %>">缺陷描述: <div class="homepagePostIntro break_word upload_img" id="activity_description_<%= user_activity_id %>">缺陷描述:
<% if activity.description? %> <% if activity.description? %>
<%= textAreailizable activity, :description, :attachments => activity.attachments %> <%= textAreailizable activity, :description, :attachments => activity.attachments %>
<% end %> <% end %>
@ -37,31 +37,25 @@
<div class="mt10" style="font-weight:normal;"> <div class="mt10" style="font-weight:normal;">
<% if activity.attachments.any? %> <% if activity.attachments.any? %>
<% activity.attachments.each do |attachment| %> <% activity.attachments.each do |attachment| %>
<div class="break_word"> <div class="break_word">
<span title="<%= attachment.filename %>" id="attachment_"> <span title="<%= attachment.filename %>" id="attachment_">
<%= link_to_short_attachment attachment,:length=> 58, :class => 'homepagePostFileAtt newsBlue', :download => true -%> <%= link_to_short_attachment attachment,:length=> 58, :class => 'homepagePostFileAtt newsBlue', :download => true -%>
</span> </span>
<% if attachment.is_text? %> <% if attachment.is_text? %>
<%= link_to image_tag('magnifier.png'), <%= link_to image_tag('magnifier.png'),
:controller => 'attachments', :controller => 'attachments',
:action => 'show', :action => 'show',
:id => attachment, :id => attachment,
:filename => attachment.filename %> :filename => attachment.filename %>
<% end %> <% end %>
<span class="postAttSize">( <span class="postAttSize">(
<%= number_to_human_size attachment.filesize %>) <%= number_to_human_size attachment.filesize %>)
</span> </span>
</div> </div>
<% end %> <% end %>
<% end %> <% end %>
</div> </div>
<!--<div class="mt10"> <div class="homepagePostSetting" id="act-<%=user_activity_id %>" style="visibility: hidden">
<a href="javascript:void(0);" class="homepagePostFileAtt newsBlue">文件附件.zip</a><span class="postAttSize">(123KB)</span>
</div>
<div>
<a href="javascript:void(0);" class="homepagePostImageAtt newsBlue">图片附件.png</a><span class="postAttSize">(123KB)</span>
</div>-->
<div class="homepagePostSetting" id="act-<%=user_activity.id %>" style="visibility: hidden">
<ul> <ul>
<li class="homepagePostSettingIcon"> <li class="homepagePostSettingIcon">
<ul class="homepagePostSettiongText"> <ul class="homepagePostSettiongText">
@ -83,24 +77,28 @@
<div class="homepagePostReplyBannerTime"><%#= format_date(activity.updated_on) %></div> <div class="homepagePostReplyBannerTime"><%#= format_date(activity.updated_on) %></div>
<% if count>2 %> <% if count>2 %>
<div class="homepagePostReplyBannerMore"> <div class="homepagePostReplyBannerMore">
<a id="reply_btn_<%= user_activity.id %>" onclick="expand_reply('#reply_div_<%= user_activity.id %> li','#reply_btn_<%=user_activity.id%>')" data-count="<%= count %>" data-init="0" class=" replyGrey" href="javascript:void(0)" value="show_help">点击展开更多回复(<%= count.to_s %> <a id="reply_btn_<%= user_activity_id %>" onclick="expand_reply('#reply_div_<%= user_activity_id %> li','#reply_btn_<%=user_activity_id%>')" data-count="<%= count %>" data-init="0" class=" replyGrey" href="javascript:void(0)" value="show_help">点击展开更多回复(<%= count.to_s %>
)</a></div> )</a></div>
<% end %> <% end %>
<!--<div class="homepagePostReplyBannerMore"><a href="javascript:void(0);" class="replyGrey">点击展开更多回复</a>
</div>-->
</div>
<!--<div class="homepagePostReplyInputContainer">
<textarea class="homepagePostReplyInput" placeholder="请输入回复"></textarea>
</div> </div>
<div class="homepagePostReplyInputContainer"> <div class="homepagePostReplyInputContainer">
<div class="homepagePostReplyEmotion"><a href="javascript:void(0);" class="replyGrey">表情</a></div> <div nhname='new_message_<%= user_activity_id%>' style="display:none;">
<div class="homepagePostReplyCancel"><a href="javascript:void(0);" class="postReplyCancel">取消</a></div> <%= form_for('new_form',:url => add_journal_issue_path(activity.id),:method => "post", :remote => true) do |f|%>
<div class="homepagePostReplySubmit"><a href="javascript:void(0);" class="postReplySubmit">发送</a></div> <input type="hidden" name="user_activity_id" value="<%=user_activity_id%>">
<textarea placeholder="有问题或有建议,请直接给我留言吧!" nhname='new_message_textarea_<%= user_activity_id%>' name="notes"></textarea>
<p nhname='contentmsg_<%= user_activity_id%>'></p>
<div nhname='toolbar_container_<%= user_activity_id%>' style="float:left;padding-top:3px;"></div>
<a id="new_message_cancel_btn_<%= user_activity_id%>" href="javascript:void(0)" class="grey_n_btn fr " style="margin-top:3px;">取消</a>
<a id="new_message_submit_btn_<%= user_activity_id%>" href="javascript:void(0)" class="blue_n_btn fr mr5 " style="margin-top:3px;">发送</a>
<% end%>
</div>
<div class="cl"></div> <div class="cl"></div>
</div>--> </div>
<% replies_all_i = 0 %> <% replies_all_i = 0 %>
<% unless activity.journals.empty? %> <% unless activity.journals.empty? %>
<div id="reply_div_<%= user_activity.id %>"> <div class="homepagePostReplyContainer" id="reply_div_<%= user_activity_id %>">
<ul> <ul>
<% activity.journals.reorder("created_on desc").each do |reply| %> <% activity.journals.reorder("created_on desc").each do |reply| %>
<% replies_all_i=replies_all_i+1 %> <% replies_all_i=replies_all_i+1 %>
@ -112,7 +110,7 @@
<div class="homepagePostReplyPublisher"> <div class="homepagePostReplyPublisher">
<% if reply.try(:user).try(:realname) == ' ' %> <% if reply.try(:user).try(:realname) == ' ' %>
<%= link_to reply.try(:user), user_path(reply.user_id), :class => "newsBlue mr10 f14" %> <%= link_to reply.try(:user), user_path(reply.user_id), :class => "newsBlue mr10 f14" %>
<% else %> <% else %>
<%= link_to reply.try(:user).try(:realname), user_path(reply.user_id), :class => "newsBlue mr10 f14" %> <%= link_to reply.try(:user).try(:realname), user_path(reply.user_id), :class => "newsBlue mr10 f14" %>
<% end %> <% end %>
<%= format_date(reply.created_on) %> <%= format_date(reply.created_on) %>

View File

@ -1,4 +1,4 @@
<div class="resources mt10"> <div class="resources mt10" id="user_activity_<%= user_activity_id%>">
<div class="homepagePostBrief"> <div class="homepagePostBrief">
<div class="homepagePostPortrait"> <div class="homepagePostPortrait">
<%= link_to image_tag(url_to_avatar(activity.author), :width => "50", :height => "50"), user_path(activity.author_id), :alt => "用户头像" %> <%= link_to image_tag(url_to_avatar(activity.author), :width => "50", :height => "50"), user_path(activity.author_id), :alt => "用户头像" %>
@ -26,14 +26,14 @@
<div class="homepagePostDate"> <div class="homepagePostDate">
时间:<%= format_date(activity.created_on) %> 时间:<%= format_date(activity.created_on) %>
</div> </div>
<div class="homepagePostIntro break_word upload_img" id="activity_description_<%= user_activity.id%>">帖子描述: <div class="homepagePostIntro break_word upload_img" id="activity_description_<%= user_activity_id%>">帖子描述:
<% if activity.parent_id.nil? %> <% if activity.parent_id.nil? %>
<%= activity.content.to_s.html_safe%> <%= activity.content.to_s.html_safe%>
<% else %> <% else %>
<%= activity.parent.content.to_s.html_safe%> <%= activity.parent.content.to_s.html_safe%>
<% end %> <% end %>
</div> </div>
<div class="homepagePostSetting" id="act-<%= user_activity.id %>" style="visibility: hidden"> <div class="homepagePostSetting" id="act-<%= user_activity_id %>" style="visibility: hidden">
<ul> <ul>
<li class="homepagePostSettingIcon"> <li class="homepagePostSettingIcon">
<ul class="homepagePostSettiongText"> <ul class="homepagePostSettiongText">
@ -60,26 +60,29 @@
)</div> )</div>
<div class="homepagePostReplyBannerTime"><%#=format_date(activity.updated_on)%></div> <div class="homepagePostReplyBannerTime"><%#=format_date(activity.updated_on)%></div>
<%if count>2 %> <%if count>2 %>
<div class="homepagePostReplyBannerMore"><a id="reply_btn_<%=user_activity.id%>" onclick="expand_reply('#reply_div_<%= user_activity.id %> li','#reply_btn_<%=user_activity.id%>')" data-count="<%= count %>" data-init="0" class=" replyGrey" href="javascript:void(0)" value="show_help" >点击展开更多回复(<%= count.to_s%>)</a></div> <div class="homepagePostReplyBannerMore"><a id="reply_btn_<%=user_activity_id%>" onclick="expand_reply('#reply_div_<%= user_activity_id %> li','#reply_btn_<%=user_activity_id%>')" data-count="<%= count %>" data-init="0" class=" replyGrey" href="javascript:void(0)" value="show_help" >点击展开更多回复(<%= count.to_s%>)</a></div>
<% end %> <% end %>
<!--<div class="homepagePostReplyBannerMore"><a href="javascript:void(0);" nhname='reply_ex_btn' class="replyGrey">点击展开更多回复</a>
</div>-->
</div>
<!--<div class="homepagePostReplyInputContainer">
<textarea class="homepagePostReplyInput" placeholder="请输入回复"></textarea>
</div> </div>
<div class="homepagePostReplyInputContainer"> <div class="homepagePostReplyInputContainer">
<div class="homepagePostReplyEmotion"><a href="javascript:void(0);" class="replyGrey">表情</a></div> <div nhname='new_message_<%= user_activity_id%>' style="display:none;">
<div class="homepagePostReplyCancel"><a href="javascript:void(0);" class="postReplyCancel">取消</a> <%= form_for('new_form',:url => {:controller=>'messages',:action => 'reply', :id => activity.id, :board_id => activity.board_id, :is_board => 'true'},:method => "post", :remote => true) do |f|%>
</div> <input type="hidden" name="quote[quote]" value="">
<div class="homepagePostReplySubmit"><a href="javascript:void(0);" class="postReplySubmit">发送</a> <input type="hidden" name="user_activity_id" value="<%=user_activity_id%>">
<textarea placeholder="有问题或有建议,请直接给我留言吧!" nhname='new_message_textarea_<%= user_activity_id%>' name="reply[content]"></textarea>
<p nhname='contentmsg_<%= user_activity_id%>'></p>
<div nhname='toolbar_container_<%= user_activity_id%>' style="float:left;padding-top:3px;"></div>
<a id="new_message_cancel_btn_<%= user_activity_id%>" href="javascript:void(0)" class="grey_n_btn fr " style="margin-top:3px;">取消</a>
<a id="new_message_submit_btn_<%= user_activity_id%>" href="javascript:void(0)" class="blue_n_btn fr mr5 " style="margin-top:3px;">发送</a>
<% end%>
</div> </div>
<div class="cl"></div> <div class="cl"></div>
</div>--> </div>
<% activity= activity.parent_id.nil? ? activity : activity.parent %> <% activity= activity.parent_id.nil? ? activity : activity.parent %>
<% replies_all_i = 0 %> <% replies_all_i = 0 %>
<% unless activity.children.empty? %> <% unless activity.children.empty? %>
<div id="reply_div_<%= user_activity.id %>"> <div class="homepagePostReplyContainer" id="reply_div_<%= user_activity_id %>">
<ul> <ul>
<% activity.children.reorder("created_on desc").each do |reply| %> <% activity.children.reorder("created_on desc").each do |reply| %>
<% replies_all_i=replies_all_i+1 %> <% replies_all_i=replies_all_i+1 %>

View File

@ -1,25 +1,25 @@
<% if attachments.nil? || attachments.empty? %> <% if attachments.nil? || attachments.empty? %>
<p class="nodata"> <!--<p class="nodata">-->
<%= l(:label_no_data) %> <!--<%#= l(:label_no_data) %>-->
</p> <!--</p>-->
<% else %> <% else %>
<% attachments.each do |attach| %> <% attachments.each do |attach| %>
<ul class="resourcesList"> <ul class="resourcesList">
<li class="resourcesListCheckbox fl"> <li class="resourcesListCheckbox fl">
<input name="checkbox1[]" type="checkbox" onclick="checkAllBox($(this));" value="<%= attach.id%>" class="resourcesCheckbox" /> <input name="checkbox1[]" type="checkbox" onclick="checkAllBox($(this));" value="<%= attach.id%>" class="resourcesCheckbox" />
</li> </li>
<li class="resourcesListName fl"> <li class="resourcesListName fl">
<!--<a href="javascript:void(0);" class="resourcesBlack"><%#=truncate(attach.filename,:length=>18)%></a>--> <!--<a href="javascript:void(0);" class="resourcesBlack"><%#=truncate(attach.filename,:length=>18)%></a>-->
<%= link_to truncate(attach.filename,:length=>18), download_named_attachment_path(attach.id, attach.filename), <%= link_to truncate(attach.filename,:length=>18), download_named_attachment_path(attach.id, attach.filename),
:title => attach.filename,:class=>'resourcesBlack'%> :title => attach.filename,:class=>'resourcesBlack'%>
</li> </li>
<li class="resourcesListSize fl"><%= number_to_human_size(attach.filesize) %></li> <li class="resourcesListSize fl"><%= number_to_human_size(attach.filesize) %></li>
<li class="resourcesListType fl"><%= get_resource_type(attach.container_type)%></li> <li class="resourcesListType fl"><%= get_resource_type(attach.container_type)%></li>
<li class="resourcesListUploader fl"><%=User.find(attach.author_id).realname.blank? ? User.find(attach.author_id).nickname : User.find(attach.author_id).realname %></li> <li class="resourcesListUploader fl"><%=User.find(attach.author_id).realname.blank? ? User.find(attach.author_id).nickname : User.find(attach.author_id).realname %></li>
<li style="display: none"><%= attach.author_id %></li> <li style="display: none"><%= attach.author_id %></li>
<li class="resourcesListTime fl"><%= format_date(attach.created_on) %></li> <li class="resourcesListTime fl"><%= format_date(attach.created_on) %></li>
<li style="display: none"><%= attach.id %></li> <li style="display: none"><%= attach.id %></li>
</ul> </ul>
<% end %> <% end %>
<% end %> <% end %>

View File

@ -1,7 +1,7 @@
<%= javascript_include_tag "/assets/kindeditor/kindeditor" %> <%= javascript_include_tag "/assets/kindeditor/kindeditor" %>
<div class="HomeWorkCon"> <div class="HomeWorkCon">
<div> <div>
<input type="text" name="homework_common[name]" id="homework_name" class="InputBox W700" maxlength="255" onfocus="$('#homework_editor').show()" onkeyup="regex_homework_name();" placeholder="请输入作业标题" value="<%= homework.name%>" > <input type="text" name="homework_common[name]" id="homework_name" class="InputBox w712" maxlength="255" onfocus="$('#homework_editor').show()" onkeyup="regex_homework_name();" placeholder="请输入作业标题" value="<%= homework.name%>" >
<p id="homework_name_span" class="c_red mt5"></p> <p id="homework_name_span" class="c_red mt5"></p>
</div> </div>
<div class="cl"></div> <div class="cl"></div>
@ -27,7 +27,7 @@
<div class="mt10"> <div class="mt10">
<!--<input type="text" class="InputBox W700 SearchIcon" placeholder="发送到课程" />--> <!--<input type="text" class="InputBox W700 SearchIcon" placeholder="发送到课程" />-->
<%= select_tag :course_id, options_for_select(get_as_teacher_courses_terms(User.current), homework.course_id), {:class => "InputBox w708"} %> <%= select_tag :course_id, options_for_select(get_as_teacher_courses(User.current), homework.course_id), {:class => "InputBox w720",:value => "请选择发布作业的课程"} %>
</div> </div>
<div class="cl"></div> <div class="cl"></div>
@ -43,8 +43,3 @@
</div> </div>
<div class="cl"></div> <div class="cl"></div>
</div> </div>
<script type="text/javascript">
$(function (){
$("#course_id").append("<option value='-1'hidden selected>请选择发布作业的课程</option>");
});
</script>

View File

@ -1,4 +1,9 @@
<% if @flag == true%> <% if @flag == true%>
$("#search_div").html('<%= escape_javascript( render :partial => 'resource_search_form',:locals => {:user=>@user,:type=>@type} ) %>');
$("#resources_list").html('<%= escape_javascript( render :partial => 'resources_list' ,:locals=>{ :attachments => @attachments})%>');
$("#res_count").html(0);
$("#checkboxAll").attr('checked',false);
$("#res_all_count").html(<%= @atta_count%>);
closePopUp(); closePopUp();
<% else%> <% else%>
<% end %> <% end %>

View File

@ -1,4 +1,9 @@
<% if @flag == true%> <% if @flag == true%>
$("#search_div").html('<%= escape_javascript( render :partial => 'resource_search_form',:locals => {:user=>@user,:type=>@type} ) %>');
$("#resources_list").html('<%= escape_javascript( render :partial => 'resources_list' ,:locals=>{ :attachments => @attachments})%>');
$("#res_count").html(0);
$("#checkboxAll").attr('checked',false);
$("#res_all_count").html(<%= @atta_count%>);
closePopUp(); closePopUp();
<% else%> <% else%>
<% end %> <% end %>

View File

@ -1,11 +1,6 @@
<!--<div class="top_new">--> <%= javascript_include_tag "/assets/kindeditor/kindeditor",'/assets/kindeditor/pasteimg',"init_KindEditor","user" %>
<!--<span class="<%#= (@user.user_extensions.identity == 0 && @user.allowed_to?(:add_course, nil, :global => true)) ? 'top_new_bg' : 'top_newcourses_bg'%> fl"></span>-->
<!--<%# if @user.user_extensions.identity == 0 && @user.allowed_to?(:add_course, nil, :global => true) %>-->
<!--<a href="<%#= url_for(:controller => 'courses', :action => 'new',) %>" class="green_n_btn fr mt2" target="_blank">新建课程</a>-->
<!--<%# end %>-->
<!--<div class="cl"></div>-->
<!--</div>-->
<style type="text/css"> <style type="text/css">
/*回复框*/
div.ke-toolbar{display:none;width:400px;border:none;background:none;padding:0px 0px;} div.ke-toolbar{display:none;width:400px;border:none;background:none;padding:0px 0px;}
span.ke-toolbar-icon{line-height:26px;font-size:14px;padding-left:26px;} span.ke-toolbar-icon{line-height:26px;font-size:14px;padding-left:26px;}
span.ke-toolbar-icon-url{background-image:url( /images/public_icon.png )} span.ke-toolbar-icon-url{background-image:url( /images/public_icon.png )}
@ -13,17 +8,7 @@
span.ke-icon-emoticons{background-position:0px -671px;width:50px;height:26px;} span.ke-icon-emoticons{background-position:0px -671px;width:50px;height:26px;}
span.ke-icon-emoticons:hover{background-position:-79px -671px;width:50px;height:26px;} span.ke-icon-emoticons:hover{background-position:-79px -671px;width:50px;height:26px;}
div.ke-toolbar .ke-outline{border:none;} div.ke-toolbar .ke-outline{border:none;}
div.respond-form .reply_btn{margin-left:565px;margin-top:5px;}
div.recall_con{width:570px;}
div.recall_con .reply_btn{margin-left:525px;margin-top:5px;}
.fr.cr{ clear: right}
</style> </style>
<%= javascript_include_tag "/assets/kindeditor/kindeditor",'/assets/kindeditor/pasteimg',"user" %>
<!--<div id="RSide" class="fl">-->
<!--<div class="users_r_top">-->
<!--<h2 class="users_r_h2">用户留言</h2>-->
<!--</div>-->
<div > <div >
<div class="resources mb10"> <div class="resources mb10">
<div class="homepageRightBanner"> <div class="homepageRightBanner">

View File

@ -4,9 +4,9 @@
<%= stylesheet_link_tag 'leftside' %> <%= stylesheet_link_tag 'leftside' %>
<%= javascript_include_tag 'attachments'%> <%= javascript_include_tag 'attachments'%>
<!--<script type="text/css">--> <!--<script type="text/css">-->
<!--html,body{ overflow-y:scroll;}--> <!--html,body{ overflow-y:scroll;}-->
<!--html,body{ overflow:scroll; min-height:101%;}--> <!--html,body{ overflow:scroll; min-height:101%;}-->
<!--html{ overflow:-moz-scrollbars-vertical;}--> <!--html{ overflow:-moz-scrollbars-vertical;}-->
<!--</script>--> <!--</script>-->
<script> <script>
function remote_get_resources(user_id,type){ function remote_get_resources(user_id,type){
@ -67,7 +67,7 @@
</li> </li>
</ul> </ul>
</div> </div>
</div> </div>
<div class="resources mt10" id="users_setting"> <div class="resources mt10" id="users_setting">
<div class="resourcesSearchBanner mt10"> <div class="resourcesSearchBanner mt10">
<div class="resourcesUploadBox"> <div class="resourcesUploadBox">
@ -93,24 +93,24 @@
</ul> </ul>
</div> </div>
<form id="resources_list_form"> <form id="resources_list_form">
<div id="resources_list"> <div id="resources_list">
<%= render :partial => 'resources_list' ,:locals=>{ :attachments => @attachments} %> <%= render :partial => 'resources_list' ,:locals=>{ :attachments => @attachments} %>
</div>
<div class="resourcesListOption">
<div class="resourcesCheckAll">
<input id="checkboxAll" type="checkbox" value="" onclick="all_select();" class="resourcesCheckbox" />
</div> </div>
<a href="javascript:void(0);" class="replyGrey1 mr15" onclick="all_select();">全选</a> <div class="resourcesListOption">
<a href="javascript:void(0);" class="replyGrey1" onclick="batch_delete();">删除</a> <div class="resourcesCheckAll">
<div class="resourcesSelectSend"> <input id="checkboxAll" type="checkbox" value="" onclick="all_select();" class="resourcesCheckbox" />
<div class="fl">选择&nbsp;<span class="c_red" id="res_count">0</span>&nbsp;个资源</div> </div>
<div class="resourcesSelectSendButton" onclick="batch_send();"> <a href="javascript:void(0);" class="replyGrey1 mr15" onclick="all_select();">全选</a>
<a href="javascript:void(0);" class="sendButtonBlue db" data-remote="true" >发送</a> <a href="javascript:void(0);" class="replyGrey1" onclick="batch_delete();">删除</a>
<div class="resourcesSelectSend">
<div class="fl">选择&nbsp;<span class="c_red" id="res_count">0</span>&nbsp;个资源</div>
<div class="resourcesSelectSendButton" onclick="batch_send();">
<a href="javascript:void(0);" class="sendButtonBlue db" data-remote="true" >发送</a>
</div>
</div> </div>
</div> </div>
</div>
</form> </form>
<div class="cl"></div> <div class="cl"></div>
<div> <div>
@ -122,7 +122,7 @@
<div class="cl"></div> <div class="cl"></div>
<!--<div id="upload_box" style="display: none">--> <!--<div id="upload_box" style="display: none">-->
<!--<%#= render :partial => 'upload_resource' ,:locals => {:user=>@user}%>--> <!--<%#= render :partial => 'upload_resource' ,:locals => {:user=>@user}%>-->
<!--</div>--> <!--</div>-->
<ul class="dropdown-menu" role="menu" aria-labelledby="dropdownMenu" id="contextMenu"> <ul class="dropdown-menu" role="menu" aria-labelledby="dropdownMenu" id="contextMenu">
<li><a tabindex="-1" href="#" onclick="if(<%= User.current.logged?%>)preview();" onfocus="this.blur()">预览</a></li> <li><a tabindex="-1" href="#" onclick="if(<%= User.current.logged?%>)preview();" onfocus="this.blur()">预览</a></li>
@ -133,73 +133,74 @@
</ul> </ul>
<script> <script>
var pageX = 0; var pageX = 0;
var pageY = 0; var pageY = 0;
//当前选中的行 //当前选中的行
var line; var line;
//已经选中的行和当前选中的行的区别是右键选中为line换一行右键后line变为last_line,line变为换行后的line //已经选中的行和当前选中的行的区别是右键选中为line换一行右键后line变为last_line,line变为换行后的line
var last_line; var last_line;
//资源名称 //资源名称
var res_name; var res_name;
//资源名称的链接 //资源名称的链接
var res_link; var res_link;
var id; //资源id var id; //资源id
var sendType; //发送到课程 1 发送到项目 2 var sendType; //发送到课程 1 发送到项目 2
var lastSendType; //保存上次发送的发送类型 var lastSendType; //保存上次发送的发送类型
$(".resourcesList").mousedown(function(e) { $("#resources_list").mousedown(function(e) {
//如果是右键的话 //如果是右键的话
if (3 == e.which) { if (3 == e.which) {
document.oncontextmenu = function() {return false;} document.oncontextmenu = function() {return false;}
pageX = e.clientX; pageX = e.clientX;
pageY = e.clientY; pageY = e.clientY;
$("#contextMenu").hide(); $("#contextMenu").hide();
$("#contextMenu").attr("style","display: block; position: fixed; top:" $("#contextMenu").attr("style","display: block; position: fixed; top:"
+ pageY + pageY
+ "px; left:" + "px; left:"
+ pageX + pageX
+ "px; width: 80px;"); + "px; width: 80px;");
$("#contextMenu").show(); $("#contextMenu").show();
//当前光标所在的对象 //当前光标所在的对象
var ele = document.elementFromPoint(pageX,pageY);
//转换为jquery对象 var ele = document.elementFromPoint(pageX,pageY);
line = $(ele).parent(); //转换为jquery对象
//如果上一条存在被选中,那么将上一条的背景色改为白色 line = $(ele).parent();
if(last_line != null){ //如果上一条存在被选中,那么将上一条的背景色改为白色
last_line.children().css("background-color", 'white'); if(last_line != null){
restore(); last_line.children().css("background-color", 'white');
last_line == null; restore();
} last_line == null;
//如果当前的tag是li那么还要li的父级元素 }
if(line.get(0).tagName === 'LI'){ //如果当前的tag是li那么还要li的父级元素
line = line.parent(); if(line.get(0).tagName === 'LI'){
} line = line.parent();
//将当前的元素的所有子元素的背景色改为蓝色 }
line.children().css("background-color", '#e1e1e1'); //将当前的元素的所有子元素的背景色改为蓝色
//将当前元素赋给 上一个对象 保存起来。 line.children().css("background-color", '#e1e1e1');
last_line = line; //将当前元素赋给 上一个对象 保存起来。
} last_line = line;
}); }
//元素包含关系计算 });
var contains = function(root, el) { //元素包含关系计算
if (root.compareDocumentPosition) var contains = function(root, el) {
return root === el || !!(root.compareDocumentPosition(el) & 16); if (root.compareDocumentPosition)
if (root.contains && el.nodeType === 1){ return root === el || !!(root.compareDocumentPosition(el) & 16);
return root.contains(el) && root !== el; if (root.contains && el.nodeType === 1){
} return root.contains(el) && root !== el;
while ((el = el.parentNode)) }
if (el === root) return true; while ((el = el.parentNode))
return false; if (el === root) return true;
} return false;
$(document.body).click(function(e) { }
//在列表上的任何单击事件都要恢复原来的样子 $(document.body).click(function(e) {
//隐藏右键菜单 //在列表上的任何单击事件都要恢复原来的样子
//隐藏右键菜单
//e.preventDefault(); //e.preventDefault();
$("#contextMenu").hide(); $("#contextMenu").hide();
document.oncontextmenu = function() {return true;} document.oncontextmenu = function() {return true;}
//如果当前行为空,那么要将当前行的拿到 //如果当前行为空,那么要将当前行的拿到
var ele; var ele;
if(line == null){ if(line == null){
ele = document.elementFromPoint(e.clientX, e.clientY); ele = document.elementFromPoint(e.clientX, e.clientY);
line = $(ele).parent(); line = $(ele).parent();
//如果是在li上点击事件那么要获得父组件 //如果是在li上点击事件那么要获得父组件
if(line.get(0).tagName === 'LI'){ if(line.get(0).tagName === 'LI'){
@ -208,322 +209,322 @@ $(document.body).click(function(e) {
} }
//如果当前对象在表格里,将当前行改变为白色,这里主要是防止点击页面的其他链接的时候,那个链接背景色变白了 //如果当前对象在表格里,将当前行改变为白色,这里主要是防止点击页面的其他链接的时候,那个链接背景色变白了
if( contains($(".resourcesList").get(0),line.get(0))){ if( contains($("#resources_list").get(0),line.get(0))){
line.children().css("background-color", 'white'); line.children().css("background-color", 'white');
} }
//当前行恢复编辑状态到链接状态 //当前行恢复编辑状态到链接状态
if(ele && ele.nodeName != 'INPUT') { if(ele && ele.nodeName != 'INPUT') {
restore(); restore();
} }
line = null; line = null;
}); });
//只要有一个选中了就是true //只要有一个选中了就是true
function checkboxSelected(){ function checkboxSelected(){
selected = false; selected = false;
$("#resources_list").find("input[name='checkbox1[]']").each(function(){ $("#resources_list").find("input[name='checkbox1[]']").each(function(){
if($(this).attr('checked') == true){ if($(this).attr('checked') == true){
selected = true; selected = true;
} }
}); });
return selected; return selected;
}
//只有全选才是true
function checkboxAllSelected(){
allSelected = true;
$("#resources_list").find("input[name='checkbox1[]']").each(function(){
if($(this).attr('checked') == undefined){
allSelected = false;
}
});
return allSelected;
}
//只有全部不选才是true
function checkboxAllDeselected(){
allDeselected = true;
$("#resources_list").find("input[name='checkbox1[]']").each(function(){
if($(this).attr('checked') == 'checked'){
allDeselected = false;
}
});
return allDeselected;
}
//查看所有的checkbox状态并且按情况更改$("#checkboxAll")的状态
function checkAllBox(checkbox){
//只有选中当前checkbox且这个时候所有的checkbox都被选中了$("#checkboxAll")才是被选中状态,其余都是非选中状态
if(checkbox.attr('checked') == 'checked' && checkboxAllSelected()){
$("#checkboxAll").attr('checked',true);
}else{
$("#checkboxAll").attr('checked',false);
} }
$("#res_count").html(getCheckBoxSeletedCount()); //只有全选才是true
function checkboxAllSelected(){
allSelected = true;
$("#resources_list").find("input[name='checkbox1[]']").each(function(){
if($(this).attr('checked') == undefined){
allSelected = false;
}
});
return allSelected;
}
//只有全部不选才是true
function checkboxAllDeselected(){
allDeselected = true;
$("#resources_list").find("input[name='checkbox1[]']").each(function(){
if($(this).attr('checked') == 'checked'){
allDeselected = false;
}
});
return allDeselected;
}
//查看所有的checkbox状态并且按情况更改$("#checkboxAll")的状态
function checkAllBox(checkbox){
//只有选中当前checkbox且这个时候所有的checkbox都被选中了$("#checkboxAll")才是被选中状态,其余都是非选中状态
if(checkbox.attr('checked') == 'checked' && checkboxAllSelected()){
$("#checkboxAll").attr('checked',true);
}else{
$("#checkboxAll").attr('checked',false);
}
$("#res_count").html(getCheckBoxSeletedCount());
} }
//获取当前checkbox选中的数目 //获取当前checkbox选中的数目
function getCheckBoxSeletedCount(){ function getCheckBoxSeletedCount(){
var i = 0; var i = 0;
$("#resources_list").find("input[name='checkbox1[]']").each(function(){ $("#resources_list").find("input[name='checkbox1[]']").each(function(){
if($(this).attr('checked') == 'checked'){ if($(this).attr('checked') == 'checked'){
i ++; i ++;
} }
}); });
return i; return i;
} }
//全选反选 //全选反选
function all_select(){ function all_select(){
if($("#checkboxAll").attr('checked')){ if($("#checkboxAll").attr('checked')){
$("#resources_list").find("input[name='checkbox1[]']").each(function(){ $("#resources_list").find("input[name='checkbox1[]']").each(function(){
$(this).attr('checked',true); $(this).attr('checked',true);
}); });
$("#res_count").html(getCheckBoxSeletedCount()); $("#res_count").html(getCheckBoxSeletedCount());
}else{ }else{
$("#resources_list").find("input[name='checkbox1[]']").each(function(){ $("#resources_list").find("input[name='checkbox1[]']").each(function(){
$(this).attr('checked',false); $(this).attr('checked',false);
}); });
$("#res_count").html(0); $("#res_count").html(0);
} }
} }
//批量删除 //批量删除
function batch_delete(){ function batch_delete(){
var data = $("#resources_list_form").serialize(); var data = $("#resources_list_form").serialize();
if(data != "" && confirm('您删不掉这其中上传者不是您的资源,确认要删除这些资源吗?')) { if(data != "" && confirm('您删不掉这其中上传者不是您的资源,确认要删除这些资源吗?')) {
$.post( $.post(
'<%= user_resource_delete_user_path(@user)%>', '<%= user_resource_delete_user_path(@user)%>',
$("#resources_list_form").serialize(),//只会对选中的控件进行序列化提交 $("#resources_list_form").serialize(),//只会对选中的控件进行序列化提交
function (data) { function (data) {
} }
); );
} }
} }
function show_send(){ function show_send(){
$("#contextMenu").hide(); $("#contextMenu").hide();
document.oncontextmenu = function() {return true;} document.oncontextmenu = function() {return true;}
line.children().css("background-color",'white'); line.children().css("background-color",'white');
id = line.children().last().html(); id = line.children().last().html();
if (lastSendType === '1'){ //如果已经发送过一次了,那么就应该沿用上次发送的类型。 if (lastSendType === '1'){ //如果已经发送过一次了,那么就应该沿用上次发送的类型。
$.ajax({ $.ajax({
type: 'get', type: 'get',
url: '<%= search_user_course_user_path(@user)%>' + '?send_id=' + id url: '<%= search_user_course_user_path(@user)%>' + '?send_id=' + id
}); });
}else{ }else{
$.ajax({ $.ajax({
type: 'get', type: 'get',
url: '<%= search_user_project_user_path(@user)%>' + '?send_id=' + id url: '<%= search_user_project_user_path(@user)%>' + '?send_id=' + id
}); });
} }
} }
function batch_send(){ function batch_send(){
if($("#resources_list_form").serialize() == ""){ if($("#resources_list_form").serialize() == ""){
alert('暂时不支持多页选择,您当前页没有选择任何资源'); alert('暂时不支持多页选择,您当前页没有选择任何资源');
return ; return ;
} }
if (lastSendType === '1'){ //如果已经发送过一次了,那么就应该沿用上次发送的类型。 if (lastSendType === '1'){ //如果已经发送过一次了,那么就应该沿用上次发送的类型。
$.ajax({ $.ajax({
type: 'get', type: 'get',
url: '<%= search_user_course_user_path(@user)%>' + '?'+ $("#resources_list_form").serialize() url: '<%= search_user_course_user_path(@user)%>' + '?'+ $("#resources_list_form").serialize()
}); });
}else{ }else{
$.ajax({ $.ajax({
type: 'get', type: 'get',
url: '<%= search_user_project_user_path(@user)%>' + '?' + $("#resources_list_form").serialize() url: '<%= search_user_project_user_path(@user)%>' + '?' + $("#resources_list_form").serialize()
}); });
} }
} }
function preview(){ function preview(){
$("#contextMenu").hide(); $("#contextMenu").hide();
document.oncontextmenu = function() {return true;} document.oncontextmenu = function() {return true;}
line.children().css("background-color",'white'); line.children().css("background-color",'white');
id = line.children().last().html(); id = line.children().last().html();
$.ajax({ $.ajax({
type:'get', type:'get',
url:'<%= resource_preview_user_path(@user)%>'+"?resource_id="+id url:'<%= resource_preview_user_path(@user)%>'+"?resource_id="+id
}); });
} }
function rename(){ function rename(){
$("#contextMenu").hide(); $("#contextMenu").hide();
document.oncontextmenu = function() {return true;} document.oncontextmenu = function() {return true;}
line.children().css("background-color",'white'); line.children().css("background-color",'white');
id = line.children().last().html(); id = line.children().last().html();
user_id = line.children().eq(5).html(); user_id = line.children().eq(5).html();
if(user_id === '<%= User.current.id%>') { if(user_id === '<%= User.current.id%>') {
res_name = line.children().eq(1).children().attr('title'); res_name = line.children().eq(1).children().attr('title');
res_link = line.children().eq(1).html(); res_link = line.children().eq(1).html();
line.children().eq(1).html('<%= form_tag(url_for(:controller => 'users',:action => 'rename_resource',:method => 'post',:remote=>true,:id=>@user.id),:id=>"res_name_form" ) do%>' + line.children().eq(1).html('<%= form_tag(url_for(:controller => 'users',:action => 'rename_resource',:method => 'post',:remote=>true,:id=>@user.id),:id=>"res_name_form" ) do%>' +
'<input name="res_name" id="res_name" ' + '<input name="res_name" id="res_name" ' +
'style="height: 2em;line-height: 2em;overflow: hidden;" onblur="restore();" ' + 'style="height: 2em;line-height: 2em;overflow: hidden;" onblur="restore();" ' +
'value="'+res_name+ 'value="'+res_name+
'"/> <input type="hidden" id ="res_id" name="res_id" value="'+id+'"/>'+ '"/> <input type="hidden" id ="res_id" name="res_id" value="'+id+'"/>'+
'<% end %>'); '<% end %>');
$("#res_name").focus(); $("#res_name").focus();
$("html,body").animate({scrollTop:$("#res_name").offset().top},1000) $("html,body").animate({scrollTop:$("#res_name").offset().top},1000)
}else{ }else{
alert('您无法修改此资源!') alert('您无法修改此资源!')
} }
} }
String.prototype.trim = function() { String.prototype.trim = function() {
var str = this, var str = this,
str = str.replace(/^\s\s*/, ''), str = str.replace(/^\s\s*/, ''),
ws = /\s/, ws = /\s/,
i = str.length; i = str.length;
while (ws.test(str.charAt(--i))); while (ws.test(str.charAt(--i)));
return str.slice(0, i + 1); return str.slice(0, i + 1);
} }
//恢复编辑状态到链接状态 //恢复编辑状态到链接状态
//如果当前是编辑状态,任何的不在输入框里的单击右键事件都需要将编辑状态变回链接状态 //如果当前是编辑状态,任何的不在输入框里的单击右键事件都需要将编辑状态变回链接状态
//如果是编辑状态,且做了修改,那么久要进行修改,并且将修改值经过处理替换到页面显示 //如果是编辑状态,且做了修改,那么久要进行修改,并且将修改值经过处理替换到页面显示
function restore(){ function restore(){
//上一行不为空 且链接不为空 //上一行不为空 且链接不为空
if( last_line != null && res_link != null && res_link != '') { if( last_line != null && res_link != null && res_link != '') {
name = $("#res_name").lenght != 0 && $("#res_name").val() != undefined ? $("#res_name").val().trim() : undefined ; name = $("#res_name").lenght != 0 && $("#res_name").val() != undefined ? $("#res_name").val().trim() : undefined ;
if (name == undefined || name === 'undefined' ){ //只要res_name没有值那么就不是编辑状态 if (name == undefined || name === 'undefined' ){ //只要res_name没有值那么就不是编辑状态
return; return;
} }
if( name && name != res_name.trim()){ if( name && name != res_name.trim()){
if(confirm('确定修改为 '+name)){ if(confirm('确定修改为 '+name)){
$.post( $.post(
'<%=rename_resource_user_path(@user) %>', '<%=rename_resource_user_path(@user) %>',
"res_name="+$('#res_name').val()+"&res_id="+$("#res_id").val(), "res_name="+$('#res_name').val()+"&res_id="+$("#res_id").val(),
function (data){ function (data){
if(data != 'fail'){//修改成功,那么将链接恢复,并且将链接的显示内容改变。链接可以不变 if(data != 'fail'){//修改成功,那么将链接恢复,并且将链接的显示内容改变。链接可以不变
last_line.children().eq(1).html(res_link); last_line.children().eq(1).html(res_link);
last_line.children().eq(1).children().attr('title',name); last_line.children().eq(1).children().attr('title',name);
last_line.children().eq(1).children().attr('href',data); last_line.children().eq(1).children().attr('href',data);
last_line.children().eq(1).children().html(name.length > 17? name.substring(0,17)+'...' : name); last_line.children().eq(1).children().html(name.length > 17? name.substring(0,17)+'...' : name);
}else{ }else{
last_line.children().eq(1).html(res_link); last_line.children().eq(1).html(res_link);
res_link = null; //如果修改失败恢复之后将res_link置空 res_link = null; //如果修改失败恢复之后将res_link置空
} }
}, },
'text' 'text'
); );
}else{ }else{
last_line.children().eq(1).html(res_link); last_line.children().eq(1).html(res_link);
res_link = null; //如果没有做修改恢复之后将res_link置空 res_link = null; //如果没有做修改恢复之后将res_link置空
} }
}else { }else {
last_line.children().eq(1).html(res_link); last_line.children().eq(1).html(res_link);
res_link = null;//如果没有做修改恢复之后将res_link置空 res_link = null;//如果没有做修改恢复之后将res_link置空
} }
} }
} }
function delete_file() { function delete_file() {
$("#contextMenu").hide(); $("#contextMenu").hide();
document.oncontextmenu = function () { document.oncontextmenu = function () {
return true; return true;
} }
line.children().css("background-color", 'white'); line.children().css("background-color", 'white');
id = line.children().last().html(); id = line.children().last().html();
user_id = line.children().eq(5).html(); user_id = line.children().eq(5).html();
if(user_id === '<%= User.current.id%>') { if(user_id === '<%= User.current.id%>') {
if (confirm('确定要删除资源"' + line.children().eq(1).children().attr('title').trim() + '"么?')) { if (confirm('确定要删除资源"' + line.children().eq(1).children().attr('title').trim() + '"么?')) {
$.ajax({ $.ajax({
type: 'post', type: 'post',
url: '<%= user_resource_delete_user_path(@user)%>' + '?resource_id=' + id + '&type=' + $('#type').val() url: '<%= user_resource_delete_user_path(@user)%>' + '?resource_id=' + id + '&type=' + $('#type').val()
}); });
} }
}else{ }else{
alert('您无法删除此资源!') alert('您无法删除此资源!')
} }
} }
//id 发送的id //id 发送的id
//发送的id数组 //发送的id数组
function chooseSendType(res_id,res_ids){ function chooseSendType(res_id,res_ids){
sendType = $(".resourcesSendType").val(); sendType = $(".resourcesSendType").val();
if (sendType === lastSendType) { if (sendType === lastSendType) {
return; return;
} else if (lastSendType != null) { //不是第一次点击的时候 } else if (lastSendType != null) { //不是第一次点击的时候
if(res_ids == "") {//如果是单个发送 if(res_ids == "") {//如果是单个发送
if (sendType === '1') { if (sendType === '1') {
$.ajax({ $.ajax({
type: 'get', type: 'get',
url: '<%= search_user_course_user_path(@user)%>' + '?send_id=' + id url: '<%= search_user_course_user_path(@user)%>' + '?send_id=' + id
}); });
} else { } else {
$.ajax({ $.ajax({
type: 'get', type: 'get',
url: '<%= search_user_project_user_path(@user)%>' + '?send_id=' + id url: '<%= search_user_project_user_path(@user)%>' + '?send_id=' + id
}); });
} }
}else{//如果是多个发送 }else{//如果是多个发送
if (sendType === '1'){ if (sendType === '1'){
$.ajax({ $.ajax({
type: 'get', type: 'get',
url: '<%= search_user_course_user_path(@user)%>' + '?'+ $("#resources_list_form").serialize() url: '<%= search_user_course_user_path(@user)%>' + '?'+ $("#resources_list_form").serialize()
}); });
}else{ }else{
$.ajax({ $.ajax({
type: 'get', type: 'get',
url: '<%= search_user_project_user_path(@user)%>' + '?' + $("#resources_list_form").serialize() url: '<%= search_user_project_user_path(@user)%>' + '?' + $("#resources_list_form").serialize()
}); });
} }
} }
} }
lastSendType = sendType; lastSendType = sendType;
} }
// var iWidth = document.documentElement.clientWidth; // var iWidth = document.documentElement.clientWidth;
// var iHeight = document.documentElement.clientHeight; // var iHeight = document.documentElement.clientHeight;
// var moveX = 0; // var moveX = 0;
// var moveY = 0; // var moveY = 0;
// var moveTop = 0; // var moveTop = 0;
// var moveLeft = 0; // var moveLeft = 0;
// var moveable = false; // var moveable = false;
// var docMouseMoveEvent = document.onmousemove; // var docMouseMoveEvent = document.onmousemove;
// var docMouseUpEvent = document.onmouseup; // var docMouseUpEvent = document.onmouseup;
// $("#upload_box").mousedown(function() { // $("#upload_box").mousedown(function() {
// var evt = getEvent(); // var evt = getEvent();
// moveable = true; // moveable = true;
// moveX = evt.clientX; // moveX = evt.clientX;
// moveY = evt.clientY; // moveY = evt.clientY;
// //
// moveTop = parseInt($("#upload_box").css('top')); // moveTop = parseInt($("#upload_box").css('top'));
// moveLeft = parseInt($("#upload_box").css('left')); // moveLeft = parseInt($("#upload_box").css('left'));
// //
// $(document).mousemove( function() { // $(document).mousemove( function() {
// if (moveable) { // if (moveable) {
// var evt = getEvent(); // var evt = getEvent();
// var x = moveLeft + evt.clientX - moveX; // var x = moveLeft + evt.clientX - moveX;
// var y = moveTop + evt.clientY - moveY; // var y = moveTop + evt.clientY - moveY;
// if ( x > 0 &&( x + 322 < iWidth) && y > 0 && (y + 257 < iHeight) ) { // if ( x > 0 &&( x + 322 < iWidth) && y > 0 && (y + 257 < iHeight) ) {
// $("#upload_box").css('left', x + "px"); // $("#upload_box").css('left', x + "px");
// $("#upload_box").css('top', y + "px"); // $("#upload_box").css('top', y + "px");
// console.log( moveX) // console.log( moveX)
// console.log( moveY) // console.log( moveY)
// } // }
// } // }
// }); // });
// $(document).mouseup (function () { // $(document).mouseup (function () {
// if (moveable) { // if (moveable) {
// document.onmousemove = docMouseMoveEvent; // document.onmousemove = docMouseMoveEvent;
// document.onmouseup = docMouseUpEvent; // document.onmouseup = docMouseUpEvent;
// moveable = false; // moveable = false;
// moveX = 0; // moveX = 0;
// moveY = 0; // moveY = 0;
// moveTop = 0; // moveTop = 0;
// moveLeft = 0; // moveLeft = 0;
// } // }
// }); // });
// }); // });
// //
// // 获得事件Event对象用于兼容IE和FireFox // // 获得事件Event对象用于兼容IE和FireFox
// function getEvent() { // function getEvent() {
// return window.event || arguments.callee.caller.arguments[0]; // return window.event || arguments.callee.caller.arguments[0];
// } // }
</script> </script>

View File

@ -171,7 +171,7 @@ RedmineApp::Application.routes.draw do
resources :contests, only: [:index] do resources :contests, only: [:index] do
resources :contestnotifications do resources :contestnotifications do
# get 'preview', on: :collection # get 'preview', on: :collection
resources :notificationcomments resources :notificationcomments
end end
collection do collection do
@ -232,7 +232,7 @@ RedmineApp::Application.routes.draw do
end end
end end
end end
resources :shares resources :shares
@ -369,7 +369,7 @@ RedmineApp::Application.routes.draw do
get 'user_resource_type' get 'user_resource_type'
get 'user_ref_resource_search' get 'user_ref_resource_search'
post 'import_resources_to_homework' post 'import_resources_to_homework'
# end # end
end end
end end
match 'users/:id/user_newfeedback', :to => 'users#user_newfeedback', :via => :get, :as => "feedback" match 'users/:id/user_newfeedback', :to => 'users#user_newfeedback', :via => :get, :as => "feedback"
@ -483,7 +483,7 @@ RedmineApp::Application.routes.draw do
collection do collection do
match "getattachtype" , :via => [:get, :post] match "getattachtype" , :via => [:get, :post]
match "search_project",:via => [:post,:get] match "search_project",:via => [:post,:get]
#match 'getattachtype/:attachtype', :to => 'files#getattachtype', :via => [:get, :post] #match 'getattachtype/:attachtype', :to => 'files#getattachtype', :via => [:get, :post]
end end
end end
@ -513,7 +513,7 @@ RedmineApp::Application.routes.draw do
resources :repositories, :except => [:index, :show] do resources :repositories, :except => [:index, :show] do
member do member do
get 'newrepo', :via => [:get, :post] get 'newrepo', :via => [:get, :post]
# get 'create', :via=>[:get, :post] # get 'create', :via=>[:get, :post]
end end
end end
match 'wiki/index', :via => :get match 'wiki/index', :via => :get
@ -544,6 +544,9 @@ RedmineApp::Application.routes.draw do
match 'bulk_edit', :via => [:get, :post] match 'bulk_edit', :via => [:get, :post]
post 'bulk_update' post 'bulk_update'
end end
member do
post 'add_journal'
end
resources :time_entries, :controller => 'timelog' do resources :time_entries, :controller => 'timelog' do
collection do collection do
get 'report' get 'report'
@ -600,8 +603,8 @@ RedmineApp::Application.routes.draw do
:controller => 'repositories', :controller => 'repositories',
:format => false, :format => false,
:constraints => { :constraints => {
:action => /(browse|show|entry|raw|annotate|diff)/, :action => /(browse|show|entry|raw|annotate|diff)/,
:rev => /[a-z0-9\.\-_]+/ :rev => /[a-z0-9\.\-_]+/
} }
get 'projects/:id/repository/statistics', :to => 'repositories#stats' get 'projects/:id/repository/statistics', :to => 'repositories#stats'
@ -618,8 +621,8 @@ RedmineApp::Application.routes.draw do
:controller => 'repositories', :controller => 'repositories',
:format => false, :format => false,
:constraints => { :constraints => {
:action => /(browse|show|entry|raw|annotate|diff)/, :action => /(browse|show|entry|raw|annotate|diff)/,
:rev => /[a-z0-9\.\-_]+/ :rev => /[a-z0-9\.\-_]+/
} }
get 'projects/:id/repository/:repository_id/:action(/*path(.:ext))', get 'projects/:id/repository/:repository_id/:action(/*path(.:ext))',
:controller => 'repositories', :controller => 'repositories',
@ -722,7 +725,7 @@ RedmineApp::Application.routes.draw do
get 'test_connection', :as => 'try_connection' get 'test_connection', :as => 'try_connection'
end end
collection do collection do
get 'autocomplete_for_new_user' get 'autocomplete_for_new_user'
end end
end end
@ -784,7 +787,7 @@ RedmineApp::Application.routes.draw do
collection do collection do
match 'chang_read_flag', :via => :get match 'chang_read_flag', :via => :get
end end
end end
end # end of resources :courses end # end of resources :courses
match 'courses/:id/feedback', :to => 'courses#feedback', :via => :get, :as => 'course_feedback' match 'courses/:id/feedback', :to => 'courses#feedback', :via => :get, :as => 'course_feedback'

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 10 KiB

View File

@ -1,74 +1,5 @@
//个人动态 //个人动态
$(function(){ $(function(){
function init_editor(params){
var editor = params.kindutil.create(params.textarea, {
resizeType : 1,minWidth:"1px",width:"100%",height:"80px",
items:['emoticons'],
afterChange:function(){//按键事件
nh_check_field({content:this,contentmsg:params.contentmsg,textarea:params.textarea});
},
afterCreate:function(){
var toolbar = $("div[class='ke-toolbar']",params.div_form);
$(".ke-outline>.ke-toolbar-icon",toolbar).append('表情');
params.toolbar_container.append(toolbar);
}
}).loadPlugin('paste');
return editor;
}
function nh_check_field(params){
var result=true;
if(params.content!=undefined){
if(params.content.isEmpty()){
result=false;
}
if(params.content.html()!=params.textarea.html() || params.issubmit==true){
params.textarea.html(params.content.html());
params.content.sync();
if(params.content.isEmpty()){
params.contentmsg.html('内容不能为空');
params.contentmsg.css({color:'#ff0000'});
}else{
params.contentmsg.html('填写正确');
params.contentmsg.css({color:'#008000'});
}
params.contentmsg.show();
}
}
return result;
}
function init_form(params){
params.form.submit(function(){
var flag = false;
if(params.form.attr('data-remote') != undefined ){
flag = true
}
var is_checked = nh_check_field({
issubmit:true,
content:params.editor,
contentmsg:params.contentmsg,
textarea:params.textarea
});
if(is_checked){
if(flag){
return true;
}else{
$(this)[0].submit();
return false;
}
}
return false;
});
}
function nh_reset_form(params){
params.form[0].reset();
params.textarea.empty();
if(params.editor != undefined){
params.editor.html(params.textarea.html());
}
params.contentmsg.hide();
}
KindEditor.ready(function(K){ KindEditor.ready(function(K){
$("a[nhname='reply_btn']").live('click',function(){ $("a[nhname='reply_btn']").live('click',function(){
var params = {}; var params = {};
@ -167,110 +98,4 @@ $(function(){
}); });
}); });
}); });
function init_list_more_div(params){
var p=params;
p.exbtn.click(function(){
var isclose = p.container.data('isclose');
var hasmore = p.container.data('hasmore');
if(isclose == '1'){
$("div[nhname='rec']",p.container).show();
p.container.data('isclose','0');
change_status_4_list_more_div(params);
return;
}
if(hasmore == '0'){
change_status_4_list_more_div(params,'get');
return;
}
var url = p.container.data('url');
if($("div[nhname='rec']",p.container).length > 0){
var lastid = $("div[nhname='rec']",p.container).filter(':last').data('id');
url += "?lastid="+lastid;
var lasttime = $("div[nhname='rec']",p.container).filter(':last').data('time');
if(lasttime != undefined){
url += "&lasttime="+lasttime;
}
}
$.ajax( {url:url,dataType:'text',success:function(data){
var html = $("<div>"+data+"</div>");
var lens = $("div[nhname='rec']",html).length;
if(lens < p.size){
p.container.data('hasmore','0');
}
if(lens>0){
var currpage = parseInt(p.container.data('currpage'))+1;
p.container.data('currpage',currpage);
p.container.append(html.html())
}
change_status_4_list_more_div(params,'get');
p.div.show();
}} );
});
p.clbtn.click(function(){
var i=0;
$("div[nhname='rec']",p.container).each(function(){
i++;
if(i> p.size){
$(this).hide();
}
});
p.container.data('isclose','1');
change_status_4_list_more_div(params);
});
p.exbtn.click();
}
function change_status_4_list_more_div(params,opt){
var p=params;
if($("div[nhname='rec']",p.container).length == 0 && opt != 'get'){
p.exbtn.click();
return;
}
var show_lens = $("div[nhname='rec']",p.container).length - $("div[nhname='rec']",p.container).filter(':hidden').length;
if( show_lens > p.size ){
p.clbtn.show();
}else{
p.clbtn.hide();
}
if($("div[nhname='rec']",p.container).length == 0){
p.exbtn.html(p.nodatamsg);
}else if( p.container.data('hasmore') == '1' || p.container.data('isclose')=='1' ){
p.exbtn.html('点击展开更多');
}else{
p.exbtn.html('没有更多了');
}
}
function init_list_more_div_params(div){
var params = {};
params.div = div;
params.container = $("div[nhname='container']",div);
params.exbtn = $("a[nhname='expand']",div);
params.clbtn = $("a[nhname='close']",div);
params.size = params.container.data('pagesize');
params.nodatamsg = params.container.data('nodatamsg');
if( params.size == undefined ){
params.size = 13;
}
return params;
}
$(function(){
$("div[nhname='list_more_div']").each(function(){
var params = init_list_more_div_params($(this));
init_list_more_div(params)
});
});
$(function(){
$(".newsType").mouseover(function(){
$(".resourcesIcon").css({background:"url(images/resource_icon_list.png) 0px -25px no-repeat"});
});
$(".newsType").mouseout(function(){
$(".resourcesIcon").css({background:"url(images/resource_icon_list.png) 0px 0px no-repeat"});
});
$(".resourcesSelected").mouseover(function(){
$(".resourcesIcon").css({background:"url(images/resource_icon_list.png) 0px -25px no-repeat"});
});
$(".resourcesSelected").mouseout(function(){
$(".resourcesIcon").css({background:"url(images/resource_icon_list.png) 0px 0px no-repeat"});
});
});
//个人动态 end //个人动态 end