cvs: bugtracker /includes comment.php /template/generic/bug comment.php

From: Date: Thu, 14 Aug 2008 01:22:44 +0000
Subject: cvs: bugtracker /includes comment.php /template/generic/bug comment.php
Groups: php.webmaster 
Request: Send a blank email to php-webmaster+get-2414@lists.php.net to get a copy of this message
bcarlyon Thu Aug 14 01:22:44 2008 UTC Modified files: /bugtracker/includes comment.php /bugtracker/template/generic/bug comment.php Log: Altered the comment engine to send emails http://cvs.php.net/viewvc.cgi/bugtracker/includes/comment.php?r1=1.18&r2=1.19&diff_format=u Index: bugtracker/includes/comment.php diff -u bugtracker/includes/comment.php:1.18 bugtracker/includes/comment.php:1.19 --- bugtracker/includes/comment.php:1.18 Wed Aug 13 22:33:33 2008 +++ bugtracker/includes/comment.php Thu Aug 14 01:22:44 2008 @@ -37,7 +37,7 @@ * @author Barry Carlyon <bcarlyon@php.net> * @copyright 2008-2008 Barry Carlyon * @license http://www.opensource.org/licenses/bsd-license.php BSD License -* @version CVS: $Id: comment.php,v 1.18 2008/08/13 22:33:33 bcarlyon Exp $ +* @version CVS: $Id: comment.php,v 1.19 2008/08/14 01:22:44 bcarlyon Exp $ * @link http://gsoc.barrycarlyon.servegame.org/ */ @@ -48,24 +48,46 @@ $this->bug_id = $comments['bug_id']; if ($comments['description']) { - $this->add_comment(DESCRIPTION,$this->bug_id,$comments['description'],$comments['handle']); + $this->add_comment(DESCRIPTION,$this->bug_id,$comments['description'],$comments['handle'], FALSE); } if ($comments['reproduce']) { - $this->add_comment(REPRODUCE,$this->bug_id,$comments['reproduce'],$comments['handle']); - $this->add_comment(EXPECTED,$this->bug_id,$comments['expected'],$comments['handle']); - $this->add_comment(ACTUAL,$this->bug_id,$comments['actual'],$comments['handle']); + $this->add_comment(REPRODUCE,$this->bug_id,$comments['reproduce'],$comments['handle'], FALSE); + $this->add_comment(EXPECTED,$this->bug_id,$comments['expected'],$comments['handle'], FALSE); + $this->add_comment(ACTUAL,$this->bug_id,$comments['actual'],$comments['handle'], FALSE); } } - function add_comment($type,$bug_id,$text,$handle= '') { - global $db; + function add_comment($type,$bug_id,$text,$handle= '', $send_email = TRUE) { + global $db, $bug, $template, $email, $cookie, $user; if (!$handle) $handle = $user->handle; + $bug->bug_id = $bug_id; + if (!$bug->is_bug()) { + $template->meta_refresh('/'); + trigger_error('An invalid bug id has been selected', E_USER_ERROR); + } $text = $db->protect_data($text); $query = 'INSERT INTO bug_comment(bug_id,comment_type,comment,handle,added) VALUES ' . "('{$bug_id}', '{$type}', '{$text}', '{$handle}', NOW())"; $db->get_data($query); + + if ($db->insert_id && $send_email) { + //email time + $email_message = 'Greetings,' . "\r\n\r\n" . 'A new comment has been left on ' . $cookie['host'] . '/bug/' . $bug->bug_id . "\r\n\r\n"; + $email->send_to_user($bug->bug_data['reported_by'], 'PHP Bugz: New Comment: #' . $bug->bug_id, $email_message); + if (!empty($bug->bug_data['assigned_to']) && $bug->bug_data['reported_by'] != $bug->bug_data['assigned_to']) { + $email->send_to_user($bug->bug_data['assigned_to'], 'PHP Bugz: New Comment: #' . $bug->bug_id, $email_message); + } + if ($user->handle != $bug->bug_data['assigned_to'] && $user->handle != $bug->bug_data['reported_by']) { + // if the bug is not the assigned to or reported by send them an email + $email->send_to_user($user->handle, 'PHP Bugz: Comment Recieved', $email_message); + } + return TRUE; + } + if ($db->insert_id) { + return TRUE; + } return; } http://cvs.php.net/viewvc.cgi/bugtracker/template/generic/bug/comment.php?r1=1.13&r2=1.14&diff_format=u Index: bugtracker/template/generic/bug/comment.php diff -u bugtracker/template/generic/bug/comment.php:1.13 bugtracker/template/generic/bug/comment.php:1.14 --- bugtracker/template/generic/bug/comment.php:1.13 Wed Aug 13 22:33:33 2008 +++ bugtracker/template/generic/bug/comment.php Thu Aug 14 01:22:44 2008 @@ -37,7 +37,7 @@ * @author Barry Carlyon <bcarlyon@php.net> * @copyright 2008-2008 Barry Carlyon * @license http://www.opensource.org/licenses/bsd-license.php BSD License -* @version CVS: $Id: comment.php,v 1.13 2008/08/13 22:33:33 bcarlyon Exp $ +* @version CVS: $Id: comment.php,v 1.14 2008/08/14 01:22:44 bcarlyon Exp $ * @link http://gsoc.barrycarlyon.servegame.org/ */ @@ -103,11 +103,10 @@ if (empty($form_data['form_error'])) { - $comment->add_comment($form_data['comment_type'], $form_data['bug_id'], $form_data['comment_text'], $form_data['handle']); - if ($db->insert_id) { + if ($comment->add_comment($form_data['comment_type'], $form_data['bug_id'], $form_data['comment_text'], $form_data['handle'])) { $content .= '<div id="success">Your comment has been added successfully</div>'; } else { - $form_data['form_error'] = '<div id="error">Your comment failed to be added</div>'; + $form_data['form_error'] = 'Your comment failed to be added'; trace('failed comment add'); $content .= '<table id="bug">'; $comment->spawn_form($form_data, $error_data);

« previous php.webmaster (#2414) next »