Smolder

 view release on metacpan or  search on metacpan

lib/Smolder/DB/Developer.pm  view on Meta::CPAN

# make sure we delete a preference when we are deleted
__PACKAGE__->add_trigger(
    after_delete => sub {
        my $self = shift;
        $self->preference->delete() if $self->preference;
    },
);

=over

=item preference

This is their default, L<Smolder::DB::Preference> object.

=cut

__PACKAGE__->has_a(preference => 'Smolder::DB::Preference');

=item project_developers

Returns a list of L<Smolder::DB::ProjectDeveloper> objects that are connected to this
Developer.

=cut

__PACKAGE__->has_many('project_developers' => 'Smolder::DB::ProjectDeveloper');

=item smoke_reports

A list of L<Smolder::DB::SmokeReport> that were added by this Developer.

=cut

__PACKAGE__->has_many('smoke_reports' => 'Smolder::DB::SmokeReport');

=back

=head2 OBJECT METHODS

=head3 project_pref

Given a L<Smolder::DB::Project> object, this returns the L<Smolder::DB::Preference>
object associated with that project and this Developer.

=cut

sub project_pref {
    my ($self, $project) = @_;
    my $sth = $self->db_Main->prepare_cached(
        qq(
        SELECT preference.* FROM preference, project_developer
        WHERE preference.id = project_developer.preference 
        AND project_developer.developer = ?
        AND project_developer.project = ?
    )
    );
    $sth->execute($self->id, $project->id);

    # there should be only one, but it returns an iterator unless
    # in list context
    my @prefs = Smolder::DB::Preference->sth_to_objects($sth);
    return $prefs[0];
}

=head3 full_name

Returns the full name of the Developer, in the following format:

    First Last

=cut

sub full_name {
    my $self = shift;
    return $self->fname . ' ' . $self->lname;
}

=head3 email_hidden

Returns the email address in HTML formatted to foil email harvesting bots.
For example, the email address
    
    test@example.com

Will become

    TODO

=cut

sub email_hidden {
    my $self = shift;

    # TODO - hide somehow
    return $self->email;
}

=head3 reset_password

Creates a new random password of between 6 and 8 characters suitable and
sets it as this Developer's password. This new password is returned unencrypted.

=cut

sub reset_password {
    my $self = shift;
    my $new_pw = join('', rand_chars(set => 'alphanumeric', min => 6, max => 8, shuffle => 1));
    $self->set('password' => $new_pw);
    $self->update();

    return $new_pw;
}

=head3 projects

Returns an array ref of all the L<Smolder::DB::Project>s that this Developer is a member
of (using the C<project_developer> join table).

=cut

sub projects {
    my $self = shift;



( run in 1.589 second using v1.01-cache-2.11-cpan-8f98c5d2c55 )