diff --git a/app/controllers/admin/users_new_interface_controller.rb b/app/controllers/admin/users_new_interface_controller.rb index 5aa448619..188cc24b5 100644 --- a/app/controllers/admin/users_new_interface_controller.rb +++ b/app/controllers/admin/users_new_interface_controller.rb @@ -4,6 +4,7 @@ class Admin::UsersNewInterfaceController < OrbitMemberController helper OrbitBackendHelper before_filter :set_attribute,:except => [:index,:show] + open_for_user :only => [:setting_account, :edit_user_data, :update] open_for_visitor :only => [:index, :show] def index @@ -192,6 +193,36 @@ class Admin::UsersNewInterfaceController < OrbitMemberController redirect_to :action => :index end end + + def edit_user_data + + if params[:users_new_interface_id].blank? + redirect_to :action => :index + else + @user = User.find(params[:users_new_interface_id]) + + if current_user.id != @user.id + redirect_to :action => :index + end + + @form_index = 0 + get_info_and_roles + end + + end + + def setting_account + + if params[:users_new_interface_id].blank? + redirect_to :action => :index + else + @user = User.find(params[:users_new_interface_id]) + if current_user.id != @user.id + redirect_to :action => :index + end + end + + end def update @@ -213,18 +244,35 @@ class Admin::UsersNewInterfaceController < OrbitMemberController render :action => :edit_passwd, :notice => flash.now[:error] end - elsif params[:edit_type] == 'edit_privilege' + elsif params[:edit_type] == 'edit_user_data' - @checkuser = User.where(:user_id => params[:user][:user_id]).first + if current_user.id != @user.id + redirect_to :action => :index + end - if @user.admin && current_user.id == @user.id - flash.now[:error] = t("users.admin_change_password") + @user.update_attributes(params[:user]) + + attribute_values_key = params[:user].has_key?('new_attribute_values') ? 'new_attribute_values' : 'attribute_values' + + attribute_values = params[:user].delete(attribute_values_key) + @user.save + + redirect_to :action => :show + + elsif params[:edit_type] == 'setting_account' + + if current_user.id != @user.id + redirect_to :action => :index + end + + if !@user.valid_password?(params[:old_password]) + flash.now[:error] = t("users.valid_old_password") end if !flash.now[:error] && @user.update_attributes(params[:user]) redirect_to :action => :show else - render :action => :edit_privilege, :notice => flash.now[:error] + render :action => :setting_account, :notice => flash.now[:error] end else diff --git a/app/views/admin/users_new_interface/_form_user_data.html.erb b/app/views/admin/users_new_interface/_form_user_data.html.erb new file mode 100644 index 000000000..ecbf6df7b --- /dev/null +++ b/app/views/admin/users_new_interface/_form_user_data.html.erb @@ -0,0 +1,81 @@ + + +<%= render :partial=>"infos"%> + +
+<%=render :partial=>"user_role_data",:collection=>Role.all.asc("_id")%> +
+ + +<% content_for :page_specific_javascript do -%> + +<% ( params[:users_new_interface_id].blank? ? @fname = 'new_attribute_values' : @fname = 'attribute_values' ) %> + + + + + + + + + + +<% end -%> \ No newline at end of file diff --git a/app/views/admin/users_new_interface/_user_role_data.html.erb b/app/views/admin/users_new_interface/_user_role_data.html.erb new file mode 100644 index 000000000..bea10438a --- /dev/null +++ b/app/views/admin/users_new_interface/_user_role_data.html.erb @@ -0,0 +1,91 @@ + + + + <% role_disable = @user.roles.include?(user_role_data) ? false : true %> + +
+
+ + <%= hidden_field_tag("user[disable_role][id][#{user_role_data.id}]",role_disable,:for=>@form_index,:value=>role_disable)%> + +

<%= user_role_data.title %><%= t(:role_info)%>

+
+ +
+ + <% @form_index = @form_index +1 %> + +
+ <%= label_tag t(:status), nil, {:func=>"field_label", :for=>"1", :class=>"control-label muted"} %> +
+ <% user_role_data.role_statuses.where(:disable => false).each_with_index do |rrs, i|%> + <%= hidden_field_tag("user[role_status][id][#{rrs.id}]", false,:for=>"#{@form_index}")%> + <%= label_tag(i,check_box_tag( "user[role_status][id][#{rrs.id}]", true, @user.role_statuses.include?(rrs))+rrs.title,:class=>"checkbox inline") %> + <% end %> +
+
+ + + <% @form_index = @form_index +1 %> + +
+ <%= label_tag t(:category), nil, {:func=>"field_label", :for=>"1", :class=>"control-label muted"} %> +
+ <% user_role_data.role_categorys.where(:disable => false).each_with_index do |rrcg, i|%> + <%= hidden_field_tag("user[role_category][id][#{rrcg.id}]", false,:for=>"#{@form_index}")%> + <%= label_tag(i,check_box_tag( "user[role_category][id][#{rrcg.id}]", true, @user.role_categorys.include?(rrcg))+rrcg.title,:class=>"checkbox inline") %> + <% end %> +
+
+ + + + <% user_role_data.attribute_fields.asc(:_id).each do |rf|%> + + <%= rf.block_helper(@user,@form_index)%> + <% @form_index = @form_index +1 %> + + <% end %> + + + + <% @form_index = @form_index +1 %> + +
+ + <% user_role_data.sub_roles.where(:disabled=>false).asc("_id").each do |sub_role| %> + + <% sub_role_disable = @user.sub_roles.include?(sub_role) ? false : true %> + +
+ +
+ <%= hidden_field_tag("user[disable_sub_role][id][#{sub_role.id}]",sub_role_disable,:for=>@form_index,:value=>sub_role_disable)%> +

<%= sub_role.title %><%= t(:role_info)%>

+
+ +
+ + <% sub_role.attribute_fields.asc(:_id).each do |af|%> + <%= af.block_helper(@user,@form_index)%> + <% @form_index = @form_index +1 %> + <% end %> + +
+ +
+ + <% end %> + +
+ + + + + +
+ +
+ + + diff --git a/app/views/admin/users_new_interface/_user_setting_account.html.erb b/app/views/admin/users_new_interface/_user_setting_account.html.erb new file mode 100644 index 000000000..65036f6e6 --- /dev/null +++ b/app/views/admin/users_new_interface/_user_setting_account.html.erb @@ -0,0 +1,53 @@ + <%#= devise_error_messages! %> + <%= flash_messages %> + +
+
+

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

+
+
+ + +
+ +
+ <%= @user.user_id %> +
+
+ + +
+ +
+ <%= password_field_tag "old_password",nil, :class=>"input-medium", :id=>"password" %> +
+
+ + +
+ +
+ <%= f.password_field :password, :class=>"input-medium", :id=>"password" %> + <%= t("users.new_password_note")%> +
+
+ + +
+ +
+ <%= f.password_field :password_confirmation, :class=>"input-medium", :id=>"confirm_password" %> +
+
+ +
+
\ No newline at end of file diff --git a/app/views/admin/users_new_interface/edit_user_data.html.erb b/app/views/admin/users_new_interface/edit_user_data.html.erb new file mode 100644 index 000000000..95c10e551 --- /dev/null +++ b/app/views/admin/users_new_interface/edit_user_data.html.erb @@ -0,0 +1,43 @@ +<% 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-ui-1.10.3.custom.min.js" %> + <%= javascript_include_tag "lib/jquery.tmpl.min.js" %> + <%= javascript_include_tag "lib/bootstrap-fileupload.js" %> + <%= javascript_include_tag "lib/bootstrap-datetimepicker.js" %> + <%= javascript_include_tag "lib/datetimepicker/date.time.picker.js" %> + <%= javascript_include_tag "lib/member/textarea-lang-btn.js" %> + <%= javascript_include_tag "lib/member/role-forms.js" %> +<% end -%> + + +<%= form_for @user, :url => admin_users_new_interface_path(@user), :html => { :multipart => true , :class=>"form-horizontal main-forms", :id=>"user-forms"} do |f| %> + +
+
+ + <%= f.error_messages %> + <%= render :partial => 'user_basic', :locals => {:f => f}%> + <%= render :partial => 'form_user_data', :locals => { :f => f } %> + +
+ +
+ <%= hidden_field_tag 'edit_type', 'edit_user_data' %> + <%= link_to t(:update_), "#", :class=>"btn btn-primary returnDecide", :onclick=>"$('#user-forms').submit()" %> + <%= link_back('btn') %> +
+ +
+ +<% end -%> + diff --git a/app/views/admin/users_new_interface/setting_account.html.erb b/app/views/admin/users_new_interface/setting_account.html.erb new file mode 100644 index 000000000..764536dc9 --- /dev/null +++ b/app/views/admin/users_new_interface/setting_account.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_setting_account', :locals => {:f => f}%> + +
+ + +
+ <%= link_back('btn') %> + <%= hidden_field_tag 'edit_type', 'setting_account' %> + <%= 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 abcd02673..a57752de5 100644 --- a/app/views/admin/users_new_interface/show.html.erb +++ b/app/views/admin/users_new_interface/show.html.erb @@ -20,8 +20,8 @@ <%= @user.email %>
<%= 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 %> + + <%= link_to(" #{t("users.change_passwd")}".html_safe,admin_users_new_interface_edit_passwd_path(@user),:class=>"btn btn-mini" ) if is_admin? and current_user.id != @user.id %>
diff --git a/app/views/layouts/_right_menu.html.erb b/app/views/layouts/_right_menu.html.erb index fba8d449d..917ea8615 100644 --- a/app/views/layouts/_right_menu.html.erb +++ b/app/views/layouts/_right_menu.html.erb @@ -31,8 +31,11 @@ <%= current_user.name %>