]>
src.bluestatic.org Git - bugdar.git/blob - editreport.php
2 /*=====================================================================*\
3 || ###################################################################
5 || # Copyright 2002-2007 Blue Static
7 || # This program is free software; you can redistribute it and/or modify
8 || # it under the terms of the GNU General Public License as published by
9 || # the Free Software Foundation; version 2 of the License.
11 || # This program is distributed in the hope that it will be useful, but
12 || # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 || # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
16 || # You should have received a copy of the GNU General Public License along
17 || # with this program; if not, write to the Free Software Foundation, Inc.,
18 || # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
19 || ###################################################################
20 \*=====================================================================*/
23 $focus [ 'showreport' ] = 'focus' ;
25 require_once ( './global.php' );
26 require_once ( './includes/functions_product.php' );
27 require_once ( './includes/class_notification.php' );
28 require_once ( './includes/api_bug.php' );
29 require_once ( './includes/api_comment.php' );
31 require_once ( './includes/class_api_error.php' );
32 APIError ( array ( new API_Error_Handler ( $message ), 'user_cumulative' ));
34 $bug = $db- > query_first ( "
35 SELECT bug.*, user.email, user.displayname, user.showemail
36 FROM " . TABLE_PREFIX
. "bug AS bug
37 LEFT JOIN " . TABLE_PREFIX
. "user AS user
38 ON (bug.userid = user.userid)
39 WHERE bug.bugid = " . $bugsys- > input_clean ( 'bugid' , TYPE_UINT
)
44 $message- > error ( L_INVALID_ID
);
47 if (! check_bug_permissions ( $bug ))
49 $message- > errorPermission ();
53 require_once ( './includes/class_logging.php' );
55 $log- > set_bugid ( $bug [ 'bugid' ]);
57 $notif = new NotificationCenter
;
59 $bugapi = new BugAPI ( $bugsys );
60 $bugapi- > set ( 'bugid' , $bugsys- > in
[ 'bugid' ]);
61 $bugapi- > set_condition ();
62 $bugapi- > dorelations
= array ();
65 // ###################################################################
67 if ( $_POST [ 'do' ] == 'kill' )
69 if (! can_perform ( 'candeletedata' , $bug [ 'product' ]))
71 $message- > errorPermission ();
76 $message- > redirect ( T ( 'The entire bug has been deleted.' ), 'index.php' );
79 // ###################################################################
81 if ( $_REQUEST [ 'do' ] == 'delete' )
83 if (! can_perform ( 'candeletedata' , $bug [ 'product' ]))
85 $message- > errorPermission ();
88 $message- > confirm ( T ( 'Are you sure you want to delete this bug? Doing so will <strong>destroy</strong> all associated data, including comments, attachments, and votes. We strongly recommend only deleting span records and nothing else as users may wish to go back and look at any bug to check its status.' ), 'editreport.php' , 'kill' , T ( 'Delete Bug Permanently' ), 'showreport.php?bugid=' . $bug [ 'bugid' ], array ( 'bugid' => $bug [ 'bugid' ]));
91 // ###################################################################
93 if ( $_POST [ 'do' ] == 'update' )
95 if (!(( can_perform ( 'caneditown' , $bug [ 'product' ]) AND $bugsys- > userinfo
[ 'userid' ] == $bug [ 'userid' ]) OR ( can_perform ( 'caneditother' , $bug [ 'product' ]) AND $bugsys- > userinfo
[ 'userid' ] != $bug [ 'userid' ])) AND ! can_perform ( 'canpostcomments' , $bug [ 'product' ]))
97 $message- > errorPermission ();
100 $log- > add_data ( true , $bugapi- > objdata
, $log- > getCommonFields (), true );
102 // -------------------------------------------------------------------
103 // handle automations
104 if ( $bugsys- > in
[ 'automation' ])
106 $automation = $db- > query_first ( "SELECT * FROM " . TABLE_PREFIX
. "automation WHERE actionid = " . $bugsys- > input_clean ( 'automation' , TYPE_UINT
));
109 $automation [ 'fields' ] = unserialize ( $automation [ 'fieldchanges' ]);
111 if ( is_array ( $automation [ 'fields' ][ 'builtin' ]))
113 foreach ( $automation [ 'fields' ][ 'builtin' ] AS $field => $value )
115 $bugsys- > in
[ " $field" ] = $value ;
119 if (is_array( $automation ['fields']['custom']))
121 foreach ( $automation ['fields']['custom'] AS $field => $value )
123 $bugsys- >in[" custom
$field" ] = $value ;
129 // -------------------------------------------------------------------
130 // process comment stuff
131 if ( $bugsys- > in
[ 'comment' ] OR $automation [ 'comment' ])
133 if (! empty ( $bugsys- > in
[ 'comment' ]) AND $automation [ 'comment' ])
135 $commenttext = $bugsys- > in
[ 'comment' ] . " \n\n " . T ( '--------------- AUTOMATIC RESPONSE ---------------' ) . " \n " . $automation [ 'comment' ];
137 else if ( empty ( $bugsys- > in
[ 'comment' ]) AND $automation [ 'comment' ])
139 $commenttext = $automation [ 'comment' ];
143 $commenttext = $bugsys- > in
[ 'comment' ];
146 $comment = new CommentAPI ( $bugsys );
147 $comment- > set ( 'bugid' , $bugsys- > in
[ 'bugid' ]);
148 $comment- > set ( 'userid' , $bugsys- > userinfo
[ 'userid' ]);
149 $comment- > set ( 'comment' , $commenttext );
150 $comment- > set ( 'parselinks' , $bugsys- > in
[ 'parselinks' ]);
153 // we redefine the bug data later, but it needs to be here in order to generate the user list
154 $notif- > set_bug_data ( $bugapi- > objdata
);
155 $notif- > send_new_comment_notice ( $comment- > values
);
157 $bugapi- > set ( 'lastposttime' , $comment- > values
[ 'dateline' ]);
158 $bugapi- > set ( 'lastpostby' , $bugsys- > userinfo
[ 'userid' ]);
159 $bugapi- > set ( 'lastpostbyname' , $bugsys- > userinfo
[ 'displayname' ]);
160 $bugapi- > set ( 'hiddenlastposttime' , $comment- > values
[ 'dateline' ]);
161 $bugapi- > set ( 'hiddenlastpostby' , $bugsys- > userinfo
[ 'userid' ]);
162 $bugapi- > set ( 'hiddenlastpostbyname' , $bugsys- > userinfo
[ 'displayname' ]);
164 if (!(( can_perform ( 'caneditown' , $bug [ 'product' ]) AND $bugsys- > userinfo
[ 'userid' ] == $bug [ 'userid' ]) OR ( can_perform ( 'caneditother' , $bug [ 'product' ]) AND $bugsys- > userinfo
[ 'userid' ] != $bug [ 'userid' ])))
168 $message- > redirect ( T ( 'Your reply has been added to the comment list.' ), "showreport.php?bugid= $bug [bugid]" );
172 // -------------------------------------------------------------------
174 $dependencies = preg_split ( '#([^0-9].*?)#' , $bugsys- > in
[ 'dependency' ], - 1 , PREG_SPLIT_NO_EMPTY
);
175 $dependencies = (( sizeof ( $dependencies ) < 1 ) ? '' : implode ( ', ' , $dependencies ));
177 if (( can_perform ( 'caneditown' , $bug [ 'product' ]) AND $bugsys- > userinfo
[ 'userid' ] == $bug [ 'userid' ]) OR ( can_perform ( 'caneditother' , $bug [ 'product' ]) AND $bugsys- > userinfo
[ 'userid' ] != $bug [ 'userid' ]))
179 $bugapi- > set ( 'summary' , $bugsys- > in
[ 'summary' ]);
180 $bugapi- > set ( 'severity' , $bugsys- > in
[ 'severity' ]);
181 $bugapi- > set ( 'duplicateof' , $bugsys- > in
[ 'duplicateof' ]);
182 $bugapi- > set ( 'dependency' , $dependencies );
183 $bugapi- > set ( 'hidden' , $bugsys- > in
[ 'hidden' ]);
185 $product = explode ( ',' , $bugsys- > in
[ 'product' ]);
186 $bugapi- > set ( 'product' , $product [ 0 ]);
187 $bugapi- > set ( 'component' , $product [ 1 ]);
188 $bugapi- > set ( 'version' , $product [ 2 ]);
191 if ( can_perform ( 'canchangestatus' , $bug [ 'product' ]))
193 $bugapi- > set ( 'priority' , $bugsys- > in
[ 'priority' ]);
194 $bugapi- > set ( 'status' , $bugsys- > in
[ 'status' ]);
195 $bugapi- > set ( 'resolution' , $bugsys- > in
[ 'resolution' ]);
197 if ( can_perform ( 'canassign' , $bug [ 'product' ]))
199 $bugapi- > set ( 'assignedto' , $bugsys- > in
[ 'assignedto' ]);
202 process_custom_fields ( $bugapi , $message , false );
204 // -------------------------------------------------------------------
205 // handle logging and perform updates
207 $notif- > set_bug_data ( $bugapi- > objdata
, array_merge ( $bugapi- > objdata
, $bugapi- > values
));
208 $log- > add_data ( false , $bugapi- > values
, $log- > getCommonFields (), true );
210 if (! $message- > hasErrors ())
219 // -------------------------------------------------------------------
222 $log- > update_history ();
224 $notif- > send_bug_changes_notice ();
228 $message- > redirect ( T ( 'Your changes to the bug have been saved.' ), "showreport.php?bugid= $bug [bugid]" );