Gantry

 view release on metacpan or  search on metacpan

lib/Gantry/Control/C/Users.pm  view on Meta::CPAN

    my @users = $AUTH_USERS->retrieve_all();
    foreach ( @users ) {
        ++$existing_ids{ $_->user_id };
    }
    
    for ( my $i = 1; $i < 300; ++$i ) {
        push( @available_ids, { label => $i, value => $i } )
            unless defined $existing_ids{ $i }; 
    }
    
    my @fields;
    
    push( @fields, 
        {   name    => 'user_id',
            is      => 'int4',
            label   => 'User ID',
            type    => 'select',
            options => \@available_ids,
        }
    ) if $self->path_info =~ /add/i;
    
    push( @fields,
        {   name    => 'active',
            label   => 'Active',
            type    => 'select',
            is      => 'boolean',
            options => [
                { label => 'Yes', value => 't' },
                { label => 'No',  value => 'f' },
            ],
        },
        {   name    => 'user_name',
            label   => 'User&nbsp;Name',
            type    => 'text',
            is      => 'varchar',
        },
        {   name    => 'passwd',
            label   => 'Password',
            is      => 'varchar',
            type    => 'password',
        },
        {   name    => 'first_name',
            label   => 'First&nbsp;Name',
            is      => 'varchar',
            type    => 'text',
        },
        {   name    => 'last_name',
            label   => 'Last&nbsp;Name',
            is      => 'varchar',
            type    => 'text',
        },
        {   optional => 1,
            name    => 'email',
            is      => 'varchar',
            label   => 'E-mail',
            type    => 'text',
        }
    );
    
    my $form =  {
        legend => $self->path_info =~ /edit/i ? 'Edit' : 'Add',
        width => 400,
        row => $row,
        fields => \@fields
    };      
            
    return( $form );

} # end _form

sub site_links {
    my $self = shift;
    
    return( [
        { link => ($self->app_rootp . '/users'), label => 'Users' },
        { link => ($self->app_rootp . '/groups'), label => 'Groups' },
        { link => ($self->app_rootp . '/pages'), label => 'Pages' },
    ] );       
}

# EOF
1;

__END__

=head1 NAME 

Gantry::Control::C::Users - User Management 

=head1 SYNOPSIS

  use Gantry::Control::C::Users;
  
=head1 DESCRIPTION

This Handler manages users in the database to facilitate the use of that
information for authentication, autorization, and use in applications. 
This replaces the use of htpasswd for user management and puts more
information at the finger tips of the application.

=head1 APACHE

  <Location /admin/users >
    SetHandler  perl-script

    PerlSetVar  title   "User Management: "

    PerlSetVar  dbconn  "dbi:Pg:dbname=..."
    PerlSetVar  dbuser  "<database_username>"
    PerlSetVar  dbpass  "<database_password>"
    PerlSetVar  dbcommit  off

    PerlHandler Gantry::Control::C::Users
  </Location>

=head1 DATABASE 

This is the auth_users table that is used by this module. It is also
used by the Authentication modules to verify usernames and passwords.
The passwords are ecrypted by the crypt(3) function in perl.



( run in 2.875 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )