diff --git a/app/controllers/account_controller.rb b/app/controllers/account_controller.rb
index 2c4929019..b5975e452 100644
--- a/app/controllers/account_controller.rb
+++ b/app/controllers/account_controller.rb
@@ -234,7 +234,7 @@ class AccountController < ApplicationController
end
def password_authentication
- user = User.try_to_login(params[:username], params[:password])
+ user, last_login_on = User.try_to_login(params[:username], params[:password])
if user.nil?
invalid_credentials
@@ -244,7 +244,7 @@ class AccountController < ApplicationController
onthefly_creation_failed(user, {:login => user.login, :auth_source_id => user.auth_source_id })
else
# Valid user
- successful_authentication(user)
+ successful_authentication(user, last_login_on)
end
end
@@ -291,7 +291,7 @@ class AccountController < ApplicationController
end
end
- def successful_authentication(user)
+ def successful_authentication(user, last_login_on)
logger.info "Successful authentication for '#{user.login}' from #{request.remote_ip} at #{Time.now.utc}"
# Valid user
self.logged_user = user
@@ -304,13 +304,18 @@ class AccountController < ApplicationController
code = /\d*/
#根据home_url生产正则表达式
eval("code = " + "/^" + home_url.gsub(/\//,"\\\/") + "\\\/*(welcome)?\\\/*(\\\/index\\\/*.*)?\$/")
- if code=~params[:back_url]
+ if code=~params[:back_url] && last_login_on != ''
redirect_to user_activities_path(user)
else
+ if last_login_on == ''
+ redirect_to my_account_url
+ else
#by young
#redirect_back_or_default my_page_path
- redirect_back_or_default User.current
+ #sredirect_back_or_default User.current
+ redirect_to my_account_url
#redirect_to User.current
+ end
end
end
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index 67948a8e1..32cfefa9d 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -124,7 +124,7 @@ class ApplicationController < ActionController::Base
else
# HTTP Basic, either username/password or API key/random
authenticate_with_http_basic do |username, password|
- user = User.try_to_login(username, password) || User.find_by_api_key(username)
+ user = User.try_to_login(username, password)[0] || User.find_by_api_key(username)
end
end
# Switch user if requested by an admin user
@@ -267,6 +267,8 @@ class ApplicationController < ActionController::Base
end
when "contest"
return true
+ when "Course"
+ allowed = User.current.allowed_to?(:course_attachments_download, @course, :global => false)
else
return true
end
diff --git a/app/controllers/attachments_controller.rb b/app/controllers/attachments_controller.rb
index a57b5f8a5..5c3503718 100644
--- a/app/controllers/attachments_controller.rb
+++ b/app/controllers/attachments_controller.rb
@@ -76,7 +76,7 @@ class AttachmentsController < ApplicationController
candown = User.current.member_of?(project) || (project.is_public && @attachment.is_public == 1)
elsif (@attachment.container.has_attribute?(:course) ||@attachment.container.has_attribute?(:course_id) ) && @attachment.container.course
course = @attachment.container.course
- candown= User.current.member_of_course?(course) || (course.is_public==1 && @attachment.is_public == 1)
+ candown = User.current.member_of_course?(course) || (course.is_public==1 && @attachment.is_public == 1)
elsif @attachment.container.is_a?(Course)
course = @attachment.container
candown= User.current.member_of_course?(course) || (course.is_public==1 && @attachment.is_public == 1)
@@ -366,7 +366,7 @@ class AttachmentsController < ApplicationController
end
rescue NoMethodError
@save_flag = false
- @save_message = [] << l(:error_attachment_empty)
+ @save_message = [] << l(:label_course_empty_select)
respond_to do |format|
format.js
end
diff --git a/app/controllers/contests_controller.rb b/app/controllers/contests_controller.rb
index 833711e3e..627e1945b 100644
--- a/app/controllers/contests_controller.rb
+++ b/app/controllers/contests_controller.rb
@@ -37,6 +37,7 @@ class ContestsController < ApplicationController
def index
+ render_404
# @contests = Contest.visible
# @contests ||= []
@offset, @limit = api_offset_and_limit(:limit => 10)
diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb
index edfc893d8..bd389ff68 100644
--- a/app/controllers/courses_controller.rb
+++ b/app/controllers/courses_controller.rb
@@ -427,6 +427,7 @@ class CoursesController < ApplicationController
end
def index
+ render_404
@course_type = params[:course_type]
@school_id = params[:school_id]
per_page_option = 10
@@ -474,7 +475,7 @@ class CoursesController < ApplicationController
respond_to do |format|
format.html {
- render :layout => 'base'
+ # render :layout => 'base'
}
format.atom {
courses = Course.visible.order('created_on DESC').limit(Setting.feeds_limit.to_i).all
diff --git a/app/controllers/files_controller.rb b/app/controllers/files_controller.rb
index ca7f8e040..251496e30 100644
--- a/app/controllers/files_controller.rb
+++ b/app/controllers/files_controller.rb
@@ -26,13 +26,15 @@ class FilesController < ApplicationController
helper :sort
include SortHelper
+ include FilesHelper
helper :project_score
def show_attachments obj
- @all_attachments = []
+ @attachments = []
obj.each do |container|
- @all_attachments += container.attachments
+ @attachments += container.attachments
end
+ @all_attachments = visable_attachemnts(@attachments)
@limit = 10
@feedback_count = @all_attachments.count
@feedback_pages = Paginator.new @feedback_count, @limit, params['page']
@@ -48,9 +50,11 @@ class FilesController < ApplicationController
#(redirect_to stores_url, :notice => l(:label_sumbit_empty);return) if params[:name].blank?
if params[:insite]
@result = find_public_attache q
+ @result = visable_attachemnts @result
@searched_attach = paginateHelper @result,10
else
@result = find_course_attache q,@course
+ @result = visable_attachemnts @result
@searched_attach = paginateHelper @result,10
end
diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb
index b3efdcf97..0b7cbbb5f 100644
--- a/app/controllers/projects_controller.rb
+++ b/app/controllers/projects_controller.rb
@@ -105,6 +105,7 @@ class ProjectsController < ApplicationController
end
def index
+ render_404
#调用存储过程更新提交次数
#ActiveRecord::Base.connection.execute("CALL sp_project_status_cursor();")
#Modified by nie
@@ -156,8 +157,8 @@ class ProjectsController < ApplicationController
respond_to do |format|
- format.html {
- render :layout => 'base'
+ format.html {
+ # render :layout => 'base'
# scope = Project
# unless params[:closed]
# scope = scope.active
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
index b466e4721..0db7facbc 100644
--- a/app/controllers/users_controller.rb
+++ b/app/controllers/users_controller.rb
@@ -295,6 +295,7 @@ class UsersController < ApplicationController
#end
def index
+
@status = params[:status] || 1
sort_init 'login', 'asc'
sort_update %w(login firstname lastname mail admin created_on last_login_on)
@@ -352,7 +353,8 @@ class UsersController < ApplicationController
respond_to do |format|
format.html {
@groups = Group.all.sort
- render :layout => @user_base_tag
+ # render :layout => @user_base_tag
+ render_404
}
format.api
end
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index 1d528c183..9c5d8c9b5 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -1830,12 +1830,11 @@ module ApplicationHelper
main_project_link = link_to l(:label_project_deposit), {:controller => 'welcome', :action => 'index', :host => Setting.project_domain}
main_contest_link = link_to l(:label_contest_innovate), {:controller => 'welcome', :action => 'index', :host => Setting.contest_domain}
- course_all_course_link = link_to l(:label_course_all), {:controller => 'courses', :action => 'index'}
+ # course_all_course_link = link_to l(:label_course_all), {:controller => 'courses', :action => 'index'}
course_teacher_all_link = link_to l(:label_teacher_all), {:controller => 'users', :action => 'index', :role => 'teacher', :host => Setting.course_domain}
- courses_link = link_to l(:label_course_practice), {:controller => 'courses', :action => 'index'}
- projects_link = link_to l(:label_project_deposit), {:controller => 'projects', :action => 'index', :project_type => 0, :host => Setting.project_domain}
+ # courses_link = link_to l(:label_course_practice), {:controller => 'courses', :action => 'index'}
users_link = link_to l(:label_software_user), {:controller => 'users', :action => 'index', :host => Setting.user_domain}
- contest_link = link_to l(:label_contest_innovate), {:controller => 'contests', :action => 'index'}
+ # contest_link = link_to l(:label_contest_innovate), {:controller => 'contests', :action => 'index'}
bids_link = link_to l(:label_requirement_enterprise), {:controller => 'bids', :action => 'index'}
forum_link = link_to l(:label_project_module_forums), {:controller => "forums", :action => "index"}
stores_link = link_to l(:label_stores_index), {:controller => 'stores', :action=> 'index'}
@@ -1844,7 +1843,7 @@ module ApplicationHelper
#@nav_dispaly_project_label
nav_list = Array.new
nav_list.push(school_all_school_link) if @nav_dispaly_course_all_label && @show_course == 1
- nav_list.push(course_all_course_link) if @nav_dispaly_course_all_label && @show_course == 1
+ # nav_list.push(course_all_course_link) if @nav_dispaly_course_all_label && @show_course == 1
nav_list.push(course_teacher_all_link) if @nav_dispaly_teacher_all_label && @show_course == 1
nav_list.push(main_project_link) if @nav_dispaly_main_project_label
@@ -1852,9 +1851,9 @@ module ApplicationHelper
nav_list.push(main_contest_link) if @nav_dispaly_main_contest_label && @show_contest == 1
nav_list.push(courses_link) if @nav_dispaly_course_label && @show_course == 1
- nav_list.push(projects_link) if @nav_dispaly_project_label
+ # nav_list.push(projects_link) if @nav_dispaly_project_label
nav_list.push(users_link) if @nav_dispaly_user_label
- nav_list.push(contest_link) if @nav_dispaly_contest_label && @show_contest == 1
+ # nav_list.push(contest_link) if @nav_dispaly_contest_label && @show_contest == 1
nav_list.push(bids_link) if @nav_dispaly_bid_label
nav_list.push(forum_link) if @nav_dispaly_forum_label
nav_list.push(stores_link) if @nav_dispaly_store_all_label
diff --git a/app/helpers/files_helper.rb b/app/helpers/files_helper.rb
index 9a0a1127f..cd7603c65 100644
--- a/app/helpers/files_helper.rb
+++ b/app/helpers/files_helper.rb
@@ -44,10 +44,10 @@ module FilesHelper
File.new(zipfile_name,'w+')
end
- def courses_check_box_tags(name,courses,current_course)
+ def courses_check_box_tags(name,courses,current_course,attachment)
s = ''
courses.each do |course|
- if course.id != current_course.id && is_course_teacher(User.current,course)
+ if !(attachment.container_type && attachment.container_id == course.id) && is_course_teacher(User.current,course)
s << "
"
end
end
@@ -72,5 +72,20 @@ module FilesHelper
result
end
+ def visable_attachemnts attachments
+ result = []
+ attachments.each do |attachment|
+ if attachment.is_public? || attachment.author_id == User.current.id
+ result << attachment
+ end
+ end
+ result
+ end
+ def get_qute_number attachment
+ if attachment.copy_from.nil?
+ return 0
+ end
+ count = Attachment.find_by_sql("select count(*) from attachments where copy_from = #{attachment.copy_from}")
+ end
end
\ No newline at end of file
diff --git a/app/models/role.rb b/app/models/role.rb
index 57fccd53c..f363b52bf 100644
--- a/app/models/role.rb
+++ b/app/models/role.rb
@@ -161,7 +161,7 @@ class Role < ActiveRecord::Base
if action.is_a? Hash
allowed_actions.include? "#{action[:controller]}/#{action[:action]}"
else
- allowed_permissions.include? action
+ allowed_permissions.include? action
end
end
diff --git a/app/models/user.rb b/app/models/user.rb
index ff627763a..fe6222359 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -230,7 +230,12 @@ class User < Principal
#选择项目成员时显示的用户信息文字
def userInfo
- info=self.nickname + ' (' + self.realname + ')';
+ if self.realname.gsub(' ','') == "" || self.realname.nil?
+ info = self.nickname;
+ else
+ info=self.nickname + ' (' + self.realname + ')';
+ end
+ info
end
###添加留言 fq
@@ -359,8 +364,9 @@ class User < Principal
end
end
end
+ last_login_on = user.last_login_on.nil? ? '' : user.last_login_on.to_s
user.update_column(:last_login_on, Time.now) if user && !user.new_record?
- user
+ [user, last_login_on]
rescue => text
raise text
end
diff --git a/app/views/account/email_valid.html.erb b/app/views/account/email_valid.html.erb
index 6f4de1197..c77c0294e 100644
--- a/app/views/account/email_valid.html.erb
+++ b/app/views/account/email_valid.html.erb
@@ -11,7 +11,7 @@
@@ -33,12 +34,7 @@ padding: 10px 16px; line-height: 1.33;" target="_blank">立即查收邮件
- - 没收到邮件? - -<%= f.text_field :login, :size => 25, :required => true %> <%= l(:label_max_number) %>
-<%= f.password_field :password, :size => 25, :required => true %> +
<%= f.password_field :password, :size => 25, :required => true %> <%= l(:text_caracters_minimum, :count => Setting.password_min_length) %>
<%= f.password_field :password_confirmation, :size => 25, :required => true %>
@@ -56,10 +56,12 @@<%= custom_field_tag_with_label :user, value %>
<% end %>共有 <%= User.current.member_of_course?(course) ? all_attachments.count : 0 %> 个资源
- + <#% end %>--> + 资源列表的多样化排序将在下周上线... +文件大小:<%= number_to_human_size(file.filesize) %>
+文件大小:<%= number_to_human_size(file.filesize) %>
<%= link_to( l(:button_delete), attachment_path(file), - :data => {:confirm => l(:text_are_you_sure)}, :method => :delete,:class => "f_r re_de") if delete_allowed %> -<%= time_tag(file.created_on).html_safe %><%= l(:label_bids_published_ago) %> | 下载<%= file.downloads %> | 引用0
+ :data => {:confirm => l(:text_are_you_sure)}, :method => :delete,:class => "f_r re_de") if delete_allowed && file.container_id == @course.id && file.container_type == "Course"%> +<%= time_tag(file.created_on).html_safe %><%= l(:label_bids_published_ago) %> | 下载<%= file.downloads %>
<%= link_to "主页", home_path %> - > <%= link_to l(:label_course_all), :controller => 'courses', :action => 'index' %> + > <%=l(:label_courses_management_platform)%> > <%= link_to @course.name, nil %>
<%=link_to l(:label_home),home_path %> > <%=link_to l(:label_project_deposit),:controller => 'projects', :action => 'index', :project_type => 0 %> > <%=link_to @project, project_path(@project) %>
<%=link_to l(:label_home),home_path %> > <%=link_to @project, project_path(@project) %>
- <%= f.text_field :login, :required => true, :size => 25, :name => "login", :readonly => true %>
+ <%= f.text_field :login, :required => true, :size => 25, :name => "login", :readonly => true, :style => 'border:1px solid #d3d3d3;'%>
<%= l(:label_max_number) %>