当前位置: 首页>>代码示例>>PHP>>正文


PHP relationship_same_type_exists函数代码示例

本文整理汇总了PHP中relationship_same_type_exists函数的典型用法代码示例。如果您正苦于以下问题:PHP relationship_same_type_exists函数的具体用法?PHP relationship_same_type_exists怎么用?PHP relationship_same_type_exists使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了relationship_same_type_exists函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: error_parameters

     error_parameters($f_src_bug_id);
     trigger_error(ERROR_BUG_READ_ONLY_ACTION_DENIED, ERROR);
 }
 # user can access to the related bug at least as viewer...
 if (!access_has_bug_level(VIEWER, $f_dest_bug_id)) {
     error_parameters($f_dest_bug_id);
     trigger_error(ERROR_RELATIONSHIP_ACCESS_LEVEL_TO_DEST_BUG_TOO_LOW, ERROR);
 }
 $t_bug = bug_get($f_src_bug_id, true);
 if ($t_bug->project_id != helper_get_current_project()) {
     # in case the current project is not the same project of the bug we are viewing...
     # ... override the current project. This to avoid problems with categories and handlers lists etc.
     $g_project_override = $t_bug->project_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);
开发者ID:kaos,项目名称:mantisbt,代码行数:31,代码来源:bug_relationship_add.php

示例2: 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.');
    }
}
开发者ID:elmarculino,项目名称:mantisbt,代码行数:65,代码来源:mc_issue_api.php

示例3: 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." );
	}
}
开发者ID:rombert,项目名称:mantisbt,代码行数:74,代码来源:mc_issue_api.php

示例4: 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;
}
开发者ID:rahmanjis,项目名称:dipstart-development,代码行数:74,代码来源:bug_api.php

示例5: 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;
}
开发者ID:jin255ff,项目名称:company_website,代码行数:64,代码来源:bug_api.php


注:本文中的relationship_same_type_exists函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。