本文整理汇总了PHP中relationship_add函数的典型用法代码示例。如果您正苦于以下问题:PHP relationship_add函数的具体用法?PHP relationship_add怎么用?PHP relationship_add使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了relationship_add函数的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: relationship_copy_all
/**
* copy all the relationships related to a specific bug to a new bug
* @param integer $p_bug_id Source bug identifier.
* @param integer $p_new_bug_id Destination bug identifier.
* @return void
*/
function relationship_copy_all($p_bug_id, $p_new_bug_id)
{
$t_relationship = relationship_get_all_src($p_bug_id);
$t_relationship_count = count($t_relationship);
for ($i = 0; $i < $t_relationship_count; $i++) {
relationship_add($p_new_bug_id, $t_relationship[$i]->dest_bug_id, $t_relationship[$i]->type);
}
$t_relationship = relationship_get_all_dest($p_bug_id);
$t_relationship_count = count($t_relationship);
for ($i = 0; $i < $t_relationship_count; $i++) {
relationship_add($t_relationship[$i]->src_bug_id, $p_new_bug_id, $t_relationship[$i]->type);
}
}
示例2: relationship_same_type_exists
}
# 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);
示例3: error_parameters
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);
}
示例4: event_signal
# Allow plugins to validate/modify the update prior to it being committed.
$t_updated_bug = event_signal('EVENT_UPDATE_BUG_DATA', $t_updated_bug, $t_existing_bug);
# Commit the bug updates to the database.
$t_text_field_update_required = $t_existing_bug->description !== $t_updated_bug->description || $t_existing_bug->additional_information !== $t_updated_bug->additional_information || $t_existing_bug->steps_to_reproduce !== $t_updated_bug->steps_to_reproduce;
$t_updated_bug->update($t_text_field_update_required, true);
# Update custom field values.
foreach ($t_custom_fields_to_set as $t_custom_field_to_set) {
custom_field_set_value($t_custom_field_to_set['id'], $f_bug_id, $t_custom_field_to_set['value']);
}
# Add a bug note if there is one.
if ($t_bug_note->note || helper_duration_to_minutes($t_bug_note->time_tracking) > 0) {
bugnote_add($f_bug_id, $t_bug_note->note, $t_bug_note->time_tracking, $t_bug_note->view_state == VS_PRIVATE, 0, '', null, false);
}
# Add a duplicate relationship if requested.
if ($t_updated_bug->duplicate_id !== 0) {
relationship_add($f_bug_id, $t_updated_bug->duplicate_id, BUG_DUPLICATE);
history_log_event_special($f_bug_id, BUG_ADD_RELATIONSHIP, BUG_DUPLICATE, $t_updated_bug->duplicate_id);
history_log_event_special($t_updated_bug->duplicate_id, BUG_ADD_RELATIONSHIP, BUG_HAS_DUPLICATE, $f_bug_id);
if (user_exists($t_existing_bug->reporter_id)) {
bug_monitor($f_bug_id, $t_existing_bug->reporter_id);
}
if (user_exists($t_existing_bug->handler_id)) {
bug_monitor($f_bug_id, $t_existing_bug->handler_id);
}
bug_monitor_copy($f_bug_id, $t_updated_bug->duplicate_id);
}
event_signal('EVENT_UPDATE_BUG', array($t_existing_bug, $t_updated_bug));
# Allow a custom function to respond to the modifications made to the bug. Note
# that custom functions are being deprecated in MantisBT. You should migrate to
# the new plugin system instead.
helper_call_custom_function('issue_update_notify', array($f_bug_id));
示例5: mc_issue_relationship_add
/**
* 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.');
}
}
示例6: mc_issue_relationship_add
/**
* 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." );
}
}
示例7: bug_resolve
/**
* resolve the given bug
* @param int p_bug_id
* @param int p_resolution resolution code
* @param int p_status optional custom status (defaults to bug_resolved_status_threshold)
* @param string p_fixed_in_version optional version string in which issue is fixed
* @param int p_duplicate_id optional id of duplicate issue (defaults to null)
* @param int p_handler_id optional id of issue handler
* @param string p_bugnote_text optional bug note to add
* @param bool p_bugnote_private optional true if bug note should be private (defaults to false)
* @param string p_time_tracking optional time spent (defaults to '0:00')
* @return bool (always true)
* @access public
*/
function bug_resolve($p_bug_id, $p_resolution, $p_status = null, $p_fixed_in_version = '', $p_duplicate_id = null, $p_handler_id = null, $p_bugnote_text = '', $p_bugnote_private = false, $p_time_tracking = '0:00')
{
$c_resolution = (int) $p_resolution;
if (null == $p_status) {
$p_status = config_get('bug_resolved_status_threshold');
}
$p_bugnote_text = trim($p_bugnote_text);
# Add bugnote if supplied
# Moved bugnote_add before bug_set_field calls in case time_tracking_no_note is off.
# Error condition stopped execution but status had already been changed
bugnote_add($p_bug_id, $p_bugnote_text, $p_time_tracking, $p_bugnote_private, 0, '', NULL, FALSE);
$t_duplicate = !is_blank($p_duplicate_id) && $p_duplicate_id != 0;
if ($t_duplicate) {
if ($p_bug_id == $p_duplicate_id) {
trigger_error(ERROR_BUG_DUPLICATE_SELF, ERROR);
# never returns
}
# the related bug exists...
bug_ensure_exists($p_duplicate_id);
# check if there is other relationship between the bugs...
$t_id_relationship = relationship_same_type_exists($p_bug_id, $p_duplicate_id, BUG_DUPLICATE);
if ($t_id_relationship > 0) {
# Update the relationship
relationship_update($t_id_relationship, $p_bug_id, $p_duplicate_id, BUG_DUPLICATE);
# Add log line to the history (both bugs)
history_log_event_special($p_bug_id, BUG_REPLACE_RELATIONSHIP, BUG_DUPLICATE, $p_duplicate_id);
history_log_event_special($p_duplicate_id, BUG_REPLACE_RELATIONSHIP, BUG_HAS_DUPLICATE, $p_bug_id);
} else {
if ($t_id_relationship != -1) {
# Add the new relationship
relationship_add($p_bug_id, $p_duplicate_id, BUG_DUPLICATE);
# Add log line to the history (both bugs)
history_log_event_special($p_bug_id, BUG_ADD_RELATIONSHIP, BUG_DUPLICATE, $p_duplicate_id);
history_log_event_special($p_duplicate_id, BUG_ADD_RELATIONSHIP, BUG_HAS_DUPLICATE, $p_bug_id);
}
}
# else relationship is -1 - same type exists, do nothing
# Copy list of users monitoring the duplicate bug to the original bug
bug_monitor_copy($p_bug_id, $p_duplicate_id);
bug_set_field($p_bug_id, 'duplicate_id', (int) $p_duplicate_id);
}
bug_set_field($p_bug_id, 'status', $p_status);
bug_set_field($p_bug_id, 'fixed_in_version', $p_fixed_in_version);
bug_set_field($p_bug_id, 'resolution', $c_resolution);
# only set handler if specified explicitly or if bug was not assigned to a handler
if (null == $p_handler_id) {
if (bug_get_field($p_bug_id, 'handler_id') == 0) {
$p_handler_id = auth_get_current_user_id();
bug_set_field($p_bug_id, 'handler_id', $p_handler_id);
}
} else {
bug_set_field($p_bug_id, 'handler_id', $p_handler_id);
}
email_resolved($p_bug_id);
email_relationship_child_resolved($p_bug_id);
if ($c_resolution >= config_get('bug_resolution_fixed_threshold') && $c_resolution < config_get('bug_resolution_not_fixed_threshold')) {
twitter_issue_resolved($p_bug_id);
}
return true;
}
示例8: relationship_copy_all
/**
* copy all the relationships related to a specific bug to a new bug
* @param int $p_bug_id Source Bug Id
* @param int $p_new_bug_id Destination Bug Id
*/
function relationship_copy_all($p_bug_id, $p_new_bug_id)
{
$c_bug_id = db_prepare_int($p_bug_id);
$c_new_bug_id = db_prepare_int($p_new_bug_id);
$t_mantis_bug_relationship_table = db_get_table('bug_relationship');
$t_relationship = relationship_get_all_src($p_bug_id);
$t_relationship_count = count($t_relationship);
for ($i = 0; $i < $t_relationship_count; $i++) {
relationship_add($p_new_bug_id, $t_relationship[$i]->dest_bug_id, $t_relationship[$i]->type);
}
$t_relationship = relationship_get_all_dest($p_bug_id);
$t_relationship_count = count($t_relationship);
for ($i = 0; $i < $t_relationship_count; $i++) {
relationship_add($t_relationship[$i]->src_bug_id, $p_new_bug_id, $t_relationship[$i]->type);
}
return;
}
示例9: add_bug
//.........这里部分代码省略.........
$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');
}
示例10: copyUserStory
function copyUserStory($us_id, $status, $sprintname)
{
global $agilemantis_pb;
global $agilemantis_tasks;
global $agilemantis_sprint;
$new_bug_id = bug_copy($us_id, null, true, true, false, true, true, true);
$agilemantis_pb->doUserStoryToSprint($new_bug_id, $sprintname);
relationship_add($new_bug_id, $us_id, 0);
$task = $agilemantis_sprint->getSprintTasks($us_id);
$agilemantis_sprint->sprint_id = $sprintname;
$sprintinfo = $agilemantis_sprint->getSprintById();
$old_userstory = $agilemantis_pb->checkForUserStory($us_id);
$agilemantis_pb->addStoryPoints($new_bug_id, $old_userstory['storypoints']);
$agilemantis_pb->addBusinessValue($new_bug_id, $old_userstory['businessValue']);
$agilemantis_pb->addRankingOrder($new_bug_id, $old_userstory['rankingorder']);
$agilemantis_pb->addTechnical($new_bug_id, $old_userstory['technical']);
$agilemantis_pb->addPresentable($new_bug_id, $old_userstory['presentable']);
$agilemantis_pb->AddInReleaseDocu($new_bug_id, $old_userstory['inReleaseDocu']);
$agilemantis_pb->AddPlannedWork($new_bug_id, $old_userstory['plannedWork']);
history_delete($new_bug_id);
$bugnote_text_new = plugin_lang_get('divide_userstories_from') . $agilemantis_pb->getUserName(auth_get_current_user_id()) . plugin_lang_get('divide_userstories_of') . ' #' . $us_id . plugin_lang_get('divide_userstories_splitted');
$bugnote_text_old = plugin_lang_get('divide_userstories_from') . $agilemantis_pb->getUserName(auth_get_current_user_id()) . plugin_lang_get('divide_userstories_from') . ', #' . $new_bug_id . plugin_lang_get('divide_userstories_splitted');
$agilemantis_sprint->sprint_id = $old_userstory['sprint'];
$sprintinfo = $agilemantis_sprint->getSprintById();
$userstory_performed = false;
$wmu = 0;
$spmu = 0;
if (!empty($task)) {
foreach ($task as $key => $value) {
if ($value['performed_capacity'] > 0 || $value['status'] >= 4) {
$userstory_performed = true;
}
if ($value['status'] < 4) {
$agilemantis_tasks->user_id = auth_get_current_user_id();
$agilemantis_tasks->name = $value['name'];
$agilemantis_tasks->us_id = $value['us_id'];
$agilemantis_tasks->description = $value['description'];
$agilemantis_tasks->developer = $value['developer_id'];
$agilemantis_tasks->status = 5;
$agilemantis_tasks->capacity = $value['performed_capacity'];
$agilemantis_tasks->planned_capacity = $value['planned_capacity'];
$agilemantis_tasks->rest_capacity = 0;
$agilemantis_tasks->id = $value['id'];
$agilemantis_tasks->unit = $value['unit'];
$agilemantis_tasks->editTask();
$agilemantis_tasks->saveDailyPerformance(0);
$agilemantis_tasks->id = 0;
$agilemantis_tasks->name = $value['name'];
$agilemantis_tasks->us_id = $new_bug_id;
$agilemantis_tasks->description = $value['description'];
$agilemantis_tasks->status = $value['status'];
if ($value['status'] == 3) {
$agilemantis_tasks->status = 2;
}
$agilemantis_tasks->developer = $value['developer_id'];
if ($agilemantis_sprint->getUnitId(plugin_config_get('gadiv_task_unit_mode')) != $sprintinfo['unit_planned_task']) {
$agilemantis_tasks->planned_capacity = 0;
$agilemantis_tasks->rest_capacity = 0;
} else {
$agilemantis_tasks->planned_capacity = $value['rest_capacity'];
$agilemantis_tasks->rest_capacity = $value['rest_capacity'];
}
$agilemantis_tasks->addFinishedNote($value['us_id'], $value['id'], auth_get_current_user_id());
$agilemantis_tasks->editTask();
$agilemantis_tasks->id = 0;
$agilemantis_tasks->updateTaskLog($value['id'], auth_get_current_user_id(), "closed");
$agilemantis_tasks->setTaskStatus($value['id'], 5);
$wmu += $value['rest_capacity'];
$new_storypoints += $value['performed_capacity'];
}
}
}
if ($sprintinfo['unit_planned_task'] == 3) {
$spmu = $wmu;
} else {
$spmu = 0;
}
# collect all user story splitting information and write these into database
$agilemantis_sprint->setSplittingInformation($us_id, $new_bug_id, $wmu, $spmu);
if ($userstory_performed === true) {
if ($sprintinfo['unit_planned_task'] < 3) {
$agilemantis_pb->addStoryPoints($new_bug_id, '');
} elseif ($sprintinfo['unit_planned_task'] == 3) {
$agilemantis_pb->addStoryPoints($new_bug_id, $old_userstory['storypoints'] - $new_storypoints);
}
$bugnote_text_new .= plugin_lang_get('divide_userstories_old_estimation') . " #" . $us_id . plugin_lang_get('divide_userstories_with') . $old_userstory['storypoints'] . " SP.";
bugnote_add($new_bug_id, $bugnote_text_new);
}
# add bug note
bugnote_add($us_id, $bugnote_text_old);
$agilemantis_tasks->setUserStoryStatus($us_id, $status, auth_get_current_user_id());
$agilemantis_tasks->closeUserStory($us_id, $status, auth_get_current_user_id());
bug_update_date($us_id);
}
示例11: bug_resolve
function bug_resolve($p_bug_id, $p_resolution, $p_fixed_in_version = '', $p_bugnote_text = '', $p_duplicate_id = null, $p_handler_id = null, $p_bugnote_private = false, $p_time_tracking = '0:00')
{
$p_bugnote_text = trim($p_bugnote_text);
# Add bugnote if supplied
# Moved bugnote_add before bug_set_field calls in case time_tracking_no_note is off.
# Error condition stopped execution but status had already been changed
bugnote_add($p_bug_id, $p_bugnote_text, $p_time_tracking, $p_bugnote_private, 0, '', NULL, FALSE);
$t_duplicate = !is_blank($p_duplicate_id) && $p_duplicate_id != 0;
if ($t_duplicate) {
if ($p_bug_id == $p_duplicate_id) {
trigger_error(ERROR_BUG_DUPLICATE_SELF, ERROR);
# never returns
}
# the related bug exists...
bug_ensure_exists($p_duplicate_id);
if (ON == config_get('enable_relationship')) {
# check if there is other relationship between the bugs...
$t_id_relationship = relationship_same_type_exists($p_bug_id, $p_duplicate_id, BUG_DUPLICATE);
if ($t_id_relationship == -1) {
# the relationship type is already set. Nothing to do
} else {
if ($t_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_id_relationship, $p_bug_id, $p_duplicate_id, BUG_DUPLICATE);
# Add log line to the history (both bugs)
history_log_event_special($p_bug_id, BUG_REPLACE_RELATIONSHIP, BUG_DUPLICATE, $p_duplicate_id);
history_log_event_special($p_duplicate_id, BUG_REPLACE_RELATIONSHIP, BUG_HAS_DUPLICATE, $p_bug_id);
} else {
# Add the new relationship
relationship_add($p_bug_id, $p_duplicate_id, BUG_DUPLICATE);
# Add log line to the history (both bugs)
history_log_event_special($p_bug_id, BUG_ADD_RELATIONSHIP, BUG_DUPLICATE, $p_duplicate_id);
history_log_event_special($p_duplicate_id, BUG_ADD_RELATIONSHIP, BUG_HAS_DUPLICATE, $p_bug_id);
}
}
}
bug_set_field($p_bug_id, 'duplicate_id', (int) $p_duplicate_id);
}
$c_resolution = db_prepare_int($p_resolution);
bug_set_field($p_bug_id, 'status', config_get('bug_resolved_status_threshold'));
bug_set_field($p_bug_id, 'fixed_in_version', $p_fixed_in_version);
bug_set_field($p_bug_id, 'resolution', $c_resolution);
# only set handler if specified explicitly or if bug was not assigned to a handler
if (null == $p_handler_id) {
if (bug_get_field($p_bug_id, 'handler_id') == 0) {
$p_handler_id = auth_get_current_user_id();
bug_set_field($p_bug_id, 'handler_id', $p_handler_id);
}
} else {
bug_set_field($p_bug_id, 'handler_id', $p_handler_id);
}
email_resolved($p_bug_id);
if ($c_resolution == FIXED) {
twitter_issue_resolved($p_bug_id);
}
# MASC RELATIONSHIP
if (ON == config_get('enable_relationship')) {
email_relationship_child_resolved($p_bug_id);
}
# MASC RELATIONSHIP
return true;
}
示例12: save_bug
//.........这里部分代码省略.........
$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;
}