This commit is contained in:
zhuhao 2014-11-24 15:28:13 +08:00
commit da9773e139
9 changed files with 1996 additions and 2170 deletions

View File

@ -66,7 +66,7 @@ class AccountController < ApplicationController
if @user.save if @user.save
@token.destroy @token.destroy
flash[:notice] = l(:notice_account_password_updated) flash[:notice] = l(:notice_account_password_updated)
redirect_to signin_path redirect_to signin_url
return return
end end
end end
@ -92,7 +92,7 @@ class AccountController < ApplicationController
Mailer.lost_password(token).deliver Mailer.lost_password(token).deliver
end end
flash[:notice] = l(:notice_account_lost_email_sent) flash[:notice] = l(:notice_account_lost_email_sent)
redirect_to signin_path redirect_to signin_url
return return
end end
end end
@ -103,7 +103,7 @@ class AccountController < ApplicationController
def register def register
# @root_path="/home/pdl/redmine-2.3.2-0/apache2/" # @root_path="/home/pdl/redmine-2.3.2-0/apache2/"
# #
@cache_identityy = params[:identity]||"" #身份 #@cache_identityy = params[:identity]||"" #身份
@cache_no = params[:no]||"" #学号 @cache_no = params[:no]||"" #学号
@cache_technical_title = params[:technical_title]||"" #教师职称 @cache_technical_title = params[:technical_title]||"" #教师职称
@cache_province = params[:province]||"" #省份 @cache_province = params[:province]||"" #省份
@ -144,22 +144,7 @@ class AccountController < ApplicationController
@user.password, @user.password_confirmation = user_params[:password], user_params[:password_confirmation] @user.password, @user.password_confirmation = user_params[:password], user_params[:password_confirmation]
end end
if(@cache_identityy == "")
if params[:identity] == "2"
@user.firstname = firstname_code
@user.lastname = lastname_code
end
flash.now[:error]= l(:label_identity)+l(:'activerecord.errors.messages.empty')
return
end
if(@cache_city == "")
if params[:identity] == "2"
@user.firstname = firstname_code
@user.lastname = lastname_code
end
flash.now[:error]= l(:label_location)+l(:'activerecord.errors.messages.empty')
return
end
case Setting.self_registration case Setting.self_registration
when '1' when '1'
@ -204,7 +189,7 @@ class AccountController < ApplicationController
token.destroy token.destroy
flash[:notice] = l(:notice_account_activated) flash[:notice] = l(:notice_account_activated)
end end
redirect_to signin_path redirect_to signin_url
end end
def valid_ajax def valid_ajax
@ -234,6 +219,10 @@ class AccountController < ApplicationController
render :json => req render :json => req
end end
def email_valid
end
private private
def authenticate_user def authenticate_user
@ -245,7 +234,7 @@ class AccountController < ApplicationController
end end
def password_authentication 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? if user.nil?
invalid_credentials invalid_credentials
@ -255,7 +244,7 @@ class AccountController < ApplicationController
onthefly_creation_failed(user, {:login => user.login, :auth_source_id => user.auth_source_id }) onthefly_creation_failed(user, {:login => user.login, :auth_source_id => user.auth_source_id })
else else
# Valid user # Valid user
successful_authentication(user) successful_authentication(user, last_login_on)
end end
end end
@ -302,7 +291,7 @@ class AccountController < ApplicationController
end end
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}" logger.info "Successful authentication for '#{user.login}' from #{request.remote_ip} at #{Time.now.utc}"
# Valid user # Valid user
self.logged_user = user self.logged_user = user
@ -315,13 +304,18 @@ class AccountController < ApplicationController
code = /\d*/ code = /\d*/
#根据home_url生产正则表达式 #根据home_url生产正则表达式
eval("code = " + "/^" + home_url.gsub(/\//,"\\\/") + "\\\/*(welcome)?\\\/*(\\\/index\\\/*.*)?\$/") 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) redirect_to user_activities_path(user)
else else
if last_login_on == ''
redirect_to my_account_url
else
#by young #by young
#redirect_back_or_default my_page_path #redirect_back_or_default my_page_path
redirect_back_or_default User.current redirect_back_or_default User.current
#redirect_to my_account_url
#redirect_to User.current #redirect_to User.current
end
end end
end end
@ -363,7 +357,7 @@ class AccountController < ApplicationController
UserStatus.create(:user_id => user.id, :changsets_count => 0, :watchers_count => 0) UserStatus.create(:user_id => user.id, :changsets_count => 0, :watchers_count => 0)
Mailer.register(token).deliver Mailer.register(token).deliver
flash[:notice] = l(:notice_account_register_done) flash[:notice] = l(:notice_account_register_done)
redirect_to signin_path render action: 'email_valid', locals: {:mail => user.mail}
else else
yield if block_given? yield if block_given?
end end
@ -380,7 +374,7 @@ class AccountController < ApplicationController
UserStatus.create(:user_id => user.id, :changsets_count => 0, :watchers_count => 0) UserStatus.create(:user_id => user.id, :changsets_count => 0, :watchers_count => 0)
self.logged_user = user self.logged_user = user
flash[:notice] = l(:notice_account_activated) flash[:notice] = l(:notice_account_activated)
redirect_to my_account_path redirect_to my_account_url
else else
yield if block_given? yield if block_given?
end end
@ -402,6 +396,6 @@ class AccountController < ApplicationController
def account_pending def account_pending
flash[:notice] = l(:notice_account_pending) flash[:notice] = l(:notice_account_pending)
redirect_to signin_path redirect_to signin_url
end end
end end

View File

@ -124,7 +124,7 @@ class ApplicationController < ActionController::Base
else else
# HTTP Basic, either username/password or API key/random # HTTP Basic, either username/password or API key/random
authenticate_with_http_basic do |username, password| 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
end end
# Switch user if requested by an admin user # Switch user if requested by an admin user

View File

@ -64,7 +64,7 @@ class AttachmentsController < ApplicationController
# modify by nwb # modify by nwb
# 下载添加权限设置 # 下载添加权限设置
candown = false candown = false
if (@attachment.container.has_attribute?(:project) || @attachment.container.has_attribute?(:project_id)) && @attachment.container.project if @attachment.container.class.to_s != "HomeworkAttach" &&(@attachment.container.has_attribute?(:project) || @attachment.container.has_attribute?(:project_id)) && @attachment.container.project
project = @attachment.container.project project = @attachment.container.project
candown= User.current.member_of?(project) || (project.is_public && @attachment.is_public == 1) candown= User.current.member_of?(project) || (project.is_public && @attachment.is_public == 1)
elsif @attachment.container.is_a?(Project) elsif @attachment.container.is_a?(Project)
@ -89,7 +89,6 @@ class AttachmentsController < ApplicationController
elsif @attachment.container_type == "Bid" && @attachment.container && @attachment.container.courses elsif @attachment.container_type == "Bid" && @attachment.container && @attachment.container.courses
candown = User.current.member_of_course?(@attachment.container.courses.first) || (course.is_public == 1 && @attachment.is_public == 1) candown = User.current.member_of_course?(@attachment.container.courses.first) || (course.is_public == 1 && @attachment.is_public == 1)
else else
candown = @attachment.is_public == 1 candown = @attachment.is_public == 1
end end
if candown || User.current.admin? || User.current.id == @attachment.author_id if candown || User.current.admin? || User.current.id == @attachment.author_id

File diff suppressed because it is too large Load Diff

View File

@ -1,76 +1,95 @@
<% @nav_dispaly_home_path_label = 1 <% @nav_dispaly_home_path_label = 1
@nav_dispaly_main_course_label = 1 @nav_dispaly_main_course_label = 1
@nav_dispaly_main_project_label = 1 @nav_dispaly_main_project_label = 1
@nav_dispaly_main_contest_label = 1 %> @nav_dispaly_main_contest_label = 1 %>
<% @nav_dispaly_forum_label = 1%> <% @nav_dispaly_forum_label = 1%>
<%= call_hook :view_account_login_top %> <%= call_hook :view_account_login_top %>
<script type="text/javascript" language="javascript"> <script type="text/javascript" language="javascript">
function clearInfo(id, content) { function clearInfo(id, content) {
var text = $('#' + id); var text = $('#' + id);
if (text.val() == content) { if (text.val() == content) {
$('#' + id).val(''); $('#' + id).val('');
} }
} }
function showInfo(id, content) { function showInfo(id, content) {
var text = $('#' + id); var text = $('#' + id);
if (text.val() == '') { if (text.val() == '') {
$('#' + id).val(content); $('#' + id).val(content);
} }
} }
</script> </script>
<div id="login-form"> <div id="login-form">
<%= form_tag(signin_path) do %> <%= form_tag(signin_path) do %>
<%= back_url_hidden_field_tag %> <%= back_url_hidden_field_tag %>
<table> <table>
<tr> <tr>
<td align="right"><label for="username"><%=l(:lable_user_name)%>:</label></td> <td align="right">
<td align="left"> <label for="username">
<%= text_field_tag 'username', params[:username], :tabindex => '1' , :value => "#{l(:label_login_prompt)}", <%=l(:lable_user_name)%>:
:onfocus => "clearInfo('username','#{l(:label_login_prompt)}')", </label>
:onblur => "showInfo('username','#{l(:label_login_prompt)}')", </td>
:style => "resize: none;font-size: 12px;color: #818283;"%> <td align="left">
</td> <%= text_field_tag 'username', params[:username], :tabindex => '1' , :value => "#{l(:label_login_prompt)}",
</tr> :onfocus => "clearInfo('username','#{l(:label_login_prompt)}')",
<tr> :onblur => "showInfo('username','#{l(:label_login_prompt)}')",
<td align="right"><label for="password"><%=l(:field_password)%>:</label></td> :style => "resize: none;font-size: 12px;color: #818283;"%>
<td align="left"><%= password_field_tag 'password', nil, :tabindex => '2' %></td> </td>
</tr> </tr>
<% if Setting.openid? %> <tr>
<tr> <td align="right">
<td align="right"><label for="openid_url"><%=l(:field_identity_url)%></label></td> <label for="password">
<td align="left"><%= text_field_tag "openid_url", nil, :tabindex => '3' %></td> <%=l(:field_password)%>:
</tr> </label>
<% end %> </td>
<tr> <td align="left">
<td></td> <%= password_field_tag 'password', nil, :tabindex => '2' %>
<td align="left"> </td>
<% if Setting.autologin? %> </tr>
<label for="autologin"><%= check_box_tag 'autologin', 1, false, :tabindex => 4 %> <%= l(:label_stay_logged_in) %></label> <% if Setting.openid? %>
<% end %> <tr>
</td> <td align="right">
</tr> <label for="openid_url">
<tr> <%=l(:field_identity_url)%>
<td colspan="2" > </label>
</td>
<span style="float: left"><% if Setting.lost_password? %> <td align="left">
<%= link_to l(:label_password_lost), lost_password_path %> <%= text_field_tag "openid_url", nil, :tabindex => '3' %>
<% end %></span> </td>
</tr>
<span style="float: right"> <% end %>
<input type="submit" class="small" name="login" value="<%=l(:button_login)%> &#187;" tabindex="5"/></span> <tr>
<td></td>
</td> <td align="left">
</tr> <% if Setting.autologin? %>
</table> <label for="autologin">
<% end %> <%= check_box_tag 'autologin', 1, false, :tabindex => 4 %>
</div> <%= l(:label_stay_logged_in) %>
<%= call_hook :view_account_login_bottom %> </label>
<% end %>
<% if params[:username].present? %> </td>
<%= javascript_tag "$('#password').focus();" %> </tr>
<% else %> <tr>
<%= javascript_tag "$('#username').focus();" %> <td colspan="2" >
<% end %>
<span style="float: left">
<% if Setting.lost_password? %>
<%= link_to l(:label_password_lost), lost_password_path %>
<% end %></span>
<span style="float: right">
<input type="submit" class="small" name="login" value="<%=l(:button_login)%> &#187;" tabindex="5"/></span>
</td>
</tr>
</table>
<% end %>
</div>
<%= call_hook :view_account_login_bottom %>
<% if params[:username].present? %>
<%= javascript_tag "$('#password').focus();" %>
<% else %>
<%= javascript_tag "$('#username').focus();" %>
<% end %>

View File

@ -1,490 +1,127 @@
<% @nav_dispaly_home_path_label = 1 <% @nav_dispaly_home_path_label = 1
@nav_dispaly_main_course_label = 1 @nav_dispaly_main_course_label = 1
@nav_dispaly_main_project_label = 1 @nav_dispaly_main_project_label = 1
@nav_dispaly_main_contest_label = 1 %> @nav_dispaly_main_contest_label = 1 %>
<% @nav_dispaly_forum_label = 1%> <% @nav_dispaly_forum_label = 1%>
<!-- added by bai 增加地区-->
<script type="text/javascript" language="javascript">
function showcity(province, cityField) {
switch (province) {
case "北京" : <!-- end -->
var cityOptions = new Array(
"东城", "西城", "朝阳", "丰台", "石景山", "海淀", "门头沟", <h3><%= l(:label_register) %> <%= link_to l(:label_login_with_open_id_option), signin_url if Setting.openid? %></h3>
"房山", "通州", "顺义", "昌平", "大兴", "平谷", "怀柔", "密云", "延庆");
break; <%= labelled_form_for @user, :url => register_path do |f| %>
case "上海" : <%= error_messages_for 'user' %>
var cityOptions = new Array( <div class="box tabular">
"崇明", "黄浦", "卢湾", "徐汇", "长宁", "静安", "普陀", "闸北", "虹口", "杨浦", "闵行",
"宝山", "嘉定", "浦东", "金山", "松江", "青浦", "南汇", "奉贤"); <% if @user.auth_source_id.nil? %>
break; <p><%= f.text_field :login, :size => 25, :required => true %><span id="valid_user_login"></span>
case "广东" : <em class="info" style="color: #acaeb1"><%= l(:label_max_number) %></em>
var cityOptions = new Array( </p>
"广州", "深圳", "珠海", "东莞", "中山", "佛山", "惠州", "河源", "潮州", "江门", "揭阳", "茂名", <p><%= f.password_field :password, :size => 25, :required => true %><span id="valid_user_password"></span>
"梅州", "清远", "汕头", "汕尾", "韶关", "顺德", "阳江", "云浮", "湛江", "肇庆"); <em class="info" style="color: #acaeb1"><%= l(:text_caracters_minimum, :count => Setting.password_min_length) %></em>
break; </p>
case "江苏" : <p><%= f.password_field :password_confirmation, :size => 25, :required => true %><span id="valid_password" style="padding-left: 10px;"></span></p>
var cityOptions = new Array( <% end %>
"南京", "常熟", "常州", "海门", "淮安", "江都", "江阴", "昆山", "连云港", "南通",
"启东", "沭阳", "宿迁", "苏州", "太仓", "泰州", "同里", "无锡", "徐州", "盐城", <p>
"扬州", "宜兴", "仪征", "张家港", "镇江", "周庄"); <%= f.text_field :mail,:size => 25, :required => true %>
break; <span id="valid_user_mail" ></span>
case "重庆" : </p>
var cityOptions = new Array( <p>
"万州", "涪陵", "渝中", "大渡口", "江北", "沙坪坝", "九龙坡", "南岸", "北碚", "万盛", <em class="info" style="color: #acaeb1">
"双挢", "渝北", "巴南", "黔江", "长寿", "綦江", "潼南", "铜梁", "大足", "荣昌", "壁山", <p><%= "#{l(:label_mail_attention)} " %></p>
"梁平", "城口", "丰都", "垫江", "武隆", "忠县", "开县", "云阳", "奉节", "巫山", "巫溪", <p><%= "#{l(:label_mail_attention1)} " %></p>
"石柱", "秀山", "酉阳", "彭水", "江津", "合川", "永川", "南川"); </em>
break; </p>
case "安徽" :
var cityOptions = new Array(
"合肥", "安庆", "蚌埠", "亳州", "巢湖", "滁州", "阜阳", "贵池", "淮北", "淮化", "淮南",
"黄山", "九华山", "六安", "马鞍山", "宿州", "铜陵", "屯溪", "芜湖", "宣城"); <!-- end -->
break; </div>
case "福建" :
var cityOptions = new Array( <p>
"福州", "厦门", "泉州", "漳州", "龙岩", "南平", "宁德", "莆田", "三明"); <table>
break; <tr>
case "甘肃" : <td><%= submit_tag l(:button_submit) %></td>
var cityOptions = new Array( </tr>
"兰州", "白银", "定西", "敦煌", "甘南", "金昌", "酒泉", "临夏", "平凉", "天水", </table>
"武都", "武威", "西峰", "张掖"); </p>
break; <% end %>
case "广西" : <% if Setting.openid? %>
var cityOptions = new Array( <p><%= f.text_field :identity_url %></p>
"南宁", "百色", "北海", "桂林", "防城港", "贵港", "河池", "贺州", "柳州", "钦州", "梧州", "玉林"); <% end %>
break; <% @user.custom_field_values.select { |v| v.editable? || v.required? }.each do |value| %>
case "贵州" : <p><%= custom_field_tag_with_label :user, value %></p>
var cityOptions = new Array( <% end %>
"贵阳", "安顺", "毕节", "都匀", "凯里", "六盘水", "铜仁", "兴义", "玉屏", "遵义"); </div>
break; <% password_min_length = Setting.password_min_length %>
case "海南" : <script type="text/javascript">
var cityOptions = new Array( jQuery(document).ready(function () {
"海口", "儋县", "陵水", "琼海", "三亚", "通什", "万宁"); var $login = $('#user_login')
break; var $mail = $('#user_mail')
case "河北" : var $password = $('#user_password')
var cityOptions = new Array( var $password_confirmation = $('#user_password_confirmation')
"石家庄", "保定", "北戴河", "沧州", "承德", "丰润", "邯郸", "衡水", "廊坊", "南戴河", "秦皇岛", $login.blur(function (event) {
"唐山", "新城", "邢台", "张家口"); if ($(this).is('#user_login')) {
break; $.get(
case "黑龙江" : '<%=account_valid_ajax_path%>',
var cityOptions = new Array( { valid: "login",
"哈尔滨", "北安", "大庆", "大兴安岭", "鹤岗", "黑河", "佳木斯", "鸡西", "牡丹江", "齐齐哈尔", value: this.value },
"七台河", "双鸭山", "绥化", "伊春"); function (data) {
break; if (data.valid) {
case "河南" : $('#valid_user_login').html('<span class="green">' + data.message + "</span>");
var cityOptions = new Array( } else {
"郑州", "安阳", "鹤壁", "潢川", "焦作", "济源", "开封", "漯河", "洛阳", "南阳", "平顶山", $('#valid_user_login').html('<span class="red">' + data.message + "</span>");
"濮阳", "三门峡", "商丘", "新乡", "信阳", "许昌", "周口", "驻马店"); }
break; });
case "香港" : }
var cityOptions = new Array( ;
"香港", "九龙", "新界"); });
break;
case "湖北" : $mail.blur(function (event) {
var cityOptions = new Array( if ($(this).is('#user_mail')) {
"武汉", "恩施", "鄂州", "黄冈", "黄石", "荆门", "荆州", "潜江", "十堰", "随州", "武穴", $.get('<%=account_valid_ajax_path%>',
"仙桃", "咸宁", "襄阳", "襄樊", "孝感", "宜昌"); { valid: "mail",
break; value: this.value },
case "湖南" : function (data) {
var cityOptions = new Array( if (data.valid) {
"长沙", "常德", "郴州", "衡阳", "怀化", "吉首", "娄底", "邵阳", "湘潭", "益阳", "岳阳", $('#valid_user_mail').html('<span class="green">' + data.message + "</span>");
"永州", "张家界", "株洲"); } else {
break; $('#valid_user_mail').html('<span class="red">' + data.message + "</span>");
case "江西" : }
var cityOptions = new Array( });
"南昌", "抚州", "赣州", "吉安", "景德镇", "井冈山", "九江", "庐山", "萍乡", }
"上饶", "新余", "宜春", "鹰潭"); ;
break; });
case "吉林" : $password.blur(function () {
var cityOptions = new Array( var pas1 = document.getElementById("user_password").value;
"长春", "吉林", "白城", "白山", "珲春", "辽源", "梅河", "四平", "松原", "通化", "延吉"); var password_min_length = <%= password_min_length %>
break; if (pas1.length >= password_min_length) {
case "辽宁" :
var cityOptions = new Array( $('#valid_user_password').html('<span class="green">'+ "</span>");
"沈阳", "鞍山", "本溪", "朝阳", "大连", "丹东", "抚顺", "阜新", "葫芦岛", "锦州", }
"辽阳", "盘锦", "铁岭", "营口"); else {
break; $('#valid_user_password').html('<span class="red">' + "<%= l(:setting_password_min_length_limit, :count => password_min_length) %>" + "</span>");
case "澳门" : }
var cityOptions = new Array("澳门");
break;
case "内蒙古" :
var cityOptions = new Array( });
"呼和浩特", "阿拉善盟", "包头", "赤峰", "东胜", "海拉尔", "集宁", "临河", "通辽", "乌海", $password_confirmation.blur(function () {
"乌兰浩特", "锡林浩特"); var password_min_length = <%= password_min_length %>
break; var pas1 = document.getElementById("user_password").value;
case "宁夏" : var pas2 = document.getElementById("user_password_confirmation").value;
var cityOptions = new Array( if (pas1.length >= password_min_length && pas1 == pas2 ) {
"银川", "固源", "石嘴山", "吴忠"); $('#valid_password').html('<span class="green">' + "<%= l(:setting_password_success) %>"+ "</span>");
break; }
case "青海" : else {
var cityOptions = new Array( $('#valid_password').html('<span class="red">' + "<%= l(:setting_password_error) %>" + "</span>");
"西宁", "德令哈", "格尔木", "共和", "海东", "海晏", "玛沁", "同仁", "玉树"); }
break;
case "山东" :
var cityOptions = new Array(
"济南", "滨州", "兖州", "德州", "东营", "菏泽", "济宁", "莱芜", "聊城", "临沂", });
"蓬莱", "青岛", "曲阜", "日照", "泰安", "潍坊", "威海", "烟台", "枣庄", "淄博"); });
break;
case "山西" :
var cityOptions = new Array(
"太原", "长治", "大同", "候马", "晋城", "离石", "临汾", "宁武", "朔州", "忻州",
"阳泉", "榆次", "运城");
break;
case "陕西" :
var cityOptions = new Array(
"西安", "安康", "宝鸡", "汉中", "渭南", "商州", "绥德", "铜川", "咸阳", "延安", "榆林");
break;
case "四川" :
var cityOptions = new Array(
"成都", "巴中", "达川", "德阳", "都江堰", "峨眉山", "涪陵", "广安", "广元", "九寨沟",
"康定", "乐山", "泸州", "马尔康", "绵阳", "眉山", "南充", "内江", "攀枝花", "遂宁",
"汶川", "西昌", "雅安", "宜宾", "自贡", "资阳");
break;
case "台湾" :
var cityOptions = new Array(
"台北", "基隆", "台南", "台中", "高雄", "屏东", "南投", "云林", "新竹", "彰化", "苗栗",
"嘉义", "花莲", "桃园", "宜兰", "台东", "金门", "马祖", "澎湖");
break;
case "天津" :
var cityOptions = new Array(
"天津", "和平", "东丽", "河东", "西青", "河西", "津南", "南开", "北辰", "河北", "武清", "红挢",
"塘沽", "汉沽", "大港", "宁河", "静海", "宝坻", "蓟县");
break;
case "新疆" :
var cityOptions = new Array(
"乌鲁木齐", "阿克苏", "阿勒泰", "阿图什", "博乐", "昌吉", "东山", "哈密", "和田", "喀什",
"克拉玛依", "库车", "库尔勒", "奎屯", "石河子", "塔城", "吐鲁番", "伊宁");
break;
case "西藏" :
var cityOptions = new Array(
"拉萨", "阿里", "昌都", "林芝", "那曲", "日喀则", "山南");
break;
case "云南" :
var cityOptions = new Array(
"昆明", "大理", "保山", "楚雄", "大理", "东川", "个旧", "景洪", "开远", "临沧", "丽江",
"六库", "潞西", "曲靖", "思茅", "文山", "西双版纳", "玉溪", "中甸", "昭通");
break;
case "浙江" :
var cityOptions = new Array(
"杭州", "安吉", "慈溪", "定海", "奉化", "海盐", "黄岩", "湖州", "嘉兴", "金华", "临安",
"临海", "丽水", "宁波", "瓯海", "平湖", "千岛湖", "衢州", "江山", "瑞安", "绍兴", "嵊州",
"台州", "温岭", "温州", "余姚", "舟山");
break;
case "海外" :
var cityOptions = new Array(
"美国", "日本", "英国", "法国", "德国", "其他");
break;
default:
var cityOptions = new Array("");
break;
}
cityField.options.length = 0;
for (var i = 0; i < cityOptions.length; i++) {
cityField.options[i] = new Option(cityOptions[i], cityOptions[i]);
/*
if (cityField.options[i].value==city)
{
//alert("here put City ok!");
document.oblogform["city"].selectedIndex = i;
}*/
}
}
</script>
<script type="text/javascript" language="javascript">
window.onload = function(){
var identity = "<%= @cache_identityy %>";
var no = "<%= @cache_no %>";
var technical_title = "<%= @cache_technical_title %>";
var province = "<%= @cache_province %>";
var city = "<%= @cache_city %>";
var enterprise_name = "<%= @cache_enterprise_name %>";
//还原身份
if(identity!=null&&identity!=""){
$('#userIdentity').children("option[value='"+identity+"']").attr("selected","selected");
showtechnical_title(identity, document.getElementById('userTechnical_title'));
if(identity=="0"){
//还原教师职称
$('#userTechnical_title').children("option[value='"+technical_title+"']").attr("selected","selected");
}else if(identity=="1"){
//还原学号
$("input[id='no']").attr("value",no);
}
}
//还原地区
if(province!=null&&province!=""){
$("#userProvince").children("option[value='"+province+"']").attr("selected","selected");
showcity(province, document.getElementById('userCity'));
$("select[id='userCity']").children("option[value='"+city+"']").attr("selected","selected");
}
//还原企业名
if(enterprise_name!=null&&enterprise_name!=""){
$("input[id='enterprise_name']").attr("value",enterprise_name);
}
}
function showtechnical_title(identity, technical_titleField) {
var technical_titleOptions = null;
switch (identity) {
case '0' :
$('#technical_title').show()
$('#no').hide()
$('#name').show()
$('#enterprise').hide()
$('#gender').show()
technical_titleOptions = new Array(
"<%= l(:label_technicl_title_professor) %>", "<%= l(:label_technicl_title_associate_professor) %>", "<%= l(:label_technicl_title_lecturer) %>", "<%= l(:label_technicl_title_teaching_assistant) %>");
break;
case '1' :
$('#technical_title').hide()
$('#no').show()
$('#name').show()
$('#enterprise').hide()
$('#gender').show()
var titleOptions = new Array("");
break;
case '2' :
$('#technical_title').hide()
$('#no').hide()
$('#name').hide()
$('#enterprise').show()
$('#gender').hide()
var titleOptions = new Array("");
break;
default:
$('#technical_title').hide()
$('#no').hide()
$('#name').show()
$('#enterprise').hide()
$('#gender').show()
var titleOptions = new Array("");
break;
}
technical_titleField.options.length = 0;
if(technical_titleOptions == null){
return;
}
for (var i = 0; i < technical_titleOptions.length; i++) {
technical_titleField.options[i] = new Option(technical_titleOptions[i], technical_titleOptions[i]);
/*
if (cityField.options[i].value==city)
{
//alert("here put City ok!");
document.oblogform["city"].selectedIndex = i;
}
*/
}
}
</script>
<!-- end -->
<h3><%= l(:label_register) %> <%= link_to l(:label_login_with_open_id_option), signin_url if Setting.openid? %></h3>
<%= labelled_form_for @user, :url => register_path do |f| %>
<%= error_messages_for 'user' %>
<div class="box tabular">
<p>
<table>
<tr>
<td class="info" align="right" style="width: 90px">
<strong><%= l(:label_identity) %><span class="required"> *</span></strong></td>
<td class="info" style="width: 10px">
<select onchange="showtechnical_title(this.value, document.getElementById('userTechnical_title'));" name="identity" id="userIdentity" class="location">
<option value="">--请选择身份--</option>
<option value="0"><%= l(:label_teacher) %></option>
<option value="1"><%= l(:label_student) %></option>
<option value="2"><%= l(:label_enterprise) %></option>
<option value="3"><%= l(:label_account_developer) %></option>
</select>
</td>
<td>
<span id='technical_title' style='display:none'>
<select name="technical_title" id="userTechnical_title"></select></span>
<span id='no' style='display:none'>
<% unless User.current.user_extensions.nil? %>
<%= text_field_tag :no, User.current.user_extensions.student_id, :placeholder => "请输入学号" %></span>
<% else %>
<%= text_field_tag :no, nil, :placeholder => "请输入学号" %></span>
<% end %>
</td>
</tr>
</table>
</p>
<% if @user.auth_source_id.nil? %>
<p><%= f.text_field :login, :size => 25, :required => true %><span id="valid_user_login"></span>
<em class="info"><%= l(:label_max_number) %></em></p>
<p><%= f.password_field :password, :size => 25, :required => true %>
<em class="info"><%= l(:text_caracters_minimum, :count => Setting.password_min_length) %></em></p>
<p><%= f.password_field :password_confirmation, :size => 25, :required => true %></p>
<% end %>
<span id='name' style='display:none'>
<p><%= f.text_field :firstname, :required => true %></p>
<p><%= f.text_field :lastname, :required => true %></p>
</span>
<span id='enterprise' style='display:none'>
<p><table>
<tr>
<td class="info" align="right" style="width: 90px"><strong>企业名<span class="required"> *</span></strong></td>
<td class="info" style="width: 10px">
<%= text_field_tag :enterprise_name %></td>
</tr>
</table>
</p>
</span>
<p><%= f.text_field :mail, :required => true %><span id="valid_user_mail"></span></p>
<p>
<em class="info"><%= "#{l(:label_mail_attention)} " %></em></p>
<p><%= f.select :language, lang_options_for_select, :required => true %></p>
<!-- added by bai 增加了身份、性别和地区-->
<span id='gender' style='display:none'>
<p>
<table>
<tr>
<td class="info" align="right" style="width: 90px">
<strong><%= l(:label_gender) %><span class="required"> &nbsp;</span></strong></td>
<td class="info" style="width: 10px">
<%= select_tag 'gender', "<option value = '0'>#{l(:label_gender_male)}</option>
<option value = '1'>#{l(:label_gender_female)}</option>".html_safe %>
</td>
</tr>
</table>
</p>
</span>
<p>
<table>
<tr>
<td class="info" align="right" style="width: 90px">
<strong><%= l(:label_location) %><span class="required"> *</span></strong>
</td>
<td class="info" style="width: 80px">
<select onchange="showcity(this.value, document.getElementById('userCity'));" name="province" id="userProvince">
<option value="">--请选择省份--</option>
<option value="北京">北京</option>
<option value="上海">上海</option>
<option value="广东">广东</option>
<option value="江苏">江苏</option>
<option value="浙江">浙江</option>
<option value="重庆">重庆</option>
<option value="安徽">安徽</option>
<option value="福建">福建</option>
<option value="甘肃">甘肃</option>
<option value="广西">广西</option>
<option value="贵州">贵州</option>
<option value="海南">海南</option>
<option value="河北">河北</option>
<option value="黑龙江">黑龙江</option>
<option value="河南">河南</option>
<option value="湖北">湖北</option>
<option value="湖南">湖南</option>
<option value="江西">江西</option>
<option value="吉林">吉林</option>
<option value="辽宁">辽宁</option>
<option value="内蒙古">内蒙古</option>
<option value="宁夏">宁夏</option>
<option value="青海">青海</option>
<option value="山东">山东</option>
<option value="山西">山西</option>
<option value="陕西">陕西</option>
<option value="四川">四川</option>
<option value="天津">天津</option>
<option value="新疆">新疆</option>
<option value="西藏">西藏</option>
<option value="云南">云南</option>
<option value="香港">香港特别行政区</option>
<option value="澳门">澳门特别行政区</option>
<option value="台湾">台湾</option>
<option value="海外">海外</option>
</select>
</td>
<td class="info" style="width: 100px">
<select name="city" id="userCity"></select>
</td>
</tr>
</table>
</p>
<!-- end -->
</div>
<p>
<table>
<tr>
<td><%= submit_tag l(:button_submit) %></td>
</tr>
</table>
</p>
<% end %>
<% if Setting.openid? %>
<p><%= f.text_field :identity_url %></p>
<% end %>
<% @user.custom_field_values.select { |v| v.editable? || v.required? }.each do |value| %>
<p><%= custom_field_tag_with_label :user, value %></p>
<% end %>
</div>
<script type="text/javascript">
jQuery(document).ready(function () {
var $login = $('#user_login')
var $mail = $('#user_mail')
$login.blur(function (event) {
if ($(this).is('#user_login')) {
$.get(
'<%=account_valid_ajax_path%>',
{ valid: "login",
value: this.value },
function (data) {
if (data.valid) {
$('#valid_user_login').html('<span class="green">' + data.message + "</span>");
} else {
$('#valid_user_login').html('<span class="red">' + data.message + "</span>");
}
});
}
;
});
$mail.blur(function (event) {
if ($(this).is('#user_mail')) {
$.get('<%=account_valid_ajax_path%>',
{ valid: "mail",
value: this.value },
function (data) {
if (data.valid) {
$('#valid_user_mail').html('<span class="green">' + data.message + "</span>");
} else {
$('#valid_user_mail').html('<span class="red">' + data.message + "</span>");
}
});
}
;
});
});
</script> </script>

View File

@ -31,6 +31,11 @@
$('#insite').attr("class", "re_schbtn b_dblue"); $('#insite').attr("class", "re_schbtn b_dblue");
} }
} }
function buttoncss()
{
$('#incourse').attr("class", "re_schbtn b_lblue");
$('#insite').attr("class", "re_schbtn b_lblue");
}
</script> </script>
@ -39,8 +44,8 @@
<div class="re_top"> <div class="re_top">
<%= form_tag( search_course_files_path(@course), method: 'get',:class => "re_search f_l",:remote=>true) do %> <%= form_tag( search_course_files_path(@course), method: 'get',:class => "re_search f_l",:remote=>true) do %>
<%= text_field_tag 'name', params[:name], name: "name", :class => 're_schbox',:style=>"padding: 0px"%> <%= text_field_tag 'name', params[:name], name: "name", :class => 're_schbox',:style=>"padding: 0px"%>
<%= submit_tag "课内搜索", :class => "re_schbtn b_lblue",:name => "incourse",:id => "incourse", :onclick => "presscss('incourse')"%> <%= submit_tag "课内搜索", :class => "re_schbtn b_lblue",:name => "incourse",:id => "incourse", :onmouseover => "presscss('incourse')",:onmouseout =>"buttoncss()" %>
<%= submit_tag "全站搜索", :class => "re_schbtn b_lblue",:name => "insite",:id => "insite",:onclick => "presscss('insite')" %> <%= submit_tag "全站搜索", :class => "re_schbtn b_lblue",:name => "insite",:id => "insite",:onmouseover => "presscss('insite')",:onmouseout =>"buttoncss()" %>
<% end %> <% end %>
<% if is_course_teacher(User.current,@course) %> <% if is_course_teacher(User.current,@course) %>
<a href="javascript:void(0)" class="re_fabu f_r b_lblue" onclick="show_upload()">上传资源</a> <a href="javascript:void(0)" class="re_fabu f_r b_lblue" onclick="show_upload()">上传资源</a>

File diff suppressed because it is too large Load Diff

View File

@ -436,7 +436,6 @@ function scmEntryClick(id, url) {
el.addClass('loading'); el.addClass('loading');
$.ajax({ $.ajax({
url: url, url: url,
beforeSend: function(xhr) {xhr.setRequestHeader('X-CSRF-Token', $('meta[name="csrf-token"]').attr('content'))},
success: function(data){ success: function(data){
el.after(data); el.after(data);
el.addClass('open').addClass('loaded').removeClass('loading'); el.addClass('open').addClass('loaded').removeClass('loading');
@ -506,7 +505,6 @@ function observeSearchfield(fieldId, targetId, url) {
$.ajax({ $.ajax({
url: url, url: url,
type: 'get', type: 'get',
beforeSend: function(xhr) {xhr.setRequestHeader('X-CSRF-Token', $('meta[name="csrf-token"]').attr('content'))},
data: {q: $this.val()}, data: {q: $this.val()},
success: function(data){ if(targetId) $('#'+targetId).html(data); }, success: function(data){ if(targetId) $('#'+targetId).html(data); },
beforeSend: function(){ $this.addClass('ajax-loading'); }, beforeSend: function(){ $this.addClass('ajax-loading'); },