|
|
|
@ -17,56 +17,16 @@
|
|
|
|
|
|
|
|
|
|
class WelcomeController < ApplicationController
|
|
|
|
|
caches_action :robots
|
|
|
|
|
before_filter :fake, :only => [:index, :course]
|
|
|
|
|
before_filter :entry_select_course, :entry_select_contest, :entry_select_user, :only => [:index]
|
|
|
|
|
|
|
|
|
|
def index
|
|
|
|
|
# @news = News.latest User.current
|
|
|
|
|
# @projects = Project.latest User.current
|
|
|
|
|
#by young
|
|
|
|
|
(redirect_to(home_url); return) unless Setting.self_registration? || session[:auth_source_registration]
|
|
|
|
|
if request.get?
|
|
|
|
|
session[:auth_source_registration] = nil
|
|
|
|
|
@user = User.new(:language => current_language.to_s)
|
|
|
|
|
else
|
|
|
|
|
user_params = params[:user] || {}
|
|
|
|
|
@user = User.new
|
|
|
|
|
@user.safe_attributes = user_params
|
|
|
|
|
@user.admin = false
|
|
|
|
|
@user.register
|
|
|
|
|
if session[:auth_source_registration]
|
|
|
|
|
@user.activate
|
|
|
|
|
@user.login = session[:auth_source_registration][:login]
|
|
|
|
|
@user.auth_source_id = session[:auth_source_registration][:auth_source_id]
|
|
|
|
|
if @user.save
|
|
|
|
|
session[:auth_source_registration] = nil
|
|
|
|
|
self.logged_user = @user
|
|
|
|
|
flash[:notice] = l(:notice_account_activated)
|
|
|
|
|
redirect_to my_account_path
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
@user.login = params[:user][:login]
|
|
|
|
|
unless user_params[:identity_url].present? && user_params[:password].blank? && user_params[:password_confirmation].blank?
|
|
|
|
|
@user.password, @user.password_confirmation = user_params[:password], user_params[:password_confirmation]
|
|
|
|
|
end
|
|
|
|
|
projectActive = Project.project_entities.active
|
|
|
|
|
@projectCount = projectActive.count
|
|
|
|
|
@projectPublicCount = projectActive.all_public.count
|
|
|
|
|
@projectHidenCount = @projectCount - @projectPublicCount
|
|
|
|
|
|
|
|
|
|
case Setting.self_registration
|
|
|
|
|
when '1'
|
|
|
|
|
register_by_email_activation(@user)
|
|
|
|
|
when '3'
|
|
|
|
|
register_automatically(@user)
|
|
|
|
|
else
|
|
|
|
|
register_manually_by_administrator(@user)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
#add by huang
|
|
|
|
|
# @memberships = @user.memberships.all(:conditions => Project.visible_condition(User.current))
|
|
|
|
|
|
|
|
|
|
# events = Redmine::Activity::Fetcher.new(User.current, :author => @user).events(nil, nil, :limit => 20)
|
|
|
|
|
# @events_by_day = events.group_by(&:event_date)
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
|
@developerCount = User.developer.count
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def robots
|
|
|
|
@ -75,9 +35,9 @@ class WelcomeController < ApplicationController
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def course
|
|
|
|
|
@course = Project.course_entities
|
|
|
|
|
@teacher = User.teacher
|
|
|
|
|
@student = User.student
|
|
|
|
|
@courseCount = Project.course_entities.count
|
|
|
|
|
@teacherCount = User.teacher.count
|
|
|
|
|
@studentCount = User.student.count
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def contest
|
|
|
|
@ -126,9 +86,31 @@ class WelcomeController < ApplicationController
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def entry_select_user
|
|
|
|
|
if request.original_url.match(/user\.trustie\.net/)
|
|
|
|
|
if request.original_url.match(/user\.trustie\.net$/)
|
|
|
|
|
redirect_to(:controller => "users", :action => "index")
|
|
|
|
|
return 0
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def render(*args)
|
|
|
|
|
_fake if @fake_filter
|
|
|
|
|
super
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
|
|
def fake
|
|
|
|
|
@fake_filter = true
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# 骗子方法
|
|
|
|
|
def _fake
|
|
|
|
|
instance_variables.map { |variable|
|
|
|
|
|
if variable.to_s =~ /Count$/
|
|
|
|
|
self.instance_variable_set(variable.to_sym,
|
|
|
|
|
("1" + (self.instance_variable_get(variable.to_sym).to_s)).to_i)
|
|
|
|
|
end
|
|
|
|
|
}
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|