diff --git a/app/controllers/admin/users_new_interface_controller.rb b/app/controllers/admin/users_new_interface_controller.rb index 8190f5df6..e4c956b62 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 @@ -182,6 +183,36 @@ class Admin::UsersNewInterfaceController < OrbitMemberController # @disable_all_field = false @user = User.find(params[:users_new_interface_id]) 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 @@ -203,6 +234,37 @@ class Admin::UsersNewInterfaceController < OrbitMemberController render :action => :edit_passwd, :notice => flash.now[:error] end + elsif params[:edit_type] == 'edit_user_data' + + if current_user.id != @user.id + redirect_to :action => :index + end + + @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 => :setting_account, :notice => flash.now[:error] + end + else @user.update_attributes(params[:user]) 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"%> + +