r303: Added SVN constant to user files; now ISSO debug information shows SVN details.
[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 $fetchtemplates = array(
14 'newcomment'
15 );
16
17 define('SVN', '$Id$');
18
19 require_once('./global.php');
20
21 if (!can_perform('canpostcomments'))
22 {
23 $message->error_permission();
24 }
25
26 // ###################################################################
27
28 if (empty($_REQUEST['do']))
29 {
30 $_REQUEST['do'] = 'add';
31 }
32
33 // ###################################################################
34
35 if ($_POST['do'] == 'insert')
36 {
37 $bugsys->in['comment_parsed'] = $bugsys->in['comment'];
38
39 if (!$bugsys->options['allowhtml'])
40 {
41 $bugsys->in['comment_parsed'] = $bugsys->sanitize($bugsys->in['comment_parsed']);
42 }
43
44 $time = TIMENOW;
45
46 $db->query("
47 INSERT INTO " . TABLE_PREFIX . "comment
48 (bugid, userid, dateline, comment, comment_parsed)
49 VALUES
50 (" . intval($bugsys->in['bugid']) . ", " . $bugsys->userinfo['userid'] . ",
51 $time, '" . $bugsys->in['comment'] . "',
52 '" . nl2br($bugsys->in['comment_parsed']) . "'
53 )"
54 );
55
56 $commentid = $db->insert_id();
57
58 $db->query("
59 UPDATE " . TABLE_PREFIX . "bug
60 SET lastposttime = $time,
61 lastpostby = " . $bugsys->userinfo['userid'] . ",
62 hiddenlastposttime = $time,
63 hiddenlastpostby = " . $bugsys->userinfo['userid'] . "
64 WHERE bugid = " . intval($bugsys->in['bugid'])
65 );
66
67 // setup logging
68 require_once('./includes/class_history.php');
69 $log = new History();
70 $log->bugid = $bugsys->in['bugid'];
71 $log->language = 'log_new_comment';
72 $log->arguments = array($commentid);
73 $log->log();
74
75 $message->redirect('comment inesrted', "showreport.php?bugid=" . intval($bugsys->in['bugid']));
76 }
77
78 // ###################################################################
79
80 if ($_REQUEST['do'] == 'add')
81 {
82 $bug = $db->query_first("SELECT bug.*, comment.comment FROM " . TABLE_PREFIX . "bug AS bug LEFT JOIN " . TABLE_PREFIX . "comment AS comment ON (bug.bugid = comment.bugid) WHERE bug.bugid = " . intval($bugsys->in['bugid']));
83 if (!$bug)
84 {
85 $message->error('alert: bad bug');
86 }
87
88 eval('$template->flush("' . $template->fetch('newcomment') . '");');
89 }
90
91 /*=====================================================================*\
92 || ###################################################################
93 || # $HeadURL$
94 || # $Id$
95 || ###################################################################
96 \*=====================================================================*/
97 ?>