r145: - Added logging mechanism to files
[bugdar.git] / editreport.php
1 <?php
2 /*=====================================================================*\
3 || ################################################################### ||
4 || # BugStrike [#]version[#]
5 || # --------------------------------------------------------------- # ||
6 || # All parts of this file are ©2002-[#]year[#] Iris Studios, Inc. No # ||
7 || # part of this file may be reproduced in any way: part or whole. # ||
8 || # --------------------------------------------------------------- # ||
9 || # ©2002 - [#]year[#] Iris Studios, Inc. | http://www.iris-studios.com # ||
10 || ################################################################### ||
11 \*=====================================================================*/
12
13 $fetchtemplates = array(
14 'editreport',
15 'pcv_select_row'
16 );
17
18 require_once('./global.php');
19
20 $bug = $db->query_first("
21 SELECT bug.*, user.email, user.displayname, user.showemail
22 FROM " . TABLE_PREFIX . "bug AS bug
23 LEFT JOIN " . TABLE_PREFIX . "user AS user
24 ON (bug.userid = user.userid)
25 WHERE bug.bugid = " . intval($bugsys->in['bugid'])
26 );
27
28 if (!$bug)
29 {
30 echo 'alert: bad bug';
31 exit;
32 }
33
34 if (!(((can_perform('caneditown') AND $bugsys->userinfo['userid'] == $comment['userid']) OR can_perform('caneditothers')) AND can_perform('caneditinfo')))
35 {
36 echo 'no permission';
37 exit;
38 }
39
40 // ###################################################################
41
42 if (empty($_REQUEST['do']))
43 {
44 $_REQUEST['do'] = 'edit';
45 }
46
47 // ###################################################################
48 /*
49 #*# do these later once we have delete permissions figured out
50 if ($_REQUEST['do'] == 'kill')
51 {
52 // run code to remove item in database
53 }
54
55 // ###################################################################
56
57 if ($_REQUEST['do'] == 'delete')
58 {
59 // display delete confirmation message
60 }*/
61
62 // ###################################################################
63
64 if ($_POST['do'] == 'update')
65 {
66 $pcv = parse_pcv_select($bugsys->in['pcv_select'], true);
67
68 if (!$bugsys->in['summary'])
69 {
70 echo 'you need to enter a summary';
71 exit;
72 }
73 if (!$pcv)
74 {
75 echo 'invalid product/component/version';
76 exit;
77 }
78
79 $hist[0] = $db->query_first("SELECT * FROM " . TABLE_PREFIX . "bug WHERE bugid = $bug[bugid]");
80
81 $db->query("
82 UPDATE " . TABLE_PREFIX . "bug
83 SET summary = '" . $bugsys->in['summary'] . "',
84 priority = " . intval($bugsys->in['priority']) . ",
85 status = " . intval($bugsys->in['status']) . ",
86 resolution = " . intval($bugsys->in['resolution']) . ",
87 assignedto = " . intval($bugsys->in['assignedto']) . ",
88 productid = " . $pcv['product'] . ",
89 componentid = " . $pcv['component'] . ",
90 versionid = " . $pcv['version'] . "
91 WHERE bugid = $bug[bugid]"
92 );
93
94 $hist[1] = $db->query_first("SELECT * FROM " . TABLE_PREFIX . "bug WHERE bugid = $bug[bugid]");
95
96 $diff[0] = array_diff_assoc($hist[0], $hist[1]);
97 $diff[1] = array_diff_assoc($hist[1], $hist[0]);
98
99 log_action($bug['bugid'], 'log_update_bug', array(), $diff[0], $diff[1]);
100
101 if (!$bugsys->in['firstcomment'])
102 {
103 echo 'you need to enter some text in the first comment';
104 exit;
105 }
106
107 $bugsys->in['comment_parsed'] = $bugsys->in['firstcomment'];
108
109 if (!$bugsys->options['allowhtml'])
110 {
111 $bugsys->in['comment_parsed'] = $bugsys->sanitize($bugsys->in['comment_parsed']);
112 }
113
114 // we could pass this as a GET param, but that's unsafe
115 $firstcomment = $db->query_first("SELECT * FROM " . TABLE_PREFIX . "comment WHERE bugid = $bug[bugid] ORDER BY dateline ASC LIMIT 1");
116
117 $db->query("
118 UPDATE " . TABLE_PREFIX . "comment
119 SET comment = '" . $bugsys->in['firstcomment'] . "',
120 comment_parsed = '" . nl2br($bugsys->in['comment_parsed']) . "'
121 WHERE commentid = $firstcomment[commentid]"
122 );
123
124 if ($bugsys->in['changeproduct'])
125 {
126 $_REQUEST['do'] = 'editproduct';
127 }
128 else
129 {
130 echo "<a href=\"showreport.php?bugid=$bug[bugid]\">done with update bug</a>";
131 }
132 }
133
134 // ###################################################################
135
136 if ($_REQUEST['do'] == 'edit')
137 {
138 foreach ($bugsys->datastore['severity'] AS $severity)
139 {
140 $value = $severity['severityid'];
141 $selected = (($severity['severityid'] == $bug['severity']) ? true : false);
142 $label = $severity['severity'];
143 eval('$select[severity] .= "' . $template->fetch('selectoption') . '";');
144 }
145
146 $show['changestatus'] = ((can_perform('canchangestatus')) ? true : false);
147 if (can_perform('canchangestatus'))
148 {
149 foreach ($bugsys->datastore['priority'] AS $priority)
150 {
151 $value = $priority['priorityid'];
152 $selected = (($priority['priorityid'] == $bug['priority']) ? true : false);
153 $label = $priority['priority'];
154 eval('$select[priority] .= "' . $template->fetch('selectoption') . '";');
155 }
156
157 foreach ($bugsys->datastore['status'] AS $status)
158 {
159 $value = $status['statusid'];
160 $selected = (($status['statusid'] == $bug['status']) ? true : false);
161 $label = $status['status'];
162 eval('$select[status] .= "' . $template->fetch('selectoption') . '";');
163 }
164
165 foreach ($bugsys->datastore['resolution'] AS $resolution)
166 {
167 $value = $resolution['resolutionid'];
168 $selected = (($resolution['resolutionid'] == $bug['resolution']) ? true : false);
169 $label = $resolution['resolution'];
170 eval('$select[resolution] .= "' . $template->fetch('selectoption') . '";');
171 }
172 }
173
174 $show['assign'] = ((can_perform('canassign')) ? true : false);
175 if (can_perform('canassign'))
176 {
177 foreach ($bugsys->datastore['assignto'] AS $dev)
178 {
179 $value = $dev['userid'];
180 $selected = (($dev['userid'] == $bug['assignedto']) ? true : false);
181 $label = construct_user_display($dev, false);
182 eval('$select[dev] .= "' . $template->fetch('selectoption') . '";');
183 }
184 }
185
186 $pcv_select = construct_pcv_select("p$bug[productid]c$bug[componentid]v$bug[versionid]");
187
188 $firstcomment = $db->query_first("SELECT * FROM " . TABLE_PREFIX . "comment WHERE bugid = $bug[bugid] ORDER BY dateline ASC LIMIT 1");
189
190 eval('$template->flush("' . $template->fetch('editreport') . '");');
191 }
192
193 /*=====================================================================*\
194 || ###################################################################
195 || # $HeadURL$
196 || # $Id$
197 || ###################################################################
198 \*=====================================================================*/
199 ?>