]>
src.bluestatic.org Git - bugdar.git/blob - newreport.php
2 /*=====================================================================*\
3 || ###################################################################
5 || # Copyright (c)2004-2009 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 \*=====================================================================*/
22 $fetchtemplates = array (
27 $focus [ 'newreport' ] = 'focus' ;
29 require_once ( './global.php' );
30 require_once ( './includes/functions_product.php' );
31 require_once ( './includes/class_notification.php' );
32 require_once ( './includes/api_bug.php' );
33 require_once ( './includes/api_comment.php' );
36 $product = explode ( ',' , $input- > in
[ 'product' ]);
37 if (! can_perform ( 'cansubmitbugs' , $product [ 0 ]))
39 $message- > errorPermission ();
42 // ###################################################################
44 if ( empty ( $_REQUEST [ 'do' ]))
46 $_REQUEST [ 'do' ] = 'add' ;
49 // ###################################################################
51 if ( $_POST [ 'do' ] == 'insert' )
54 $comment = new CommentAPI ();
56 $notif = new NotificationCenter ();
58 $bug- > set ( 'userid' , bugdar
:: $userinfo [ 'userid' ]);
59 $bug- > set ( 'username' , bugdar
:: $userinfo [ 'displayname' ]);
60 $bug- > set ( 'summary' , $input- > in
[ 'summary' ]);
61 $bug- > set ( 'severity' , $input- > in
[ 'severity' ]);
63 $comment- > set ( 'userid' , bugdar
:: $userinfo [ 'userid' ]);
64 $comment- > set ( 'comment' , $input- > in
[ 'comment' ]);
65 $comment- > set ( 'parselinks' , $input- > in
[ 'parselinks' ]);
67 // -------------------------------------------------------------------
68 // check permissions on various input values
69 if (! can_perform ( 'canchangestatus' , $input- > in
[ 'product' ]))
71 $bug- > set ( 'priority' , bugdar
:: $options [ 'defaultpriority' ]);
72 $bug- > set ( 'status' , bugdar
:: $options [ 'defaultstatus' ]);
73 $bug- > set ( 'resolution' , bugdar
:: $options [ 'defaultresolve' ]);
77 $bug- > set ( 'priority' , $input- > in
[ 'priority' ]);
78 $bug- > set ( 'status' , $input- > in
[ 'status' ]);
79 $bug- > set ( 'resolution' , $input- > in
[ 'resolution' ]);
81 if (! can_perform ( 'canassign' , $input- > in
[ 'product' ]))
83 $bug- > set ( 'assignedto' , bugdar
:: $options [ 'defaultassign' ]);
87 // assigned person is not a dev or a valid user
88 $bug- > set ( 'assignedto' , $input- > in
[ 'assignedto' ]);
91 $product = explode ( ',' , $input- > in
[ 'product' ]);
92 $bug- > set ( 'product' , $product [ 0 ]);
93 $bug- > set ( 'component' , $product [ 1 ]);
94 $bug- > set ( 'version' , $product [ 2 ]);
96 process_custom_fields ( $bug , $message , true );
98 if (! $message- > hasErrors ())
102 $comment- > set ( 'bugid' , $bug- > insertid
);
105 $notif- > sendNewBugNotice ( $bug- > values
, $comment- > values
);
107 $bug = new BugAPI (); // need to destroy because update will think the insert fields need to be changed, too
108 $bug- > set ( 'bugid' , $comment- > values
[ 'bugid' ]);
110 $bug- > set ( 'dateline' , $comment- > values
[ 'dateline' ]);
111 $bug- > set ( 'initialreport' , $comment- > insertid
);
112 $bug- > set ( 'lastposttime' , $comment- > values
[ 'dateline' ]);
113 $bug- > set ( 'lastpostby' , bugdar
:: $userinfo [ 'userid' ]);
114 $bug- > set ( 'lastpostbyname' , bugdar
:: $userinfo [ 'displayname' ]);
115 $bug- > set ( 'hiddenlastposttime' , $comment- > values
[ 'dateline' ]);
116 $bug- > set ( 'hiddenlastpostby' , bugdar
:: $userinfo [ 'userid' ]);
117 $bug- > set ( 'hiddenlastpostbyname' , bugdar
:: $userinfo [ 'displayname' ]);
120 $notif- > setBugData ( $bug- > record
);
124 $message- > redirect ( T ( 'The bug has been added to the database.' ), ( $input- > in
[ 'submit_reload' ] == '' ? "showreport.php?bugid=" . $bug- > values
[ 'bugid' ] : 'newreport.php' ));
128 $show [ 'errors' ] = true ;
129 $_REQUEST [ 'do' ] = 'add' ;
133 // ###################################################################
135 if ( $_REQUEST [ 'do' ] == 'add' )
137 if (! is_array ( bugdar
:: $datastore [ 'product' ]))
139 $message- > error ( T ( 'No products have been setup, therefore no bugs can be added.' ));
141 if (! is_array ( bugdar
:: $datastore [ 'version' ]))
143 $message- > error ( T ( 'No versions have been setup underneath your product(s), therefore no bugs can be added.' ));
146 $select [ 'severity' ] = construct_datastore_select ( 'severity' , 'severity' , 'severityid' , ( $input- > in
[ 'severity' ] ? $input- > in
[ 'severity' ] : bugdar
:: $options [ 'defaultseverity' ]));
148 $show [ 'changestatus' ] = can_perform ( 'canchangestatus' );
150 if ( can_perform ( 'canchangestatus' ))
152 $select [ 'priority' ] = construct_datastore_select ( 'priority' , 'priority' , 'priorityid' , ( $input- > in
[ 'priority' ] ? $input- > in
[ 'priority' ] : bugdar
:: $options [ 'defaultpriority' ]));
153 $select [ 'status' ] = construct_datastore_select ( 'status' , 'status' , 'statusid' , ( $input- > in
[ 'status' ] ? $input- > in
[ 'status' ] : bugdar
:: $options [ 'defaultstatus' ]));
154 $select [ 'resolution' ] = construct_datastore_select ( 'resolution' , 'resolution' , 'resolutionid' , ( $input- > in
[ 'resolution' ] ? $input- > in
[ 'resolution' ] : bugdar
:: $options [ 'defaultresolve' ]));
157 $show [ 'assign' ] = can_perform ( 'canassign' );
159 if ( can_perform ( 'canassign' ))
161 foreach ( bugdar
:: $datastore [ 'assignto' ] as $dev )
163 $tpl = new BSTemplate ( 'selectoption' );
165 'value' => $dev [ 'userid' ],
166 'label' => construct_user_display ( $dev , false ),
167 'selected' => ( $input- > in
[ 'assignedto' ] ? ( $input- > in
[ 'assignedto' ] == $dev [ 'userid' ]) : ( $dev [ 'userid' ] == bugdar
:: $options [ 'defaultassign' ]))
169 $select [ 'dev' ] = $tpl- > evaluate ()-> getTemplate ();
174 $fields = construct_custom_fields ( $input- > in
, true );
176 foreach ( $fields AS $field )
180 $customfields [ 'left' ] .= $field ;
184 $customfields [ 'right' ] .= $field ;
189 $tpl = new BSTemplate ( 'newreport' );
191 'reporter' => construct_user_display ( bugdar
:: $userinfo ),
192 'productSelect' => construct_product_select ( 'cansubmitbugs' , $input- > in
[ 'product' ], false ),
194 'customfields' => $customfields
196 $tpl- > evaluate ()-> flush ();