diff --git a/app/controllers/admin/users_new_interface_controller.rb b/app/controllers/admin/users_new_interface_controller.rb index 8190f5df..5aa44861 100644 --- a/app/controllers/admin/users_new_interface_controller.rb +++ b/app/controllers/admin/users_new_interface_controller.rb @@ -181,6 +181,16 @@ class Admin::UsersNewInterfaceController < OrbitMemberController def edit_passwd # @disable_all_field = false @user = User.find(params[:users_new_interface_id]) + if current_user.id == @user.id + redirect_to :action => :index + end + end + + def edit_privilege + @user = User.find(params[:users_new_interface_id]) + if current_user.id == @user.id + redirect_to :action => :index + end end def update @@ -203,6 +213,20 @@ class Admin::UsersNewInterfaceController < OrbitMemberController render :action => :edit_passwd, :notice => flash.now[:error] end + elsif params[:edit_type] == 'edit_privilege' + + @checkuser = User.where(:user_id => params[:user][:user_id]).first + + if @user.admin && current_user.id == @user.id + flash.now[:error] = t("users.admin_change_password") + end + + if !flash.now[:error] && @user.update_attributes(params[:user]) + redirect_to :action => :show + else + render :action => :edit_privilege, :notice => flash.now[:error] + end + else @user.update_attributes(params[:user]) diff --git a/app/views/admin/users_new_interface/_user_basic_passwd.html.erb b/app/views/admin/users_new_interface/_user_basic_passwd.html.erb index 302c7889..898b1a4b 100644 --- a/app/views/admin/users_new_interface/_user_basic_passwd.html.erb +++ b/app/views/admin/users_new_interface/_user_basic_passwd.html.erb @@ -39,16 +39,5 @@ - -
- -
- -
-
- \ No newline at end of file diff --git a/app/views/admin/users_new_interface/_user_basic_privilege.html.erb b/app/views/admin/users_new_interface/_user_basic_privilege.html.erb new file mode 100644 index 00000000..1be4f1d0 --- /dev/null +++ b/app/views/admin/users_new_interface/_user_basic_privilege.html.erb @@ -0,0 +1,32 @@ + <%#= devise_error_messages! %> + <%= flash_messages %> + +
+
+

<%=t("users.setting_privilege")%>

+
+
+ + +
+ +
+ <%= @user.user_id %> +
+
+ + +
+ +
+ +
+
+ +
+
\ No newline at end of file diff --git a/app/views/admin/users_new_interface/_user_for_listing.html.erb b/app/views/admin/users_new_interface/_user_for_listing.html.erb index 12b983c2..987d1b57 100644 --- a/app/views/admin/users_new_interface/_user_for_listing.html.erb +++ b/app/views/admin/users_new_interface/_user_for_listing.html.erb @@ -20,7 +20,7 @@
diff --git a/app/views/admin/users_new_interface/_user_for_summary.html.erb b/app/views/admin/users_new_interface/_user_for_summary.html.erb index de5a8879..c9cc5bc8 100644 --- a/app/views/admin/users_new_interface/_user_for_summary.html.erb +++ b/app/views/admin/users_new_interface/_user_for_summary.html.erb @@ -12,7 +12,7 @@

<%= link_to(content_tag(:i, nil, :class => 'icon-edit'),edit_admin_users_new_interface_path(user_for_summary),:class=>"edit" ) if is_admin?%> - <%= link_to(content_tag(:i, nil, :class => 'icon-key'),'#',:class=>"key" ) if is_admin?%> + <%= link_to(content_tag(:i, nil, :class => 'icon-key'),admin_users_new_interface_edit_privilege_path(user_for_summary),:class=>"key" ) if is_admin? and current_user.id != user_for_summary.id %> <%= link_to(content_tag(:i, nil, :class => 'icon-trash'), admin_users_new_interface_path(user_for_summary, :at=>params[:at]), :confirm => t(:sure?), :method => :delete, :class=>"trash", :remote => true) if is_admin? %>
<%= image_tag(user_for_summary.avatar) %> diff --git a/app/views/admin/users_new_interface/_user_for_thumbnail.html.erb b/app/views/admin/users_new_interface/_user_for_thumbnail.html.erb index e3557110..1f8ec540 100644 --- a/app/views/admin/users_new_interface/_user_for_thumbnail.html.erb +++ b/app/views/admin/users_new_interface/_user_for_thumbnail.html.erb @@ -12,7 +12,7 @@
<%= link_to(content_tag(:i, nil, :class => 'icon-edit'),edit_admin_users_new_interface_path(user_for_thumbnail),:class=>"edit" ) if is_admin?%> - <%= link_to(content_tag(:i, nil, :class => 'icon-key'),'#',:class=>"key" ) if is_admin?%> + <%= link_to(content_tag(:i, nil, :class => 'icon-key'),admin_users_new_interface_edit_privilege_path(user_for_thumbnail),:class=>"key" ) if is_admin? and current_user.id != user_for_thumbnail.id %> <%= link_to(content_tag(:i, nil, :class => 'icon-trash'), admin_users_new_interface_path(user_for_thumbnail, :at=>params[:at]), :confirm => t(:sure?), :method => :delete, :class=>"trash", :remote => true) if is_admin? %>
diff --git a/app/views/admin/users_new_interface/edit_privilege.html.erb b/app/views/admin/users_new_interface/edit_privilege.html.erb new file mode 100644 index 00000000..c98bf289 --- /dev/null +++ b/app/views/admin/users_new_interface/edit_privilege.html.erb @@ -0,0 +1,39 @@ +<% content_for :side_bar do %> + <%= render :partial => 'admin/users_new_interface/side_bar' %> +<% end %> + +<% content_for :page_specific_css do -%> + <%= stylesheet_link_tag "lib/wrap-nav.css" %> + <%= stylesheet_link_tag "lib/pageslide.css" %> + <%= stylesheet_link_tag "lib/main-forms.css" %> + <%= stylesheet_link_tag "lib/fileupload.css" %> + <%= stylesheet_link_tag "lib/togglebox.css" %> +<% end -%> +<% content_for :page_specific_javascript do -%> + <%= javascript_include_tag "lib/jquery.tmpl.min.js" %> + <%= javascript_include_tag "lib/bootstrap-fileupload.js" %> + <%= javascript_include_tag "lib/member/role-forms.js" %> + <%= javascript_include_tag "lib/member/textarea-lang-btn.js" %> +<% end -%> + + +<%= form_for @user, :url => admin_users_new_interface_path(@user), :html => { :multipart => true , :class=>"form-horizontal main-forms"} do |f| %> + +
+
+ + <%= f.error_messages %> + <%= render :partial => 'user_basic_privilege', :locals => {:f => f}%> + +
+ + +
+ <%= link_back('btn') %> + <%= hidden_field_tag 'edit_type', 'edit_privilege' %> + <%= link_to t(:update_), "#", :class=>"btn btn-primary returnDecide", :onclick=>"$('#edit_user_#{@user.id}').submit()" %> +
+ +
+ +<% end -%> diff --git a/app/views/admin/users_new_interface/show.html.erb b/app/views/admin/users_new_interface/show.html.erb index 216177e2..abcd0267 100644 --- a/app/views/admin/users_new_interface/show.html.erb +++ b/app/views/admin/users_new_interface/show.html.erb @@ -21,6 +21,7 @@
<%= link_to(" #{t(:edit)}".html_safe,edit_admin_users_new_interface_path(@user),:class=>"btn btn-mini" ) if is_admin?%> <%= link_to(" #{t("users.change_passwd")}".html_safe,admin_users_new_interface_edit_passwd_path(@user),:class=>"btn btn-mini" ) if is_admin?%> + <%= link_to(" #{t("users.setting_privilege")}".html_safe,admin_users_new_interface_edit_privilege_path(@user),:class=>"btn btn-mini" ) if is_admin? and current_user.id != @user.id %>
diff --git a/config/locales/en.yml b/config/locales/en.yml index c51d7fc9..92bb2dfa 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -487,7 +487,8 @@ en: users: admin_change_password: You cannot change your own password here! avatar: Profile Picture - change_passwd: Change password + change_passwd: Password + setting_privilege: Privilege email: Email first_name: First Name last_name: Last Name diff --git a/config/locales/zh_tw.yml b/config/locales/zh_tw.yml index 562e7ec4..86157011 100644 --- a/config/locales/zh_tw.yml +++ b/config/locales/zh_tw.yml @@ -489,6 +489,7 @@ zh_tw: admin_change_password: 您不能在此處修改自己的密碼! avatar: 大頭貼照 change_passwd: 變更密碼 + setting_privilege: 權限設定 email: 電子郵件 first_name: 名字 male: 男性 diff --git a/config/routes.rb b/config/routes.rb index 19eb91ad..185c8554 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -221,6 +221,7 @@ Orbit::Application.routes.draw do post 'update_order_list' end match "edit_passwd" => "users_new_interface#edit_passwd" ,:as => :edit_passwd + match "edit_privilege" => "users_new_interface#edit_privilege" ,:as => :edit_privilege end resources :member_selects do