diff --git a/Gemfile.lock b/Gemfile.lock index 4ba8ecf6c..6916219a9 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -125,6 +125,7 @@ GEM mocha (1.1.0) metaclass (~> 0.0.1) multi_json (1.10.1) + mysql2 (0.3.11) mysql2 (0.3.11-x86-mingw32) net-ldap (0.3.1) nokogiri (1.6.3) diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb index 3326d0b1a..9b1e045e3 100644 --- a/app/controllers/admin_controller.rb +++ b/app/controllers/admin_controller.rb @@ -126,7 +126,7 @@ class AdminController < ApplicationController @status = params[:status] || 1 scope = User.logged.status(@status) - scope = scope.like(params[:name]) if params[:name].present? + scope = scope.like(params[:name],params[:search_by][:id]) if params[:name].present? @user_count = scope.count @user_pages = Paginator.new @user_count, @limit, params['page'] @user_base_tag = params[:id] ? 'base_users':'base' diff --git a/app/controllers/auto_completes_controller.rb b/app/controllers/auto_completes_controller.rb index 9e7467bfc..205d4aa01 100644 --- a/app/controllers/auto_completes_controller.rb +++ b/app/controllers/auto_completes_controller.rb @@ -29,7 +29,11 @@ class AutoCompletesController < ApplicationController @issues += scope.where("LOWER(#{Issue.table_name}.subject) LIKE LOWER(?)", "%#{q}%").order("#{Issue.table_name}.id DESC").limit(10).all @issues.compact! end - render :layout => false + #render :layout => false + render :json => @issues.map {|issue| { + 'value' => issue[:subject] + + }} end diff --git a/app/controllers/files_controller.rb b/app/controllers/files_controller.rb index 8dd8ba93f..91176efdf 100644 --- a/app/controllers/files_controller.rb +++ b/app/controllers/files_controller.rb @@ -265,6 +265,7 @@ class FilesController < ApplicationController 'size' => "#{Attachment.table_name}.filesize", 'downloads' => "#{Attachment.table_name}.downloads" sort='' + if params[:sort] params[:sort].split(",").each do |sort_type| order_by = sort_type.split(":") diff --git a/app/controllers/forums_controller.rb b/app/controllers/forums_controller.rb index d5fc1770c..cd51d2e58 100644 --- a/app/controllers/forums_controller.rb +++ b/app/controllers/forums_controller.rb @@ -52,7 +52,7 @@ class ForumsController < ApplicationController def index @offset, @limit = api_offset_and_limit({:limit => 10}) - @forums_all = Forum.where('1=1') + @forums_all = Forum.reorder("sticky DESC") @forums_count = @forums_all.count @forums_pages = Paginator.new @forums_count, @limit, params['page'] @@ -208,6 +208,8 @@ class ForumsController < ApplicationController end end + + private diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 9b2e5990a..3b6e9a7d2 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -374,7 +374,7 @@ class UsersController < ApplicationController "show_changesets" => true } scope = User.logged.status(@status) - scope = scope.like(params[:name]) if params[:name].present? + scope = scope.like(params[:name],params[:search_by][:id]) if params[:name].present? @user_count = scope.count @user_pages = Paginator.new @user_count, @limit, params['page'] @user_base_tag = params[:id] ? 'base_users':'users_base' diff --git a/app/models/course.rb b/app/models/course.rb index 1f0cb0979..b2da58a81 100644 --- a/app/models/course.rb +++ b/app/models/course.rb @@ -5,7 +5,7 @@ class Course < ActiveRecord::Base STATUS_CLOSED = 5 STATUS_ARCHIVED = 9 - attr_accessible :code, :extra, :name, :state, :tea_id, :time , :location, :state, :term, :password,:is_public,:description,:class_period + attr_accessible :code, :extra, :name, :state, :tea_id, :time , :location, :state, :term, :password,:is_public,:description,:class_period, :open_student belongs_to :project, :class_name => 'Course', :foreign_key => :extra, primary_key: :identifier belongs_to :teacher, :class_name => 'User', :foreign_key => :tea_id # 定义一个方法teacher,该方法通过tea_id来调用User表 belongs_to :school, :class_name => 'School', :foreign_key => :school_id #定义一个方法school,该方法通过school_id来调用School表 @@ -52,7 +52,8 @@ class Course < ActiveRecord::Base 'term', 'is_public', 'description', - 'class_period' + 'class_period', + 'open_student' acts_as_customizable diff --git a/app/models/forum.rb b/app/models/forum.rb index 24b5b15e0..e0592723e 100644 --- a/app/models/forum.rb +++ b/app/models/forum.rb @@ -8,7 +8,9 @@ class Forum < ActiveRecord::Base 'topic_count', 'memo_count', 'last_memo_id', - 'creator_id' + 'creator_id', + 'sticky', + 'locked' validates_presence_of :name, :creator_id, :description validates_length_of :name, maximum: 50 #validates_length_of :description, maximum: 255 diff --git a/app/models/issue.rb b/app/models/issue.rb index 6bbcd727f..09e093177 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -1359,7 +1359,7 @@ class Issue < ActiveRecord::Base # Callback on file attachment def attachment_added(obj) - if @current_journal && !obj.new_record? + if @current_journal && !obj.new_record? && @current_journal.journalized_id == obj.author_id @current_journal.details << JournalDetail.new(:property => 'attachment', :prop_key => obj.id, :value => obj.filename) end end diff --git a/app/models/message.rb b/app/models/message.rb index 0fdfc5b15..8af3265cc 100644 --- a/app/models/message.rb +++ b/app/models/message.rb @@ -78,9 +78,13 @@ class Message < ActiveRecord::Base safe_attributes 'subject', 'content' - safe_attributes 'locked', 'sticky', 'board_id', + safe_attributes 'board_id','locked', 'sticky', :if => lambda {|message, user| - user.allowed_to?(:edit_messages, message.project) + if message.project + user.allowed_to?(:edit_messages, message.project) + else + user.allowed_to?(:edit_messages, message.course) + end } def visible?(user=User.current) @@ -158,6 +162,7 @@ class Message < ActiveRecord::Base #更新用户分数 -by zjc def be_user_score #新建message且无parent的为发帖 + if self.parent_id.nil? && !self.board.project.nil? UserScore.joint(:post_message, self.author,nil,self, { message_id: self.id }) update_memo_number(self.author,1) diff --git a/app/models/user.rb b/app/models/user.rb index bbee7f763..ff627763a 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -199,13 +199,19 @@ class User < Principal } scope :sorted, lambda { order(*User.fields_for_order_statement)} - scope :like, lambda {|arg| + scope :like, lambda {|arg, type| if arg.blank? where(nil) else pattern = "%#{arg.to_s.strip.downcase}%" #where(" LOWER(concat(lastname, firstname)) LIKE :p ", :p => pattern) - where(" LOWER(login) LIKE :p ", :p => pattern) + if type == "0" + where(" LOWER(login) LIKE :p ", :p => pattern) + elsif type == "1" + where(" LOWER(concat(lastname, firstname)) LIKE :p ", :p => pattern) + else + where(" LOWER(mail) LIKE :p ", :p => pattern) + end end } diff --git a/app/views/admin/search.html.erb b/app/views/admin/search.html.erb index 5d49d84fa..758c7b32f 100644 --- a/app/views/admin/search.html.erb +++ b/app/views/admin/search.html.erb @@ -17,7 +17,10 @@ <%= select_tag 'group_id', content_tag('option') + options_from_collection_for_select(@groups, :id, :name, params[:group_id].to_i), :onchange => "this.form.submit(); return false;" %> <% end %> - + + <%= select "search_by", "id", + { l(:label_search_by_login) => "0", l(:label_search_by_name) => "1", l(:label_search_by_email) => "2" }, + :size => 20 %> <%= text_field_tag 'name', params[:name], :size => 30 %> <%= submit_tag l(:label_search), :class => "small", :name => nil %> diff --git a/app/views/admin/users.html.erb b/app/views/admin/users.html.erb index 7bbdf1c3e..12aa95a16 100644 --- a/app/views/admin/users.html.erb +++ b/app/views/admin/users.html.erb @@ -17,7 +17,10 @@ <%= select_tag 'group_id', content_tag('option') + options_from_collection_for_select(@groups, :id, :name, params[:group_id].to_i), :onchange => "this.form.submit(); return false;" %> <% end %> - + + <%= select "search_by", "id", + { l(:label_search_by_login) => "0", l(:label_search_by_name) => "1", l(:label_search_by_email) => "2" }, + :size => 20 %> <%= text_field_tag 'name', params[:name], :size => 30 %> <%= submit_tag l(:label_search), :class => "small", :name => nil %> diff --git a/app/views/courses/_course_form.html.erb b/app/views/courses/_course_form.html.erb index c9ac7541d..305b6fa19 100644 --- a/app/views/courses/_course_form.html.erb +++ b/app/views/courses/_course_form.html.erb @@ -43,6 +43,7 @@ <%= text_field_tag :class_period, @course.class_period, :placeholder => "#{l(:lable_input_class)}", :maxlength => 5 %> +  <%= l(:label_class_hour) %>   <%= l(:label_class_hour) %> @@ -57,6 +58,9 @@ - +
+ <%= l(:label_class_period) %> + <%= l(:label_class_period) %> + *   <%= l(:label_class_period) %> *   @@ -64,6 +68,8 @@ <%= text_field_tag :class_period, nil, :placeholder => "#{l(:lable_input_class)}", :maxlength => 5 %> + <%= l(:label_class_hour) %> + <%= l(:label_class_hour) %> <%= l(:label_class_hour) %> @@ -80,6 +86,7 @@ @@ -99,12 +107,14 @@
+ <%= l(:label_term) %> *   <%= l(:label_term) %> *   @@ -89,6 +96,7 @@ <%= select_tag :time,options_for_select(course_time_option,@course.time), {} %> + <%= select_tag :term,options_for_select(course_term_option,@course.term),{} %> <%= select_tag :term,options_for_select(course_term_option,@course.term || cur_course_term),{} %>

+

+ <%= l(:text_command) %> <%= l(:text_command) %> @@ -124,12 +134,19 @@ <%= f.check_box :is_public, :style => "margin-left:10px;" %> <%= l(:label_course_public_info) %> -

+

+

+ + <%= f.check_box :open_student, :style => "margin-left:10px;" %> + <%= l(:label_course_open_student_info) %> + +

<%= f.text_field :course_type, :value => 1 %>

<%= wikitoolbar_for 'course_description' %> <% @course.custom_field_values.each do |value| %> +

<%= custom_field_tag_with_label :course, value %>

<%= custom_field_tag_with_label :course, value %>

diff --git a/app/views/courses/_join_private_course.html.erb b/app/views/courses/_join_private_course.html.erb index 65dd04aa6..e3e75b9d7 100644 --- a/app/views/courses/_join_private_course.html.erb +++ b/app/views/courses/_join_private_course.html.erb @@ -62,8 +62,8 @@
  • - <%= l(:label_new_join) %> - <%= l(:button_cancel)%> + <%= l(:label_new_join) %> + <%= l(:button_cancel)%>
  • <% end%> diff --git a/app/views/files/_course_file.html.erb b/app/views/files/_course_file.html.erb index a1dae9a33..9f476aba8 100644 --- a/app/views/files/_course_file.html.erb +++ b/app/views/files/_course_file.html.erb @@ -2,6 +2,7 @@ <% attachmenttypes = @course.attachmenttypes %> <% sufixtypes = @course.contenttypes %> + <%= t(:label_user_course) %>资源共享区
    @@ -49,7 +50,8 @@ <% if attachmenttypes.any? %>       - <%= select_tag "attachment_browse", content_tag(:option, l(:attachment_all), :value => '0') +options_from_collection_for_select(attachmenttypes, "id", "typeName"), + <%= select_tag "attachment_browse", content_tag(:option, l(:attachment_all), :value => '0' ) +options_from_collection_for_select(attachmenttypes, "id", "typeName", params[:type]), + :onchange => "course_attachmenttypes_searchex(this.value)" %> <% end %> <% if sufixtypes.any? %> diff --git a/app/views/files/_project_file.html.erb b/app/views/files/_project_file.html.erb index 315314828..f52b7d353 100644 --- a/app/views/files/_project_file.html.erb +++ b/app/views/files/_project_file.html.erb @@ -52,7 +52,7 @@ <% if attachmenttypes.any? %>       - <%= select_tag "attachment_browse", content_tag(:option, l(:attachment_all), :value => '0') +options_from_collection_for_select(attachmenttypes, "id", "typeName"), + <%= select_tag "attachment_browse", content_tag(:option, l(:attachment_all), :value => '0') +options_from_collection_for_select(attachmenttypes, "id", "typeName",params[:type]), :onchange => "attachmenttypes_searchex(this.value)" %> <% end %> <% if sufixtypes.any? %> diff --git a/app/views/forums/_form.html.erb b/app/views/forums/_form.html.erb index 556238732..9b3519b05 100644 --- a/app/views/forums/_form.html.erb +++ b/app/views/forums/_form.html.erb @@ -17,6 +17,18 @@
    <%= f.text_field :name, :required => true, :style => 'width: 100%;', :class => 'create-share' %>
    +
    + <% if User.current.logged? && User.current.admin? %> + <% if @forum.safe_attribute? 'sticky' %> + <%= f.check_box :sticky %> + <%= label_tag 'message_sticky', l(:label_board_sticky) %> + <% end %> + <% if @forum.safe_attribute? 'locked' %> + <%= f.check_box :locked %> + <%= label_tag 'message_locked', l(:label_board_locked) %> + <% end %> + <% end %> +

    diff --git a/app/views/forums/_forum_list.html.erb b/app/views/forums/_forum_list.html.erb index 9d0eba923..874dc355f 100644 --- a/app/views/forums/_forum_list.html.erb +++ b/app/views/forums/_forum_list.html.erb @@ -7,9 +7,14 @@ <%= forum.creator.nil? ? (link_to image_tag(url_to_avatar(forum.creator), :class => "avatar")) : (link_to image_tag(url_to_avatar(forum.creator), :class => "avatar"), user_path(forum.creator)) %>

    -

    <%= link_to h(forum.name), forum_path(forum) %>

    -

    <%= textAreailizable forum.description%>

    -

    <%= authoring forum.created_at, forum.creator %>

    + + + + +
    +

    <%= link_to h(forum.name), forum_path(forum) %>

    <%= textAreailizable forum.description%>

    <%= authoring forum.created_at, forum.creator %>

    +
    <%= link_to (forum.memo_count), forum_path(forum) %><%= link_to (forum.topic_count), forum_path(forum) %>
    回答帖子
    diff --git a/app/views/forums/index.html.erb b/app/views/forums/index.html.erb index fa6e74ccd..31d00891e 100644 --- a/app/views/forums/index.html.erb +++ b/app/views/forums/index.html.erb @@ -11,7 +11,8 @@
    <% if User.current.logged? %> <%= link_to( l(:label_forum_new), new_forum_path, :class => 'icon icon-add') %> - <% end %> + <% end %> + - <% if User.current.member_of_course?(@course) %> + <% if (User.current.logged? && @course.open_student == 1) || (User.current.member_of_course?(@course)) %> <%= link_to "#{studentCount(@course)}", course_member_path(@course, :role => 2), :course => '1' %> <% else %> diff --git a/app/views/layouts/base_projects.html.erb b/app/views/layouts/base_projects.html.erb index 8f6d86f29..f656f5263 100644 --- a/app/views/layouts/base_projects.html.erb +++ b/app/views/layouts/base_projects.html.erb @@ -95,7 +95,7 @@ <%= l(:label_member) %> <%= l(:label_user_watchered) %> <%= l(:label_project_issues) %>
    diff --git a/app/views/layouts/base_users.html.erb b/app/views/layouts/base_users.html.erb index 97d5fc47f..04501532d 100644 --- a/app/views/layouts/base_users.html.erb +++ b/app/views/layouts/base_users.html.erb @@ -21,6 +21,9 @@ <%= call_hook :view_layouts_base_html_head %> <%= yield :header_tags -%> + <% title1 = @user.user_extensions.technical_title %> + <% language1 = @user.language %> + - +
    @@ -193,8 +240,8 @@ <%= l(:label_technical_title) %>: - - <%= @user.user_extensions.technical_title %> + + <% end %> diff --git a/app/views/memos/_form.html.erb b/app/views/memos/_form.html.erb index 41ea73fcd..961e54ded 100644 --- a/app/views/memos/_form.html.erb +++ b/app/views/memos/_form.html.erb @@ -1,3 +1,3 @@ <%= error_messages_for 'bid' %>

    <%= f.text_field :content, :required => true, :size => 60, :style => "width:150px;" %>

    -

    <%= hidden_field_tag 'subject', ||=@memo.subject %> \ No newline at end of file +

    <%= hidden_field_tag 'subject'||=@memo.subject %> \ No newline at end of file diff --git a/app/views/messages/_course_show.html.erb b/app/views/messages/_course_show.html.erb index 40094b162..f5c2a4211 100644 --- a/app/views/messages/_course_show.html.erb +++ b/app/views/messages/_course_show.html.erb @@ -106,7 +106,11 @@ <%= authoring @topic.created_on, @topic.author %>

    - <%= toggle_link l(:button_reply), "reply", :focus => 'message_content' %> + <% if User.current.logged? %> + <%= toggle_link l(:button_reply), "reply", :focus => 'message_content' %> + <% else %> + <%= link_to l(:button_reply), signin_path %> + <% end %>
    diff --git a/app/views/messages/_project_show.html.erb b/app/views/messages/_project_show.html.erb index 98a1a5767..b0a593180 100644 --- a/app/views/messages/_project_show.html.erb +++ b/app/views/messages/_project_show.html.erb @@ -111,7 +111,11 @@ <%= authoring @topic.created_on, @topic.author %>
    - <%= toggle_link l(:button_reply), "reply", :focus => 'message_content' %> + <% if User.current.logged? %> + <%= toggle_link l(:button_reply), "reply", :focus => 'message_content' %> + <% else %> + <%= link_to l(:button_reply), signin_path %> + <% end %>
    diff --git a/app/views/my/account.html.erb b/app/views/my/account.html.erb index 38f1e3b9f..fc712933c 100644 --- a/app/views/my/account.html.erb +++ b/app/views/my/account.html.erb @@ -61,7 +61,7 @@

    - <%= f.text_field :login, :required => true, :name => "login"%> + <%= f.text_field :login, :required => true, :size => 25, :name => "login"%> <%= l(:label_max_number) %>

    @@ -69,13 +69,13 @@
    diff --git a/app/views/users/index.html.erb b/app/views/users/index.html.erb index 25c1c15c8..65e1bf2f5 100644 --- a/app/views/users/index.html.erb +++ b/app/views/users/index.html.erb @@ -8,8 +8,10 @@ alert("搜索条件不能为空"); return; } + $("#search_user_form").submit(); } +
    @@ -21,8 +23,12 @@ -