Ejemplo n.º 1
0
function custom_function_default_checkin($p_issue_id, $p_comment, $p_file, $p_new_version, $p_fixed)
{
    if (bug_exists($p_issue_id)) {
        history_log_event_special($p_issue_id, CHECKIN, $p_file, $p_new_version);
        bugnote_add($p_issue_id, $p_comment, VS_PRIVATE == config_get('source_control_notes_view_status'));
        $t_status = config_get('source_control_set_status_to');
        if (OFF != $t_status && $p_fixed) {
            bug_set_field($p_issue_id, 'status', $t_status);
            bug_set_field($p_issue_id, 'resolution', config_get('source_control_set_resolution_to'));
        }
    }
}
Ejemplo n.º 2
0
 function display_bug_id($p_event, $p_text)
 {
     $p_bug_id = (int) $p_text;
     if (!bug_exists($p_bug_id)) {
         return $p_text;
     }
     $bug = bug_get($p_bug_id);
     $project = $bug->__get("project_id");
     if ($project != plugin_config_get('project_id')) {
         return $p_text;
     }
     $p_field_id = plugin_config_get('field_id');
     $prefix = plugin_config_get('prefix');
     $has_parent = false;
     $t_bugs_ids = relationship_get_all_src($p_bug_id);
     foreach ($t_bugs_ids as $t_relaship) {
         if ($t_relaship->type == BUG_BLOCKS) {
             $has_parent = true;
             break;
         }
     }
     $t_bugs_ids = relationship_get_all_dest($p_bug_id);
     foreach ($t_bugs_ids as $t_relaship) {
         if ($t_relaship->type == BUG_DEPENDANT) {
             $has_parent = true;
             break;
         }
     }
     $prefix_two = plugin_config_get('prefix_two');
     if ($has_parent) {
         $prefix = $prefix_two;
     }
     $p_def = custom_field_get_definition($p_field_id);
     $t_custom_field_value = custom_field_get_value($p_field_id, $p_bug_id);
     global $g_custom_field_type_definition;
     if (isset($g_custom_field_type_definition[$p_def['type']]['#function_string_value'])) {
         return $prefix . call_user_func($g_custom_field_type_definition[$p_def['type']]['#function_string_value'], $t_custom_field_value);
     }
     return $prefix . $t_custom_field_value;
 }
/**
 * @param PDF $pdf
 * @param $bug_ids
 * @param $version_date
 * @param $chapter_prefix
 * @param $option_show_duration
 * @param $detail_flag
 */
function process_content(PDF $pdf, $bug_ids, $version_date, $chapter_prefix, $option_show_duration, $detail_flag)
{
    $specmanagement_editor_api = new specmanagement_editor_api();
    $bug_counter = 10;
    foreach ($bug_ids as $bug_id) {
        if (bug_exists($bug_id)) {
            $bug_data = $specmanagement_editor_api->calculate_bug_data($bug_id, $version_date);
            if ($detail_flag) {
                $pdf->SetFont('Arial', 'B', 12);
                $pdf->Cell(95, 10, $chapter_prefix . '.' . $bug_counter . ' ' . utf8_decode(string_display($bug_data[1]) . ' (' . bug_format_id($bug_data[0])) . ')');
                $pdf->SetFont('Arial', '', 12);
                if ($option_show_duration == '1' && !($bug_data[7] == 0 || is_null($bug_data[7]))) {
                    $pdf->SetFont('Arial', 'B', 12);
                    $pdf->Cell(95, 10, plugin_lang_get('editor_bug_duration') . ': ' . $bug_data[7] . ' ' . plugin_lang_get('editor_duration_unit'), '', 0, 0);
                    $pdf->SetFont('Arial', '', 12);
                }
                $pdf->Ln();
                $pdf->MultiCell(0, 10, utf8_decode(trim($bug_data[2])), 0, 1);
                $pdf->MultiCell(0, 10, utf8_decode(trim($bug_data[3])), 0, 1);
                $pdf->MultiCell(0, 10, utf8_decode(trim($bug_data[4])), 0, 1);
                if (!empty($bug_data[5])) {
                    $bug_attachements = file_get_visible_attachments($bug_id);
                    $bug_attachements_count = count($bug_attachements);
                    $pdf->MultiCell(0, 10, utf8_decode(plugin_lang_get('editor_bug_attachments')) . ' (' . $bug_attachements_count . ')', 0, 1);
                    foreach ($bug_attachements as $bug_attachement) {
                        //                  var_dump( $bug_attachement );
                        /** TODO: Bilder anzeigen */
                        if ($bug_attachement['type'] == 'image') {
                            $file_download_url = config_get_global('path') . $bug_attachement['download_url'];
                            //                  $file_download_url = 'https://upload.wikimedia.org/wikipedia/commons/c/c6/Bayerischer_Wald_-_Aufichtenwald_001.jpg';
                            fopen($file_download_url, 'r');
                            $contents = file_get_contents($file_download_url);
                            $savename = '_' . $bug_attachement['id'] . $bug_attachement['display_name'];
                            $savefile = fopen($savename, 'w');
                            fwrite($savefile, $contents);
                            fclose($savefile);
                            //                     $pdf->Image( $savename );
                        }
                    }
                }
                if (!is_null($bug_data[6]) && $bug_data[6] != 0) {
                    $pdf->MultiCell(0, 10, utf8_decode(plugin_lang_get('editor_bug_notes_note')) . ' (' . $bug_data[6] . ')', 0, 1);
                }
            } else {
                $pdf->Cell(95, 10, $chapter_prefix . '.' . $bug_counter . ' ' . utf8_decode(string_display($bug_data[1]) . ' (' . bug_format_id($bug_data[0])) . ')', 0, 0);
                $pdf->Cell(95, 10, $pdf->PageNo(), 0, 1, 'R');
            }
            $bug_counter += 10;
        }
    }
}
Ejemplo n.º 4
0
/**
 * Given a set of changeset objects, parse the bug links
 * and save the changes.
 * @param array Changeset objects
 * @param object Repository object
 */
function Source_Process_Changesets($p_changesets, $p_repo = null)
{
    global $g_cache_current_user_id;
    if (!is_array($p_changesets)) {
        return;
    }
    if (is_null($p_repo)) {
        $t_repos = SourceRepo::load_by_changesets($p_changesets);
    } else {
        $t_repos = array($p_repo->id => $p_repo);
    }
    $t_resolved_threshold = config_get('bug_resolved_status_threshold');
    $t_fixed_threshold = config_get('bug_resolution_fixed_threshold');
    $t_notfixed_threshold = config_get('bug_resolution_not_fixed_threshold');
    # Link author and committer name/email to user accounts
    foreach ($p_changesets as $t_key => $t_changeset) {
        $p_changesets[$t_key] = Source_Parse_Users($t_changeset);
    }
    # Parse normal bug links
    foreach ($p_changesets as $t_changeset) {
        $t_changeset->bugs = Source_Parse_Buglinks($t_changeset->message);
    }
    # Parse fixed bug links
    $t_fixed_bugs = array();
    # Find and associate resolve links with the changeset
    foreach ($p_changesets as $t_changeset) {
        $t_bugs = Source_Parse_Bugfixes($t_changeset->message);
        foreach ($t_bugs as $t_bug_id) {
            $t_fixed_bugs[$t_bug_id] = $t_changeset;
        }
        # Add the link to the normal set of buglinks
        $t_changeset->bugs = array_unique(array_merge($t_changeset->bugs, $t_bugs));
    }
    # Save changeset data before processing their consequences
    foreach ($p_changesets as $t_changeset) {
        $t_changeset->repo = $p_repo;
        $t_changeset->save();
    }
    # Precache information for resolved bugs
    bug_cache_array_rows(array_keys($t_fixed_bugs));
    $t_current_user_id = $g_cache_current_user_id;
    $t_enable_resolving = config_get('plugin_Source_enable_resolving');
    $t_enable_message = config_get('plugin_Source_enable_message');
    $t_enable_mapping = config_get('plugin_Source_enable_mapping');
    $t_bugfix_status = config_get('plugin_Source_bugfix_status');
    $t_bugfix_status_pvm = config_get('plugin_Source_bugfix_status_pvm');
    $t_resolution = config_get('plugin_Source_bugfix_resolution');
    $t_handler = config_get('plugin_Source_bugfix_handler');
    $t_message_template = str_replace(array('$1', '$2', '$3', '$4', '$5', '$6'), array('%1$s', '%2$s', '%3$s', '%4$s', '%5$s', '%6$s'), config_get('plugin_Source_bugfix_message'));
    $t_mappings = array();
    # Start fixing and/or resolving issues
    foreach ($t_fixed_bugs as $t_bug_id => $t_changeset) {
        # make sure the bug exists before processing
        if (!bug_exists($t_bug_id)) {
            continue;
        }
        # fake the history entries as the committer/author user ID
        $t_user_id = null;
        if ($t_changeset->committer_id > 0) {
            $t_user_id = $t_changeset->committer_id;
        } else {
            if ($t_changeset->user_id > 0) {
                $t_user_id = $t_changeset->user_id;
            }
        }
        if (!is_null($t_user_id)) {
            $g_cache_current_user_id = $t_user_id;
        } else {
            if (!is_null($t_current_user_id)) {
                $g_cache_current_user_id = $t_current_user_id;
            } else {
                $g_cache_current_user_id = 0;
            }
        }
        # generate the branch mappings
        $t_version = '';
        $t_pvm_version_id = 0;
        if ($t_enable_mapping) {
            $t_repo_id = $t_changeset->repo_id;
            if (!isset($t_mappings[$t_repo_id])) {
                $t_mappings[$t_repo_id] = SourceMapping::load_by_repo($t_repo_id);
            }
            if (isset($t_mappings[$t_repo_id][$t_changeset->branch])) {
                $t_mapping = $t_mappings[$t_repo_id][$t_changeset->branch];
                if (Source_PVM()) {
                    $t_pvm_version_id = $t_mapping->apply_pvm($t_bug_id);
                } else {
                    $t_version = $t_mapping->apply($t_bug_id);
                }
            }
        }
        # generate a note message
        if ($t_enable_message) {
            $t_message = sprintf($t_message_template, $t_changeset->branch, $t_changeset->revision, $t_changeset->timestamp, $t_changeset->message, $t_repos[$t_changeset->repo_id]->name, $t_changeset->id);
        } else {
            $t_message = '';
        }
        $t_bug = bug_get($t_bug_id);
        # Update the resolution, fixed-in version, and/or add a bugnote
        $t_update = false;
        if (Source_PVM()) {
            if ($t_bugfix_status_pvm > 0 && $t_pvm_version_id > 0) {
                $t_matrix = new ProductMatrix($t_bug_id);
                if (isset($t_matrix->status[$t_pvm_version_id])) {
                    $t_matrix->status[$t_pvm_version_id] = $t_bugfix_status_pvm;
                    $t_matrix->save();
                }
            }
        } else {
            if ($t_bugfix_status > 0 && $t_bug->status != $t_bugfix_status) {
                $t_bug->status = $t_bugfix_status;
                $t_update = true;
            } else {
                if ($t_enable_resolving && $t_bugfix_status == -1 && $t_bug->status < $t_resolved_threshold) {
                    $t_bug->status = $t_resolved_threshold;
                    $t_update = true;
                }
            }
            if ($t_bug->resolution < $t_fixed_threshold || $t_bug->resolution >= $t_notfixed_threshold) {
                $t_bug->resolution = $t_resolution;
                $t_update = true;
            }
            if (is_blank($t_bug->fixed_in_version)) {
                $t_bug->fixed_in_version = $t_version;
                $t_update = true;
            }
        }
        if ($t_handler && !is_null($t_user_id)) {
            $t_bug->handler_id = $t_user_id;
        }
        $t_private = plugin_config_get('bugfix_message_view_status') == VS_PRIVATE;
        if ($t_update) {
            if ($t_message) {
                bugnote_add($t_bug_id, $t_message, '0:00', $t_private, 0, '', null, false);
            }
            $t_bug->update();
        } else {
            if ($t_message) {
                bugnote_add($t_bug_id, $t_message, '0:00', $t_private);
            }
        }
    }
    # reset the user ID
    $g_cache_current_user_id = $t_current_user_id;
    # Allow other plugins to post-process commit data
    event_signal('EVENT_SOURCE_COMMITS', array($p_changesets));
    event_signal('EVENT_SOURCE_FIXED', array($t_fixed_bugs));
}
Ejemplo n.º 5
0
/**
 * Check if the bug exists and the user has a access right to read it.
 *
 * @param integer   $p_user_id         The user id.
 * @param integer   $p_bug_id          The bug id.
 * @return true if the user has access rights and the bug exists, otherwise return false
 */
function mci_check_access_to_bug($p_user_id, $p_bug_id)
{
    if (!bug_exists($p_bug_id)) {
        return false;
    }
    $t_project_id = bug_get_field($p_bug_id, 'project_id');
    $g_project_override = $t_project_id;
    if (!mci_has_readonly_access($p_user_id, $t_project_id)) {
        return false;
    }
    if (!access_has_bug_level(config_get('view_bug_threshold', null, null, $t_project_id), $p_bug_id, $p_user_id)) {
        return false;
    }
    return true;
}
Ejemplo n.º 6
0
/**
 * Retrieves the raw history events for the specified bug id and returns it in an array
 * The array is indexed from 0 to N-1.  The second dimension is: 'date', 'userid', 'username',
 * 'field','type','old_value','new_value'
 * @param int $p_bug_id
 * @param int $p_user_id
 * @return array
 */
function history_get_raw_events_array($p_bug_id, $p_user_id = null)
{
    $t_mantis_bug_history_table = db_get_table('mantis_bug_history_table');
    $t_mantis_user_table = db_get_table('mantis_user_table');
    $t_history_order = config_get('history_order');
    $c_bug_id = db_prepare_int($p_bug_id);
    $t_user_id = null === $p_user_id ? auth_get_current_user_id() : $p_user_id;
    $t_roadmap_view_access_level = config_get('roadmap_view_threshold');
    $t_due_date_view_threshold = config_get('due_date_view_threshold');
    # grab history and display by date_modified then field_name
    # @@@ by MASC I guess it's better by id then by field_name. When we have more history lines with the same
    # date, it's better to respect the storing order otherwise we should risk to mix different information
    # I give you an example. We create a child of a bug with different custom fields. In the history of the child
    # bug we will find the line related to the relationship mixed with the custom fields (the history is creted
    # for the new bug with the same timestamp...)
    $query = "SELECT *\n\t\t\t\tFROM {$t_mantis_bug_history_table}\n\t\t\t\tWHERE bug_id=" . db_param() . "\n\t\t\t\tORDER BY date_modified {$t_history_order},id";
    $result = db_query_bound($query, array($c_bug_id));
    $raw_history_count = db_num_rows($result);
    $raw_history = array();
    $t_private_bugnote_threshold = config_get('private_bugnote_threshold');
    $t_private_bugnote_visible = access_has_bug_level(config_get('private_bugnote_threshold'), $p_bug_id, $t_user_id);
    $t_tag_view_threshold = config_get('tag_view_threshold');
    $t_view_attachments_threshold = config_get('view_attachments_threshold');
    $t_show_monitor_list_threshold = config_get('show_monitor_list_threshold');
    $t_show_handler_threshold = config_get('view_handler_threshold');
    $t_standard_fields = columns_get_standard();
    for ($i = 0, $j = 0; $i < $raw_history_count; ++$i) {
        $t_row = db_fetch_array($result);
        $v_type = $t_row['type'];
        $v_field_name = $t_row['field_name'];
        $v_user_id = $t_row['user_id'];
        $v_new_value = $t_row['new_value'];
        $v_old_value = $t_row['old_value'];
        $v_date_modified = $t_row['date_modified'];
        if ($v_type == NORMAL_TYPE) {
            if (!in_array($v_field_name, $t_standard_fields)) {
                # check that the item should be visible to the user
                # We are passing 32 here to notify the custom field API
                # that legacy history entries for field names longer than
                # 32 chars created when the db column was of that size were
                # truncated (no longer the case since 1.1.0a4, see #8002)
                $t_field_id = custom_field_get_id_from_name($v_field_name, 32);
                if (false !== $t_field_id && !custom_field_has_read_access($t_field_id, $p_bug_id, $t_user_id)) {
                    continue;
                }
            }
            if ($v_field_name == 'target_version' && !access_has_bug_level($t_roadmap_view_access_level, $p_bug_id, $t_user_id)) {
                continue;
            }
            if ($v_field_name == 'due_date' && !access_has_bug_level($t_due_date_view_threshold, $p_bug_id, $t_user_id)) {
                continue;
            }
            if ($v_field_name == 'handler_id' && !access_has_bug_level($t_show_handler_threshold, $p_bug_id, $t_user_id)) {
                continue;
            }
        }
        // bugnotes
        if ($t_user_id != $v_user_id) {
            // bypass if user originated note
            if ($v_type == BUGNOTE_ADDED || $v_type == BUGNOTE_UPDATED || $v_type == BUGNOTE_DELETED) {
                if (!$t_private_bugnote_visible && bugnote_get_field($v_old_value, 'view_state') == VS_PRIVATE) {
                    continue;
                }
            }
            if ($v_type == BUGNOTE_STATE_CHANGED) {
                if (!$t_private_bugnote_visible && bugnote_get_field($v_new_value, 'view_state') == VS_PRIVATE) {
                    continue;
                }
            }
        }
        // tags
        if ($v_type == TAG_ATTACHED || $v_type == TAG_DETACHED || $v_type == TAG_RENAMED) {
            if (!access_has_bug_level($t_tag_view_threshold, $p_bug_id, $t_user_id)) {
                continue;
            }
        }
        # attachments
        if ($v_type == FILE_ADDED || $v_type == FILE_DELETED) {
            if (!access_has_bug_level($t_view_attachments_threshold, $p_bug_id, $t_user_id)) {
                continue;
            }
        }
        // monitoring
        if ($v_type == BUG_MONITOR || $v_type == BUG_UNMONITOR) {
            if (!access_has_bug_level($t_show_monitor_list_threshold, $p_bug_id, $t_user_id)) {
                continue;
            }
        }
        # relationships
        if ($v_type == BUG_ADD_RELATIONSHIP || $v_type == BUG_DEL_RELATIONSHIP || $v_type == BUG_REPLACE_RELATIONSHIP) {
            $t_related_bug_id = $v_new_value;
            # If bug doesn't exist, then we don't know whether to expose it or not based on the fact whether it was
            # accessible to user or not.  This also simplifies client code that is accessing the history log.
            if (!bug_exists($t_related_bug_id) || !access_has_bug_level(VIEWER, $t_related_bug_id, $t_user_id)) {
                continue;
            }
        }
        $raw_history[$j]['date'] = $v_date_modified;
        $raw_history[$j]['userid'] = $v_user_id;
        # user_get_name handles deleted users, and username vs realname
        $raw_history[$j]['username'] = user_get_name($v_user_id);
        $raw_history[$j]['field'] = $v_field_name;
        $raw_history[$j]['type'] = $v_type;
        $raw_history[$j]['old_value'] = $v_old_value;
        $raw_history[$j]['new_value'] = $v_new_value;
        $j++;
    }
    # end for loop
    return $raw_history;
}
Ejemplo n.º 7
0
/**
 * Check if a bug exists. If it doesn't then trigger an error
 * @param int p_bug_id integer representing bug id
 * @return null
 * @access public
 */
function bug_ensure_exists($p_bug_id)
{
    if (!bug_exists($p_bug_id)) {
        error_parameters($p_bug_id);
        trigger_error(ERROR_BUG_NOT_FOUND, ERROR);
    }
}
 /**
  * @param $bug_id
  */
 public function get_workpackage_by_bug_id($bug_id)
 {
     $plugin_src_table = $this->get_mantis_plugin_table('src');
     if (bug_exists($bug_id)) {
         $query = "SELECT work_package FROM {$plugin_src_table}\n            WHERE bug_id = " . $bug_id;
         var_dump($query);
         $result = $this->mysqli->query($query);
         if (0 != $result->num_rows) {
             $row = mysqli_fetch_row($result);
             $work_package = $row[0];
             return $work_package;
         }
     }
 }
Ejemplo n.º 9
0
function relationship_get_details($p_bug_id, $p_relationship, $p_html = false, $p_html_preview = false, $p_show_project = false)
{
    $t_summary_wrap_at = strlen(config_get('email_separator2')) - 28;
    $t_icon_path = config_get('icon_path');
    $p_user_id = auth_get_current_user_id();
    if ($p_bug_id == $p_relationship->src_bug_id) {
        # root bug is in the src side, related bug in the dest side
        $t_related_bug_id = $p_relationship->dest_bug_id;
        $t_related_project_name = project_get_name($p_relationship->dest_project_id);
        $t_relationship_descr = relationship_get_description_src_side($p_relationship->type);
    } else {
        # root bug is in the dest side, related bug in the src side
        $t_related_bug_id = $p_relationship->src_bug_id;
        $t_related_project_name = project_get_name($p_relationship->src_project_id);
        $t_relationship_descr = relationship_get_description_dest_side($p_relationship->type);
    }
    # related bug not existing...
    if (!bug_exists($t_related_bug_id)) {
        return '';
    }
    # user can access to the related bug at least as a viewer
    if (!access_has_bug_level(VIEWER, $t_related_bug_id)) {
        return '';
    }
    if ($p_html_preview == false) {
        $t_td = '<td>';
    } else {
        $t_td = '<td class="print">';
    }
    # get the information from the related bug and prepare the link
    $t_bug = bug_prepare_display(bug_get($t_related_bug_id, true));
    $t_status = string_attribute(get_enum_element('status', $t_bug->status));
    $t_resolution = string_attribute(get_enum_element('resolution', $t_bug->resolution));
    $t_relationship_info_html = $t_td . '<nobr>' . $t_relationship_descr . '</nobr>&nbsp;</td>';
    if ($p_html_preview == false) {
        $t_relationship_info_html .= '<td><a href="' . string_get_bug_view_url($t_related_bug_id) . '">' . bug_format_id($t_related_bug_id) . '</a></td>';
        $t_relationship_info_html .= '<td><a title="' . $t_resolution . '"><u>' . $t_status . '</u>&nbsp;</a></td>';
    } else {
        $t_relationship_info_html .= $t_td . bug_format_id($t_related_bug_id) . '</td>';
        $t_relationship_info_html .= $t_td . $t_status . '&nbsp;</td>';
    }
    $t_relationship_info_text = str_pad($t_relationship_descr, 20);
    $t_relationship_info_text .= str_pad(bug_format_id($t_related_bug_id), 8);
    # get the handler name of the related bug
    $t_relationship_info_html .= $t_td;
    if ($t_bug->handler_id > 0) {
        $t_relationship_info_html .= '<nobr>' . prepare_user_name($t_bug->handler_id) . '</nobr>';
    }
    $t_relationship_info_html .= '&nbsp;</td>';
    # add project name
    if ($p_show_project) {
        $t_relationship_info_html .= $t_td . $t_related_project_name . '&nbsp;</td>';
    }
    # add summary
    $t_relationship_info_html .= $t_td . $t_bug->summary;
    if (VS_PRIVATE == $t_bug->view_state) {
        $t_relationship_info_html .= sprintf(' <img src="%s" alt="(%s)" title="%s" />', $t_icon_path . 'protected.gif', lang_get('private'), lang_get('private'));
    }
    if (strlen($t_bug->summary) <= $t_summary_wrap_at) {
        $t_relationship_info_text .= $t_bug->summary;
    } else {
        $t_relationship_info_text .= substr($t_bug->summary, 0, $t_summary_wrap_at - 3) . '...';
    }
    # add delete link if bug not read only and user has access level
    if (!bug_is_readonly($p_bug_id) && !current_user_is_anonymous() && $p_html_preview == false) {
        if (access_has_bug_level(config_get('update_bug_threshold'), $p_bug_id)) {
            $t_relationship_info_html .= " [<a class=\"small\" href=\"bug_relationship_delete.php?bug_id={$p_bug_id}&rel_id={$p_relationship->id}\">" . lang_get('delete_link') . '</a>]';
        }
    }
    $t_relationship_info_html .= '&nbsp;</td>';
    $t_relationship_info_text .= "\n";
    if ($p_html_preview == false) {
        $t_relationship_info_html = '<tr bgcolor="' . get_status_color($t_bug->status) . '">' . $t_relationship_info_html . '</tr>' . "\n";
    } else {
        $t_relationship_info_html = '<tr>' . $t_relationship_info_html . '</tr>';
    }
    if ($p_html == true) {
        return $t_relationship_info_html;
    } else {
        return $t_relationship_info_text;
    }
}
Ejemplo n.º 10
0
 function getProductBacklogByBugId($p_bug_id)
 {
     if (bug_exists($p_bug_id)) {
         $this->getAdditionalProjectFields();
         $t_value = custom_field_get_value($this->pb, $p_bug_id);
         if (!empty($t_value)) {
             $t_sql = "SELECT * FROM gadiv_productbacklogs WHERE name=" . db_param(0);
             $t_result = $this->executeQuery($t_sql, array($t_value));
             if (count($t_result) > 0) {
                 return $t_result[0];
             }
         }
     }
     return null;
 }
Ejemplo n.º 11
0
<?php

# Copyright (c) 2012 John Reese
# Licensed under the MIT license
form_security_validate('plugin_Source_attach');
access_ensure_global_level(plugin_config_get('update_threshold'));
$f_changeset_id = gpc_get_int('id');
$f_bug_ids = gpc_get_string('bug_ids');
$t_changeset = SourceChangeset::load($f_changeset_id);
$t_changeset->load_bugs();
$t_user_id = auth_get_current_user_id();
$t_bug_ids = explode(',', $f_bug_ids);
foreach ($t_bug_ids as $t_bug_id) {
    $t_bug_id = (int) $t_bug_id;
    if ($t_bug_id < 1 || !bug_exists($t_bug_id)) {
        continue;
    }
    if (!in_array($t_bug_id, $t_changeset->bugs)) {
        $t_changeset->bugs[] = $t_bug_id;
    }
}
$t_changeset->save_bugs($t_user_id);
form_security_purge('plugin_Source_attach');
print_successful_redirect(plugin_page('view', true) . '&id=' . $t_changeset->id);
Ejemplo n.º 12
0
/**
 * Log a checkin event on the issue
 *
 * @param string $p_username  The name of the user trying to access the issue.
 * @param string $p_password  The password of the user.
 * @param integer $p_issue_id The id of the issue to log a checkin.
 * @param string $p_comment   The comment to add
 * @param boolean $p_fixed    True if the issue is to be set to fixed
 * @return boolean  true success, false otherwise.
 */
function mc_issue_checkin($p_username, $p_password, $p_issue_id, $p_comment, $p_fixed)
{
    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();
    }
    if (!bug_exists($p_issue_id)) {
        return SoapObjectsFactory::newSoapFault('Client', "Issue '{$p_issue_id}' not found.");
    }
    $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);
    }
    helper_call_custom_function('checkin', array($p_issue_id, $p_comment, '', '', $p_fixed));
    return true;
}
$req_id = $_POST["req_id"];
$req_version_id = $_POST["req_ver_id"];
$reason_for_change = session_validate_form_get_field("req_reason_change", "", session_use_FCKeditor());
$req_name = session_validate_form_get_field('req_name_required');
$req_area = session_validate_form_get_field('req_area');
$req_type = session_validate_form_get_field('req_type');
$req_status = session_validate_form_get_field('req_status');
$req_functionality = session_validate_form_get_field("req_functionality");
$req_priority = session_validate_form_get_field("req_priority");
$req_release = session_validate_form_get_field("assigned_release");
$req_defect_id = session_validate_form_get_field("defect_id");
if ($req_defect_id == '') {
    $req_defect_id = 0;
}
# return the user to the previous page if the new_bug_id doesn't exist in the bug table
if (!bug_exists($req_defect_id) && $req_defect_id != 0) {
    html_redirect($redirect_on_error);
}
requirement_edit($project_id, $req_id, $req_version_id, $req_defect_id, $req_name, $req_area, $req_type, $req_status, $detail, $reason_for_change, $req_functionality, $req_priority, $req_release);
session_validate_form_reset();
############################################################################
# EMAIL NOTIFICATION
############################################################################
$recipients = requirement_get_notify_users($project_id, $req_id);
requirement_email($project_id, $req_id, $recipients, $action = "updated");
############################################################################
############################################################################
html_print_operation_successful('req_edit_page', "requirement_detail_page.php");
# ---------------------------------------------------------------------
# $Log: requirement_edit_action.php,v $
# Revision 1.6  2006/09/27 23:58:33  gth2
Ejemplo n.º 14
0
 /**
  * Send message bug_actions.
  */
 function bug_actions($p_event, $p_event_str, $p_bug_id)
 {
     if (!bug_exists($p_bug_id)) {
         return;
     }
     if (check_user_from_projects_table($p_bug_id)) {
         $f_action = gpc_get_string('action');
         switch ($f_action) {
             case 'CLOSE':
                 if (ON == plugin_config_get('send_mes_new_state_90')) {
                     $reporter_user_id = bug_get_field($p_bug_id, 'reporter_id');
                     $bugnote_text = gpc_get_string('bugnote_text', '');
                     send_msg(get_xmpp_login($reporter_user_id), gen_close_bug_msg($reporter_user_id, $p_bug_id, $bugnote_text));
                 }
                 break;
             case 'MOVE':
                 if (ON == plugin_config_get('send_mes_move_bug')) {
                     $reporter_user_id = bug_get_field($p_bug_id, 'reporter_id');
                     send_msg(get_xmpp_login($reporter_user_id), gen_move_bug_msg($reporter_user_id, $p_bug_id));
                 }
                 break;
             case 'RESOLVE':
                 if (ON == plugin_config_get('send_mes_new_state_80')) {
                     $reporter_user_id = bug_get_field($p_bug_id, 'reporter_id');
                     $bugnote_text = gpc_get_string('bugnote_text', '');
                     send_msg(get_xmpp_login($reporter_user_id), gen_resolve_bug_msg($reporter_user_id, $p_bug_id, $bugnote_text));
                 }
                 break;
             case 'ASSIGN':
                 if (ON == plugin_config_get('send_mes_new_assign')) {
                     $reporter_user_id = bug_get_field($p_bug_id, 'reporter_id');
                     send_msg(get_xmpp_login($reporter_user_id), gen_assign_bug_msg_in($reporter_user_id, $p_bug_id));
                     send_msg(get_xmpp_login(gpc_get_int('assign')), gen_assign_bug_msg_out($reporter_user_id, $p_bug_id));
                 }
                 break;
             case 'UP_PRIOR':
                 if (ON == plugin_config_get('send_mes_up_prior')) {
                     $reporter_user_id = bug_get_field($p_bug_id, 'reporter_id');
                     send_msg(get_xmpp_login($reporter_user_id), gen_up_priority_bug_msg($reporter_user_id, $p_bug_id));
                 }
                 break;
             case 'UP_STATUS':
                 if (ON == plugin_config_get('send_mes_up_status')) {
                     $reporter_user_id = bug_get_field($p_bug_id, 'reporter_id');
                     $bugnote_text = gpc_get_string('bugnote_text', '');
                     $status = gpc_get_int('status');
                     switch ($status) {
                         case '10':
                             if (ON == plugin_config_get('send_mes_new_state_10')) {
                                 send_msg(get_xmpp_login($reporter_user_id), gen_up_status_bug_msg($reporter_user_id, $p_bug_id, $bugnote_text));
                             }
                             break;
                         case '20':
                             if (ON == plugin_config_get('send_mes_new_state_20')) {
                                 send_msg(get_xmpp_login($reporter_user_id), gen_up_status_bug_msg($reporter_user_id, $p_bug_id, $bugnote_text));
                             }
                             break;
                         case '30':
                             if (ON == plugin_config_get('send_mes_new_state_30')) {
                                 send_msg(get_xmpp_login($reporter_user_id), gen_up_status_bug_msg($reporter_user_id, $p_bug_id, $bugnote_text));
                             }
                             break;
                         case '40':
                             if (ON == plugin_config_get('send_mes_new_state_40')) {
                                 send_msg(get_xmpp_login($reporter_user_id), gen_up_status_bug_msg($reporter_user_id, $p_bug_id, $bugnote_text));
                             }
                             break;
                         case '50':
                             if (ON == plugin_config_get('send_mes_new_state_50')) {
                                 send_msg(get_xmpp_login($reporter_user_id), gen_up_status_bug_msg($reporter_user_id, $p_bug_id, $bugnote_text));
                             }
                             break;
                         case '80':
                             if (ON == plugin_config_get('send_mes_new_state_80')) {
                                 send_msg(get_xmpp_login($reporter_user_id), gen_up_status_bug_msg($reporter_user_id, $p_bug_id, $bugnote_text));
                             }
                             break;
                         case '90':
                             if (ON == plugin_config_get('send_mes_new_state_90')) {
                                 send_msg(get_xmpp_login($reporter_user_id), gen_up_status_bug_msg($reporter_user_id, $p_bug_id, $bugnote_text));
                             }
                             break;
                     }
                 }
                 break;
             case 'UP_CATEGORY':
                 if (gpc_get_int('category') != 0 && ON == plugin_config_get('send_mes_up_category')) {
                     $reporter_user_id = bug_get_field($p_bug_id, 'reporter_id');
                     send_msg(get_xmpp_login($reporter_user_id), gen_up_category_bug_msg($reporter_user_id, $p_bug_id));
                 }
                 break;
             case 'VIEW_STATUS':
                 if (ON == plugin_config_get('send_mes_up_view')) {
                     $reporter_user_id = bug_get_field($p_bug_id, 'reporter_id');
                     send_msg(get_xmpp_login($reporter_user_id), gen_up_view_status_bug_msg($reporter_user_id, $p_bug_id));
                 }
                 break;
         }
     }
 }
Ejemplo n.º 15
0
/**
 * 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 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 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( 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_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
	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;
}
 /**
  * @param $bug_ids
  * @param $version_date
  * @param $chapter_prefix
  * @param $chapter_suffix
  * @param $option_show_duration
  * @param $detail_flag
  * @param $print_flag
  */
 public function process_content($bug_ids, $version_date, $chapter_prefix, $chapter_suffix, $option_show_duration, $detail_flag, $print_flag)
 {
     $bug_counter = 10;
     foreach ($bug_ids as $bug_id) {
         if (bug_exists($bug_id)) {
             $bug_data = $this->calculate_bug_data($bug_id, $version_date);
             if ($detail_flag) {
                 $this->print_bug($chapter_prefix, $bug_counter, $bug_data, $option_show_duration, $print_flag);
             } else {
                 $this->print_chapter_directory($print_flag, $chapter_suffix, $chapter_prefix, $bug_counter, $bug_data, false);
             }
             $bug_counter += 10;
         }
     }
 }
Ejemplo n.º 17
0
 public function get($request)
 {
     /*
      *      Returns a Response with a representation of the bug.
      *
      *      @param $request - The HTTP request we're responding to
      */
     $this->bug_id = Bug::get_mantis_id_from_url($request->url);
     if (!bug_exists($this->bug_id)) {
         throw new HTTPException(404, "No such bug: {$this->bug_id}");
     }
     if (!access_has_bug_level(VIEWER, $this->bug_id)) {
         throw new HTTPException(403, "Permission denied");
     }
     $this->populate_from_db();
     $resp = new Response();
     $resp->status = 200;
     $resp->body = $this->_repr($request);
     return $resp;
 }
Ejemplo n.º 18
0
/**
 * Log a checkin event on the issue
 *
 * @param string $p_username  The name of the user trying to access the issue.
 * @param string $p_password  The password of the user.
 * @param integer $p_issue_id The id of the issue to log a checkin.
 * @param string $p_comment   The comment to add
 * @param boolean $p_fixed    True if the issue is to be set to fixed
 * @return boolean  true success, false otherwise.
 */
function mc_issue_checkin($p_username, $p_password, $p_issue_id, $p_comment, $p_fixed)
{
    $t_user_id = mci_check_login($p_username, $p_password);
    if ($t_user_id === false) {
        return new soap_fault('Client', '', 'Access Denied');
    }
    if (!bug_exists($p_issue_id)) {
        return new soap_fault('Client', '', "Issue '{$p_issue_id}' not found.");
    }
    $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');
    }
    helper_call_custom_function('checkin', array($p_issue_id, $p_comment, '', '', $p_fixed));
    return true;
}
Ejemplo n.º 19
0
<?php

include '../../config.inc.php';
include '../common.inc.php';
include '../../libs/url.class.php';
include '../../libs/bugreport.class.php';
include '../../libs/func.lib.php';
include '../../libs/pager.class.php';
if (!bug_exists($_GET['bug'])) {
    die('Specify a bug report!');
}
if (isset($_GET['pick'])) {
    if ($_GET['pick'] == 'new') {
        $bug = new BugReport();
        $bug->loaddb($_GET['bug']);
        $text = ereg_prepare($bug->text);
        $stack = ereg_prepare($bug->stack);
        $query = "INSERT INTO " . TBUGS . " (bug_error_regexp,bug_stack_regexp) VALUES ('" . mysql_real_escape_string($text) . "','" . mysql_real_escape_string($stack) . "')";
        $result = mysql_query($query) or die("MySQL Error: " . mysql_error());
        $bug->bug = mysql_insert_id();
        $bug->update2db();
        echo "<script type=\"text/javascript\">\n";
        echo "<!--\n";
        echo "window.opener.location='index.php?show=bug&id=" . $bug->bug . "'\n";
        echo "window.close()\n";
        echo "-->\n";
        echo "</script>";
    } else {
        $bug = new BugReport();
        $bug->loaddb($_GET['bug']);
        $bug->bug = $_GET['pick'];
$testset_id = $s_results['testset_id'];
$test_id = $s_results['test_id'];
$test_run_id = $s_results['test_run_id'];
$verify_id = $s_results['verify_id'];
$comments = util_clean_post_vars('verification_comments');
$status = util_clean_post_vars('verification_status');
$current_bug_id = util_clean_post_vars('current_bug_id');
$new_bug_id = util_clean_post_vars('new_bug_id');
if ($new_bug_id == '') {
    $new_bug_id = 0;
}
# Need to verify the user entered a valid id and
# update the bug table if the user has changed this value
if ($current_bug_id != $new_bug_id) {
    # return the user to the previous page if the new_bug_id doesn't exist in the bug table
    if (!bug_exists($new_bug_id) && $new_bug_id != 0) {
        html_redirect($redirect_on_error);
    }
    # see if the verify_id exists anywhere in the bug table
    $related_bug_id = bug_get_bug_id_from_verification_id($verify_id);
    # remove the old verify_id from the bug table if it exists
    if (!empty($related_bug_id)) {
        bug_update_field($related_bug_id, BUG_TEST_VERIFY_ID, $value = "");
    }
    # set the new verify_id in the bug table
    bug_update_field($new_bug_id, BUG_TEST_VERIFY_ID, $verify_id);
}
# Update the verify results table
results_update_verification($test_run_id, $verify_id, $status, $comments, $new_bug_id);
html_print_operation_successful('update_verification', $redirect_page);
# ---------------------------------------------------------------------
Ejemplo n.º 21
0
/**
 * return an href anchor that links to a bug VIEW page for the given bug
 * account for the user preference and site override
 * @param integer $p_bug_id      A bug identifier.
 * @param integer $p_bugnote_id  A bugnote identifier.
 * @param integer $p_user_id     A valid user identifier.
 * @param boolean $p_detail_info Whether to include more detailed information (e.g. title attribute / project) in the returned string.
 * @param boolean $p_fqdn        Whether to return an absolute or relative link.
 * @return string
 */
function string_get_bugnote_view_link($p_bug_id, $p_bugnote_id, $p_user_id = null, $p_detail_info = true, $p_fqdn = false)
{
    $t_bug_id = (int) $p_bug_id;
    if (bug_exists($t_bug_id) && bugnote_exists($p_bugnote_id)) {
        $t_link = '<a href="';
        if ($p_fqdn) {
            $t_link .= config_get_global('path');
        } else {
            $t_link .= config_get_global('short_path');
        }
        $t_link .= string_get_bugnote_view_url($p_bug_id, $p_bugnote_id, $p_user_id) . '"';
        if ($p_detail_info) {
            $t_reporter = string_attribute(user_get_name(bugnote_get_field($p_bugnote_id, 'reporter_id')));
            $t_update_date = string_attribute(date(config_get('normal_date_format'), bugnote_get_field($p_bugnote_id, 'last_modified')));
            $t_link .= ' title="' . bug_format_id($t_bug_id) . ': [' . $t_update_date . '] ' . $t_reporter . '"';
        }
        $t_link .= '>' . bug_format_id($t_bug_id) . ':' . bugnote_format_id($p_bugnote_id) . '</a>';
    } else {
        $t_link = bugnote_format_id($t_bug_id) . ':' . bugnote_format_id($p_bugnote_id);
    }
    return $t_link;
}
Ejemplo n.º 22
0
function relgraph_add_child(&$p_bug_list, $p_bug_id)
{
    # Check if the issue is already in the issue list.
    if (isset($p_bug_list[$p_bug_id])) {
        # The issue is in the list, but we cannot discard it since it
        # may be a parent issue (whose children were not visited).
        if (!$p_bug_list[$p_bug_id]->is_descendant) {
            # Yes, we visited this issue as a parent... This is the case
            # where someone set up a cyclic relationship (I really hope
            # nobody ever do this, but should keep sanity) for this
            # issue. We just have to finish the job, visiting all issues
            # that were already listed by _add_parent().
            $p_bug_list[$p_bug_id]->is_descendant = true;
            foreach ($p_bug_list[$p_bug_id]->children as $t_child) {
                relgraph_add_child($p_bug_id, $t_child);
            }
        }
    } else {
        # The issue is not in the list, proceed as usual.
        # Check if the issue really exists and we have access to it.
        # If not, it is like it didn't exist.
        if (!bug_exists($p_bug_id)) {
            return false;
        }
        if (!access_has_bug_level(VIEWER, $p_bug_id)) {
            return false;
        }
        # Add the issue to the list.
        $p_bug_list[$p_bug_id] = bug_get($p_bug_id, false);
        $p_bug_list[$p_bug_id]->is_descendant = true;
        $p_bug_list[$p_bug_id]->parents = array();
        $p_bug_list[$p_bug_id]->children = array();
        # Add all parent issues to the list of parents. Do not visit them
        # for the same reason we didn't visit the children of all
        # ancestors.
        $t_relationships = relationship_get_all_dest($p_bug_id);
        foreach ($t_relationships as $t_relationship) {
            if ($t_relationship->type != BUG_DEPENDANT) {
                continue;
            }
            $p_bug_list[$p_bug_id]->parents[] = $t_relationship->src_bug_id;
        }
        # Add all child issues to the list of children and visit them
        # recursively.
        $t_relationships = relationship_get_all_src($p_bug_id);
        foreach ($t_relationships as $t_relationship) {
            if ($t_relationship->type != BUG_DEPENDANT) {
                continue;
            }
            $p_bug_list[$p_bug_id]->children[] = $t_relationship->dest_bug_id;
            relgraph_add_child($p_bug_list, $t_relationship->dest_bug_id);
        }
    }
    return true;
}
Ejemplo n.º 23
0
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);
Ejemplo n.º 24
0
 private function mail_is_a_bugnote($p_mail_subject, $p_references)
 {
     $t_bug_id = $this->get_bug_id_from_subject($p_mail_subject);
     if ($t_bug_id !== FALSE && bug_exists($t_bug_id)) {
         return $t_bug_id;
     }
     //Get the ids from Mail References(header)
     $t_bug_id = $this->get_bug_id_from_references($p_references);
     if ($t_bug_id !== FALSE && bug_exists($t_bug_id)) {
         return $t_bug_id;
     }
     return FALSE;
 }
Ejemplo n.º 25
0
/**
 * Gets the next accessible history event for current user and specified db result.
 * @param  string  $p_result      The database result.
 * @param  integer $p_user_id     The user id or null for logged in user.
 * @param  boolean $p_check_access_to_issue true: check that user has access to bugs,
 *                                          false otherwise.
 * @return array containing the history event or false if no more matches.
 */
function history_get_event_from_row($p_result, $p_user_id = null, $p_check_access_to_issue = true)
{
    static $s_bug_visible = array();
    $t_user_id = null === $p_user_id ? auth_get_current_user_id() : $p_user_id;
    $t_project_id = helper_get_current_project();
    while ($t_row = db_fetch_array($p_result)) {
        extract($t_row, EXTR_PREFIX_ALL, 'v');
        # Make sure the entry belongs to current project.
        if ($t_project_id != ALL_PROJECTS && $t_project_id != bug_get_field($v_bug_id, 'project_id')) {
            continue;
        }
        if ($p_check_access_to_issue) {
            if (!isset($s_bug_visible[$v_bug_id])) {
                $s_bug_visible[$v_bug_id] = access_has_bug_level(VIEWER, $v_bug_id);
            }
            if (!$s_bug_visible[$v_bug_id]) {
                continue;
            }
        }
        if ($v_type == NORMAL_TYPE) {
            if (!in_array($v_field_name, columns_get_standard())) {
                # check that the item should be visible to the user
                $t_field_id = custom_field_get_id_from_name($v_field_name);
                if (false !== $t_field_id && !custom_field_has_read_access($t_field_id, $v_bug_id, $t_user_id)) {
                    continue;
                }
            }
            if ($v_field_name == 'target_version' && !access_has_bug_level(config_get('roadmap_view_threshold'), $v_bug_id, $t_user_id)) {
                continue;
            }
            if ($v_field_name == 'due_date' && !access_has_bug_level(config_get('due_date_view_threshold'), $v_bug_id, $t_user_id)) {
                continue;
            }
            if ($v_field_name == 'handler_id' && !access_has_bug_level(config_get('view_handler_threshold'), $v_bug_id, $t_user_id)) {
                continue;
            }
        }
        # bugnotes
        if ($t_user_id != $v_user_id) {
            # bypass if user originated note
            if ($v_type == BUGNOTE_ADDED || $v_type == BUGNOTE_UPDATED || $v_type == BUGNOTE_DELETED) {
                if (!access_has_bug_level(config_get('private_bugnote_threshold'), $v_bug_id, $t_user_id) && bugnote_get_field($v_old_value, 'view_state') == VS_PRIVATE) {
                    continue;
                }
            }
            if ($v_type == BUGNOTE_STATE_CHANGED) {
                if (!access_has_bug_level(config_get('private_bugnote_threshold'), $v_bug_id, $t_user_id) && bugnote_get_field($v_new_value, 'view_state') == VS_PRIVATE) {
                    continue;
                }
            }
        }
        # tags
        if ($v_type == TAG_ATTACHED || $v_type == TAG_DETACHED || $v_type == TAG_RENAMED) {
            if (!access_has_bug_level(config_get('tag_view_threshold'), $v_bug_id, $t_user_id)) {
                continue;
            }
        }
        # attachments
        if ($v_type == FILE_ADDED || $v_type == FILE_DELETED) {
            if (!access_has_bug_level(config_get('view_attachments_threshold'), $v_bug_id, $t_user_id)) {
                continue;
            }
        }
        # monitoring
        if ($v_type == BUG_MONITOR || $v_type == BUG_UNMONITOR) {
            if (!access_has_bug_level(config_get('show_monitor_list_threshold'), $v_bug_id, $t_user_id)) {
                continue;
            }
        }
        # relationships
        if ($v_type == BUG_ADD_RELATIONSHIP || $v_type == BUG_DEL_RELATIONSHIP || $v_type == BUG_REPLACE_RELATIONSHIP) {
            $t_related_bug_id = $v_new_value;
            # If bug doesn't exist, then we don't know whether to expose it or not based on the fact whether it was
            # accessible to user or not.  This also simplifies client code that is accessing the history log.
            if (!bug_exists($t_related_bug_id) || !access_has_bug_level(config_get('view_bug_threshold'), $t_related_bug_id, $t_user_id)) {
                continue;
            }
        }
        $t_event = array();
        $t_event['bug_id'] = $v_bug_id;
        $t_event['date'] = $v_date_modified;
        $t_event['userid'] = $v_user_id;
        # user_get_name handles deleted users, and username vs realname
        $t_event['username'] = user_get_name($v_user_id);
        $t_event['field'] = $v_field_name;
        $t_event['type'] = $v_type;
        $t_event['old_value'] = $v_old_value;
        $t_event['new_value'] = $v_new_value;
        return $t_event;
    }
    return false;
}
Ejemplo n.º 26
0
/**
 * Retrieves the raw history events for the specified bug id and returns it in an array
 * The array is indexed from 0 to N-1.  The second dimension is: 'date', 'userid', 'username',
 * 'field','type','old_value','new_value'
 * @param integer $p_bug_id  A valid bug identifier.
 * @param integer $p_user_id A valid user identifier.
 * @param integer $p_start_time The start time to filter by, or null for all.
 * @param integer $p_end_time   The end time to filter by, or null for all.
 * @return array
 */
function history_get_raw_events_array($p_bug_id, $p_user_id = null, $p_start_time = null, $p_end_time = null)
{
    $t_history_order = config_get('history_order');
    $t_user_id = null === $p_user_id ? auth_get_current_user_id() : $p_user_id;
    $t_roadmap_view_access_level = config_get('roadmap_view_threshold');
    $t_due_date_view_threshold = config_get('due_date_view_threshold');
    # grab history and display by date_modified then field_name
    # @@@ by MASC I guess it's better by id then by field_name. When we have more history lines with the same
    # date, it's better to respect the storing order otherwise we should risk to mix different information
    # I give you an example. We create a child of a bug with different custom fields. In the history of the child
    # bug we will find the line related to the relationship mixed with the custom fields (the history is creted
    # for the new bug with the same timestamp...)
    $t_params = array($p_bug_id);
    $t_query = 'SELECT * FROM {bug_history} WHERE bug_id=' . db_param();
    $t_where = array();
    if ($p_start_time !== null) {
        $t_where[] = 'date_modified >= ' . db_param();
        $t_params[] = $p_start_time;
    }
    if ($p_end_time !== null) {
        $t_where[] = 'date_modified < ' . db_param();
        $t_params[] = $p_end_time;
    }
    if (count($t_where) > 0) {
        $t_query .= ' AND ' . implode(' AND ', $t_where);
    }
    $t_query .= ' ORDER BY date_modified ' . $t_history_order . ',id';
    $t_result = db_query($t_query, $t_params);
    $t_raw_history = array();
    $t_private_bugnote_visible = access_has_bug_level(config_get('private_bugnote_threshold'), $p_bug_id, $t_user_id);
    $t_tag_view_threshold = config_get('tag_view_threshold');
    $t_view_attachments_threshold = config_get('view_attachments_threshold');
    $t_show_monitor_list_threshold = config_get('show_monitor_list_threshold');
    $t_show_handler_threshold = config_get('view_handler_threshold');
    $t_standard_fields = columns_get_standard();
    $j = 0;
    while ($t_row = db_fetch_array($t_result)) {
        extract($t_row, EXTR_PREFIX_ALL, 'v');
        if ($v_type == NORMAL_TYPE) {
            if (!in_array($v_field_name, $t_standard_fields)) {
                # check that the item should be visible to the user
                $t_field_id = custom_field_get_id_from_name($v_field_name);
                if (false !== $t_field_id && !custom_field_has_read_access($t_field_id, $p_bug_id, $t_user_id)) {
                    continue;
                }
            }
            if ($v_field_name == 'target_version' && !access_has_bug_level($t_roadmap_view_access_level, $p_bug_id, $t_user_id)) {
                continue;
            }
            if ($v_field_name == 'due_date' && !access_has_bug_level($t_due_date_view_threshold, $p_bug_id, $t_user_id)) {
                continue;
            }
            if ($v_field_name == 'handler_id' && !access_has_bug_level($t_show_handler_threshold, $p_bug_id, $t_user_id)) {
                continue;
            }
        }
        # bugnotes
        if ($t_user_id != $v_user_id) {
            # bypass if user originated note
            if ($v_type == BUGNOTE_ADDED || $v_type == BUGNOTE_UPDATED || $v_type == BUGNOTE_DELETED) {
                if (!$t_private_bugnote_visible && bugnote_get_field($v_old_value, 'view_state') == VS_PRIVATE) {
                    continue;
                }
            }
            if ($v_type == BUGNOTE_STATE_CHANGED) {
                if (!$t_private_bugnote_visible && bugnote_get_field($v_new_value, 'view_state') == VS_PRIVATE) {
                    continue;
                }
            }
        }
        # tags
        if ($v_type == TAG_ATTACHED || $v_type == TAG_DETACHED || $v_type == TAG_RENAMED) {
            if (!access_has_bug_level($t_tag_view_threshold, $p_bug_id, $t_user_id)) {
                continue;
            }
        }
        # attachments
        if ($v_type == FILE_ADDED || $v_type == FILE_DELETED) {
            if (!access_has_bug_level($t_view_attachments_threshold, $p_bug_id, $t_user_id)) {
                continue;
            }
        }
        # monitoring
        if ($v_type == BUG_MONITOR || $v_type == BUG_UNMONITOR) {
            if (!access_has_bug_level($t_show_monitor_list_threshold, $p_bug_id, $t_user_id)) {
                continue;
            }
        }
        # relationships
        if ($v_type == BUG_ADD_RELATIONSHIP || $v_type == BUG_DEL_RELATIONSHIP || $v_type == BUG_REPLACE_RELATIONSHIP) {
            $t_related_bug_id = $v_new_value;
            # If bug doesn't exist, then we don't know whether to expose it or not based on the fact whether it was
            # accessible to user or not.  This also simplifies client code that is accessing the history log.
            if (!bug_exists($t_related_bug_id) || !access_has_bug_level(config_get('view_bug_threshold'), $t_related_bug_id, $t_user_id)) {
                continue;
            }
        }
        $t_raw_history[$j]['date'] = $v_date_modified;
        $t_raw_history[$j]['userid'] = $v_user_id;
        # user_get_name handles deleted users, and username vs realname
        $t_raw_history[$j]['username'] = user_get_name($v_user_id);
        $t_raw_history[$j]['field'] = $v_field_name;
        $t_raw_history[$j]['type'] = $v_type;
        $t_raw_history[$j]['old_value'] = $v_old_value;
        $t_raw_history[$j]['new_value'] = $v_new_value;
        $j++;
    }
    # end for loop
    return $t_raw_history;
}
Ejemplo n.º 27
0
/**
 * return formatted string with all the details on the requested relationship
 * @param integer             $p_bug_id       A bug identifier.
 * @param BugRelationshipData $p_relationship A bug relationship object.
 * @param boolean             $p_html         Whether to return html or text output.
 * @param boolean             $p_html_preview Whether to include style/hyperlinks - if preview is false, we prettify the output.
 * @param boolean             $p_show_project Show Project details.
 * @return string
 */
function relationship_get_details($p_bug_id, BugRelationshipData $p_relationship, $p_html = false, $p_html_preview = false, $p_show_project = false)
{
    $t_summary_wrap_at = utf8_strlen(config_get('email_separator2')) - 28;
    $t_icon_path = config_get('icon_path');
    if ($p_bug_id == $p_relationship->src_bug_id) {
        # root bug is in the source side, related bug in the destination side
        $t_related_bug_id = $p_relationship->dest_bug_id;
        $t_related_project_name = project_get_name($p_relationship->dest_project_id);
        $t_relationship_descr = relationship_get_description_src_side($p_relationship->type);
    } else {
        # root bug is in the dest side, related bug in the source side
        $t_related_bug_id = $p_relationship->src_bug_id;
        $t_related_project_name = project_get_name($p_relationship->src_project_id);
        $t_relationship_descr = relationship_get_description_dest_side($p_relationship->type);
    }
    # related bug not existing...
    if (!bug_exists($t_related_bug_id)) {
        return '';
    }
    # user can access to the related bug at least as a viewer
    if (!access_has_bug_level(VIEWER, $t_related_bug_id)) {
        return '';
    }
    if ($p_html_preview == false) {
        $t_td = '<td>';
    } else {
        $t_td = '<td class="print">';
    }
    # get the information from the related bug and prepare the link
    $t_bug = bug_get($t_related_bug_id, false);
    $t_status_string = get_enum_element('status', $t_bug->status, auth_get_current_user_id(), $t_bug->project_id);
    $t_resolution_string = get_enum_element('resolution', $t_bug->resolution, auth_get_current_user_id(), $t_bug->project_id);
    $t_relationship_info_html = $t_td . string_no_break($t_relationship_descr) . '&#160;</td>';
    if ($p_html_preview == false) {
        $t_relationship_info_html .= '<td><a href="' . string_get_bug_view_url($t_related_bug_id) . '">' . string_display_line(bug_format_id($t_related_bug_id)) . '</a></td>';
        $t_relationship_info_html .= '<td><span class="issue-status" title="' . string_attribute($t_resolution_string) . '">' . string_display_line($t_status_string) . '</span></td>';
    } else {
        $t_relationship_info_html .= $t_td . string_display_line(bug_format_id($t_related_bug_id)) . '</td>';
        $t_relationship_info_html .= $t_td . string_display_line($t_status_string) . '&#160;</td>';
    }
    $t_relationship_info_text = utf8_str_pad($t_relationship_descr, 20);
    $t_relationship_info_text .= utf8_str_pad(bug_format_id($t_related_bug_id), 8);
    # get the handler name of the related bug
    $t_relationship_info_html .= $t_td;
    if ($t_bug->handler_id > 0) {
        $t_relationship_info_html .= string_no_break(prepare_user_name($t_bug->handler_id));
    }
    $t_relationship_info_html .= '&#160;</td>';
    # add project name
    if ($p_show_project) {
        $t_relationship_info_html .= $t_td . string_display_line($t_related_project_name) . '&#160;</td>';
    }
    # add summary
    if ($p_html == true) {
        $t_relationship_info_html .= $t_td . string_display_line_links($t_bug->summary);
        if (VS_PRIVATE == $t_bug->view_state) {
            $t_relationship_info_html .= sprintf(' <img src="%s" alt="(%s)" title="%s" />', $t_icon_path . 'protected.gif', lang_get('private'), lang_get('private'));
        }
    } else {
        if (utf8_strlen($t_bug->summary) <= $t_summary_wrap_at) {
            $t_relationship_info_text .= string_email_links($t_bug->summary);
        } else {
            $t_relationship_info_text .= utf8_substr(string_email_links($t_bug->summary), 0, $t_summary_wrap_at - 3) . '...';
        }
    }
    # add delete link if bug not read only and user has access level
    if (!bug_is_readonly($p_bug_id) && !current_user_is_anonymous() && $p_html_preview == false) {
        if (access_has_bug_level(config_get('update_bug_threshold'), $p_bug_id)) {
            $t_relationship_info_html .= ' [<a class="small" href="bug_relationship_delete.php?bug_id=' . $p_bug_id . '&amp;rel_id=' . $p_relationship->id . htmlspecialchars(form_security_param('bug_relationship_delete')) . '">' . lang_get('delete_link') . '</a>]';
        }
    }
    $t_relationship_info_html .= '&#160;</td>';
    $t_relationship_info_text .= "\n";
    if ($p_html_preview == false) {
        # choose color based on status
        $t_status_label = html_get_status_css_class($t_bug->status, auth_get_current_user_id(), $t_bug->project_id);
        $t_relationship_info_html = '<tr class="' . $t_status_label . '">' . $t_relationship_info_html . '</tr>' . "\n";
    } else {
        $t_relationship_info_html = '<tr>' . $t_relationship_info_html . '</tr>';
    }
    if ($p_html == true) {
        return $t_relationship_info_html;
    } else {
        return $t_relationship_info_text;
    }
}
Ejemplo n.º 28
0
function bug_add_relationship($bug_id, $related_bug_id, $rel_type)
{
    global $db;
    $bug_assoc_tbl = BUG_ASSOC_TBL;
    $f_assoc_id = BUG_ASSOC_ID;
    $f_src_id = BUG_ASSOC_SRC_ID;
    $f_dest_id = BUG_ASSOC_DEST_ID;
    $f_rel_type = BUG_ASSOC_REL_TYPE;
    # Make sure the related_bug_id is valid
    $bug_exists = bug_exists($related_bug_id);
    if (!$bug_exists) {
        return false;
    }
    # Make sure a relationship has not already been created
    $q = "\tSELECT {$f_assoc_id}\n\t\t\tFROM {$bug_assoc_tbl}\n\t\t\tWHERE ( {$f_src_id} = '{$bug_id}' AND {$f_dest_id} = '{$related_bug_id}' )\n\t\t\t\tOR ( {$f_src_id} = '{$related_bug_id}' AND {$f_dest_id} = '{$bug_id}' )";
    $rs = db_query($db, $q);
    $relationship_exits = db_num_rows($db, $rs);
    if ($relationship_exits) {
        return false;
    }
    # rel_type
    # Related = 0
    # Child	  = 1
    # Parent  = 2
    $q = "INSERT INTO {$bug_assoc_tbl}\n\t\t  ( {$f_src_id}, {$f_dest_id}, {$f_rel_type} )\n\t\t  VALUES\n\t\t  ( '{$bug_id}', '{$related_bug_id}', '{$rel_type}' )";
    #print"$q<br>";
    db_query($db, $q);
    # Only add record to monitor table and email user if status array is true
    if ($GLOBALS['default_notify_flags']['update']) {
        # enter user_id in bug_monitor table and gather recipients
        bug_monitor_attach_user($bug_id);
        $recipients = bug_email_collect_recipients($bug_id, "update_bug");
        if ($recipients != '') {
            $project_id = session_get_project_id();
            bug_email($project_id, $bug_id, $recipients, "add_relationship");
        }
    }
    return true;
}