@@ -186,11 +186,11 @@ public function __get($name) {
186
186
$ this ->fetch_extended_info ();
187
187
return $ this ->{$ name };
188
188
}
189
-
189
+
190
190
/**
191
191
* @private
192
192
*/
193
- public function __isset ($ name ) {
193
+ public function __isset ($ name ) {
194
194
return isset ( $ this ->{$ name } );
195
195
}
196
196
@@ -206,13 +206,13 @@ public function loadrow( $p_row ) {
206
206
}
207
207
$ this ->loading = false ;
208
208
}
209
-
209
+
210
210
/**
211
211
* Retrieves extended information for bug (e.g. bug description)
212
212
* @return null
213
213
*/
214
214
private function fetch_extended_info () {
215
- if ( $ this ->description == '' ) {
215
+ if ( $ this ->description == '' ) {
216
216
$ t_text = bug_text_cache_row ($ this ->id );
217
217
218
218
$ this ->description = $ t_text ['description ' ];
@@ -1054,21 +1054,32 @@ function bug_move( $p_bug_id, $p_target_project_id ) {
1054
1054
// Move the issue to the new project.
1055
1055
bug_set_field ( $ p_bug_id , 'project_id ' , $ p_target_project_id );
1056
1056
1057
- // Check if the category for the issue is global or not.
1057
+ // Update the category if needed
1058
1058
$ t_category_id = bug_get_field ( $ p_bug_id , 'category_id ' );
1059
- $ t_category_project_id = category_get_field ( $ t_category_id , 'project_id ' );
1060
-
1061
- // If not global, then attempt mapping it to the new project.
1062
- if ( $ t_category_project_id != ALL_PROJECTS && !project_hierarchy_inherit_parent ( $ p_target_project_id , $ t_category_project_id ) ) {
1063
- // Map by name
1064
- $ t_category_name = category_get_field ( $ t_category_id , 'name ' );
1065
- $ t_target_project_category_id = category_get_id_by_name ( $ t_category_name , $ p_target_project_id , /* triggerErrors */ false );
1066
- if ( $ t_target_project_category_id === false ) {
1067
- // Use default category after moves, since there is no match by name.
1068
- $ t_target_project_category_id = config_get ( 'default_category_for_moves ' );
1069
- }
1070
1059
1071
- bug_set_field ( $ p_bug_id , 'category_id ' , $ t_target_project_category_id );
1060
+ // Bug has no category
1061
+ if ( $ t_category_id == 0 ) {
1062
+ // Category is required in target project, set it to default
1063
+ if ( ON != config_get ( 'allow_no_category ' , null , null , $ p_target_project_id ) ) {
1064
+ bug_set_field ( $ p_bug_id , 'category_id ' , config_get ( 'default_category_for_moves ' ) );
1065
+ }
1066
+ }
1067
+ // Check if the category is global, and if not attempt mapping it to the new project
1068
+ else {
1069
+ $ t_category_project_id = category_get_field ( $ t_category_id , 'project_id ' );
1070
+
1071
+ if ( $ t_category_project_id != ALL_PROJECTS
1072
+ && !project_hierarchy_inherit_parent ( $ p_target_project_id , $ t_category_project_id )
1073
+ ) {
1074
+ // Map by name
1075
+ $ t_category_name = category_get_field ( $ t_category_id , 'name ' );
1076
+ $ t_target_project_category_id = category_get_id_by_name ( $ t_category_name , $ p_target_project_id , /* triggerErrors */ false );
1077
+ if ( $ t_target_project_category_id === false ) {
1078
+ // Use default category after moves, since there is no match by name.
1079
+ $ t_target_project_category_id = config_get ( 'default_category_for_moves ' );
1080
+ }
1081
+ bug_set_field ( $ p_bug_id , 'category_id ' , $ t_target_project_category_id );
1082
+ }
1072
1083
}
1073
1084
}
1074
1085
@@ -1735,16 +1746,16 @@ function bug_monitor( $p_bug_id, $p_user_id ) {
1735
1746
1736
1747
/**
1737
1748
* Returns the list of users monitoring the specified bug
1738
- *
1749
+ *
1739
1750
* @param int $p_bug_id
1740
1751
*/
1741
1752
function bug_get_monitors ( $ p_bug_id ) {
1742
-
1753
+
1743
1754
if ( ! access_has_bug_level ( config_get ( 'show_monitor_list_threshold ' ), $ p_bug_id ) ) {
1744
1755
return Array ();
1745
1756
}
1746
-
1747
-
1757
+
1758
+
1748
1759
$ c_bug_id = db_prepare_int ( $ p_bug_id );
1749
1760
$ t_bug_monitor_table = db_get_table ( 'mantis_bug_monitor_table ' );
1750
1761
$ t_user_table = db_get_table ( 'mantis_user_table ' );
@@ -1762,9 +1773,9 @@ function bug_get_monitors( $p_bug_id ) {
1762
1773
$ row = db_fetch_array ( $ result );
1763
1774
$ t_users [$ i ] = $ row ['user_id ' ];
1764
1775
}
1765
-
1776
+
1766
1777
user_cache_array_rows ( $ t_users );
1767
-
1778
+
1768
1779
return $ t_users ;
1769
1780
}
1770
1781
0 commit comments