本文整理汇总了PHP中relationship_get_complementary_type函数的典型用法代码示例。如果您正苦于以下问题:PHP relationship_get_complementary_type函数的具体用法?PHP relationship_get_complementary_type怎么用?PHP relationship_get_complementary_type使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了relationship_get_complementary_type函数的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: filter_get_bug_rows
//.........这里部分代码省略.........
if (!filter_field_is_any($t_filter[FILTER_PROPERTY_MONITOR_USER_ID])) {
$t_clauses = array();
$t_table_name = 'user_monitor';
array_push($t_join_clauses, 'LEFT JOIN {bug_monitor} ' . $t_table_name . ' ON ' . $t_table_name . '.bug_id = {bug}.id');
foreach ($t_filter[FILTER_PROPERTY_MONITOR_USER_ID] as $t_filter_member) {
$c_user_monitor = (int) $t_filter_member;
if (filter_field_is_myself($c_user_monitor)) {
array_push($t_clauses, $c_user_id);
} else {
array_push($t_clauses, $c_user_monitor);
}
}
if (1 < count($t_clauses)) {
$t_where_tmp = array();
foreach ($t_clauses as $t_clause) {
$t_where_tmp[] = db_param();
$t_where_params[] = $t_clause;
}
array_push($t_where_clauses, '( ' . $t_table_name . '.user_id in (' . implode(', ', $t_where_tmp) . ') )');
} else {
$t_where_params[] = $t_clauses[0];
array_push($t_where_clauses, '( ' . $t_table_name . '.user_id=' . db_param() . ' )');
}
}
# bug relationship
$t_any_found = false;
$c_rel_type = $t_filter[FILTER_PROPERTY_RELATIONSHIP_TYPE];
$c_rel_bug = $t_filter[FILTER_PROPERTY_RELATIONSHIP_BUG];
if (-1 == $c_rel_type || 0 == $c_rel_bug) {
$t_any_found = true;
}
if (!$t_any_found) {
# use the complementary type
$t_comp_type = relationship_get_complementary_type($c_rel_type);
$t_clauses = array();
$t_table_dst = 'rel_dst';
$t_table_src = 'rel_src';
array_push($t_join_clauses, 'LEFT JOIN {bug_relationship} ' . $t_table_dst . ' ON ' . $t_table_dst . '.destination_bug_id = {bug}.id');
array_push($t_join_clauses, 'LEFT JOIN {bug_relationship} ' . $t_table_src . ' ON ' . $t_table_src . '.source_bug_id = {bug}.id');
# get reverse relationships
$t_where_params[] = $t_comp_type;
$t_where_params[] = $c_rel_bug;
$t_where_params[] = $c_rel_type;
$t_where_params[] = $c_rel_bug;
array_push($t_clauses, '(' . $t_table_dst . '.relationship_type=' . db_param() . ' AND ' . $t_table_dst . '.source_bug_id=' . db_param() . ')');
array_push($t_clauses, '(' . $t_table_src . '.relationship_type=' . db_param() . ' AND ' . $t_table_src . '.destination_bug_id=' . db_param() . ')');
array_push($t_where_clauses, '(' . implode(' OR ', $t_clauses) . ')');
}
# tags
$c_tag_string = trim($t_filter[FILTER_PROPERTY_TAG_STRING]);
$c_tag_select = trim($t_filter[FILTER_PROPERTY_TAG_SELECT]);
if (is_blank($c_tag_string) && !is_blank($c_tag_select) && $c_tag_select != 0) {
$t_tag = tag_get($c_tag_select);
$c_tag_string = $t_tag['name'];
}
if (!is_blank($c_tag_string)) {
$t_tags = tag_parse_filters($c_tag_string);
if (count($t_tags)) {
$t_tags_all = array();
$t_tags_any = array();
$t_tags_none = array();
foreach ($t_tags as $t_tag_row) {
switch ($t_tag_row['filter']) {
case 1:
$t_tags_all[] = $t_tag_row;
break;
示例2: bug_update_date
# 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));
示例3: relationship_same_type_exists
/**
* check if there is a relationship between two bugs
* return:
* 0 if the relationship is not found
* -1 if the relationship is found and it's of the same type $p_rel_type
* id if the relationship is found and it's of a different time (this means it can be replaced with the new type $p_rel_type
* @param integer $p_src_bug_id Source Bug Id.
* @param integer $p_dest_bug_id Destination Bug Id.
* @param integer $p_rel_type Relationship Type.
* @return integer 0, -1 or id
*/
function relationship_same_type_exists($p_src_bug_id, $p_dest_bug_id, $p_rel_type)
{
# Check if there is already a relationship set between them
$t_id_relationship = relationship_exists($p_src_bug_id, $p_dest_bug_id);
if ($t_id_relationship > 0) {
# if there is...
# get all the relationship info
$t_relationship = relationship_get($t_id_relationship);
if ($t_relationship->src_bug_id == $p_src_bug_id && $t_relationship->dest_bug_id == $p_dest_bug_id) {
if ($t_relationship->type == $p_rel_type) {
$t_id_relationship = -1;
}
} else {
if ($t_relationship->type == relationship_get_complementary_type($p_rel_type)) {
$t_id_relationship = -1;
}
}
}
return $t_id_relationship;
}
示例4: mc_issue_relationship_delete
/**
* Delete the relationship with the specified target id.
*
* @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 source issue for the relationship.
* @param integer $p_relationship_id The id of relationship to delete.
* @return boolean true: success, false: failure
*/
function mc_issue_relationship_delete($p_username, $p_password, $p_issue_id, $p_relationship_id)
{
global $g_project_override;
$t_user_id = mci_check_login($p_username, $p_password);
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 remove a relationship from this issue.');
}
# 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.');
}
# retrieve the destination bug of the relationship
$t_dest_issue_id = relationship_get_linked_bug_id($p_relationship_id, $p_issue_id);
# user can access to the related bug at least as viewer, if it's exist...
if (bug_exists($t_dest_issue_id)) {
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_bug_relationship_data = relationship_get($p_relationship_id);
$t_rel_type = $t_bug_relationship_data->type;
# delete relationship from the DB
log_event(LOG_WEBSERVICE, 'deleting relationship id \'' . $p_relationship_id . '\'');
relationship_delete($p_relationship_id);
# update bug last updated
bug_update_date($p_issue_id);
bug_update_date($t_dest_issue_id);
# set the rel_type for both bug and dest_bug based on $t_rel_type and on who is the dest bug
if ($p_issue_id == $t_bug_relationship_data->src_bug_id) {
$t_bug_rel_type = $t_rel_type;
$t_dest_bug_rel_type = relationship_get_complementary_type($t_rel_type);
} else {
$t_bug_rel_type = relationship_get_complementary_type($t_rel_type);
$t_dest_bug_rel_type = $t_rel_type;
}
# send email and update the history for the src issue
history_log_event_special($p_issue_id, BUG_DEL_RELATIONSHIP, $t_bug_rel_type, $t_dest_issue_id);
email_relationship_deleted($p_issue_id, $t_dest_issue_id, $t_bug_rel_type);
if (bug_exists($t_dest_issue_id)) {
# send email and update the history for the dest issue
history_log_event_special($t_dest_issue_id, BUG_DEL_RELATIONSHIP, $t_dest_bug_rel_type, $p_issue_id);
email_relationship_deleted($t_dest_issue_id, $p_issue_id, $t_dest_bug_rel_type);
}
return true;
}
示例5: 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);
示例6: 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');
}
示例7: error_parameters
if (bug_exists($t_dest_bug_id)) {
if (!access_has_bug_level(VIEWER, $t_dest_bug_id)) {
error_parameters($t_dest_bug_id);
trigger_error(ERROR_RELATIONSHIP_ACCESS_LEVEL_TO_DEST_BUG_TOO_LOW, ERROR);
}
}
helper_ensure_confirmed(lang_get('delete_relationship_sure_msg'), lang_get('delete_relationship_button'));
$t_bug_relationship_data = relationship_get($f_rel_id);
$t_rel_type = $t_bug_relationship_data->type;
# delete relationship from the DB
relationship_delete($f_rel_id);
# update bug last updated (just for the src bug)
bug_update_date($f_bug_id);
# set the rel_type for both bug and dest_bug based on $t_rel_type and on who is the dest bug
if ($f_bug_id == $t_bug_relationship_data->src_bug_id) {
$t_bug_rel_type = $t_rel_type;
$t_dest_bug_rel_type = relationship_get_complementary_type($t_rel_type);
} else {
$t_bug_rel_type = relationship_get_complementary_type($t_rel_type);
$t_dest_bug_rel_type = $t_rel_type;
}
# send email and update the history for the src issue
history_log_event_special($f_bug_id, BUG_DEL_RELATIONSHIP, $t_bug_rel_type, $t_dest_bug_id);
email_relationship_deleted($f_bug_id, $t_dest_bug_id, $t_bug_rel_type);
if (bug_exists($t_dest_bug_id)) {
# send email and update the history for the dest issue
history_log_event_special($t_dest_bug_id, BUG_DEL_RELATIONSHIP, $t_dest_bug_rel_type, $f_bug_id);
email_relationship_deleted($t_dest_bug_id, $f_bug_id, $t_dest_bug_rel_type);
}
form_security_purge('bug_relationship_delete');
print_header_redirect_view($f_bug_id);
示例8: filter_get_bug_rows
//.........这里部分代码省略.........
}
}
if (count($t_filter['user_monitor']) == 0) {
$t_any_found = true;
}
if (!$t_any_found) {
$t_clauses = array();
$t_table_name = 'user_monitor';
array_push($t_from_clauses, $t_bug_monitor_table);
array_push($t_join_clauses, "LEFT JOIN {$t_bug_monitor_table} {$t_table_name} ON {$t_table_name}.bug_id = {$t_bug_table}.id");
foreach ($t_filter['user_monitor'] as $t_filter_member) {
$c_user_monitor = db_prepare_int($t_filter_member);
if (META_FILTER_MYSELF == $c_user_monitor) {
array_push($t_clauses, $c_user_id);
} else {
array_push($t_clauses, $c_user_monitor);
}
}
if (1 < count($t_clauses)) {
array_push($t_where_clauses, "( {$t_table_name}.user_id in (" . implode(', ', $t_clauses) . ") )");
} else {
array_push($t_where_clauses, "( {$t_table_name}.user_id={$t_clauses['0']} )");
}
}
# bug relationship
$t_any_found = false;
$c_rel_type = $t_filter['relationship_type'];
$c_rel_bug = $t_filter['relationship_bug'];
if (-1 == $c_rel_type || 0 == $c_rel_bug) {
$t_any_found = true;
}
if (!$t_any_found) {
# use the complementary type
$t_comp_type = relationship_get_complementary_type($c_rel_type);
$t_clauses = array();
$t_table_name = 'relationship';
array_push($t_from_clauses, $t_bug_relationship_table);
array_push($t_join_clauses, "LEFT JOIN {$t_bug_relationship_table} {$t_table_name} ON {$t_table_name}.destination_bug_id = {$t_bug_table}.id");
array_push($t_join_clauses, "LEFT JOIN {$t_bug_relationship_table} {$t_table_name}2 ON {$t_table_name}2.source_bug_id = {$t_bug_table}.id");
// get reverse relationships
array_push($t_clauses, "({$t_table_name}.relationship_type='{$t_comp_type}' AND {$t_table_name}.source_bug_id='{$c_rel_bug}')");
array_push($t_clauses, "({$t_table_name}" . "2.relationship_type='{$c_rel_type}' AND {$t_table_name}" . "2.destination_bug_id='{$c_rel_bug}')");
array_push($t_where_clauses, '(' . implode(' OR ', $t_clauses) . ')');
}
# tags
$c_tag_string = trim($t_filter['tag_string']);
if (!is_blank($c_tag_string)) {
$t_tags = tag_parse_filters($c_tag_string);
if (count($t_tags)) {
$t_tags_all = array();
$t_tags_any = array();
$t_tags_none = array();
foreach ($t_tags as $t_tag_row) {
switch ($t_tag_row['filter']) {
case 1:
$t_tags_all[] = $t_tag_row;
break;
case 0:
$t_tags_any[] = $t_tag_row;
break;
case -1:
$t_tags_none[] = $t_tag_row;
break;
}
}
if (0 < $t_filter['tag_select'] && tag_exists($t_filter['tag_select'])) {
示例9: filter_get_bug_rows
//.........这里部分代码省略.........
if (!filter_field_is_any($t_filter[FILTER_PROPERTY_MONITOR_USER_ID])) {
$t_clauses = array();
$t_table_name = 'user_monitor';
array_push($t_join_clauses, "LEFT JOIN {$t_bug_monitor_table} {$t_table_name} ON {$t_table_name}.bug_id = {$t_bug_table}.id");
foreach ($t_filter[FILTER_PROPERTY_MONITOR_USER_ID] as $t_filter_member) {
$c_user_monitor = db_prepare_int($t_filter_member);
if (filter_field_is_myself($c_user_monitor)) {
array_push($t_clauses, $c_user_id);
} else {
array_push($t_clauses, $c_user_monitor);
}
}
if (1 < count($t_clauses)) {
$t_where_tmp = array();
foreach ($t_clauses as $t_clause) {
$t_where_tmp[] = db_param();
$t_where_params[] = $t_clause;
}
array_push($t_where_clauses, "( {$t_table_name}.user_id in (" . implode(', ', $t_where_tmp) . ") )");
} else {
$t_where_params[] = $t_clauses[0];
array_push($t_where_clauses, "( {$t_table_name}.user_id=" . db_param() . " )");
}
}
# bug relationship
$t_any_found = false;
$c_rel_type = $t_filter[FILTER_PROPERTY_RELATIONSHIP_TYPE];
$c_rel_bug = $t_filter[FILTER_PROPERTY_RELATIONSHIP_BUG];
if (-1 == $c_rel_type || 0 == $c_rel_bug) {
$t_any_found = true;
}
if (!$t_any_found) {
# use the complementary type
$t_comp_type = relationship_get_complementary_type($c_rel_type);
$t_clauses = array();
$t_table_name = 'relationship';
array_push($t_join_clauses, "LEFT JOIN {$t_bug_relationship_table} {$t_table_name} ON {$t_table_name}.destination_bug_id = {$t_bug_table}.id");
array_push($t_join_clauses, "LEFT JOIN {$t_bug_relationship_table} {$t_table_name}2 ON {$t_table_name}2.source_bug_id = {$t_bug_table}.id");
// get reverse relationships
$t_where_params[] = $t_comp_type;
$t_where_params[] = $c_rel_bug;
$t_where_params[] = $c_rel_type;
$t_where_params[] = $c_rel_bug;
array_push($t_clauses, "({$t_table_name}.relationship_type=" . db_param() . " AND {$t_table_name}.source_bug_id=" . db_param() . ')');
array_push($t_clauses, "({$t_table_name}" . "2.relationship_type=" . db_param() . " AND {$t_table_name}" . "2.destination_bug_id=" . db_param() . ')');
array_push($t_where_clauses, '(' . implode(' OR ', $t_clauses) . ')');
}
# tags
$c_tag_string = trim($t_filter[FILTER_PROPERTY_TAG_STRING]);
$c_tag_select = trim($t_filter[FILTER_PROPERTY_TAG_SELECT]);
if (is_blank($c_tag_string) && !is_blank($c_tag_select) && $c_tag_select != 0) {
$t_tag = tag_get($c_tag_select);
$c_tag_string = $t_tag['name'];
}
if (!is_blank($c_tag_string)) {
$t_tags = tag_parse_filters($c_tag_string);
if (count($t_tags)) {
$t_tags_all = array();
$t_tags_any = array();
$t_tags_none = array();
foreach ($t_tags as $t_tag_row) {
switch ($t_tag_row['filter']) {
case 1:
$t_tags_all[] = $t_tag_row;
break;
case 0:
示例10: mc_issue_relationship_delete
/**
* Delete the relationship with the specified target id.
*
* @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 source issue for the relationship
* @param integer $p_relationship_id The id of relationship to delete.
* @return true: success, false: failure
*/
function mc_issue_relationship_delete($p_username, $p_password, $p_issue_id, $p_relationship_id)
{
$t_user_id = mci_check_login($p_username, $p_password);
if ($t_user_id === false) {
return new soap_fault('Client', '', 'Access Denied');
}
$t_project_id = bug_get_field($p_issue_id, 'project_id');
if (!mci_has_readwrite_access($t_user_id, $t_project_id)) {
return new soap_fault('Client', '', 'Access Denied');
}
# user has access to update the bug...
if (!access_has_bug_level(config_get('update_bug_threshold'), $p_issue_id, $t_user_id)) {
return new soap_fault('Client', '', "Active user does not have access level required to remove a relationship from this issue.");
}
# bug is not read-only...
if (bug_is_readonly($p_issue_id)) {
return new soap_fault('Client', '', "Issue '{$p_issue_id}' is readonly.");
}
# retrieve the destination bug of the relationship
$t_dest_issue_id = relationship_get_linked_bug_id($p_relationship_id, $p_issue_id);
# user can access to the related bug at least as viewer, if it's exist...
if (bug_exists($t_dest_issue_id)) {
if (!access_has_bug_level(VIEWER, $t_dest_issue_id, $t_user_id)) {
return new soap_fault('Client', '', "The issue '{$t_dest_issue_id}' requires higher access level.");
}
}
$t_bug_relationship_data = relationship_get($p_relationship_id);
$t_rel_type = $t_bug_relationship_data->type;
# delete relationship from the DB
relationship_delete($p_relationship_id);
# update bug last updated (just for the src bug)
bug_update_date($p_issue_id);
# set the rel_type for both bug and dest_bug based on $t_rel_type and on who is the dest bug
if ($p_issue_id == $t_bug_relationship_data->src_bug_id) {
$t_bug_rel_type = $t_rel_type;
$t_dest_bug_rel_type = relationship_get_complementary_type($t_rel_type);
} else {
$t_bug_rel_type = relationship_get_complementary_type($t_rel_type);
$t_dest_bug_rel_type = $t_rel_type;
}
# send email and update the history for the src issue
history_log_event_special($p_issue_id, BUG_DEL_RELATIONSHIP, $t_bug_rel_type, $t_dest_issue_id);
email_relationship_deleted($p_issue_id, $t_dest_issue_id, $t_bug_rel_type);
if (bug_exists($t_dest_issue_id)) {
# send email and update the history for the dest issue
history_log_event_special($t_dest_issue_id, BUG_DEL_RELATIONSHIP, $t_dest_bug_rel_type, $p_issue_id);
email_relationship_deleted($t_dest_issue_id, $p_issue_id, $t_dest_bug_rel_type);
}
return true;
}
示例11: filter_get_bug_rows
//.........这里部分代码省略.........
}
}
if (count($t_filter['user_monitor']) == 0) {
$t_any_found = true;
}
if (!$t_any_found) {
$t_clauses = array();
$t_table_name = 'user_monitor';
array_push($t_from_clauses, $t_bug_monitor_table);
array_push($t_join_clauses, "LEFT JOIN {$t_bug_monitor_table} {$t_table_name} ON {$t_table_name}.bug_id = {$t_bug_table}.id");
foreach ($t_filter['user_monitor'] as $t_filter_member) {
$c_user_monitor = db_prepare_int($t_filter_member);
if (META_FILTER_MYSELF == $c_user_monitor) {
array_push($t_clauses, $c_user_id);
} else {
array_push($t_clauses, $c_user_monitor);
}
}
if (1 < count($t_clauses)) {
array_push($t_where_clauses, "( {$t_table_name}.user_id in (" . implode(', ', $t_clauses) . ") )");
} else {
array_push($t_where_clauses, "( {$t_table_name}.user_id={$t_clauses['0']} )");
}
}
# bug relationship
$t_any_found = false;
$c_rel_type = $t_filter['relationship_type'];
$c_rel_bug = $t_filter['relationship_bug'];
if (-1 == $c_rel_type || 0 == $c_rel_bug) {
$t_any_found = true;
}
if (!$t_any_found) {
# use the complementary type
$c_rel_type = relationship_get_complementary_type($c_rel_type);
$t_clauses = array();
$t_table_name = 'relationship';
array_push($t_from_clauses, $t_bug_relationship_table);
array_push($t_join_clauses, "LEFT JOIN {$t_bug_relationship_table} {$t_table_name} ON {$t_table_name}.destination_bug_id = {$t_bug_table}.id");
// get reverse relationships
if ($c_rel_type == 1) {
array_push($t_join_clauses, "LEFT JOIN {$t_bug_relationship_table} {$t_table_name}" . "2 ON {$t_table_name}" . "2.source_bug_id = {$t_bug_table}.id");
}
array_push($t_clauses, "({$t_table_name}.relationship_type='{$c_rel_type}' AND {$t_table_name}.source_bug_id='{$c_rel_bug}')");
// get reverse relationships
if ($c_rel_type == 1) {
array_push($t_clauses, "({$t_table_name}" . "2.relationship_type='{$c_rel_type}' AND {$t_table_name}" . "2.destination_bug_id='{$c_rel_bug}')");
}
array_push($t_where_clauses, '(' . implode(' OR ', $t_clauses) . ')');
}
# custom field filters
if (ON == config_get('filter_by_custom_fields')) {
# custom field filtering
$t_custom_fields = custom_field_get_linked_ids($t_project_id);
foreach ($t_custom_fields as $t_cfid) {
$t_first_time = true;
$t_custom_where_clause = '';
# Ignore all custom filters that are not set, or that are set to '' or "any"
$t_any_found = false;
foreach ($t_filter['custom_fields'][$t_cfid] as $t_filter_member) {
if (META_FILTER_ANY == $t_filter_member && is_numeric($t_filter_member)) {
$t_any_found = true;
}
}
if (!isset($t_filter['custom_fields'][$t_cfid])) {
$t_any_found = 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;
}