svn: /web/php-bugs/trunk/ include/functions.php scripts/cron/no-feedback www/bug.php www/patch-add.php
| From: | Jani Taskinen | Date: | Tue, 09 Mar 2010 16:40:59 +0000 |
| Subject: | svn: /web/php-bugs/trunk/ include/functions.php scripts/cron/no-feedback www/bug.php www/patch-add.php | ||
| Groups: | php.webmaster | ||
| Request: | Send a blank email to php-webmaster+get-7531@lists.php.net to get a copy of this message | ||
jani Tue, 09 Mar 2010 16:40:59 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=295997
Log:
- Added function for adding comments
Changed paths:
U web/php-bugs/trunk/include/functions.php
U web/php-bugs/trunk/scripts/cron/no-feedback
U web/php-bugs/trunk/www/bug.php
U web/php-bugs/trunk/www/patch-add.php
Modified: web/php-bugs/trunk/include/functions.php
===================================================================
--- web/php-bugs/trunk/include/functions.php 2010-03-09 13:52:56 UTC (rev 295996)
+++ web/php-bugs/trunk/include/functions.php 2010-03-09 16:40:59 UTC (rev 295997)
@@ -1410,6 +1410,21 @@
}
/**
+ * Add bug comment
+ */
+function bugs_add_comment ($bug_id, $from, $from_name, $comment, $type = 'comment')
+{
+ global $dbh;
+
+ return $dbh->prepare("
+ INSERT INTO bugdb_comments (bug, email, reporter_name, comment, comment_type, ts)
+ VALUES (?, ?, ?, ?, ?, NOW())
+ ")->execute(array(
+ $bug_id, $from, $from_name, $comment, $type,
+ ));
+}
+
+/**
* Verify bug password
*
* @return bool
Modified: web/php-bugs/trunk/scripts/cron/no-feedback
===================================================================
--- web/php-bugs/trunk/scripts/cron/no-feedback 2010-03-09 13:52:56 UTC (rev 295996)
+++ web/php-bugs/trunk/scripts/cron/no-feedback 2010-03-09 16:40:59 UTC (rev 295997)
@@ -35,14 +35,7 @@
$log_comment = bug_diff_render_html($changed);
}
if (!empty($log_comment)) {
- $dbh->prepare('
- INSERT INTO bugdb_comments (bug, email, comment, reporter_name, comment_type, ts)
- VALUES (?, ?, ?, "", "log", NOW())
- ')->execute(array(
- $bug['id'],
- $mailfrom,
- $log_comment,
- ));
+ $res = bugs_add_comment($bug['id'], $mailfrom, '', $log_comment,
'log');
}
// No feedback message
@@ -53,14 +46,7 @@
} else {
die('[no-feedback] Could not find resolve reason! (this should not happen!)');
}
- $dbh->prepare('
- INSERT INTO bugdb_comments (bug, email, comment, reporter_name, comment_type, ts)
- VALUES (?, ?, ?, "", "comment", NOW())
- ')->execute(array(
- $bug['id'],
- $mailfrom,
- $message,
- ));
+ $res = bugs_add_comment($bug['id'], $mailfrom, '', $message,
'comment');
// Update status
$dbh->prepare('
Modified: web/php-bugs/trunk/www/bug.php
===================================================================
--- web/php-bugs/trunk/www/bug.php 2010-03-09 13:52:56 UTC (rev 295996)
+++ web/php-bugs/trunk/www/bug.php 2010-03-09 16:40:59 UTC (rev 295997)
@@ -187,15 +187,8 @@
$_POST['in']['name'] = $auth_user->name;
}
- $res = $dbh->prepare('
- INSERT INTO bugdb_comments (bug, email, comment, reporter_name, ts)
- VALUES (?, ?, ?, ?, NOW())
- ')->execute(array(
- $bug_id,
- $_POST['in']['commentemail'],
- $ncomment,
- $_POST['in']['name'],
- ));
+ $res = bugs_add_comment($bug_id, $_POST['in']['commentemail'],
$_POST['in']['name'], $ncomment, 'comment');
+
} while (false);
if (isset($auth_user) && $auth_user) {
@@ -272,12 +265,7 @@
));
if (!empty($ncomment)) {
- $dbh->prepare("
- INSERT INTO bugdb_comments (bug, email, comment, ts)
- VALUES ({$bug_id}, ?, ?, NOW())
- ")->execute(array(
- $from, $ncomment,
- ));
+ $res = bugs_add_comment($bug_id, $from, '', $ncomment, 'comment');
}
}
} elseif (isset($_POST['in']) && isset($_POST['preview']) &&
$edit == 2) {
@@ -408,27 +396,19 @@
$_POST['in']['php_os'],
));
+ // Add changelog entry
$changed = bug_diff($bug, $_POST['in']);
if (!empty($changed)) {
$log_comment = bug_diff_render_html($changed);
- }
- if (!empty($log_comment)) {
- $dbh->prepare("
- INSERT INTO bugdb_comments (bug, email, comment, reporter_name, comment_type, ts)
- VALUES (?, ?, ?, ?, 'log', NOW())
- ")->execute(array(
- $bug_id, $from, $log_comment, $comment_name,
- ));
+ if (!empty($log_comment)) {
+ $res = bugs_add_comment($bug_id, $from, $comment_name, $log_comment, 'log');
+ }
}
+ // Add normal comment
if (!empty($ncomment)) {
- $dbh->prepare("
- INSERT INTO bugdb_comments (bug, email, comment, reporter_name, comment_type, ts)
- VALUES (?, ?, ?, ?, 'comment', NOW())
- ")->execute(array(
- $bug_id, $from, $ncomment, $comment_name,
- ));
+ $res = bugs_add_comment($bug_id, $from, $comment_name, $ncomment, 'comment');
}
}
} elseif (isset($_POST['in']) && isset($_POST['preview']) &&
$edit == 1) {
Modified: web/php-bugs/trunk/www/patch-add.php
===================================================================
--- web/php-bugs/trunk/www/patch-add.php 2010-03-09 13:52:56 UTC (rev 295996)
+++ web/php-bugs/trunk/www/patch-add.php 2010-03-09 16:40:59 UTC (rev 295997)
@@ -127,17 +127,7 @@
URL: {$patch_url}
TXT;
- $query = '
- INSERT INTO bugdb_comments (
- bug, email, comment, reporter_name, comment_type, ts
- ) VALUES (?, ?, ?, ?, "patch", NOW())
- ';
- $res = $dbh->prepare($query)->execute(array(
- $bug_id,
- $auth_user->email,
- $text,
- $auth_user->name,
- ));
+ $res = bugs_add_comment($bug_id, $auth_user->email, $auth_user->name, $text,
'patch');
// Send emails
list($mailto, $mailfrom) = get_package_mail($package_name);