use CGI qw/:standard/;
use CGI::Carp qw(fatalsToBrowser);
-$CGI::POST_MAX=1024 * 100; # max 100K posts
-$CGI::DISABLE_UPLOADS = 1; # no uploads
+$CGI::POST_MAX = 1024 * 100; # max 100K posts
+$CGI::DISABLE_UPLOADS = 1; # no uploads
use URI::Escape;
readconfig;
my $dbh = opendb;
-sub fourohfour()
-{
+sub fourohfour() {
my $id = shift;
- print header( -charset => 'utf-8', -status => '404 Not Found');
+ print header( -charset => 'utf-8', -status => '404 Not Found' );
print start_html(
-title => $c{TrackerName} . ": 404 - Not found",
-style => { 'src' => $c{StyleSheet} }
);
print h1("404 - Not Found");
- print p([ "No Bugs Here...", "Cannot find bug at: " .code(htmlsanit(url(-absolute=>1)))]);
+ print p(
+ [
+ "No Bugs Here...",
+ "Cannot find bug at: " . code( htmlsanit( url( -absolute => 1 ) ) )
+ ]
+ );
print end_html;
exit(0);
}
# Parse path to determine bug number and (optional) mode:
-my $path = url(-absolute=>1);
+my $path = url( -absolute => 1 );
$path =~ m,^$c{CGIPath}bug/([0-9]+)(?:/(mbox))?/?$, or fourohfour();
my $bugid = $1;
-my $mode = "normal";
+my $mode = "normal";
$mode = $2 if $2;
my $bug = Emesinae::Bug->new( $dbh, ID => $bugid );
fourohfour() unless $bug;
if ( $mode eq "mbox" ) {
- print header( -type => 'application/mbox', -charset => 'utf-8',);
+ print header( -type => 'application/mbox', -charset => 'utf-8', );
foreach my $m ( sort msgcmp $bug->messages ) {
eval {
$fh = $m->body;
print for (<$fh>);
};
+
# Ignore errors...
}
"Date: " . htmlsanit($creationdate),
"Last Update: " . htmlsanit($lastchangedate),
"Severity: " . htmlsanit( $bug->{severity} ),
- "Affects: " . htmlsanit(join(", ", $bug->tags("affects") ) ),
+ "Affects: " . htmlsanit( join( ", ", $bug->tags("affects") ) ),
"State: " . b( $bug->{open} ? "Open" : "Closed" )
]
)
);
-print p(
- { -class => "bugcontrol" },
- "[ "
- . buglink($bug, "Retrieve as mbox", "/mbox")
- . " ]"
- ) . "\n";
+print p( { -class => "bugcontrol" },
+ "[ " . buglink( $bug, "Retrieve as mbox", "/mbox" ) . " ]" )
+ . "\n";
print hr;
use CGI qw/:standard/;
use CGI::Carp qw(fatalsToBrowser);
-$CGI::POST_MAX=1024 * 100; # max 100K posts
-$CGI::DISABLE_UPLOADS = 1; # no uploads
+$CGI::POST_MAX = 1024 * 100; # max 100K posts
+$CGI::DISABLE_UPLOADS = 1; # no uploads
use Emesinae::Bug;
use Emesinae::Common;
EOS
print start_html(
- -title => $c{TrackerName} . ": $ml - All Bugs",
- -style => { 'src' => $c{StyleSheet} },
+ -title => $c{TrackerName} . ": $ml - All Bugs",
+ -style => { 'src' => $c{StyleSheet} },
-script => [
- { -type => 'text/javascript',
- -src => '/javascript/jquery/jquery.js',
- },
- { -code => $jscript,
- },
- ]
-
+ {
+ -type => 'text/javascript',
+ -src => '/javascript/jquery/jquery.js',
+ },
+ { -code => $jscript, },
+ ]
+
) . "\n";
print h1( $c{TrackerName} );
. ". "
. "Information on the control syntax is available "
. a(
- { -href => "http://" . $c{TrackerHost} . $c{StaticContent} . "control.txt" }, "here"
+ {
+ -href => "http://"
+ . $c{TrackerHost}
+ . $c{StaticContent}
+ . "control.txt"
+ },
+ "here"
)
. "."
- . ($c{ControlHelpURL} ? " For guidance on manipulating bugs please see ".a( { -href => $c{ControlHelpURL} }, $c{ControlHelpURL})."." : "")
+ . (
+ $c{ControlHelpURL}
+ ? " For guidance on manipulating bugs please see "
+ . a( { -href => $c{ControlHelpURL} }, $c{ControlHelpURL} ) . "."
+ : ""
+ )
]
) . "\n";
}
if ( param('affectsfilter') ) {
- print h2("Bugs affecting: " . join(", ",@{[param('affectsfilter')]}));
-} else {
+ print h2(
+ "Bugs affecting: " . join( ", ", @{ [ param('affectsfilter') ] } ) );
+}
+else {
print h2("Bugs affecting: any version");
}
-print p(ul (@index)) if @index;
+print p( ul(@index) ) if @index;
if ( !$lists ) {
$lists = h1("No bugs match the criteria.");
print h2("Search");
sub affects_checkboxes() {
- my @affects = list_tags($dbh, "affects");
- my (@values, @defaults, %attributes);
+ my @affects = list_tags( $dbh, "affects" );
+ my ( @values, @defaults, %attributes );
foreach my $vers (@affects) {
push @values, $vers->{name};
push @defaults, $vers->{name} if $vers->{active} eq "true";
- $attributes{$vers->{name}} = {};
+ $attributes{ $vers->{name} } = {};
- $attributes{$vers->{name}}{'class'} = 'old_version' if $vers->{advanced} eq "true"
+ $attributes{ $vers->{name} }{'class'} = 'old_version'
+ if $vers->{advanced} eq "true";
}
- return checkbox_group(-name => 'affectsfilter',
- -values => \@values,
- -default => \@defaults,
- -attributes => \%attributes);
+ return checkbox_group(
+ -name => 'affectsfilter',
+ -values => \@values,
+ -default => \@defaults,
+ -attributes => \%attributes
+ );
}
-print
- start_form( -method => "POST" ),
- table(
+print start_form( -method => "POST" ), table(
Tr(
[
td(
)
]
),
- td( [ "Title contains:", i("TBD") ] ), #textfield('titlefilter') ] ),
- td( [ "Only Those Affecting:",
- affects_checkboxes(),
- small(a({-href=>"javascript:showOldVersions();", -id=>"showOldVersions"},"Show Older Versions"))
+ td( [ "Title contains:", i("TBD") ] )
+ , #textfield('titlefilter') ] ),
+ td(
+ [
+ "Only Those Affecting:",
+ affects_checkboxes(),
+ small(
+ a(
+ {
+ -href => "javascript:showOldVersions();",
+ -id => "showOldVersions"
+ },
+ "Show Older Versions"
+ )
+ )
]
),
td(
}
sub buglink {
- my $b = shift;
- my $t = shift or $b->{title};
- my $p = shift or ""; # Optional subpath
+ my $b = shift;
+ my $t = shift or $b->{title};
+ my $p = shift or ""; # Optional subpath
my $url = cgipath( "bug/" . $b->{id} . $p );
return a( { href => $url }, $t );
use CGI qw/:standard/;
use CGI::Carp qw(fatalsToBrowser);
-$CGI::POST_MAX=1024 * 100; # max 100K posts
-$CGI::DISABLE_UPLOADS = 1; # no uploads
+$CGI::POST_MAX = 1024 * 100; # max 100K posts
+$CGI::DISABLE_UPLOADS = 1; # no uploads
use Emesinae::Bug;
use Emesinae::Common;
readconfig;
my $dbh = opendb;
-sub fourohfour()
-{
+sub fourohfour() {
my $id = shift;
- print header( -charset => 'utf-8', -status => '404 Not Found');
+ print header( -charset => 'utf-8', -status => '404 Not Found' );
print start_html(
-title => $c{TrackerName} . ": 404 - Not found",
-style => { 'src' => $c{StyleSheet} }
);
print h1("404 - Not Found");
- print p([ "No Message Here...", "Cannot find message at: " .code(htmlsanit(url(-absolute=>1)))]);
+ print p(
+ [
+ "No Message Here...",
+ "Cannot find message at: "
+ . code( htmlsanit( url( -absolute => 1 ) ) )
+ ]
+ );
print end_html;
exit(0);
}
use Emesinae::Message;
use Emesinae::Common;
-my $SELECT_FIELDS = "bugs.bug_id,title_raw,creationdate,lastchangedate,owner_raw,severity,open";
+my $SELECT_FIELDS =
+ "bugs.bug_id,title_raw,creationdate,lastchangedate,owner_raw,severity,open";
sub new {
my $class = shift;
}
sub set_title {
- my $self = shift;
+ my $self = shift;
my $title = shift;
- $self->_set("title_raw", $title);
+ $self->_set( "title_raw", $title );
}
sub set_owner {
- my $self = shift;
+ my $self = shift;
my $owner = shift;
- $self->_set("owner_raw", $owner);
+ $self->_set( "owner_raw", $owner );
}
sub set_severity {
my $self = shift;
- my $sev = shift;
+ my $sev = shift;
assert_valid_severity($sev);
- $self->_set("severity", $sev);
+ $self->_set( "severity", $sev );
}
sub _lookup_tag($$$) {
- my ($self,$ns,$tag) = @_;
+ my ( $self, $ns, $tag ) = @_;
my $sth = $self->{dbh}->prepare( "
SELECT tag_id
WHERE namespace = ?
AND name = ?
" );
- $sth->execute ( $ns, $tag ) or die "Unable to find tag $ns:$tag";
+ $sth->execute( $ns, $tag ) or die "Unable to find tag $ns:$tag";
my $row = $sth->fetchrow_arrayref;
$row or die "Unable to find tag $ns:$tag";
$sth->finish;
}
sub set_tag($$$) {
- my ($self,$ns,$tag) = @_;
+ my ( $self, $ns, $tag ) = @_;
- my $tag_id = $self->_lookup_tag($ns,$tag);
+ my $tag_id = $self->_lookup_tag( $ns, $tag );
my $sth = $self->{dbh}->prepare( "
INSERT OR REPLACE INTO bug2tag(bug_id,tag_id)
VALUES (?,?)
" );
- $sth->execute( $self->{id}, $tag_id ) or die "Setting tag $ns:$tag on Bug #" . $self->{id};
+ $sth->execute( $self->{id}, $tag_id )
+ or die "Setting tag $ns:$tag on Bug #" . $self->{id};
$sth->rows == 1 or die "Failed to set tag $ns:$tag on Bug #" . $self->{id};
$sth->finish;
}
sub clear_tag($$$) {
- my ($self,$ns,$tag) = @_;
+ my ( $self, $ns, $tag ) = @_;
- my $tag_id = $self->_lookup_tag($ns,$tag);
+ my $tag_id = $self->_lookup_tag( $ns, $tag );
my $sth = $self->{dbh}->prepare( "
DELETE FROM bug2tag
WHERE bug_id = ?
AND tag_id = ?
" );
- $sth->execute( $self->{id}, $tag_id ) or die "Clearing tag $ns:$tag on Bug #" . $self->{id};
+ $sth->execute( $self->{id}, $tag_id )
+ or die "Clearing tag $ns:$tag on Bug #" . $self->{id};
$sth->finish;
}
sub tags($$) {
- my ($self,$ns) = @_;
+ my ( $self, $ns ) = @_;
my $sth = $self->{dbh}->prepare( "
SELECT tags.name
WHERE tags.tag_id == bug2tag.tag_id
AND tags.namespace == ?
AND bug2tag.bug_id == ?
- ");
- $sth->execute( $ns, $self->{id} ) or die "Listing $ns tags on Bug #" . $self->{id};
+ " );
+ $sth->execute( $ns, $self->{id} )
+ or die "Listing $ns tags on Bug #" . $self->{id};
# An array ref (rows) of array refs (columns)
my $tref = $sth->fetchall_arrayref();
my $dbh = shift;
my %args = @_;
- my (@args,@where);
+ my ( @args, @where );
my $select = "SELECT DISTINCT $SELECT_FIELDS FROM bugs";
if ( $args{State} eq "Open" ) { push @where, qq(open = "true" ) }
elsif ( $args{State} eq "Closed" ) { push @where, qq(open = "false" ) }
- if ( @{$args{Severities}} ) {
- #print "<p>SEVERITIES: ".@{$args{Severities}}." ".join(" ",@{$args{Severities}})."</p>";
- map { assert_valid_severity($_) } @ { $args{Severities} };
+ if ( @{ $args{Severities} } ) {
+
+#print "<p>SEVERITIES: ".@{$args{Severities}}." ".join(" ",@{$args{Severities}})."</p>";
+ map { assert_valid_severity($_) } @{ $args{Severities} };
push @where,
- join( " OR ", map { push @args,$_; qq{severity = ?} } @{ $args{Severities} } );
+ join( " OR ",
+ map { push @args, $_; qq{severity = ?} } @{ $args{Severities} } );
}
- if ( @{$args{Affects}} ) {
- #print "<p>AFFECTS: ".@{$args{Affects}}." ".join(" ",@{$args{Affects}})."</p>";
+ if ( @{ $args{Affects} } ) {
+
+ #print "<p>AFFECTS: ".@{$args{Affects}}." ".join(" ",@{$args{Affects}})."</p>";
$select .= " JOIN bug2tag ON bug2tag.bug_id == bugs.bug_id ";
$select .= " JOIN tags ON bug2tag.tag_id == tags.tag_id ";
push @where, "tags.namespace = \"affects\"";
push @where,
- join( " OR ", map { push @args,$_; qq{tags.name = ?} } @{ $args{Affects} });
+ join( " OR ",
+ map { push @args, $_; qq{tags.name = ?} } @{ $args{Affects} } );
}
$select .= " WHERE " . join( " AND ", map { qq{($_)} } @where ) if @where;
$c{OwnerAddressFull} = $c{OwnerAddress} . "@" . $c{MailDomain};
if ( $c{ControlAllowPath} ) {
- open CA, "<".$c{ControlAllowPath} or die "unable to open ".$c{ControlAllowPath}.": $!";
+ open CA, "<" . $c{ControlAllowPath}
+ or die "unable to open " . $c{ControlAllowPath} . ": $!";
$c{ControAllow} = [];
while (<CA>) {
chomp;
- push @ { $c{ControlAllow} }, $_;
+ push @{ $c{ControlAllow} }, $_;
}
}
}
}
sub list_tags($$) {
- my ($dbh,$ns) = @_;
+ my ( $dbh, $ns ) = @_;
my $sth = $dbh->prepare( "
SELECT name,active,advanced
FROM tags
WHERE namespace = ?
" );
- $sth->execute( $ns ) or die "Unable to obtain list of tags in namesapce $ns";
+ $sth->execute($ns) or die "Unable to obtain list of tags in namesapce $ns";
# Gets an array ref of hash refs.
- my $tags = $sth->fetchall_arrayref({});
+ my $tags = $sth->fetchall_arrayref( {} );
$sth->finish;
- return @{$tags}
+ return @{$tags};
}
#------- locking -------
my $refto =
Emesinae::Message->lookup_msgid( $self->{dbh}, $irt, Insert => 1 );
$sth =
- $self->{dbh}
- ->prepare(q{INSERT OR IGNORE INTO refs (parent_id,child_id) VALUES (?1,?2)});
+ $self->{dbh}->prepare(
+ q{INSERT OR IGNORE INTO refs (parent_id,child_id) VALUES (?1,?2)});
$sth->execute( $refto->{id}, $self->{id} );
}
my $refto =
Emesinae::Message->lookup_msgid( $self->{dbh}, $r, Insert => 1 );
$sth =
- $self->{dbh}
- ->prepare(q{INSERT OR IGNORE INTO refs (parent_id,child_id) VALUES (?1,?2)});
+ $self->{dbh}->prepare(
+q{INSERT OR IGNORE INTO refs (parent_id,child_id) VALUES (?1,?2)}
+ );
$sth->execute( $refto->{id}, $self->{id} );
}
}
$c{LockDir} = "/var/local/emesinae/locks/";
$c{ReportingURL} = "http://bugs.example.com/Howto_Report_Bugs.html";
-# Optionally set this to the URL of a page offering advice/instructions for the
+
+# Optionally set this to the URL of a page offering advice/instructions for the
# control bot.
#$c{ControlHelpURL} = "http://bugs.example.com/Control_Help.html";
-
# <MSGID> is replaced by the real message id.
%{ $c{Archives} } = (
"marc.info" => "http://marc.info/?i=<MSGID>",
# ControlAllowPath should contain the path to a file with one email address per
# line.
$c{ControlAllowPath} = "/etc/emesinae/control.users";
+
# Otherwise ControlAllow should be an array of email addresses
#@{ $c{ControlAllow} } = qw/admin@example.com/;
if ( $b eq "it" ) {
die "No previous bug found" unless @bugs;
- my $it = $bugs [ $#bugs ];
+ my $it = $bugs[$#bugs];
$bugs{$it} = 0 unless $bugs{$it};
return Emesinae::Bug->new( $dbh, ID => $it );
}
m/^(${MATCH_BUGID})\s+(.*)/ or die "Cannot parse arguments";
my $b = lookup_bugid $1;
push @reply, "Set title for #" . $b->{id} . " to `$2'";
- $b->set_title( $2 );
+ $b->set_title($2);
return 1;
}
my $b = lookup_bugid $1;
my $o = parse_address $2;
push @reply, "Change owner for #" . $b->{id} . " to `$o'";
- $b->set_owner( $o );
+ $b->set_owner($o);
return 1;
}
m/^(${MATCH_BUGID})\s+(.*)/ or die "Cannot parse arguments";
my $b = lookup_bugid $1;
push @reply, "Change severity for #" . $b->{id} . " to `$2'";
- $b->set_severity( $2 );
+ $b->set_severity($2);
return 1;
}
if ( $2 eq "+" or $2 eq "" ) {
push @reply, "Bug #" . $b->{id} . " affects `$3'";
$b->set_tag( "affects", $3 );
- } else {
+ }
+ else {
push @reply, "Bug #" . $b->{id} . " does not affect `$3'";
$b->clear_tag( "affects", $3 );
}
gmtime( $ENV{FAKE_RECEIVE_TIME} || time );
my $queue = $map;
-my $id = time . $$;
+my $id = time . $$;
chdir("$c{SpoolDir}/incoming") || &failure("chdir to spool: $!");
open( FILE, ">T.$id" ) || &failure("open temporary file: $!");
my $envelope = <STDIN>;
-print(FILE $envelope) || &failure("write envelope to temporary file: $!");
+print( FILE $envelope ) || &failure("write envelope to temporary file: $!");
printf( FILE
"Received: (at %s) by $c{MailDomain}; %d %s %d %02d:%02d:%02d +0000\n",