Add relationship

This modification updates automatically the new bug to add a pre-defined relationship.

For all bugs:

Here are the modification:

  • in the custom_functions_inc.php file (create it if necessary), add this:
define( 'RELATIONSHIP_BUG_ID', id ); // Specify here the bug ID (replace the id by the bug id)
define( 'RELATIONSHIP_TYPE', BUG_* ); // Replace BUG_* by one of the following values: 
// BUG_DUPLICATE, BUG_RELATED, BUG_DEPENDANT, BUG_BLOCKS or BUG_HAS_DUPLICATE. 
 
function custom_function_override_issue_create_notify( $p_issue_id ) {
    relationship_add( $p_issue_id, RELATIONSHIP_BUG_ID, RELATIONSHIP_TYPE );
}

Bugs per project:

Here are the modification:

  • in the custom_functions_inc.php file (create it if necessary), add this:
$g_relationship_bug_id = array( 0 => id, 1 => id, 2 => id, ... ); 
             // Specify here the bug ID (replace the id by the bug id)
             // 0 means by default (it is mandatory), 1 means for project id 1, 2 means for project id 2...
             // If the bug ID is set to 0, no relationship will be added. 
$g_relationship_type = array( 0 => BUG_*, 1 => BUG_*, 2 => BUG_*, ... ); 
             // Replace BUG_* by one of the following values: 
             // BUG_DUPLICATE, BUG_RELATED, BUG_DEPENDANT, BUG_BLOCKS or BUG_HAS_DUPLICATE. 
 
function custom_function_override_issue_create_notify( $p_issue_id ) {
    global $g_relationship_bug_id, $g_relationship_type;
 
    $t_project_id = bug_get_field( $p_issue_id, 'project_id' );
    if ( !isset( $g_relationship_bug_id[$t_project_id] ) ) {
        $t_project_id_id = 0;
    } else {
        $t_project_id_id = $t_project_id;
    }
    if ( !isset( $g_relationship_type[$t_project_id] ) ) {
        $t_project_id_type = 0;
    } else {
        $t_project_id_type = $t_project_id;
    }
    if ( isset( $g_relationship_bug_id[$t_project_id_id] ) && $g_relationship_bug_id[$t_project_id_id] != 0 ) {
        relationship_add( $p_issue_id, $g_relationship_bug_id[$t_project_id_id], 
                          $g_relationship_type[$t_project_id_type] );
    }
}

Back to Functions list