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"%> + +