@ -746,14 +746,34 @@ class UsersController < ApplicationController
end
end
# end
jours = @user . journals_for_messages . where ( 'm_parent_id IS NULL' ) . order ( 'created_on DESC' )
@page = params [ :page ] ? params [ :page ] . to_i + 1 : 0
if params [ :type ] . present?
case params [ :type ]
when " public "
jours = @user . journals_for_messages . where ( 'm_parent_id IS NULL and private = 0' ) . order ( 'created_on DESC' )
@jour_count = jours . count
@jour = jours . limit ( 10 ) . offset ( @page * 10 )
when " private "
jours = @user . journals_for_messages . where ( 'm_parent_id IS NULL and private = 1' ) . order ( 'created_on DESC' )
@jour_count = jours . count
@jour = jours . limit ( 10 ) . offset ( @page * 10 )
else
jours = @user . journals_for_messages . where ( 'm_parent_id IS NULL' ) . order ( 'created_on DESC' )
@jour_count = jours . count
@jour = jours . limit ( 10 ) . offset ( @page * 10 )
end
else
jours = @user . journals_for_messages . where ( 'm_parent_id IS NULL' ) . order ( 'created_on DESC' )
@jour_count = jours . count
@jour = jours . limit ( 10 ) . offset ( @page * 10 )
end
@type = params [ :type ]
if User . current == @user
jours . update_all ( :is_readed = > true , :status = > false )
jours . each do | journal |
fetch_user_leaveWord_reply ( journal ) . update_all ( :is_readed = > true , :status = > false )
end
end
@jour = paginateHelper jours , 10
@state = false
render :layout = > 'new_base_user'
end
@ -1753,6 +1773,48 @@ class UsersController < ApplicationController
end
end
def share_news_to_course
news = News . find ( params [ :send_id ] )
course_ids = params [ :course_ids ]
course_ids . each do | course_id |
if Course . find ( course_id ) . news . map ( & :id ) . exclude? ( news . id )
course_news = News . create ( :course_id = > course_id . to_i , :title = > news . title , :summary = > news . summary , :description = > news . description , :author_id = > User . current . id , :created_on = > Time . now , :project_id = > - 1 )
news . attachments . each do | attach |
course_news . attachments << Attachment . new ( :filename = > attach . filename , :disk_filename = > attach . disk_filename , :filesize = > attach . filesize , :content_type = > attach . content_type , :digest = > attach . digest ,
:downloads = > 0 , :author_id = > User . current . id , :created_on = > Time . now , :description = > attach . description , :disk_directory = > attach . disk_directory , :attachtype = > attach . attachtype ,
:is_public = > attach . is_public , :quotes = > 0 )
end
end
end
end
def share_news_to_project
news = News . find ( params [ :send_id ] )
project_ids = params [ :project_ids ]
project_ids . each do | project_id |
if Project . find ( project_id ) . news . map ( & :id ) . exclude? ( news . id )
project_news = News . create ( :project_id = > project_id . to_i , :title = > news . title , :summary = > news . summary , :description = > news . description , :author_id = > User . current . id , :created_on = > Time . now )
news . attachments . each do | attach |
project_news . attachments << Attachment . new ( :filename = > attach . filename , :disk_filename = > attach . disk_filename , :filesize = > attach . filesize , :content_type = > attach . content_type , :digest = > attach . digest ,
:downloads = > 0 , :author_id = > User . current . id , :created_on = > Time . now , :description = > attach . description , :disk_directory = > attach . disk_directory , :attachtype = > attach . attachtype ,
:is_public = > attach . is_public , :quotes = > 0 )
end
end
end
end
def share_news_to_org
news = News . find ( params [ :send_id ] )
field_id = params [ :subfield ]
org_news = News . create ( :org_subfield_id = > field_id . to_i , :title = > news . title , :summary = > news . summary , :description = > news . description , :author_id = > User . current . id , :created_on = > Time . now , :project_id = > - 1 )
news . attachments . each do | attach |
org_news . attachments << Attachment . new ( :filename = > attach . filename , :disk_filename = > attach . disk_filename , :filesize = > attach . filesize , :content_type = > attach . content_type , :digest = > attach . digest ,
:downloads = > 0 , :author_id = > User . current . id , :created_on = > Time . now , :description = > attach . description , :disk_directory = > attach . disk_directory , :attachtype = > attach . attachtype ,
:is_public = > attach . is_public , :quotes = > 0 )
end
OrgActivity . create ( :container_type = > 'OrgSubfield' , :container_id = > field_id . to_i , :org_act_type = > 'News' , :org_act_id = > org_news . id , :user_id = > User . current . id )
end
def change_org_subfield
end
@ -2102,9 +2164,17 @@ class UsersController < ApplicationController
@user = User . current
if ! params [ :search ] . nil? #发送到有栏目类型为资源的组织中
search = " % #{ params [ :search ] . to_s . strip . downcase } % "
@orgs = @user . organizations . where ( " name like ? " , search ) . select { | org | OrgSubfield . where ( " organization_id = #{ org . id } and field_type='Resource' " ) . count > 0 }
if params [ :send_type ] . present? and params [ :send_type ] == 'news'
@orgs = @user . organizations . where ( " name like ? " , search ) . select { | org | OrgSubfield . where ( " organization_id = #{ org . id } and field_type='Post' " ) . count > 0 }
else
@orgs = @user . organizations . where ( " name like ? " , search ) . select { | org | OrgSubfield . where ( " organization_id = #{ org . id } and field_type='Resource' " ) . count > 0 }
end
else
@orgs = @user . organizations . select { | org | OrgSubfield . where ( " organization_id = #{ org . id } and field_type='Resource' " ) . count > 0 }
if params [ :send_type ] . present? and params [ :send_type ] == 'news'
@orgs = @user . organizations . select { | org | OrgSubfield . where ( " organization_id = #{ org . id } and field_type='Post' " ) . count > 0 }
else
@orgs = @user . organizations . select { | org | OrgSubfield . where ( " organization_id = #{ org . id } and field_type='Resource' " ) . count > 0 }
end
end
@search = params [ :search ]
#这里仅仅是传递需要发送的资源id