AnnoCPAN

 view release on metacpan or  search on metacpan

lib/AnnoCPAN/DBI.pm  view on Meta::CPAN

    my ($self) = @_;
    # make sure no notes use us as their reference section...
    for my $note ($self->original_notes) {
        my $max_sim = 0;
        my $best_sect;
        for my $notepos ($note->notepos) {
            if ($notepos->section->id != $self->id 
                and $notepos->score > $max_sim) 
            {
                $max_sim   = $notepos->score;
                $best_sect = $notepos->section;
            }
        }
        $note->section($best_sect);
        $note->update;
    }
}

=head2 AnnoCPAN::DBI::User

Represents an AnnoCPAN user. Columns:

    id
    username
    password
    name
    email
    profile 
    reputation
    member_since
    last_visit
    privs

Note that some of these columns are unused, but they exist for historical
reasons.

Other Methods:

=over

=cut

package AnnoCPAN::DBI::User;
use base 'AnnoCPAN::DBI';
__PACKAGE__->table('user');
__PACKAGE__->columns(Essential => qw(id username password name email profile 
    reputation member_since last_visit privs));

=item $user->can_delete($note)

Return true if the user has the authority to delete $note (an
AnnoCPAN::DBI::Note object).

=cut

sub can_delete {
    my ($user, $note) = @_;
    ($user->privs > 1 or $user == $note->user);
}

=item $user->can_edit($note)

Return true if the user has the authority to edit $note (an
AnnoCPAN::DBI::Note object).

=cut

sub can_edit { shift->can_delete(@_) }

=item $user->can_move($note)

Return true if the user has the authority to move $note (an
AnnoCPAN::DBI::Note object).

=back

=cut

sub can_move { shift->can_delete(@_) }
sub can_hide { shift->can_delete(@_) }

package AnnoCPAN::DBI::Prefs;
use base 'AnnoCPAN::DBI';
__PACKAGE__->table('prefs');
__PACKAGE__->columns(Essential => qw(id user name value));
__PACKAGE__->has_a(user => 'AnnoCPAN::DBI::User');

package AnnoCPAN::DBI::Vote;
use base 'AnnoCPAN::DBI';
__PACKAGE__->table('vote');
__PACKAGE__->columns(Essential => qw(id note user value));

=head2 AnnoCPAN::DBI::Note

Represents a note. Columns:

    id
    pod
    min_ver
    max_ver
    note
    ip
    time
    score
    user
    section

Note that some of these columns are unused, but they exist for historical
reasons.

=cut

package AnnoCPAN::DBI::Note;
use base 'AnnoCPAN::DBI';
use String::Similarity 'similarity';
use AnnoCPAN::PodParser ':all';
use POSIX qw(nice);
use constant {
    ORIGINAL    => 1,
    MOVED       => 2,
    CALCULATED  => 0,
    HIDDEN      => -1,
    SCALE       => 1000,
};

my $recent_notes = AnnoCPAN::Config->option('recent_notes') || 25;

__PACKAGE__->table('note');



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