Sha256: c1b94e7504b3567b700901aa74929f6b51d582239e8fc97d995656d7e5c62891

Contents?: true

Size: 1.24 KB

Versions: 1

Compression:

Stored size: 1.24 KB

Contents

class Admin::UsersController < Admin::BaseController

  def list
    index
    render :action => 'index' if current_user.profile.label == 'admin'
  end

  def index
    if current_user.profile.label == 'admin'
      @users = User.find :all
    else
      redirect_to :action => 'edit'
    end
  end

  def new
    @user = User.new(params[:user])
    setup_profiles
    if request.post? and @user.save
      flash[:notice] = _('User was successfully created.')
      redirect_to :action => 'list'
    end
  end

  def edit
    if current_user.profile.label == 'admin'
      @user = User.find_by_id(params[:id])
    else
      if params[:id] and params[:id].to_i != current_user[:id]
        flash[:error] = _("Error, you are not allowed to perform this action")
      end
      @user = User.find_by_id(current_user.id)
    end
    setup_profiles
    @user.attributes = params[:user]
    if request.post? and @user.save
      flash[:notice] = _('User was successfully updated.')
      redirect_to :action => 'list'
    end
  end

  def destroy
    @user = User.find(params[:id])
    if request.post?
      @user.destroy if User.count > 1
      redirect_to :action => 'list'
    end
  end

  def setup_profiles
    @profiles = Profile.find(:all, :order => 'id')
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
typo-5.1.3 app/controllers/admin/users_controller.rb