# it's a child generation... let's create the relationship and add some lines in the history # update master bug last updated bug_update_date($f_master_bug_id); # Add log line to record the cloning action history_log_event_special($t_bug_id, BUG_CREATED_FROM, '', $f_master_bug_id); history_log_event_special($f_master_bug_id, BUG_CLONED_TO, '', $t_bug_id); if ($f_rel_type >= 0) { # Add the relationship relationship_add($t_bug_id, $f_master_bug_id, $f_rel_type); # Add log line to the history (both issues) history_log_event_special($f_master_bug_id, BUG_ADD_RELATIONSHIP, relationship_get_complementary_type($f_rel_type), $t_bug_id); history_log_event_special($t_bug_id, BUG_ADD_RELATIONSHIP, $f_rel_type, $f_master_bug_id); # update relationship target bug last updated bug_update_date($t_bug_id); # Send the email notification email_relationship_added($f_master_bug_id, $t_bug_id, relationship_get_complementary_type($f_rel_type)); } # copy notes from parent if ($f_copy_notes_from_parent) { $t_parent_bugnotes = bugnote_get_all_bugnotes($f_master_bug_id); foreach ($t_parent_bugnotes as $t_parent_bugnote) { $t_private = $t_parent_bugnote->view_state == VS_PRIVATE; bugnote_add($t_bug_id, $t_parent_bugnote->note, $t_parent_bugnote->time_tracking, $t_private, $t_parent_bugnote->note_type, $t_parent_bugnote->note_attr, $t_parent_bugnote->reporter_id, FALSE, FALSE); } } # copy attachments from parent if ($f_copy_attachments_from_parent) { file_copy_attachments($f_master_bug_id, $t_bug_id); } } helper_call_custom_function('issue_create_notify', array($t_bug_id));
} # check if there is other relationship between the bugs... $t_old_id_relationship = relationship_same_type_exists($f_src_bug_id, $f_dest_bug_id, $f_rel_type); if ($t_old_id_relationship == -1) { # the relationship type is exactly the same of the new one. No sense to proceed trigger_error(ERROR_RELATIONSHIP_ALREADY_EXISTS, ERROR); } else { if ($t_old_id_relationship > 0) { # there is already a relationship between them -> we have to update it and not to add a new one helper_ensure_confirmed(lang_get('replace_relationship_sure_msg'), lang_get('replace_relationship_button')); # Update the relationship relationship_update($t_old_id_relationship, $f_src_bug_id, $f_dest_bug_id, $f_rel_type); # Add log line to the history (both bugs) history_log_event_special($f_src_bug_id, BUG_REPLACE_RELATIONSHIP, $f_rel_type, $f_dest_bug_id); history_log_event_special($f_dest_bug_id, BUG_REPLACE_RELATIONSHIP, relationship_get_complementary_type($f_rel_type), $f_src_bug_id); } else { # Add the new relationship relationship_add($f_src_bug_id, $f_dest_bug_id, $f_rel_type); # Add log line to the history (both bugs) history_log_event_special($f_src_bug_id, BUG_ADD_RELATIONSHIP, $f_rel_type, $f_dest_bug_id); history_log_event_special($f_dest_bug_id, BUG_ADD_RELATIONSHIP, relationship_get_complementary_type($f_rel_type), $f_src_bug_id); } } # update bug last updated (just for the src bug) bug_update_date($f_src_bug_id); # send email notification to the users addressed by both the bugs email_relationship_added($f_src_bug_id, $f_dest_bug_id, $f_rel_type); email_relationship_added($f_dest_bug_id, $f_src_bug_id, relationship_get_complementary_type($f_rel_type)); } form_security_purge('bug_relationship_add'); print_header_redirect_view($f_src_bug_id);
/** * Submit a new relationship. * * @param string $p_username The name of the user trying to add a note to an issue. * @param string $p_password The password of the user. * @param integer $p_issue_id The id of the issue of the source issue. * @param stdClass $p_relationship The relationship to add (RelationshipData SOAP object). * @return integer The id of the added relationship. */ function mc_issue_relationship_add($p_username, $p_password, $p_issue_id, stdClass $p_relationship) { global $g_project_override; $t_user_id = mci_check_login($p_username, $p_password); $p_relationship = SoapObjectsFactory::unwrapObject($p_relationship); $t_dest_issue_id = $p_relationship['target_id']; $t_rel_type = SoapObjectsFactory::unwrapObject($p_relationship['type']); if ($t_user_id === false) { return mci_soap_fault_login_failed(); } $t_project_id = bug_get_field($p_issue_id, 'project_id'); $g_project_override = $t_project_id; if (!mci_has_readwrite_access($t_user_id, $t_project_id)) { return mci_soap_fault_access_denied($t_user_id); } # user has access to update the bug... if (!access_has_bug_level(config_get('update_bug_threshold'), $p_issue_id, $t_user_id)) { return mci_soap_fault_access_denied($t_user_id, 'Active user does not have access level required to add a relationship to this issue'); } # source and destination bugs are the same bug... if ($p_issue_id == $t_dest_issue_id) { return SoapObjectsFactory::newSoapFault('Client', 'An issue can\'t be related to itself.'); } # the related bug exists... if (!bug_exists($t_dest_issue_id)) { return SoapObjectsFactory::newSoapFault('Client', 'Issue \'' . $t_dest_issue_id . '\' not found.'); } # bug is not read-only... if (bug_is_readonly($p_issue_id)) { return mci_soap_fault_access_denied($t_user_id, 'Issue \'' . $p_issue_id . '\' is readonly'); } # user can access to the related bug at least as viewer... if (!access_has_bug_level(config_get('view_bug_threshold', null, null, $t_project_id), $t_dest_issue_id, $t_user_id)) { return mci_soap_fault_access_denied($t_user_id, 'The issue \'' . $t_dest_issue_id . '\' requires higher access level'); } $t_old_id_relationship = relationship_same_type_exists($p_issue_id, $t_dest_issue_id, $t_rel_type['id']); if ($t_old_id_relationship == 0) { log_event(LOG_WEBSERVICE, 'adding relationship type \'' . $t_rel_type['id'] . '\' between \'' . $p_issue_id . '\' and \'' . $t_dest_issue_id . '\''); relationship_add($p_issue_id, $t_dest_issue_id, $t_rel_type['id']); # The above function call into MantisBT does not seem to return a valid BugRelationshipData object. # So we call db_insert_id in order to find the id of the created relationship. $t_relationship_id = db_insert_id(db_get_table('bug_relationship')); # Add log line to the history (both bugs) history_log_event_special($p_issue_id, BUG_ADD_RELATIONSHIP, $t_rel_type['id'], $t_dest_issue_id); history_log_event_special($t_dest_issue_id, BUG_ADD_RELATIONSHIP, relationship_get_complementary_type($t_rel_type['id']), $p_issue_id); # update bug last updated for both bugs bug_update_date($p_issue_id); bug_update_date($t_dest_issue_id); # send email notification to the users addressed by both the bugs email_relationship_added($p_issue_id, $t_dest_issue_id, $t_rel_type['id']); email_relationship_added($t_dest_issue_id, $p_issue_id, relationship_get_complementary_type($t_rel_type['id'])); return $t_relationship_id; } else { return SoapObjectsFactory::newSoapFault('Client', 'Relationship already exists.'); } }
/** * Submit a new relationship. * * @param string $p_username The name of the user trying to add a note to an issue. * @param string $p_password The password of the user. * @param integer $p_issue_id The id of the issue of the source issue. * @param RelationshipData $p_relationship The relationship to add. * @return integer The id of the added relationship. */ function mc_issue_relationship_add( $p_username, $p_password, $p_issue_id, $p_relationship ) { $t_user_id = mci_check_login( $p_username, $p_password ); $t_dest_issue_id = $p_relationship['target_id']; $t_rel_type = $p_relationship['type']; if( $t_user_id === false ) { return mci_soap_fault_login_failed(); } $t_project_id = bug_get_field( $p_issue_id, 'project_id' ); if( !mci_has_readwrite_access( $t_user_id, $t_project_id ) ) { return mci_soap_fault_access_denied( $t_user_id ); } # user has access to update the bug... if( !access_has_bug_level( config_get( 'update_bug_threshold' ), $p_issue_id, $t_user_id ) ) { return mci_soap_fault_access_denied( $t_user_id, "Active user does not have access level required to add a relationship to this issue" ); } # source and destination bugs are the same bug... if( $p_issue_id == $t_dest_issue_id ) { return new soap_fault( 'Client', '', "An issue can't be related to itself." ); } # the related bug exists... if( !bug_exists( $t_dest_issue_id ) ) { return new soap_fault( 'Client', '', "Issue '$t_dest_issue_id' not found." ); } # bug is not read-only... if( bug_is_readonly( $p_issue_id ) ) { return new mci_soap_fault_access_denied( $t_user_id, "Issue '$p_issue_id' is readonly" ); } # user can access to the related bug at least as viewer... if( !access_has_bug_level( VIEWER, $t_dest_issue_id, $t_user_id ) ) { return mci_soap_fault_access_denied( $t_user_id, "The issue '$t_dest_issue_id' requires higher access level" ); } $t_old_id_relationship = relationship_same_type_exists( $p_issue_id, $t_dest_issue_id, $t_rel_type['id'] ); if( $t_old_id_relationship == 0 ) { relationship_add( $p_issue_id, $t_dest_issue_id, $t_rel_type['id'] ); // The above function call into MantisBT does not seem to return a valid BugRelationshipData object. // So we call db_insert_id in order to find the id of the created relationship. $t_relationship_id = db_insert_id( db_get_table( 'bug_relationship' ) ); # Add log line to the history (both bugs) history_log_event_special( $p_issue_id, BUG_ADD_RELATIONSHIP, $t_rel_type['id'], $t_dest_issue_id ); history_log_event_special( $t_dest_issue_id, BUG_ADD_RELATIONSHIP, relationship_get_complementary_type( $t_rel_type['id'] ), $p_issue_id ); # update bug last updated for both bugs bug_update_date( $p_issue_id ); bug_update_date( $t_dest_issue_id ); # send email notification to the users addressed by both the bugs email_relationship_added( $p_issue_id, $t_dest_issue_id, $t_rel_type['id'] ); email_relationship_added( $t_dest_issue_id, $p_issue_id, relationship_get_complementary_type( $t_rel_type['id'] ) ); return $t_relationship_id; } else { return new soap_fault( 'Client', '', "Relationship already exists." ); } }
private function add_bug(&$p_email, $p_overwrite_project_id = FALSE) { $this->show_memory_usage('Start add bug'); //Merge References and In-Reply-To headers into one array $t_references = $p_email['References']; $t_references[] = $p_email['In-Reply-To']; if ($this->_mail_add_bugnotes) { $t_bug_id = $this->mail_is_a_bugnote($p_email['Subject'], $t_references); } else { $t_bug_id = FALSE; } if ($t_bug_id !== FALSE && !bug_is_readonly($t_bug_id)) { // @TODO@ Disabled for now until we find a good solution on how to handle the reporters possible lack of access permissions // access_ensure_bug_level( config_get( 'add_bugnote_threshold' ), $f_bug_id ); $t_description = $p_email['X-Mantis-Body']; $t_description = $this->identify_replies($t_description); $t_description = $this->strip_signature($t_description); $t_description = $this->add_additional_info('note', $p_email, $t_description); $t_project_id = bug_get_field($t_bug_id, 'project_id'); ERP_set_temporary_overwrite('project_override', $t_project_id); # Event integration # Core mantis event already exists within bugnote_add function $t_description = event_signal('EVENT_ERP_BUGNOTE_DATA', $t_description, $t_bug_id); if (bug_is_resolved($t_bug_id)) { # Reopen issue and add a bug note bug_reopen($t_bug_id, $t_description); } elseif (!is_blank($t_description)) { # Add a bug note bugnote_add($t_bug_id, $t_description); } } elseif ($this->_mail_add_bug_reports) { // @TODO@ Disabled for now until we find a good solution on how to handle the reporters possible lack of access permissions // access_ensure_project_level( config_get('report_bug_threshold' ) ); $f_master_bug_id = $t_bug_id !== FALSE && bug_is_readonly($t_bug_id) ? $t_bug_id : 0; $this->fix_empty_fields($p_email); $t_project_id = $p_overwrite_project_id === FALSE ? $this->_mailbox['project_id'] : $p_overwrite_project_id; ERP_set_temporary_overwrite('project_override', $t_project_id); $t_bug_data = new BugData(); $t_bug_data->build = ''; $t_bug_data->platform = ''; $t_bug_data->os = ''; $t_bug_data->os_build = ''; $t_bug_data->version = ''; $t_bug_data->profile_id = 0; $t_bug_data->handler_id = 0; $t_bug_data->view_state = (int) config_get('default_bug_view_status'); $t_bug_data->category_id = (int) $this->_mailbox['global_category_id']; $t_bug_data->reproducibility = (int) config_get('default_bug_reproducibility'); $t_bug_data->severity = (int) config_get('default_bug_severity'); $t_bug_data->priority = (int) ($this->_mail_use_bug_priority ? $p_email['Priority'] : config_get('default_bug_priority')); $t_bug_data->projection = (int) config_get('default_bug_projection'); $t_bug_data->eta = (int) config_get('default_bug_eta'); $t_bug_data->resolution = config_get('default_bug_resolution'); $t_bug_data->status = config_get('bug_submit_status'); $t_bug_data->summary = $p_email['Subject']; $t_description = $p_email['X-Mantis-Body']; $t_description = $this->strip_signature($t_description); $t_description = $this->add_additional_info('issue', $p_email, $t_description); $t_bug_data->description = $t_description; $t_bug_data->steps_to_reproduce = config_get('default_bug_steps_to_reproduce'); $t_bug_data->additional_information = config_get('default_bug_additional_info'); $t_bug_data->due_date = date_get_null(); $t_bug_data->project_id = $t_project_id; $t_bug_data->reporter_id = $p_email['Reporter_id']; // This function might do stuff that EmailReporting cannot handle. Disabled //helper_call_custom_function( 'issue_create_validate', array( $t_bug_data ) ); // @TODO@ Disabled for now but possibly needed for other future features # Validate the custom fields before adding the bug. /* $t_related_custom_field_ids = custom_field_get_linked_ids( $t_bug_data->project_id ); foreach( $t_related_custom_field_ids as $t_id ) { $t_def = custom_field_get_definition( $t_id ); # Produce an error if the field is required but wasn't posted if ( !gpc_isset_custom_field( $t_id, $t_def['type'] ) && ( $t_def['require_report'] || $t_def['type'] == CUSTOM_FIELD_TYPE_ENUM || $t_def['type'] == CUSTOM_FIELD_TYPE_LIST || $t_def['type'] == CUSTOM_FIELD_TYPE_MULTILIST || $t_def['type'] == CUSTOM_FIELD_TYPE_RADIO ) ) { error_parameters( lang_get_defaulted( custom_field_get_field( $t_id, 'name' ) ) ); trigger_error( ERROR_EMPTY_FIELD, ERROR ); } if ( !custom_field_validate( $t_id, gpc_get_custom_field( "custom_field_$t_id", $t_def['type'], NULL ) ) ) { error_parameters( lang_get_defaulted( custom_field_get_field( $t_id, 'name' ) ) ); trigger_error( ERROR_CUSTOM_FIELD_INVALID_VALUE, ERROR ); } }*/ # Allow plugins to pre-process bug data $t_bug_data = event_signal('EVENT_REPORT_BUG_DATA', $t_bug_data); $t_bug_data = event_signal('EVENT_ERP_REPORT_BUG_DATA', $t_bug_data); # Create the bug $t_bug_id = $t_bug_data->create(); // @TODO@ Disabled for now but possibly needed for other future features # Handle custom field submission /* foreach( $t_related_custom_field_ids as $t_id ) { # Do not set custom field value if user has no write access. if( !custom_field_has_write_access( $t_id, $t_bug_id ) ) { continue; } $t_def = custom_field_get_definition( $t_id ); if( !custom_field_set_value( $t_id, $t_bug_id, gpc_get_custom_field( "custom_field_$t_id", $t_def['type'], '' ), false ) ) { { error_parameters( lang_get_defaulted( custom_field_get_field( $t_id, 'name' ) ) ); trigger_error( ERROR_CUSTOM_FIELD_INVALID_VALUE, ERROR ); } }*/ // Lets link a readonly already existing bug to the newly created one if ($f_master_bug_id > 0) { $f_rel_type = BUG_RELATED; # update master bug last updated bug_update_date($f_master_bug_id); # Add the relationship relationship_add($t_bug_id, $f_master_bug_id, $f_rel_type); # Add log line to the history (both issues) history_log_event_special($f_master_bug_id, BUG_ADD_RELATIONSHIP, relationship_get_complementary_type($f_rel_type), $t_bug_id); history_log_event_special($t_bug_id, BUG_ADD_RELATIONSHIP, $f_rel_type, $f_master_bug_id); # Send the email notification email_relationship_added($f_master_bug_id, $t_bug_id, relationship_get_complementary_type($f_rel_type)); } helper_call_custom_function('issue_create_notify', array($t_bug_id)); # Allow plugins to post-process bug data with the new bug ID event_signal('EVENT_REPORT_BUG', array($t_bug_data, $t_bug_id)); email_new_bug($t_bug_id); } else { // Not allowed to add issues and not allowed / able to add notes. Need to stop processing $this->custom_error('Not allowed to create a new issue. Email ignored'); return; } $this->custom_error('Reporter: ' . $p_email['Reporter_id'] . ' - ' . $p_email['From_parsed']['email'] . ' --> Issue ID: #' . $t_bug_id, FALSE); $this->show_memory_usage('Finished add bug'); $this->show_memory_usage('Start processing attachments'); # Add files if ($this->_allow_file_upload) { if (count($p_email['X-Mantis-Parts']) > 0) { $t_rejected_files = NULL; while ($t_part = array_shift($p_email['X-Mantis-Parts'])) { $t_file_rejected = $this->add_file($t_bug_id, $t_part); if ($t_file_rejected !== TRUE) { $t_rejected_files .= $t_file_rejected; } } if ($t_rejected_files !== NULL) { $t_part = array('name' => 'Rejected files.txt', 'ctype' => 'text/plain', 'body' => 'List of rejected files' . "\n\n" . $t_rejected_files); $t_reject_rejected_files = $this->add_file($t_bug_id, $t_part); if ($t_reject_rejected_files !== TRUE) { $t_part['body'] .= $t_reject_rejected_files; $this->custom_error('Failed to add "' . $t_part['name'] . '" to the issue. See below for all errors.' . "\n" . $t_part['body']); } } } } //Add the users in Cc and To list in mail header $this->add_monitors($t_bug_id, $p_email); //Add the message-id to the database $this->add_msg_id($t_bug_id, $p_email['Message-ID']); ERP_set_temporary_overwrite('project_override', NULL); $this->show_memory_usage('Finished processing attachments'); }
function save_bug($p_project_id, $p_user_id) { require 'ProfileAcraExt.php'; $t_project_id = $p_project_id; global $g_cache_current_user_id; $g_cache_current_user_id = $p_user_id; $t_bug_data = new BugData(); $t_bug_data->project_id = $t_project_id; $t_bug_data->reporter_id = $p_user_id; $t_bug_data->build = gpc_get_string('APP_VERSION_CODE', ''); $t_bug_data->platform = "Android"; $t_bug_data->os = gpc_get_string('ANDROID_VERSION', ''); //gpc_get_string( 'os', '' ); $t_os_build = gpc_get_string('BUILD', ''); if (preg_match('/DISPLAY\\s*=\\s*(.*)/', $t_os_build, $t_match)) { var_dump($t_match); $t_os_build = $t_match[1]; } else { $t_os_build = gpc_get_string('ANDROID_VERSION', ''); } $t_bug_data->os_build = $t_os_build; //gpc_get_string( 'os_build', '' ); $t_bug_data->version = gpc_get_string('APP_VERSION_NAME', ''); $t_bug_data->profile_id = profile_create_unique(ALL_USERS, $t_bug_data->platform, $t_bug_data->os, $t_bug_data->os_build, ""); $t_bug_data->handler_id = gpc_get_int('handler_id', 0); $t_bug_data->view_state = gpc_get_int('view_state', config_get('default_bug_view_status', 'VS_PRIVATE', 'acra_reporter')); $t_bug_data->category_id = $this->get_category_id($p_project_id); //gpc_get_int( 'category_id', 0 ); $t_bug_data->reproducibility = 10; //gpc_get_int( 'reproducibility', config_get( 'default_bug_reproducibility' ) ); $t_bug_data->severity = CRASH; //gpc_get_int( 'severity', config_get( 'default_bug_severity' ) ); $t_bug_data->priority = HIGH; //gpc_get_int( 'priority', config_get( 'default_bug_priority' ) ); $t_bug_data->projection = gpc_get_int('projection', config_get('default_bug_projection')); $t_bug_data->eta = gpc_get_int('eta', config_get('default_bug_eta')); $t_bug_data->resolution = OPEN; //gpc_get_string('resolution', config_get( 'default_bug_resolution' ) ); $t_bug_data->status = NEW_; //gpc_get_string( 'status', config_get( 'bug_submit_status' ) ); $t_bug_data->description = gpc_get_string('STACK_TRACE'); //gpc_get_string( 'description' ); $t_bug_data->summary = get_bug_summary_by_version(gpc_get_string('APP_VERSION_NAME', ''), $t_bug_data->description, $t_project_id); $t_bug_data->steps_to_reproduce = gpc_get_string('LOGCAT', ""); $t_bug_data->additional_information = gpc_get_string('CRASH_CONFIGURATION', ""); $t_bug_data->due_date = gpc_get_string('USER_CRASH_DATE', ''); if (is_blank($t_bug_data->due_date)) { $t_bug_data->due_date = date_get_null(); } $f_files = gpc_get_file('ufile', null); /** @todo (thraxisp) Note that this always returns a structure */ $f_report_stay = gpc_get_bool('report_stay', false); $f_copy_notes_from_parent = gpc_get_bool('copy_notes_from_parent', false); helper_call_custom_function('issue_create_validate', array($t_bug_data)); # Validate the custom fields before adding the bug. $t_related_custom_field_ids = custom_field_get_linked_ids($t_bug_data->project_id); foreach ($t_related_custom_field_ids as $t_id) { $t_def = custom_field_get_definition($t_id); # Produce an error if the field is required but wasn't posted if (!gpc_isset_custom_field($t_id, $t_def['type']) && $t_def['require_report']) { error_parameters(lang_get_defaulted(custom_field_get_field($t_id, 'name'))); trigger_error(ERROR_EMPTY_FIELD, ERROR); } if (!custom_field_validate($t_id, gpc_get_custom_field("custom_field_{$t_id}", $t_def['type'], NULL))) { error_parameters(lang_get_defaulted(custom_field_get_field($t_id, 'name'))); trigger_error(ERROR_CUSTOM_FIELD_INVALID_VALUE, ERROR); } } # Allow plugins to pre-process bug data $t_bug_data = event_signal('EVENT_REPORT_BUG_DATA', $t_bug_data); # Ensure that resolved bugs have a handler if ($t_bug_data->handler_id == NO_USER && $t_bug_data->status >= config_get('bug_resolved_status_threshold')) { $t_bug_data->handler_id = $this->get_user_id(); } # Create the bug $t_bug_id = $t_bug_data->create(); # Mark the added issue as visited so that it appears on the last visited list. last_visited_issue($t_bug_id); # Handle the file upload if ($f_files != null) { $t_files = helper_array_transpose($f_files); if ($t_files != null) { foreach ($t_files as $t_file) { if (!empty($t_file['name'])) { file_add($t_bug_id, $t_file, 'bug'); } } } } # Handle custom field submission foreach ($t_related_custom_field_ids as $t_id) { # Do not set custom field value if user has no write access if (!custom_field_has_write_access($t_id, $t_bug_id)) { continue; } $t_def = custom_field_get_definition($t_id); 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']), false)) { error_parameters(lang_get_defaulted(custom_field_get_field($t_id, 'name'))); trigger_error(ERROR_CUSTOM_FIELD_INVALID_VALUE, ERROR); } } $f_master_bug_id = gpc_get_int('m_id', 0); $f_rel_type = gpc_get_int('rel_type', -1); if ($f_master_bug_id > 0) { # it's a child generation... let's create the relationship and add some lines in the history # update master bug last updated bug_update_date($f_master_bug_id); # Add log line to record the cloning action history_log_event_special($t_bug_id, BUG_CREATED_FROM, '', $f_master_bug_id); history_log_event_special($f_master_bug_id, BUG_CLONED_TO, '', $t_bug_id); if ($f_rel_type >= 0) { # Add the relationship relationship_add($t_bug_id, $f_master_bug_id, $f_rel_type); # Add log line to the history (both issues) history_log_event_special($f_master_bug_id, BUG_ADD_RELATIONSHIP, relationship_get_complementary_type($f_rel_type), $t_bug_id); history_log_event_special($t_bug_id, BUG_ADD_RELATIONSHIP, $f_rel_type, $f_master_bug_id); # update relationship target bug last updated bug_update_date($t_bug_id); # Send the email notification email_relationship_added($f_master_bug_id, $t_bug_id, relationship_get_complementary_type($f_rel_type)); } # copy notes from parent if ($f_copy_notes_from_parent) { $t_parent_bugnotes = bugnote_get_all_bugnotes($f_master_bug_id); foreach ($t_parent_bugnotes as $t_parent_bugnote) { $t_private = $t_parent_bugnote->view_state == VS_PRIVATE; bugnote_add($t_bug_id, $t_parent_bugnote->note, $t_parent_bugnote->time_tracking, $t_private, $t_parent_bugnote->note_type, $t_parent_bugnote->note_attr, $t_parent_bugnote->reporter_id, FALSE, FALSE); } } } helper_call_custom_function('issue_create_notify', array($t_bug_id)); # Allow plugins to post-process bug data with the new bug ID event_signal('EVENT_REPORT_BUG', array($t_bug_data, $t_bug_id)); email_new_bug($t_bug_id); // log status and resolution changes if they differ from the default if ($t_bug_data->status != config_get('bug_submit_status')) { history_log_event($t_bug_id, 'status', config_get('bug_submit_status')); } if ($t_bug_data->resolution != config_get('default_bug_resolution')) { history_log_event($t_bug_id, 'resolution', config_get('default_bug_resolution')); } return $t_bug_id; }