r303: Added SVN constant to user files; now ISSO debug information shows SVN details.
[bugdar.git] / editcomment.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 'editcomment'
15 );
16
17 define('SVN', '$Id$');
18
19 require_once('./global.php');
20
21 $comment = $db->query_first("
22 SELECT comment.*, user.email, user.showemail, user.displayname
23 FROM " . TABLE_PREFIX . "comment AS comment
24 LEFT JOIN " . TABLE_PREFIX . "user AS user
25 ON (comment.userid = user.userid)
26 WHERE comment.commentid = " . intval($bugsys->in['commentid'])
27 );
28
29 if (!$comment)
30 {
31 $message->error('alert: bad comment');
32 }
33
34 $bug = $db->query_first("SELECT * FROM " . TABLE_PREFIX . "bug WHERE bugid = $comment[bugid]");
35
36 if (!((can_perform('caneditown') AND $bugsys->userinfo['userid'] == $comment['userid']) OR can_perform('caneditothers')))
37 {
38 $message->error_permission();
39 }
40
41 if ($bug['hidden'] AND !can_perform('canviewhidden'))
42 {
43 $message->error_permissison();
44 }
45
46 // ###################################################################
47
48 if (empty($_REQUEST['do']))
49 {
50 $_REQUEST['do'] = 'edit';
51 }
52
53 // ###################################################################
54
55 if ($_POST['do'] == 'update')
56 {
57 if (!$bugsys->in['comment'])
58 {
59 $message->error('you need to enter some text');
60 }
61
62 $bugsys->in['comment_parsed'] = $bugsys->in['comment'];
63
64 if (!$bugsys->options['allowhtml'])
65 {
66 $bugsys->in['comment_parsed'] = $bugsys->sanitize($bugsys->in['comment_parsed']);
67 }
68
69 $db->query("
70 UPDATE " . TABLE_PREFIX . "comment
71 SET comment = '" . $bugsys->in['comment'] . "',
72 comment_parsed = '" . nl2br($bugsys->in['comment_parsed']) . "',
73 hidden = " . intval($bugsys->in['hidden']) . "
74 WHERE commentid = $comment[commentid]"
75 );
76
77 // setup logging
78 require_once('./includes/class_history.php');
79 $log = new History();
80 $log->bugid = $bug['bugid'];
81 $log->language = 'log_update_comment';
82 $log->arguments = array($comment['commentid']);
83 $log->log();
84 $log->log($log->diff('hidden', $comment['hidden'], intval($bugsys->in['hidden'])));
85
86 $lastgood = $db->query_first("SELECT * FROM " . TABLE_PREFIX . "comment WHERE bugid = $bug[bugid] AND !hidden ORDER BY dateline DESC");
87 $db->query("
88 UPDATE " . TABLE_PREFIX . "bug
89 SET hiddenlastposttime = $lastgood[dateline],
90 hiddenlastpostby = $lastgood[userid]
91 WHERE bugid = $bug[bugid]"
92 );
93
94 $message->redirect('comment saved', "showreport.php?bugid=$bug[bugid]");
95 }
96
97 // ###################################################################
98
99 if ($_REQUEST['do'] == 'edit')
100 {
101 $comment['posttime'] = $datef->format($bugsys->options['dateformat'], $comment['dateline']);
102 $comment['postby'] = construct_user_display($comment);
103 $comment['comment'] = $bugsys->sanitize($comment['comment']);
104 eval('$template->flush("' . $template->fetch('editcomment') . '");');
105 }
106
107 /*=====================================================================*\
108 || ###################################################################
109 || # $HeadURL$
110 || # $Id$
111 || ###################################################################
112 \*=====================================================================*/
113 ?>