head	1.15;
access;
symbols
	TIGRIS_1_1_0RC2:1.11.2.1
	TIGRIS_1_1_0RC1:1.11.2.1
	TIGRIS_1_1:1.11.2.1.0.2
	TIGRIS_1_0_8:1.11.2.1
	TIGRIS_1_0_8RC3:1.11.2.1
	TIGRIS_1_0_8RC2:1.11.2.1
	TIGRIS_1_0_8RC1:1.11.2.1
	TIGRIS_1_0_7:1.11.2.1
	TIGRIS_1_0_7RC3:1.11.2.1
	TIGRIS_1_0_7RC2:1.11.2.1
	TIGRIS_1_0_7RC1:1.11.2.1
	TIGRIS_1_0_6:1.11.2.1
	TIGRIS_1_0_6RC5:1.11.2.1
	TIGRIS_1_0_6RC4:1.11.2.1
	TIGRIS_1_0_6RC3:1.11.2.1
	TIGRIS_1_0_6RC2:1.11.2.1
	TIGRIS_1_0_6RC1:1.11.2.1
	TIGRIS_1_0_5:1.11.2.1
	TIGRIS_1_0_5RC6:1.11.2.1
	TIGRIS_1_0_5RC5:1.11.2.1
	TIGRIS_1_0_5RC4:1.11.2.1
	TIGRIS_1_0_5RC3:1.11.2.1
	TIGRIS_1_0_5RC2:1.11.2.1
	TIGRIS_1_0_5RC1:1.11.2.1
	TIGRIS_1_0_4:1.11.2.1
	TIGRIS_1_0_3:1.11.2.1
	TIGRIS_1_0_2:1.11.2.1
	TIGRIS_1_0_1:1.11.2.1
	TIGRIS_1_0:1.11.2.1.0.4
	TIGRIS_1_0_0:1.11.2.1
	TIGRIS_1_0_0_RC1:1.11.0.2
	HELM_PEER_PORT_BRANCH:1.10.0.2
	TIGRIS_0_9_2_4:1.8.4.1
	TIGRIS_0_9_2_3:1.8.4.1
	TIGRIS_0_9_2:1.8.0.4
	TIGRIS_0_9_0:1.8.0.2
	ISSUEZILLA_OPENOFFICE:1.1.0.4
	IZ_TEMP_TAG:1.1
	TIGRIS_0_8_4:1.6.0.2
	ISSUEZILLA_11292000:1.6
	ISSUEZILLA_BASELINE:1.1.0.2
	ISSUEZILLA_BASELINE_BASE:1.1
	ISSUEZILLA_11062000:1.3
	TIGRIS_710_FF:1.3
	TIGRIS_706:1.3
	ISSUEZILLA_10252000:1.3
	TIGRIS_SEP_13_2000:1.3.0.2
	TIGRIS_705:1.3
	TIGRIS_704:1.3
	TIGRIS_703:1.3
	TIGRIS_702:1.3
	TIGRIS_701:1.3;
locks; strict;
comment	@# @;


1.15
date	2001.04.30.20.56.15;	author kmaples;	state dead;
branches;
next	1.14;

1.14
date	2001.03.29.22.12.47;	author kmaples;	state Exp;
branches;
next	1.13;

1.13
date	2001.03.29.21.57.40;	author kmaples;	state Exp;
branches;
next	1.12;

1.12
date	2001.03.28.01.36.37;	author kmaples;	state Exp;
branches;
next	1.11;

1.11
date	2001.02.23.22.50.36;	author kmaples;	state Exp;
branches
	1.11.2.1;
next	1.10;

1.10
date	2001.01.30.22.16.26;	author kmaples;	state Exp;
branches;
next	1.9;

1.9
date	2001.01.22.23.09.58;	author kmaples;	state Exp;
branches;
next	1.8;

1.8
date	2000.12.15.22.43.54;	author kmaples;	state Exp;
branches
	1.8.4.1;
next	1.7;

1.7
date	2000.12.11.18.45.03;	author kmaples;	state Exp;
branches;
next	1.6;

1.6
date	2000.11.29.03.42.04;	author kmaples;	state Exp;
branches
	1.6.2.1;
next	1.5;

1.5
date	2000.11.07.15.59.39;	author kmaples;	state Exp;
branches;
next	1.4;

1.4
date	2000.11.07.02.39.12;	author kmaples;	state Exp;
branches;
next	1.3;

1.3
date	2000.10.11.17.17.33;	author kmaples;	state Exp;
branches;
next	1.2;

1.2
date	2000.10.05.21.50.37;	author kmaples;	state Exp;
branches;
next	1.1;

1.1
date	2000.09.28.04.28.27;	author npm;	state Exp;
branches
	1.1.4.1;
next	;

1.1.4.1
date	2001.03.09.23.57.14;	author kmaples;	state Exp;
branches;
next	;

1.6.2.1
date	2000.12.12.05.13.21;	author jrobbins;	state Exp;
branches;
next	;

1.8.4.1
date	2001.01.30.21.27.57;	author kmaples;	state Exp;
branches;
next	;

1.11.2.1
date	2001.03.29.01.20.41;	author kmaples;	state Exp;
branches;
next	;


desc
@@


1.15
log
@Issuezilla is now a separate module
@
text
@#!/usr/bin/perl
# -*- Mode: perl; indent-tabs-mode: nil -*-
#
# The contents of this file are subject to the Mozilla Public
# License Version 1.1 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
# implied. See the License for the specific language governing
# rights and limitations under the License.
#
# The Original Code is the Issuezilla Issue Tracking System.
#
# The Initial Developer of the Original Code is Netscape Communications
# Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s): Terry Weissman <terry@@mozilla.org>,
#                 Bryce Nesbitt <bryce-mozilla@@nextbus.com>
#                 Dan Mosedale <dmose@@mozilla.org>

# To recreate the shadow database,  run "processmail regenerate" .

#use diagnostics;
use strict;
use RelationSet;

require "globals.pl";
require "CGI.pl";
$| = 1;

umask(077);

# Global for number of file locks on the maillock file:
$::lockcount      = 0;

# Flag that the shadow database is to be rebuilt: 
my $regenerate    = 0;

# Global for email address to exclude from notification:
my $nametoexclude = "";

# Global flag indicating that the above was excluded:
my $didexclude = 0;

# Global hash of users who have been been emailed, e.g.
# '$seen{'me@@foo.org'} = 1;'
my %seen;

# Global array of email addresses of users which have been mailed:
my @@sentlist;

# Global array of users to CC:
my @@forcecc;

#-----------------
sub SendMail {
#-----------------
    # Perform the actual mail-related nonesense
    ## NPM -- removed "sendmailnow" param, not relevant to qmail
    
    my $mailtext = shift;
    my $mailcmd  = '|/var/qmail/bin/qmail-inject -froot';
    
    if(open(SENDMAIL, $mailcmd)){
    	print SENDMAIL $mailtext;
    	close SENDMAIL;
    } else {
    	return(0);
    }
    return(1);
}
#-----------------
sub Lock {
#-----------------
    if ($::lockcount <= 0) {
        $::lockcount = 0;
        if (!open(LOCKFID, ">>$::data_dir/maillock")) {
            mkdir "$::data_dir", 0700;
            chmod 0700, "$::data_dir";
            open(LOCKFID, ">>$::data_dir/maillock") || die "Can't open lockfile.";
        }
        my $val = flock(LOCKFID,2);
        if (!$val) { # '2' is magic 'exclusive lock' const.
            print "Lock failed: $val\n";
        }
        chmod 0600, "$::data_dir/maillock";
    }
    $::lockcount++;
}
#-----------------
sub Unlock {
#-----------------
    $::lockcount--;
    if ($::lockcount <= 0) {
        flock(LOCKFID,8);       # '8' is magic 'unlock' const.
        close LOCKFID;
    }
}

#-----------------
sub FileSize {
#-----------------
    my ($filename) = (@@_);
    my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
        $atime,$mtime,$ctime,$blksize,$blocks)
        = stat($filename);
    if (defined $size) {
        return $size;
    }
    return -1;
}

#-----------------
sub Different {
#-----------------
    my ($file1, $file2) = (@@_);
    my $size1 = FileSize($file1);
    my $size2 = FileSize($file2);
    if ($size1 != $size2) {
        return 1;
    }
    open(FID1, "<$file1") || die "Can't open $file1";
    open(FID2, "<$file2") || die "Can't open $file2";
    my $d1; 
    my $d2; 
    if (read(FID1, $d1, $size1) ne $size1) {
        die "Can't read $size1 bytes from $file1";
    }
    if (read(FID2, $d2, $size2) ne $size2) {
        die "Can't read $size2 bytes from $file2";
    }
    close FID1;
    close FID2;
    return ($d1 ne $d2);
}
#-----------------
sub DescCC {
#-----------------
    my $cclist = shift();

    return "" if ( $cclist->size() == 0 );

    return "Cc: " . $cclist->toString() . "\n";
}
#-----------------
sub DescDependencies {
#-----------------
    my ($id) = (@@_);
    if (!Param("usedependencies")) {
        return "";
    }
    my $result = "";
    my $me = "blocked";
    my $target = "dependson";
    my $title = "IssuesThisDependsOn";
    for (1..2) {
        SendSQL("select $target from dependencies where $me = $id order by $target");
        my @@list;
        while (MoreSQLData()) {
            push(@@list, FetchOneColumn());
        }
        if (@@list) {
            my @@verbose;
            my $count = 0;
            foreach my $i (@@list) {
                SendSQL("select issue_status, resolution from issues where issue_id = $i");
                my ($issue_status, $resolution) = (FetchSQLData());
                my $desc;
                if ($issue_status eq "NEW" || $issue_status eq "STARTED" ||
                    $issue_status eq "REOPENED") {
                    $desc = "";
                } else {
                    $desc = "[$resolution]";
                }
                push(@@verbose, $i . "$desc");
                $count++;
            }
            if ($count > 5) {
                $result .= "$title: Big list (more than 5) has been omitted\n";
            } else {
                $result .= "$title: " . join(', ', @@verbose) . "\n";
            }
        }
        my $tmp = $me;
        $me = $target;
        $target = $tmp;
        $title = "OtherIssuesDependingOnThis";
    }
    return $result;
}
#-----------------
sub GetIssueText {
#-----------------
    my ($id) = (@@_);
    undef %::issue;
    
    my @@collist = ("issue_id", "component", "version", "rep_platform", "op_sys",
                   "issue_status", "resolution", "priority", "issue_type",
                   "assigned_to", "reporter", "issue_file_loc",
                   "short_desc", "subcomponent", "qa_contact", "target_milestone",
                   "status_whiteboard", "groupset");

    my $query = "select " . join(", ", @@collist) .
        " from issues where issue_id = $id";

    SendSQL($query);

    my @@row;
    if (!(@@row = FetchSQLData())) {
        return "";
    }
    foreach my $field (@@collist) {
        $::issue{$field} = shift @@row;
        if (!defined $::issue{$field}) {
            $::issue{$field} = "";
        }
    }

    $::issue{'assigned_to'} = DBID_to_name($::issue{'assigned_to'});
    $::issue{'reporter'}    = DBID_to_name($::issue{'reporter'});
    my $qa_contact = "";
    my $target_milestone = "";
    my $status_whiteboard = "";

    if (Param('useqacontact') && $::issue{'qa_contact'} > 0) {
        $::issue{'qa_contact'} = DBID_to_name($::issue{'qa_contact'});
        $qa_contact = "QAContact: $::issue{'qa_contact'}\n";
    } else {
        $::issue{'qa_contact'} = "";
    }

    if (Param('usetargetmilestone') && $::issue{'target_milestone'} ne "") {
        $target_milestone = "TargetMilestone: $::issue{'target_milestone'}\n";
    }
    if (Param('usestatuswhiteboard') && $::issue{'status_whiteboard'} ne "") {
        $status_whiteboard = "StatusWhiteboard: $::issue{'status_whiteboard'}\n";
    }

    $::issue{'long_desc'} = GetLongDescriptionAsText($id);

    my $cclist = new RelationSet();
    
    $cclist->mergeFromDB("select who from cc where issue_id = $id");
    my @@voterlist;
    
    SendSQL("select profiles.login_name from votes, profiles where votes.issue_id = $id and profiles.userid = votes.who");
    
    while (MoreSQLData()) {
        my $v = FetchOneColumn();
        push(@@voterlist, $v);
    }
    
    $::issue{'cclist'} = $cclist->toString();
    $::issue{'voterlist'} = join(',', @@voterlist);

    if (Param("prettyasciimail")) {
        my $short_desc;
        # Add the short description if permitted:
        $short_desc = $::iz_send_diff ? $::issue{'short_desc'} : 'SUMMARY';

		# Format the data in the prettyascii format:
        my $prettymail = FormatPrettyAscii(
        	$short_desc, $id, $::issue{'component'}, 
        	$::issue{'issue_status'}, $::issue{'version'}, $::issue{'resolution'},
        	$::issue{'rep_platform'}, $::issue{'issue_type'}, $::issue{'op_sys'}, 
        	$::issue{'priority'}, $::issue{'subcomponent'}, $::issue{'assigned_to'},
        	$::issue{'reporter'}, $qa_contact, DescCC($cclist),
        	$target_milestone, ${status_whiteboard}, $::issue{'issue_file_loc'},
        	DescDependencies($id)       
        );
        
        # Add the longdescription if permitted:
        if($::iz_send_diff){
            $prettymail .= 
                '|                              DESCRIPTION                                   |';
            $prettymail .= "\n";   
            $prettymail .= $::issue{'long_desc'};
        }  
        
        return($prettymail);

    } else {
        #KPM: Note: tests of '$::iz_send_diff' are to filter out
        # 'sensitive' information from the emails if that flag
        # is set in localconfig: 
        
        my $mailtext = "Issue\#: $id
Component: $::issue{'component'}
Version: $::issue{'version'}
Platform: $::issue{'rep_platform'}
OS/Version: $::issue{'op_sys'}
Status: $::issue{'issue_status'}   
Resolution: $::issue{'resolution'}
Issue type: $::issue{'issue_type'}
Priority: $::issue{'priority'}
Subcomponent: $::issue{'subcomponent'}
AssignedTo: $::issue{'assigned_to'}                            
ReportedBy: $::issue{'reporter'}               
$qa_contact$target_milestone${status_whiteboard}URL: $::issue{'issue_file_loc'}\n";

        $mailtext .= DescCC($cclist) . "\n";
        $mailtext .= "Summary: $::issue{'short_desc'}\n" if $::iz_send_diff;
        $mailtext .= DescDependencies($id) . "\n";
        $mailtext .= "$::issue{'long_desc'}\n" if $::iz_send_diff;

        return($mailtext);
    }
}
#-----------------
sub fixaddresses {
#-----------------
    my ($field, $list) = (@@_);
    my @@result;
    foreach my $i (@@$list) {
        if (!defined $i || $i eq "") {
            next;
        }
        SendSQL("select emailnotification, groupset & $::issue{'groupset'} from profiles where login_name = " .
                SqlQuote($i));
        my ($emailnotification, $groupset) = (FetchSQLData());
        if ($groupset ne $::issue{'groupset'}) {
            next;
        }
        if ($emailnotification eq "CConly") {
            if ($field ne "cc") {
                next;
            }
        }
        if ($emailnotification eq "ExcludeSelfChanges" &&
           (lc($i) eq $nametoexclude)) {
            $didexclude = 1;
            next;
        }
        
        if (!defined $::nomail{$i} && !defined $seen{$i}) {
            push(@@result, $i . Param('emailsuffix'));
            $seen{$i} = 1;
        }
    }
    return join(", ",  @@result);
}
#-----------------
sub Log {
#-----------------
    my ($str) = (@@_);
    Lock();
    open(FID, ">>$::data_dir/maillog") || die "Can't write to $::data_dir/maillog";
    print FID time2str("%D %H:%M", time()) . ": $str\n";
    close FID;
    Unlock();
}
#-----------------
sub FormatTriple {
#-----------------
    my ($a, $b, $c) = (@@_);

    # Zero out the line accumulator:
    local $^A = '';

    my $temp = formline << 'END;', $a, $b, $c;
^>>>>>>>>>>>>>>>>>>>>>>>>>|^<<<<<<<<<<<<<<<<<<<<<<<<<<|^<<<<<<<<<<<<<<<<<<<<<<<<<<~~
END;

    return $^A;
}
#-----------------
sub FormatDouble {
#-----------------
    my ($a, $b) = (@@_);
    $a .= ":";

    # Zero out the line accumulator:
    local $^A = '';

    my $temp = formline << 'END;', $a, $b;
^>>>>>>>>>>>>>>>>>>>>>>>>> ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<~~
END;

    return $^A;
}
#-----------------
sub FormatPrettyAscii {
#-----------------
    # Grab the values to format:
    my @@vals = @@_;
    
    # Zero out the line accumulator:
    local $^A = '';
    
    my $text = formline <<'END;', @@vals;
+============================================================================+
| @@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< |
+----------------------------------------------------------------------------+
|      Issue #: @@<<<<<<<<<<<              Component: @@<<<<<<<<<<<<<<<<<<<<<< |
|       Status: @@<<<<<<<<<<<<<<<<<<         Version: @@<<<<<<<<<<<<<<<<<<<<<< |
|   Resolution: @@<<<<<<<<<<<<<<<<<<        Platform: @@<<<<<<<<<<<<<<<<<<<<<< |
|   Issue type: @@<<<<<<<<<<<<<<<<<<      OS/Version: @@<<<<<<<<<<<<<<<<<<<<<< |
|     Priority: @@<<<<<<<<<<<<<<<<<<    Subcomponent: @@<<<<<<<<<<<<<<<<<<<<<< |
+----------------------------------------------------------------------------+
|  Assigned To: @@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< |
|  Reported By: @@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< |
|  ~QA Contact: ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< |
|  ~   CC list: ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< |
+----------------------------------------------------------------------------+
| ~  Milestone: ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< |
|~  Whiteboard: ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< |
|          URL: @@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< |
|~Dependencies: ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< |
+============================================================================+
END;
    return($^A);
}
#-----------------
sub NewProcessOneIssue {
#-----------------
    my ($id) = (@@_);

    my @@headerlist;
    my %values;
    my %defmailhead;
    my %fielddescription;

    my $msg = "";

    SendSQL("SELECT name, description, mailhead FROM fielddefs " .
            "ORDER BY sortkey");
            
    while (MoreSQLData()) {
        my ($field, $description, $mailhead) = (FetchSQLData());
        push(@@headerlist, $field);
        $defmailhead{$field} = $mailhead;
        $fielddescription{$field} = $description;
    }
        
    SendSQL("SELECT " . join(',', @@::log_columns) . ", lastdiffed, now() " .
            "FROM issues WHERE issue_id = $id");
            
    my @@row = FetchSQLData();
    foreach my $i (@@::log_columns) {
        $values{$i} = shift(@@row);
    }
    my ($start, $end) = (@@row);
    my $ccSet = new RelationSet();
    $ccSet->mergeFromDB("SELECT who FROM cc WHERE issue_id = $id");
    $values{'cc'} = $ccSet->toString();
    
    my @@voterlist;
    SendSQL("SELECT profiles.login_name FROM votes, profiles " .
            "WHERE votes.issue_id = $id AND profiles.userid = votes.who");
    while (MoreSQLData()) {
        push(@@voterlist, FetchOneColumn());
    }

    $values{'assigned_to'} = DBID_to_name($values{'assigned_to'});
    $values{'reporter'} = DBID_to_name($values{'reporter'});
    if ($values{'qa_contact'}) {
        $values{'qa_contact'} = DBID_to_name($values{'qa_contact'});
    }

    my @@diffs;


    SendSQL("SELECT profiles.login_name, fielddefs.description, " .
            "       issue_when, oldvalue, newvalue " .
            "FROM issues_activity, fielddefs, profiles " .
            "WHERE issue_id = $id " .
            "  AND fielddefs.fieldid = issues_activity.fieldid " .
            "  AND profiles.userid = who " .
            "  AND issue_when > '$start' " .
            "  AND issue_when <= '$end' " .
            "ORDER BY issue_when"
            );

    while (MoreSQLData()) {
        my @@row = FetchSQLData();
        push(@@diffs, \@@row);
    }

    my $difftext = "";
    my $lastwho = "";
    foreach my $ref (@@diffs) {
        my ($who, $what, $when, $old, $new) = (@@$ref);
        if ($who ne $lastwho) {
            $lastwho = $who;
            $difftext .= "\n$who" . Param('emailsuffix') . " changed:\n\n";
            $difftext .= FormatTriple("What    ", "Old Value", "New Value");
            $difftext .= ('=' x 82) . "\n";
        }
        # Check if we're suppressing summaries:
        if($what =~ m/Summary/ && !$::iz_send_diff){
            ($old, $new) = ('---', '---');  
        }  

        $difftext .= FormatTriple($what, $old, $new);
        $difftext .= ('-' x 82) . "\n";
    }

    $difftext = trim($difftext);


    my $deptext = "";

    SendSQL("SELECT issues_activity.issue_id, fielddefs.name, " .
            "       oldvalue, newvalue " .
            "FROM issues_activity, dependencies, fielddefs ".
            "WHERE issues_activity.issue_id = dependencies.dependson " .
            "  AND dependencies.blocked = $id " .
            "  AND fielddefs.fieldid = issues_activity.fieldid" .
            "  AND (fielddefs.name = 'issue_status' " .
            "    OR fielddefs.name = 'resolution') " .
            "  AND issue_when > '$start' " .
            "  AND issue_when <= '$end' " .
            "ORDER BY issue_when, issue_id");
    
    my $thisdiff = "";
    my $lastissue = "";
    my $interestingchange = 0;
    while (MoreSQLData()) {
        my ($issue, $what, $old, $new) = (FetchSQLData());
        if ($issue ne $lastissue) {
            if ($interestingchange) {
                $deptext .= $thisdiff;
            }
            $lastissue = $issue;
            $thisdiff =
                "\nThis issue depends on issue $issue, which changed state:\n\n";
            $thisdiff .= FormatTriple("What    ", "Old Value", "New Value");
            $thisdiff .= ('-' x 82) . "\n";
            $interestingchange = 0;
        }
        $thisdiff .= FormatTriple($fielddescription{$what}, $old, $new);
        $difftext .= ('-' x 82) . "\n";
        if ($what eq 'issue_status' && IsOpenedState($old) ne IsOpenedState($new)) {
            $interestingchange = 1;
        }
    }
    if ($interestingchange) {
        $deptext .= $thisdiff;
    }

    $deptext = trim($deptext);

    if ($deptext) {
        $difftext = trim($difftext . "\n\n" . $deptext);
    }

    my $newcomments = GetLongDescriptionAsText($id, $start, $end);  
    
    my $count = 0;
    my @@personlist = ($values{'assigned_to'}, $values{'reporter'},
                      split(/,/, $values{'cc'}),
                      @@voterlist,
                      @@forcecc);
    if ($values{'qa_contact'}) { push @@personlist, $values{'qa_contact'} }
    for my $person (@@personlist) {
        $count++;

        my $match = "^[^@@, ]*@@[^@@, ]*\.[^@@, ]*\$";
        if ($person !~ /$match/) {
          $person = $person . Param('emailsuffix');
        }

        &NewProcessOnePerson($person, $count, \@@headerlist, \%values,
                             \%defmailhead, \%fielddescription, $difftext, 
                             $newcomments, $start, $id, 1);
    }

    SendSQL("UPDATE issues SET lastdiffed = '$end', delta_ts = delta_ts " .
            "WHERE issue_id = $id");
}
#-----------------
sub NewProcessOnePerson ($$\@@\%\%\%$$$$) {
#-----------------
    my ($person, $count, $hlRef, $valueRef, $dmhRef, $fdRef, $difftext, 
        $newcomments, $start, $id, $checkWatchers) = @@_;

    my %values = %$valueRef;
    my @@headerlist = @@$hlRef;
    my %defmailhead = %$dmhRef;
    my %fielddescription = %$fdRef;

    if ($seen{$person}) {
      return;
    }
        
    SendSQL("SELECT userid, emailnotification, newemailtech," .
            "       groupset & $values{'groupset'} " .
            "FROM profiles WHERE login_name = " . SqlQuote($person));
    my ($userid, $emailnotification, $newemailtech, 
        $groupset) =  (FetchSQLData());
    
    # check for watchers, and recurse if we find any, but tell the
    # recursive call not to check for watchers 
    #
    if (Param("supportwatchers") && $checkWatchers)  {
      my $personId = DBname_to_id($person);
      my $watcherSet = new RelationSet();
      $watcherSet->mergeFromDB("SELECT watcher FROM watch WHERE" .
                               " watched = $personId");

      foreach my $watcher ( $watcherSet->toArray() ) {
        
        &NewProcessOnePerson(DBID_to_name($watcher) . Param('emailsuffix'), 
                            $count, \@@headerlist, \%values,
                            \%defmailhead, \%fielddescription, $difftext, 
                            $newcomments, $start, $id, 0);
      }

    }

    if (!$newemailtech || !Param('newemailtech')) {
      return;
    }
    $seen{$person} = 1;

    # if this person doesn't have permission to see info on this issue, 
    # return.
    #
    # XXX - I _think_ this currently means that if an issue is suddenly given
    # more restrictive permissions, people without those permissions won't
    # see the action of restricting the issue itself; the issue will just 
    # quietly disappear from their radar.
    #
    if ($groupset ne $values{'groupset'}) {
      return;
    }

    if ($emailnotification eq "ExcludeSelfChanges" &&
        lc($person) eq $nametoexclude) {
      $didexclude = 1;
      return;
    }

    # "$count < 3" means "this person is either assigned_to or reporter"
    #
    if ($emailnotification eq "CCOnly" && $count < 3) {
      return;
    }
    
    my %mailhead = %defmailhead;
    
    my $head = "";
    
    foreach my $f (@@headerlist) {
      if ($mailhead{$f}) {
        my $value = $values{$f};
        if (!defined $value) {
          # Probaby ought to whine or something. ###
          next;
        }
        my $desc = $fielddescription{$f};

        #KPM: check to see if we're suppressing summary
        # descriptions:
        if($desc =~ m/Summary/ && !$::iz_send_diff){
            next;
        }

        $head .= FormatDouble($desc, $value);
      }
    }
    
    if ($difftext eq "" && $newcomments eq "") {
      # Whoops, no differences!
      return;
    }
    
    my $isnew = ($start !~ m/[1-9]/);
    
    my %substs;

    $person .= Param('emailsuffix');
# 09/13/2000 cyeh@@bluemartini.com
# If an issue is changed, don't put the word "Changed" in the subject mail
# since if the issue didn't change, you wouldn't be getting mail
# in the first place! see http://issuezilla.mozilla.org/show_bug.cgi?id=29820
# for details.
    $substs{"neworchanged"} = $isnew ? "New" : "";
    $substs{"to"} = $person;
    $substs{"cc"} = '';
    $substs{"issueid"} = $id;

    if($::iz_send_diff){
        # It's ok to send bug details via email:    
        if ($isnew) {
          $substs{"diffs"} = $head . "\n\n" . $newcomments;
        } else {
          $substs{"diffs"} = $difftext . "\n\n" . $newcomments;
        }
        $substs{"summary"} = $values{'short_desc'};
    } else {
        # It's NOT ok to send bug details via email:
        if ($isnew) {
          $substs{"diffs"} = $head . "\n\n";
        } else {
          $substs{"diffs"} = $difftext . "\n\n";
        }
        $substs{"summary"} = '-summary-';
    } 


    my $template = Param("newchangedmail");

    my $msg = PerformSubsts($template, \%substs);

    my $sendmailparam = "-ODeliveryMode=deferred";
    if (Param("sendmailnow")) {
       $sendmailparam = "";
    }

    SendMail( trim($msg) . "\n" );

    push(@@sentlist, $person);
    
}


#-----------------
sub ProcessOneIssue {
#-----------------
  # unusual way of saying '$i = shift':
  my $i = $_[0];

  # looks like a passthrough:
  NewProcessOneIssue($i);

  my $old = "$::shadow_dir/$i";
  my $new = "$::shadow_dir/$i.tmp.$$";
  my $diffs = "$::shadow_dir/$i.diffs.$$";
  my $verb = "Changed";

  # build the shadow dir, if not present (?), and create the old file, if need be:  
  if (!stat($old)) {
    mkdir "$::shadow_dir", 0700;
    chmod 0700, "$::shadow_dir";
        open(OLD, ">$old") || die "Couldn't create null $old";
        close OLD;
        $verb = "New";
  }
  my $text = GetIssueText($i);
  if ($text eq "") {
      die "Couldn't find issue $i.";
  }
  if(open(FID, ">$new")){
        print FID $text;
        close FID;
  }
  if (Different($old, $new)) {
      system("diff -c -b $old $new > $diffs");
      my $tolist = fixaddresses("to",
                                [$::issue{'assigned_to'}, $::issue{'reporter'},
                                 $::issue{'qa_contact'}]);
      my @@combinedcc;
      foreach my $v (split(/,/, "$::issue{'cclist'},$::issue{'voterlist'}")) {
          push @@combinedcc, $v;
      }
      push (@@combinedcc, (@@forcecc));
      my $cclist = fixaddresses("cc", \@@combinedcc);
      my $logstr = "Issue $i $verb";
      if ($tolist ne "" || $cclist ne "") {
          my %substs;

          $substs{"fullissuereport"} = $text; # added ability to include the full issue report
          $substs{"to"} = $tolist;
          $substs{"cc"} = $cclist;
          $substs{"issueid"} = $i;
          $substs{"diffs"} = "";
          open(DIFFS, "<$diffs") || die "Can't open $diffs";
          while (<DIFFS>) {
              $substs{"diffs"} .= $_;
          }
          close DIFFS;
          $substs{"neworchanged"} = $verb;
          $substs{"summary"} = $::issue{'short_desc'};
          my $msg = PerformSubsts(Param("changedmail"), \%substs);

          if (!$regenerate) {
              # Note: fixaddresses may result in a Cc: only.  This seems
              # harmless.
              my $sendmailparam = "-ODeliveryMode=deferred";
              if (Param("sendmailnow")) {
                  $sendmailparam = "";
              }
                             
              SendMail($msg);   

              foreach my $n (split(/[, ]+/, "$tolist,$cclist")) {
                  if ($n ne "") {
                      push(@@sentlist, $n);
                  }
              }

              $logstr = "$logstr; mail sent to $tolist, $cclist";
          }
      }
      unlink($diffs);
      Log($logstr);
  }
  if (@@sentlist) {
      print "<B>Email sent to:</B> " . join(", ", @@sentlist) . "\n";
      if ($didexclude) {
          print qq{<B>Excluding:</B> $nametoexclude (<a href="userprefs.cgi?bank=diffs">change your preferences</a> if you wish not to be excluded)\n};
      }
  }
  rename($new, $old) || die "Can't rename $new to $old";
  chmod 0600, $old;
  if ($regenerate) {
      print "$i ";
  }
  %seen = ();
  @@sentlist = ();
}

# Code starts here
# MAIN ----------------------------------------------------------------#

ConnectToDatabase();
GetVersionTable();
Lock();

# KPM: not at all clear what it is that this is trying to do:
if (open(FID, "<$::data_dir/nomail")) {
    while (<FID>) {
        $::nomail{trim($_)} = 1;
    }
    close FID;
}

# KPM: command line option; believed unused in IZ except when 
# checksetup.pl is run:
# To recreate the shadow database,  run "processmail regenerate" .
if ($#ARGV >= 0 && $ARGV[0] eq "regenerate") {
    $regenerate = 1;
    shift @@ARGV;
    SendSQL("select issue_id from issues order by issue_id");
    my @@regenerate_list;
    while (my @@row = FetchSQLData()) {
        push @@regenerate_list, $row[0];
    }
    foreach my $i (@@regenerate_list) {
        ProcessOneIssue($i);
        Unlock();
        Lock();
    }
    print("\n");
    exit;
}

# /processmail", "-forcecc", $origCcString, $id, $::FORM{'who'}
# add some folks to the global @@forcecc array:
if ($#ARGV >= 0 && $ARGV[0] eq "-forcecc") {
    shift(@@ARGV);
    foreach my $i (split(/,/, shift(@@ARGV))) {
        push(@@forcecc, trim($i));
    }
}

if (($#ARGV < 0) || ($#ARGV > 1)) {
    print "Usage error: processmail {issueid} {nametoexclude}\nOr: processmail regenerate\n";
    exit;
}

if ($#ARGV == 1) {
    $nametoexclude = lc($ARGV[1]);
}

if ($ARGV[0] eq "rescanall") {
    print "<br> Collecting issue ids...\n";
    SendSQL("select issue_id from issues where to_days(now()) - to_days(delta_ts) <= 2 order by issue_id");
    my @@list;
    while (my @@row = FetchSQLData()) {
        push @@list, $row[0];
    }
    foreach my $id (@@list) {
        $ARGV[0] = $id;
        print "<br> Doing issue $id\n";
        ProcessOneIssue($ARGV[0]);
    }
} else {
    ProcessOneIssue($ARGV[0]);
}

exit;








@


1.14
log
@Whoops - defined that routine twice.
@
text
@@


1.13
log
@Cleaning up the formatting and sendmail code so that the whole thing is
easier to deal with.
@
text
@a889 34
#-----------------
sub GetPrettyAscii {
#-----------------
    my @@vals = @@_;
    my $text = formline <<'END',@@vals;
+============================================================================+
| @@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< |
+----------------------------------------------------------------------------+
|      Issue #: @@<<<<<<<<<<<              Component: @@<<<<<<<<<<<<<<<<<<<<<< |
|       Status: @@<<<<<<<<<<<<<<<<<<         Version: @@<<<<<<<<<<<<<<<<<<<<<< |
|   Resolution: @@<<<<<<<<<<<<<<<<<<        Platform: @@<<<<<<<<<<<<<<<<<<<<<< |
|   Issue type: @@<<<<<<<<<<<<<<<<<<      OS/Version: @@<<<<<<<<<<<<<<<<<<<<<< |
|     Priority: @@<<<<<<<<<<<<<<<<<<    Subcomponent: @@<<<<<<<<<<<<<<<<<<<<<< |
+----------------------------------------------------------------------------+
|  Assigned To: @@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< |
|  Reported By: @@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< |
|  ~QA Contact: ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< |
|  ~   CC list: ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< |
+----------------------------------------------------------------------------+
| ~  Milestone: ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< |
|~  Whiteboard: ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< |
|          URL: @@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< |
|~Dependencies: ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< |
+============================================================================+
END
    return($text);
}







@


1.12
log
@First attempt to address 'gated' token to suppress the emailing of sensitive
contents (e.g., summaries and descriptions).  It's ugly, and needs to be
rewritten, but it's a start.
@
text
@d29 1
a32 2
use RelationSet;

d37 7
a43 2
$::lockcount = 0;
my $regenerate = 0;
d46 11
d60 17
a263 23
    
        $^A = "";
        my $temp = formline <<'END',$short_desc,$id,$::issue{'component'},$::issue{'issue_status'},$::issue{'version'},$::issue{'resolution'},$::issue{'rep_platform'},$::issue{'issue_type'},$::issue{'op_sys'},$::issue{'priority'},$::issue{'subcomponent'},$::issue{'assigned_to'},$::issue{'reporter'},$qa_contact,DescCC($cclist),$target_milestone,${status_whiteboard},$::issue{'issue_file_loc'},DescDependencies($id);
+============================================================================+
| @@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< |
+----------------------------------------------------------------------------+
|      Issue #: @@<<<<<<<<<<<              Component: @@<<<<<<<<<<<<<<<<<<<<<< |
|       Status: @@<<<<<<<<<<<<<<<<<<         Version: @@<<<<<<<<<<<<<<<<<<<<<< |
|   Resolution: @@<<<<<<<<<<<<<<<<<<        Platform: @@<<<<<<<<<<<<<<<<<<<<<< |
|   Issue type: @@<<<<<<<<<<<<<<<<<<      OS/Version: @@<<<<<<<<<<<<<<<<<<<<<< |
|     Priority: @@<<<<<<<<<<<<<<<<<<    Subcomponent: @@<<<<<<<<<<<<<<<<<<<<<< |
+----------------------------------------------------------------------------+
|  Assigned To: @@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< |
|  Reported By: @@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< |
|  ~QA Contact: ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< |
|  ~   CC list: ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< |
+----------------------------------------------------------------------------+
| ~  Milestone: ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< |
|~  Whiteboard: ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< |
|          URL: @@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< |
|~Dependencies: ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< |
+============================================================================+
END
d265 10
a274 1
        my $prettymail = $^A;
a312 5


my $didexclude = 0;
my %seen;
my @@sentlist;
d360 5
a364 2
    $^A = "";
    my $temp = formline << 'END', $a, $b, $c;
d366 2
a367 2
END
    ; # This semicolon appeases my emacs editor macros. :-)
d375 5
a379 2
    $^A = "";
    my $temp = formline << 'END', $a, $b;
d381 2
a382 2
END
    ; # This semicolon appeases my emacs editor macros. :-)
d386 32
d715 1
a715 5
    open(SENDMAIL, "|/var/qmail/bin/qmail-inject -froot") || ## NPM -- removed "sendmailnow" param, not relevant to qmail
      die "Can't open /var/qmail/bin/qmail-inject";

    print SENDMAIL trim($msg) . "\n";
    close SENDMAIL;
d788 2
a789 3
              open(SENDMAIL, 
                   "|/var/qmail/bin/qmail-inject -froot") || ## NPM -- removed "sendmailnow" param, not relevant to qmail
                     die "Can't open sendmail";
a790 2
              print SENDMAIL $msg;
              close SENDMAIL;
d888 41
@


1.11
log
@Require CGI
@
text
@d192 1
a192 1
    $::issue{'reporter'} = DBID_to_name($::issue{'reporter'});
d196 1
d203 1
d214 1
d217 1
d219 1
d224 1
d229 4
d234 1
a234 1
        my $temp = formline <<'END',$::issue{'short_desc'},$id,$::issue{'component'},$::issue{'issue_status'},$::issue{'version'},$::issue{'resolution'},$::issue{'rep_platform'},$::issue{'issue_type'},$::issue{'op_sys'},$::issue{'priority'},$::issue{'subcomponent'},$::issue{'assigned_to'},$::issue{'reporter'},$qa_contact,DescCC($cclist),$target_milestone,${status_whiteboard},$::issue{'issue_file_loc'},DescDependencies($id);
a253 1
|                              DESCRIPTION                                   |
d256 11
a266 3
    my $prettymail = $^A . $::issue{'long_desc'};
        return $prettymail;

d269 5
a273 1
        return "Issue\#: $id
d285 6
a290 6
$qa_contact$target_milestone${status_whiteboard}URL: $::issue{'issue_file_loc'}
" . DescCC($cclist) . "Summary: $::issue{'short_desc'}
" . DescDependencies($id) . "
$::issue{'long_desc'}
";
}
d292 2
d380 1
d387 1
d390 1
d442 5
a455 2
#    my $resid = 

d500 2
a501 3

    my $newcomments = GetLongDescriptionAsText($id, $start, $end);

a568 1

d580 1
d586 1
d605 7
d629 1
a629 1
# in the first place! see http://issuezilla.mozilla.org/show_bug.cgi?id=29820 
d635 9
a643 2
    if ($isnew) {
      $substs{"diffs"} = $head . "\n\n" . $newcomments;
d645 10
a654 4
      $substs{"diffs"} = $difftext . "\n\n" . $newcomments;
    }
    $substs{"summary"} = $values{'short_desc'};
    
d656 1
a656 1
    
d663 1
d666 1
a666 1
    
d669 1
d702 3
a704 3
  	print FID $text;
  	close FID;
  }	
d781 1
d789 2
d809 2
d844 1
@


1.11.2.1
log
@Merging changes from HEAD to suppress sensitive emails
@
text
@d192 1
a192 1
    $::issue{'reporter'}    = DBID_to_name($::issue{'reporter'});
a195 1

a201 1

a211 1
    
a213 1
    
a214 1
    
a218 1
    
a222 4
        my $short_desc;
        # Add the short description if permitted:
        $short_desc = $::iz_send_diff ? $::issue{'short_desc'} : 'SUMMARY';
    
d224 1
a224 1
        my $temp = formline <<'END',$short_desc,$id,$::issue{'component'},$::issue{'issue_status'},$::issue{'version'},$::issue{'resolution'},$::issue{'rep_platform'},$::issue{'issue_type'},$::issue{'op_sys'},$::issue{'priority'},$::issue{'subcomponent'},$::issue{'assigned_to'},$::issue{'reporter'},$qa_contact,DescCC($cclist),$target_milestone,${status_whiteboard},$::issue{'issue_file_loc'},DescDependencies($id);
d244 1
d247 3
a249 11
        my $prettymail = $^A;
        
        # Add the longdescription if permitted:
        if($::iz_send_diff){
            $prettymail .= 
                '|                              DESCRIPTION                                   |';
            $prettymail .= "\n";   
            $prettymail .= $::issue{'long_desc'};
        }  
        
        return($prettymail);
d252 1
a252 5
        #KPM: Note: tests of '$::iz_send_diff' are to filter out
        # 'sensitive' information from the emails if that flag
        # is set in localconfig: 
        
        my $mailtext = "Issue\#: $id
d264 6
a269 6
$qa_contact$target_milestone${status_whiteboard}URL: $::issue{'issue_file_loc'}\n";

        $mailtext .= DescCC($cclist) . "\n";
        $mailtext .= "Summary: $::issue{'short_desc'}\n" if $::iz_send_diff;
        $mailtext .= DescDependencies($id) . "\n";
        $mailtext .= "$::issue{'long_desc'}\n" if $::iz_send_diff;
a270 2
        return($mailtext);
    }
a356 1
            
a362 1
        
a364 1
            
a415 5
        # Check if we're suppressing summaries:
        if($what =~ m/Summary/ && !$::iz_send_diff){
            ($old, $new) = ('---', '---');  
        }  

d425 2
d471 3
a473 2
    my $newcomments = GetLongDescriptionAsText($id, $start, $end);  
    
d541 1
a552 1

a557 1

a575 7

        #KPM: check to see if we're suppressing summary
        # descriptions:
        if($desc =~ m/Summary/ && !$::iz_send_diff){
            next;
        }

d593 1
a593 1
# in the first place! see http://issuezilla.mozilla.org/show_bug.cgi?id=29820
d599 2
a600 9

    if($::iz_send_diff){
        # It's ok to send bug details via email:    
        if ($isnew) {
          $substs{"diffs"} = $head . "\n\n" . $newcomments;
        } else {
          $substs{"diffs"} = $difftext . "\n\n" . $newcomments;
        }
        $substs{"summary"} = $values{'short_desc'};
d602 4
a605 10
        # It's NOT ok to send bug details via email:
        if ($isnew) {
          $substs{"diffs"} = $head . "\n\n";
        } else {
          $substs{"diffs"} = $difftext . "\n\n";
        }
        $substs{"summary"} = '-summary-';
    } 


d607 1
a607 1

a613 1

d616 1
a616 1

a618 1

d651 3
a653 3
        print FID $text;
        close FID;
  }
a729 1
# KPM: not at all clear what it is that this is trying to do:
a736 2
# KPM: command line option; believed unused in IZ except when 
# checksetup.pl is run:
a754 2
# /processmail", "-forcecc", $origCcString, $id, $::FORM{'who'}
# add some folks to the global @@forcecc array:
a787 1

@


1.10
log
@Removed -w warnings; commented out diagnostics
@
text
@d31 1
a31 1

@


1.9
log
@Committed the following act:
perl -pi -e 's/ASSIGNED/STARTED/g' `find . -type f`
@
text
@d1 1
a1 1
#!/usr/bin/perl -w
d27 1
a27 1
use diagnostics;
@


1.8
log
@Changed directory check to prevent possible 'print on closed filehandle'
warnings.
@
text
@d141 1
a141 1
                if ($issue_status eq "NEW" || $issue_status eq "ASSIGNED" ||
@


1.8.4.1
log
@Removed -w flags and 'use diagnostics' calls
@
text
@d1 1
a1 1
#!/usr/bin/perl 
d27 1
a27 1
#use diagnostics;
@


1.7
log
@Added css to editmilestones, fixed mail formatting to address 1331.
@
text
@d650 4
a653 3
  open(FID, ">$new") || die "Couldn't create $new";
  print FID $text;
  close FID;
@


1.6
log
@Trying to track down where the email link gets created.
@
text
@d326 1
a326 1
^>>>>>>>>>>>>>>>>>>|^<<<<<<<<<<<<<<<<<<<<<<<<<<<|^<<<<<<<<<<<<<<<<<<<<<<<<<<<~~
d338 1
a338 1
^>>>>>>>>>>>>>>>>>> ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<~~
d414 1
a414 1
            $difftext .= ('-' x 76) . "\n";
d417 1
d452 1
a452 1
            $thisdiff .= ('-' x 76) . "\n";
d456 1
@


1.6.2.1
log
@moved over changes from HEAD
@
text
@d326 1
a326 1
^>>>>>>>>>>>>>>>>>>>>>>>>>|^<<<<<<<<<<<<<<<<<<<<<<<<<<|^<<<<<<<<<<<<<<<<<<<<<<<<<<~~
d338 1
a338 1
^>>>>>>>>>>>>>>>>>>>>>>>>> ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<~~
d414 1
a414 1
            $difftext .= ('=' x 82) . "\n";
a416 1
        $difftext .= ('-' x 82) . "\n";
d451 1
a451 1
            $thisdiff .= ('-' x 82) . "\n";
a454 1
        $difftext .= ('-' x 82) . "\n";
@


1.5
log
@Converted 'assigned to' to pulldown (routine in CGI.pl which needs to be
refactored once the needs are stable).  Cosmetic adjustments to processmail.
@
text
@d44 1
d46 1
d62 1
a62 1

d64 1
d72 1
d74 1
d85 1
a85 2


d87 1
d108 1
a108 2


d110 1
d117 1
a117 2


d119 1
d163 1
a163 3



d165 1
d277 1
d279 1
d310 1
a310 2


d312 1
d320 1
a320 2
    

d322 1
d331 1
a331 1
    
d333 1
d343 1
a343 2
    

d345 1
d424 1
a424 1
    my $resid = 
d494 1
a494 1

d496 1
d622 1
d624 2
d627 2
d630 1
d635 2
d643 55
a697 55
    }
    my $text = GetIssueText($i);
    if ($text eq "") {
        die "Couldn't find issue $i.";
    }
    open(FID, ">$new") || die "Couldn't create $new";
    print FID $text;
    close FID;
    if (Different($old, $new)) {
        system("diff -c -b $old $new > $diffs");
        my $tolist = fixaddresses("to",
                                  [$::issue{'assigned_to'}, $::issue{'reporter'},
                                   $::issue{'qa_contact'}]);
        my @@combinedcc;
        foreach my $v (split(/,/, "$::issue{'cclist'},$::issue{'voterlist'}")) {
            push @@combinedcc, $v;
        }
        push (@@combinedcc, (@@forcecc));
        my $cclist = fixaddresses("cc", \@@combinedcc);
        my $logstr = "Issue $i $verb";
        if ($tolist ne "" || $cclist ne "") {
            my %substs;

            $substs{"fullissuereport"} = $text; # added ability to include the full issue report
            $substs{"to"} = $tolist;
            $substs{"cc"} = $cclist;
            $substs{"issueid"} = $i;
            $substs{"diffs"} = "";
            open(DIFFS, "<$diffs") || die "Can't open $diffs";
            while (<DIFFS>) {
                $substs{"diffs"} .= $_;
            }
            close DIFFS;
            $substs{"neworchanged"} = $verb;
            $substs{"summary"} = $::issue{'short_desc'};
            my $msg = PerformSubsts(Param("changedmail"), \%substs);

            if (!$regenerate) {
                # Note: fixaddresses may result in a Cc: only.  This seems
                # harmless.
                my $sendmailparam = "-ODeliveryMode=deferred";
                if (Param("sendmailnow")) {
                    $sendmailparam = "";
                }
                open(SENDMAIL, 
                     "|/var/qmail/bin/qmail-inject -froot") || ## NPM -- removed "sendmailnow" param, not relevant to qmail
                       die "Can't open sendmail";

                print SENDMAIL $msg;
                close SENDMAIL;
                foreach my $n (split(/[, ]+/, "$tolist,$cclist")) {
                    if ($n ne "") {
                        push(@@sentlist, $n);
                    }
                }
d699 19
a717 19
                $logstr = "$logstr; mail sent to $tolist, $cclist";
            }
        }
        unlink($diffs);
        Log($logstr);
    }
    if (@@sentlist) {
        print "<B>Email sent to:</B> " . join(", ", @@sentlist) . "\n";
        if ($didexclude) {
            print qq{<B>Excluding:</B> $nametoexclude (<a href="userprefs.cgi?bank=diffs">change your preferences</a> if you wish not to be excluded)\n};
        }
    }
    rename($new, $old) || die "Can't rename $new to $old";
    chmod 0600, $old;
    if ($regenerate) {
        print "$i ";
    }
    %seen = ();
    @@sentlist = ();
d721 1
@


1.4
log
@Changed all references to 'products' to 'components', and all references to
'components' to 'subcomponents' (not in that order, obviously).
@
text
@d224 1
a224 1
|      Issue #: @@<<<<<<<<<<<                Component: @@<<<<<<<<<<<<<<<<<<<<<< |
d228 1
a228 1
|     Priority: @@<<<<<<<<<<<<<<<<<<       Subcomponent: @@<<<<<<<<<<<<<<<<<<<<<< |
@


1.3
log
@Fixed formatting problem when 'prettyasciimail' is on.
@
text
@d165 1
a165 1
    my @@collist = ("issue_id", "product", "version", "rep_platform", "op_sys",
d168 1
a168 1
                   "short_desc", "component", "qa_contact", "target_milestone",
d220 1
a220 1
        my $temp = formline <<'END',$::issue{'short_desc'},$id,$::issue{'product'},$::issue{'issue_status'},$::issue{'version'},$::issue{'resolution'},$::issue{'rep_platform'},$::issue{'issue_type'},$::issue{'op_sys'},$::issue{'priority'},$::issue{'component'},$::issue{'assigned_to'},$::issue{'reporter'},$qa_contact,DescCC($cclist),$target_milestone,${status_whiteboard},$::issue{'issue_file_loc'},DescDependencies($id);
d224 1
a224 1
|      Issue #: @@<<<<<<<<<<<                Product: @@<<<<<<<<<<<<<<<<<<<<<< |
d228 1
a228 1
|     Priority: @@<<<<<<<<<<<<<<<<<<       Component: @@<<<<<<<<<<<<<<<<<<<<<< |
d249 1
a249 1
Product: $::issue{'product'}
d257 1
a257 1
Component: $::issue{'component'}
@


1.2
log
@Initial checkin of scripts altered to support multiple databases segregated
by virtual host.
@
text
@d224 1
a224 1
|        Issue #: @@<<<<<<<<<<<                Product: @@<<<<<<<<<<<<<<<<<<<<<< |
d227 1
a227 1
|     Issue type: @@<<<<<<<<<<<<<<<<<<      OS/Version: @@<<<<<<<<<<<<<<<<<<<<<< |
@


1.1
log
@Notes on Bugzilla/IssueZilla.

--------------------

This is bugzilla straight outta CVS as of mid-september 2000.

Edited by NPM to work w/ tigris, qmail, etc

Further edited by NPM replacing most instances of "bugs"-->"issues"
"a issue" --> "an issue" etc.

NPM twiddled with query.cgi to lay things out more reasonably, and
add space for future enhancements/customizations.

NPM Removed bugs db column 'severity' and replaced it with 'issue-type'.
Severity seems silly and it's confusing/redundant with priority 'P1'-'P5'.
Some aspects of 'severity' are handled by 'issue-type', e.g.  you
distinguish between an enhancement, feature, task, or defect.

--------------------

To do an upgrade against mozilla.org, move all directories 'CVS' to 'CVS.bak',
e.g. (in tcsh)P:

| beral-5-.../sandbox/issuezilla> foreach i (`find . -name CVS`)
| foreach? mv $i $i.bak
| foreach? end

Then move all 'CVS.mozilla' to 'CVS':

| beral-6-.../sandbox/issuezilla> foreach i (`find . -name CVS.mozilla`)
| foreach? mv $i `dirname $i`/CVS
| foreach? end


Then to see what files might have changed, since this version was last
updated, do:

| beral-6-.../sandbox/issuezilla> cvs -qn update

Then you can either do 'cvs update' and be very careful to watch the output
of cvs, noting any conflicts between the issuezilla edits and mozilla.org's
edits... (files marked w/ 'C').

--------------------

Note the following files are to be instantiated by a tigris SANDBOX initialization script
which someone needs to write...

./data/params.in             ---> ./data/params
./localconfig.in	     ---> ./localconfig
./20issue-track.conf.in      ---> ./20issue-track.conf
@
text
@d47 4
a50 4
        if (!open(LOCKFID, ">>data/maillock")) {
            mkdir "data", 0700;
            chmod 0700, "data";
            open(LOCKFID, ">>data/maillock") || die "Can't open lockfile.";
d56 1
a56 1
        chmod 0600, "data/maillock";
d309 1
a309 1
    open(FID, ">>data/maillog") || die "Can't write to data/maillog";
d617 3
a619 3
  my $old = "shadow/$i";
  my $new = "shadow/$i.tmp.$$";
  my $diffs = "shadow/$i.diffs.$$";
d622 2
a623 2
    mkdir "shadow", 0700;
    chmod 0700, "shadow";
d710 1
a710 1
if (open(FID, "<data/nomail")) {
@


1.1.4.1
log
@Merging changes and additions that were made to netbeans.
@
text
@d224 1
a224 1
|        Issue #: @@<<<<<<<<<                Product: @@<<<<<<<<<<<<<<<<<<<<<< |
d227 1
a227 1
|     Issue type: @@<<<<<<<<<<<<<<<<      OS/Version: @@<<<<<<<<<<<<<<<<<<<<<< |
@


