Esempio n. 1
0
 function sendBugCommentEmail($bug)
 {
     include_once 'pear-bugs-utils.php';
     $pbu = new PEAR_Bugs_Utils();
     $ncomment = trim($bug['comment']);
     $tla = array('Open' => 'Opn', 'Bogus' => 'Bgs', 'Feedback' => 'Fbk', 'No Feedback' => 'NoF', 'Wont fix' => 'WFx', 'Duplicate' => 'Dup', 'Critical' => 'Ctl', 'Assigned' => 'Asn', 'Analyzed' => 'Ana', 'Verified' => 'Ver', 'Suspended' => 'Sus', 'Closed' => 'Csd', 'Spam' => 'Spm');
     $types = array('Bug' => 'Bug', 'Feature/Change Request' => 'Req', 'Documentation Problem' => 'Doc');
     $headers = $text = array();
     /* Default addresses */
     list($mailto, $mailfrom, $Bcc) = $pbu->getPackageMail($bug['package_name'], $bug['id']);
     $headers[] = array(" ID", $bug['id']);
     $headers[] = array(" Comment by", $this->handle);
     $from = "\"{$this->handle}\" <{$this->email}>";
     $prefix = " ";
     if ($f = $pbu->spamProtect($this->email, 'text')) {
         $headers[] = array($prefix . 'Reported By', $f);
     }
     $fields = array('sdesc' => 'Summary', 'status' => 'Status', 'bug_type' => 'Type', 'package_name' => 'Package', 'php_os' => 'Operating System', 'package_version' => 'Package Version', 'php_version' => 'PHP Version', 'assign' => 'Assigned To');
     foreach ($fields as $name => $desc) {
         $prefix = " ";
         /* only fields that are set get added. */
         if ($f = $bug[$name]) {
             $headers[] = array($prefix . $desc, $f);
         }
     }
     # make header output aligned
     $actlength = $maxlength = 0;
     foreach ($headers as $v) {
         $actlength = strlen($v[0]) + 1;
         $maxlength = $maxlength < $actlength ? $actlength : $maxlength;
     }
     # align header content with headers (if a header contains
     # more than one line, wrap it intelligently)
     $header_text = "";
     $spaces = str_repeat(" ", $maxlength + 1);
     foreach ($headers as $v) {
         $hcontent = wordwrap($v[1], 72 - $maxlength, "\n{$spaces}");
         # wrap and indent
         $hcontent = rtrim($hcontent);
         # wordwrap may add spacer to last line
         $header_text .= str_pad($v[0] . ":", $maxlength) . " " . $hcontent . "\n";
     }
     if ($ncomment) {
         $text[] = " New Comment:\n\n" . $ncomment;
     }
     $text[] = $pbu->getOldComments($bug['id'], empty($ncomment));
     /* format mail so it looks nice, use 72 to make piners happy */
     $wrapped_text = wordwrap(join("\n", $text), 72);
     /* developer text with headers, previous messages, and edit link */
     $dev_text = 'Edit report at ' . "http://pear.php.net/bugs/bug.php?id={$bug['id']}&edit=1\n\n" . $header_text . $wrapped_text . "\n-- \nEdit this bug report at " . "http://pear.php.net/bugs/bug.php?id={$bug['id']}&edit=1\n";
     $user_text = $dev_text;
     $subj = $types[$bug['bug_type']];
     $new_status = $bug['status'];
     $subj .= " #{$bug['id']} [Com]: ";
     # the user gets sent mail with an envelope sender that ignores bounces
     if (DEVBOX === false) {
         @mail($bug['email'], "[PEAR-BUG] " . $subj . $bug['sdesc'], $user_text, "From: PEAR Bug Database <{$mailfrom}>\n" . "Bcc: {$Bcc}\n" . "X-PHP-Bug: {$bug['id']}\n" . "In-Reply-To: <bug-{$bug['id']}@pear.php.net>", "-f " . PEAR_BOUNCE_EMAIL);
         # but we go ahead and let the default sender get used for the list
         @mail($mailto, "[PEAR-BUG] " . $subj . $bug['sdesc'], $dev_text, "From: {$from}\n" . "X-PHP-Bug: {$bug['id']}\n" . "X-PHP-Type: " . $bug['bug_type'] . "\n" . "X-PHP-PackageVersion: " . $bug['package_version'] . "\n" . "X-PHP-Version: " . $bug['php_version'] . "\n" . "X-PHP-Category: " . $bug['package_name'] . "\n" . "X-PHP-OS: " . $bug['php_os'] . "\n" . "X-PHP-Status: " . $new_status . "\n" . "In-Reply-To: <bug-{$bug['id']}@pear.php.net>", "-f " . PEAR_BOUNCE_EMAIL);
     }
 }