r67: - Upping template system to use ISSO
[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 require_once('./global.php');
18
19 sanitize(array('commentid' => INT));
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 = $vars[commentid]"
27 );
28
29 if (!$comment)
30 {
31 echo 'alert: bad comment';
32 exit;
33 }
34
35 $bug = $db->query_first("SELECT * FROM " . TABLE_PREFIX . "bug WHERE bugid = $comment[bugid]");
36
37 if (!((can_perform('caneditown') AND $bugsys->userinfo['userid'] == $comment['userid']) OR can_perform('caneditothers')))
38 {
39 echo 'no permission';
40 exit;
41 }
42
43 // ###################################################################
44
45 if (empty($_REQUEST['do']))
46 {
47 $_REQUEST['do'] = 'edit';
48 }
49 /*
50 #*# do these later after we work out some kind of permission system
51 // ###################################################################
52
53 if ($_REQUEST['do'] == 'kill')
54 {
55 // run code to remove item in database
56 }
57
58 // ###################################################################
59
60 if ($_REQUEST['do'] == 'delete')
61 {
62 // display delete confirmation message
63 }*/
64
65 // ###################################################################
66
67 if ($_POST['do'] == 'update')
68 {
69 sanitize(array('comment' => STR));
70
71 if (!$vars['comment'])
72 {
73 echo 'you need to enter some text';
74 exit;
75 }
76
77 $vars['comment_parsed'] = $vars['comment'];
78
79 if (!$bugsys->options['allowhtml'])
80 {
81 $vars['comment_parsed'] = htmlspecialcharslike($vars['comment_parsed']);
82 }
83
84 $db->query("
85 UPDATE " . TABLE_PREFIX . "comment
86 SET comment = '" . addslasheslike($vars['comment']) . "',
87 comment_parsed = '" . addslasheslike(nl2br($vars['comment_parsed'])) . "'
88 WHERE commentid = $vars[commentid]"
89 );
90
91 echo "<a href=\"showreport.php?bugid=$bug[bugid]\">comment saved</a>";
92 }
93
94 // ###################################################################
95
96 if ($_REQUEST['do'] == 'edit')
97 {
98 $comment['posttime'] = datelike('standard', $comment['dateline']);
99 $comment['postby'] = construct_user_display($comment);
100 $comment['comment'] = htmlspecialcharslike($comment['comment']);
101 eval('$template->flush("' . $template->fetch('editcomment') . '");');
102 }
103
104 /*=====================================================================*\
105 || ###################################################################
106 || # $HeadURL$
107 || # $Id$
108 || ###################################################################
109 \*=====================================================================*/
110 ?>