r489: Cleaning up the logging system to work a little better
[bugdar.git] / newcomment.php
1 <?php
2 /*=====================================================================*\
3 || ################################################################### ||
4 || # BugStrike [#]version[#]
5 || # --------------------------------------------------------------- # ||
6 || # Copyright ©2002-[#]year[#] by Iris Studios, Inc. All Rights Reserved. # ||
7 || # This file may not be reproduced in any way without permission. # ||
8 || # --------------------------------------------------------------- # ||
9 || # User License Agreement at http://www.iris-studios.com/license/ # ||
10 || ################################################################### ||
11 \*=====================================================================*/
12
13 define('SVN', '$Id$');
14
15 require_once('./global.php');
16
17 if (!can_perform('canpostcomments'))
18 {
19 $message->error_permission();
20 }
21
22 // ###################################################################
23
24 if ($_POST['do'] == 'insert')
25 {
26 $bugsys->in['comment_parsed'] = $bugsys->in['comment'];
27
28 if (!$bugsys->options['allowhtml'])
29 {
30 $bugsys->in['comment_parsed'] = $bugsys->sanitize($bugsys->in['comment_parsed']);
31 }
32
33 $time = TIMENOW;
34
35 $db->query("
36 INSERT INTO " . TABLE_PREFIX . "comment
37 (bugid, userid, dateline, comment, comment_parsed)
38 VALUES
39 (" . intval($bugsys->in['bugid']) . ", " . $bugsys->userinfo['userid'] . ",
40 $time, '" . $bugsys->in['comment'] . "',
41 '" . nl2br($bugsys->in['comment_parsed']) . "'
42 )"
43 );
44
45 $commentid = $db->insert_id();
46
47 $db->query("
48 UPDATE " . TABLE_PREFIX . "bug
49 SET lastposttime = $time,
50 lastpostby = " . $bugsys->userinfo['userid'] . ",
51 hiddenlastposttime = $time,
52 hiddenlastpostby = " . $bugsys->userinfo['userid'] . "
53 WHERE bugid = " . intval($bugsys->in['bugid'])
54 );
55
56 // setup logging
57 require_once('./includes/class_history.php');
58 $log = new History();
59 $log->bugid = $bugsys->in['bugid'];
60 $log->arguments = array($commentid);
61 $log->log();
62
63 $message->redirect($lang->string('Your reply has been added to the comment list.'), "showreport.php?bugid=" . intval($bugsys->in['bugid']));
64 }
65
66 /*=====================================================================*\
67 || ###################################################################
68 || # $HeadURL$
69 || # $Id$
70 || ###################################################################
71 \*=====================================================================*/
72 ?>