カレンダ機能を追加する
Revision | efc24f99d2fdb2226ac226f84f17a9729d464ac7 (tree) |
---|---|
Time | 2017-09-01 17:44:22 |
Author | stingll <jostingll@gmai...> |
Commiter | stingll |
他のMantisのチケット登録を、違うMantisに登録するためのPHPファイルを作成
bug_reppot.php -> bug_report2.php
セッション・クッキー情報のチェックを外し、user_id,profile_id等もチェックしないようにする
@@ -0,0 +1,215 @@ | ||
1 | +<?php | |
2 | +# Mantis - a php based bugtracking system | |
3 | + | |
4 | +# Copyright (C) 2000 - 2002 Kenzaburo Ito - kenito@300baud.org | |
5 | +# Copyright (C) 2002 - 2009 Mantis Team - mantisbt-dev@lists.sourceforge.net | |
6 | + | |
7 | +# Mantis 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, either version 2 of the License, or | |
10 | +# (at your option) any later version. | |
11 | +# | |
12 | +# Mantis is distributed in the hope that it will be useful, | |
13 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 | +# GNU General Public License for more details. | |
16 | +# | |
17 | +# You should have received a copy of the GNU General Public License | |
18 | +# along with Mantis. If not, see <http://www.gnu.org/licenses/>. | |
19 | + | |
20 | + # -------------------------------------------------------- | |
21 | + # $Id: bug_report.php,v 1.49.2.1 2007-10-13 22:32:51 giallu Exp $ | |
22 | + # -------------------------------------------------------- | |
23 | + | |
24 | + # This page stores the reported bug | |
25 | + | |
26 | + require_once( 'core.php' ); | |
27 | + | |
28 | + $t_core_path = config_get( 'core_path' ); | |
29 | + | |
30 | + require_once( $t_core_path.'string_api.php' ); | |
31 | + require_once( $t_core_path.'file_api.php' ); | |
32 | + require_once( $t_core_path.'bug_api.php' ); | |
33 | + require_once( $t_core_path.'custom_field_api.php' ); | |
34 | + | |
35 | + // form にも入るトークン(bug_reportトークンやセッションで持つ配列にあるかチェックしている。 | |
36 | + // core/form_api.php よって他Mantisからバグ登録を処理するのでトークンは有効でないため | |
37 | + // ここではコメントアウトする | |
38 | + // form_security_validate( 'bug_report' ); | |
39 | + | |
40 | + // user_id を中心にバグ登録するプロジェクトの権限があるかチェックする、user_idはRP_Mantisには | |
41 | + // 登録して権限も設定しているから、このチェックは実施。→最悪コメントアウト | |
42 | + access_ensure_project_level( config_get('report_bug_threshold' ) ); | |
43 | + | |
44 | + $t_bug_data = new BugData; | |
45 | + $t_bug_data->build = gpc_get_string( 'build', '' ); | |
46 | + $t_bug_data->platform = gpc_get_string( 'platform', '' ); | |
47 | + $t_bug_data->os = gpc_get_string( 'os', '' ); | |
48 | + $t_bug_data->os_build = gpc_get_string( 'os_build', '' ); | |
49 | + $t_bug_data->version = gpc_get_string( 'product_version', '' ); | |
50 | + $t_bug_data->profile_id = gpc_get_int( 'profile_id', 0 ); | |
51 | + $t_bug_data->handler_id = gpc_get_int( 'handler_id', 0 ); | |
52 | + $t_bug_data->view_state = gpc_get_int( 'view_state', config_get( 'default_bug_view_status' ) ); | |
53 | + | |
54 | + $t_bug_data->category = gpc_get_string( 'category', config_get( 'default_bug_category' ) ); | |
55 | + $t_bug_data->reproducibility = gpc_get_int( 'reproducibility', config_get( 'default_bug_reproducibility' ) ); | |
56 | + $t_bug_data->severity = gpc_get_int( 'severity', config_get( 'default_bug_severity' ) ); | |
57 | + $t_bug_data->priority = gpc_get_int( 'priority', config_get( 'default_bug_priority' ) ); | |
58 | + $t_bug_data->summary = gpc_get_string( 'summary' ); | |
59 | + $t_bug_data->description = gpc_get_string( 'description' ); | |
60 | + $t_bug_data->steps_to_reproduce = gpc_get_string( 'steps_to_reproduce', config_get( 'default_bug_steps_to_reproduce' ) ); | |
61 | + $t_bug_data->additional_information = gpc_get_string( 'additional_info', config_get ( 'default_bug_additional_info' ) ); | |
62 | + | |
63 | + $f_file = gpc_get_file( 'file', null ); #@@@ (thraxisp) Note that this always returns a structure | |
64 | + # size = 0, if no file | |
65 | + $f_report_stay = gpc_get_bool( 'report_stay', false ); | |
66 | + $t_bug_data->project_id = gpc_get_int( 'project_id' ); | |
67 | + | |
68 | + // 一度なんらかの処理で保存してある、user_id で cookie等チェック、cookieをもとにDBを検索してuser_idを特定しているので | |
69 | + // このチェックは外す。ここでは特定UserID(営業担当eigyo:145)に設定する | |
70 | + //$t_bug_data->reporter_id = auth_get_current_user_id(); | |
71 | + $t_bug_data->reporter_id = '145'; | |
72 | + | |
73 | + $t_bug_data->summary = trim( $t_bug_data->summary ); | |
74 | + | |
75 | + $t_bug_data->target_version = access_has_project_level( config_get( 'roadmap_update_threshold' ), $t_bug_data->project_id ) ? gpc_get_string( 'target_version', '' ) : ''; | |
76 | + | |
77 | + # if a profile was selected then let's use that information | |
78 | + if ( 0 != $t_bug_data->profile_id ) { | |
79 | + // profile_id よりmantis_user_pref_tableからデータ取得。 | |
80 | + // DBを2回引いている気がする | |
81 | + if ( profile_is_global( $t_bug_data->profile_id ) ) { | |
82 | + $row = user_get_profile_row( ALL_USERS, $t_bug_data->profile_id ); | |
83 | + } else { | |
84 | + $row = user_get_profile_row( $t_bug_data->reporter_id, $t_bug_data->profile_id ); | |
85 | + } | |
86 | + | |
87 | + if ( is_blank( $t_bug_data->platform ) ) { | |
88 | + $t_bug_data->platform = $row['platform']; | |
89 | + } | |
90 | + if ( is_blank( $t_bug_data->os ) ) { | |
91 | + $t_bug_data->os = $row['os']; | |
92 | + } | |
93 | + if ( is_blank( $t_bug_data->os_build ) ) { | |
94 | + $t_bug_data->os_build = $row['os_build']; | |
95 | + } | |
96 | + } | |
97 | + helper_call_custom_function( 'issue_create_validate', array( $t_bug_data ) ); | |
98 | + | |
99 | + # Validate the custom fields before adding the bug. | |
100 | + $t_related_custom_field_ids = custom_field_get_linked_ids( $t_bug_data->project_id ); | |
101 | + foreach( $t_related_custom_field_ids as $t_id ) { | |
102 | + $t_def = custom_field_get_definition( $t_id ); | |
103 | + if ( $t_def['require_report'] && !gpc_isset_custom_field( $t_id, $t_def['type'] ) ) { | |
104 | + error_parameters( lang_get_defaulted( custom_field_get_field( $t_id, 'name' ) ) ); | |
105 | + trigger_error( ERROR_EMPTY_FIELD, ERROR ); | |
106 | + } | |
107 | + if ( !custom_field_validate( $t_id, gpc_get_custom_field( "custom_field_$t_id", $t_def['type'], NULL ) ) ) { | |
108 | + error_parameters( lang_get_defaulted( custom_field_get_field( $t_id, 'name' ) ) ); | |
109 | + trigger_error( ERROR_CUSTOM_FIELD_INVALID_VALUE, ERROR ); | |
110 | + } | |
111 | + } | |
112 | + | |
113 | + # Create the bug | |
114 | + $t_bug_id = bug_create( $t_bug_data ); | |
115 | + | |
116 | + # Handle the file upload | |
117 | + if ( !is_blank( $f_file['tmp_name'] ) && ( 0 < $f_file['size'] ) ) { | |
118 | + $f_file_error = ( isset( $f_file['error'] ) ) ? $f_file['error'] : 0; | |
119 | + file_add( $t_bug_id, $f_file['tmp_name'], $f_file['name'], $f_file['type'], 'bug', $f_file_error ); | |
120 | + } | |
121 | + | |
122 | + # Handle custom field submission | |
123 | + foreach( $t_related_custom_field_ids as $t_id ) { | |
124 | + # Do not set custom field value if user has no write access. | |
125 | + if( !custom_field_has_write_access( $t_id, $t_bug_id ) ) { | |
126 | + continue; | |
127 | + } | |
128 | + | |
129 | + $t_def = custom_field_get_definition( $t_id ); | |
130 | + if( !custom_field_set_value( $t_id, $t_bug_id, gpc_get_custom_field( "custom_field_$t_id", $t_def['type'], $t_def['default_value'] ) ) ) { | |
131 | + error_parameters( lang_get_defaulted( custom_field_get_field( $t_id, 'name' ) ) ); | |
132 | + trigger_error( ERROR_CUSTOM_FIELD_INVALID_VALUE, ERROR ); | |
133 | + } | |
134 | + } | |
135 | + | |
136 | + $f_master_bug_id = gpc_get_int( 'm_id', 0 ); | |
137 | + $f_rel_type = gpc_get_int( 'rel_type', -1 ); | |
138 | + | |
139 | + if ( $f_master_bug_id > 0 ) { | |
140 | + # it's a child generation... let's create the relationship and add some lines in the history | |
141 | + | |
142 | + # update master bug last updated | |
143 | + bug_update_date( $f_master_bug_id ); | |
144 | + | |
145 | + # Add log line to record the cloning action | |
146 | + history_log_event_special( $t_bug_id, BUG_CREATED_FROM, '', $f_master_bug_id ); | |
147 | + history_log_event_special( $f_master_bug_id, BUG_CLONED_TO, '', $t_bug_id ); | |
148 | + | |
149 | + if ( $f_rel_type >= 0 ) { | |
150 | + # Add the relationship | |
151 | + relationship_add( $t_bug_id, $f_master_bug_id, $f_rel_type ); | |
152 | + | |
153 | + # Add log line to the history (both issues) | |
154 | + history_log_event_special( $f_master_bug_id, BUG_ADD_RELATIONSHIP, relationship_get_complementary_type( $f_rel_type ), $t_bug_id ); | |
155 | + history_log_event_special( $t_bug_id, BUG_ADD_RELATIONSHIP, $f_rel_type, $f_master_bug_id ); | |
156 | + | |
157 | + # Send the email notification | |
158 | + email_relationship_added( $f_master_bug_id, $t_bug_id, relationship_get_complementary_type( $f_rel_type ) ); | |
159 | + } | |
160 | + } | |
161 | + | |
162 | + email_new_bug( $t_bug_id ); | |
163 | + | |
164 | + helper_call_custom_function( 'issue_create_notify', array( $t_bug_id ) ); | |
165 | + | |
166 | + form_security_purge( 'bug_report' ); | |
167 | + | |
168 | + html_page_top1(); | |
169 | + | |
170 | + if ( ! $f_report_stay ) { | |
171 | + html_meta_redirect( 'view_all_bug_page.php' ); | |
172 | + } | |
173 | + | |
174 | + html_page_top2(); | |
175 | + | |
176 | + // Other Mantis co-operation | |
177 | + if ( $t_bug_data->project_id == 12 ) { | |
178 | + $param = strstr($_SERVER["REQUEST_URI"], '?'); | |
179 | + print "<h3>Param:".$param."</h3>"; | |
180 | + exec("nohup php -c '' 'OtheMantisSubmit.php?'$param > /dev/null &"); | |
181 | + } | |
182 | + | |
183 | +?> | |
184 | +<br /> | |
185 | +<div align="center"> | |
186 | +<?php | |
187 | + echo lang_get( 'operation_successful' ) . '<br />'; | |
188 | + print_bracket_link( string_get_bug_view_url( $t_bug_id ), lang_get( 'view_submitted_bug_link' ) . " $t_bug_id" ); | |
189 | + print_bracket_link( 'view_all_bug_page.php', lang_get( 'view_bugs_link' ) ); | |
190 | + | |
191 | + if ( $f_report_stay ) { | |
192 | +?> | |
193 | + <p> | |
194 | + <form method="post" action="<?php echo string_get_bug_report_url() ?>"> | |
195 | + <input type="hidden" name="category" value="<?php echo $t_bug_data->category ?>" /> | |
196 | + <input type="hidden" name="severity" value="<?php echo $t_bug_data->severity ?>" /> | |
197 | + <input type="hidden" name="reproducibility" value="<?php echo $t_bug_data->reproducibility ?>" /> | |
198 | + <input type="hidden" name="profile_id" value="<?php echo $t_bug_data->profile_id ?>" /> | |
199 | + <input type="hidden" name="platform" value="<?php echo $t_bug_data->platform ?>" /> | |
200 | + <input type="hidden" name="os" value="<?php echo $t_bug_data->os ?>" /> | |
201 | + <input type="hidden" name="os_build" value="<?php echo $t_bug_data->os_build ?>" /> | |
202 | + <input type="hidden" name="product_version" value="<?php echo $t_bug_data->version ?>" /> | |
203 | + <input type="hidden" name="target_version" value="<?php echo $t_bug_data->target_version ?>" /> | |
204 | + <input type="hidden" name="build" value="<?php echo $t_bug_data->build ?>" /> | |
205 | + <input type="hidden" name="report_stay" value="1" /> | |
206 | + <input type="hidden" name="view_state" value="<?php echo $t_bug_data->view_state ?>" /> | |
207 | + <input type="submit" class="button" value="<?php echo lang_get( 'report_more_bugs' ) ?>" /> | |
208 | + </form> | |
209 | + </p> | |
210 | +<?php | |
211 | + } | |
212 | +?> | |
213 | +</div> | |
214 | + | |
215 | +<?php html_page_bottom1( __FILE__ ) ?> |