Ado
view release on metacpan or search on metacpan
lib/Ado/Model/Users.pm view on Meta::CPAN
=head2 login_name
=head2 login_password
=head2 first_name
=head2 last_name
=head2 email
=head2 description
=head2 created_by
=head2 changed_by
=head2 tstamp
=head2 reg_date
=head2 disabled
=head2 start_date
=head2 stop_date
=head1 ALIASES
none
=head1 METHODS
Ado::Model::Users inherits all methods from Ado::Model and provides the
following additional methods:
=head2 add
Given enough parameters creates a new user object and inserts it into the
table C<users>. Creates a primary group for the user with the same group
C<name>. Throws an exception if any of the above fails. Returns (the
eventually newly created) user object.
my $user = Ado::Model::Users->add(
login_name => $login_name,
login_password => Mojo::Util::sha1_hex($login_name.$login_password)
);
=head2 add_to_group
Adds a user with C<login_name> to a group.
Creates the group if it does not already exists.
Returns the group.
$ingroup = $user->add_to_group(ingroup=>'admin');
=head2 by_email
Selects a user by email column.
my $user = Ado::Model::Users->by_email('user@example.com');
say $user->email if $user->id;
=head2 by_group_name
Selects active users (C<WHERE (disabled=0 AND (stop_date>$now OR stop_date=0)
AND start_date<$now )>) belonging to a given group only and within a given
range, ordered by C<first_name, last_name> alphabetically. C<$limit> defaults
to 500 and C<$offset> to 0. Only the following fields are retrieved: C<id,
login_name, first_name, last_name, email>.
Returns an array of hashes. The L</name> method is executed for each row in
the resultset and the evaluation is available via key 'name'.
#get contacts of the user 'berov'
my @users = Ado::Model::Users->by_group_name('vest_contacts_for_berov', $limit, $offset);
=head2 by_login_name
Selects a user by login_name column.
my $user = Ado::Model::Users->by_login_name('guest');
say $user->login_name if $user->id;
=head2 ingroup
Given a group name returns true if a user is member of the group.
Returns false otherwise.
Returns a list of all group names a user belongs to if no group name passed.
say $user->name . ' is admin!' if $user->ingroup('admin');
say $user->name .' is member of the following groups:'
. join(', ', $user->ingroup);
=head1 GENERATOR
L<DBIx::Simple::Class::Schema>
This class contains also custom code.
=head1 SEE ALSO
L<Ado::Command::adduser>, L<Email::Address>,
L<Ado::Model>, L<DBIx::Simple::Class>, L<DBIx::Simple::Class::Schema>
=cut
( run in 0.319 second using v1.01-cache-2.11-cpan-d7a12ab2c7f )