Beispiel #1
0
function wiki_xwiki_get_page_id_for_issue($p_issue_id)
{
    $t_project_id = project_get_name(bug_get_field($p_issue_id, 'project_id'));
    $c_issue_id = db_prepare_int($p_issue_id);
    return $c_issue_id;
    return $t_project_id . '/' . $c_issue_id;
}
Beispiel #2
0
/**
 * Print Change Status to: AJAXified button
 * This code is similar to button_bug_change_status except that the 
 * button is AJAXified.
 * Uses projax.php
 *
 * @param int $p_bug_id
 * @param int $t_project_id
 * @param int $t_user_id
 * @return null
 */
function kanban_ajax_button_bug_change_status($p_bug_id, $t_project_id, $t_user_id)
{
    global $g_projax;
    $t_bug_project_id = bug_get_field($p_bug_id, 'project_id');
    $t_bug_current_state = bug_get_field($p_bug_id, 'status');
    $t_current_access = access_get_project_level($t_bug_project_id);
    $t_enum_list = get_status_option_list($t_current_access, $t_bug_current_state, false, bug_get_field($p_bug_id, 'reporter_id') == auth_get_current_user_id() && ON == config_get('allow_reporter_close'), $t_bug_project_id);
    if (count($t_enum_list) > 0) {
        # resort the list into ascending order after noting the key from the first element (the default)
        $t_default_arr = each($t_enum_list);
        $t_default = $t_default_arr['key'];
        ksort($t_enum_list);
        reset($t_enum_list);
        echo "<div id=\"ajax_statuschange\"><form method=\"post\" id=\"ajax_status_form\" action=\"xmlhttprequest.php\">";
        # CSRF protection not required here - form does not result in modifications
        echo "<input type=\"hidden\" name=\"project_id\" id=\"project_id\" value=\"{$t_project_id}\" />";
        echo "<input type=\"hidden\" name=\"user_id\" id=\"user_id\" value=\"{$t_user_id}\" />";
        echo "<input type=\"hidden\" name=\"entrypoint\" id=\"entrypoint\" value=\"bug_update_status\" />";
        $t_button_text = lang_get('bug_status_to_button');
        // AJAX button options
        $options = array('url' => plugin_page('kanban_ajax_request'), 'with' => true, 'confirm' => lang_get('confirm_change_status'), 'success' => 'location.reload()', 'failure' => 'alert("Error: " ' + request . status + ')');
        echo $g_projax->submit_to_remote('ajax_status', $t_button_text, $options);
        echo " <select name=\"new_status\">";
        # space at beginning of line is important
        foreach ($t_enum_list as $key => $val) {
            echo "<option value=\"{$key}\" ";
            check_selected($key, $t_default);
            echo ">{$val}</option>";
        }
        echo '</select>';
        $t_bug_id = string_attribute($p_bug_id);
        echo "<input type=\"hidden\" name=\"id\" value=\"{$t_bug_id}\" />\n";
        echo "</form></div>\n";
    }
}
/**
 * Print the list of selected issues and the legend for the status colors.
 *
 * @param $p_bug_ids_array   An array of issue ids.
 */
function bug_group_action_print_bug_list($p_bug_ids_array)
{
    $t_legend_position = config_get('status_legend_position');
    if (STATUS_LEGEND_POSITION_TOP == $t_legend_position) {
        html_status_legend();
        echo '<br />';
    }
    echo '<div align="center">';
    echo '<table class="width75" cellspacing="1">';
    echo '<tr class="row-1">';
    echo '<td class="category" colspan="2">';
    echo lang_get('actiongroup_bugs');
    echo '</td>';
    echo '</tr>';
    $t_i = 1;
    foreach ($p_bug_ids_array as $t_bug_id) {
        $t_class = sprintf("row-%d", $t_i++ % 2 + 1);
        echo sprintf("<tr bgcolor=\"%s\"> <td>%s</td> <td>%s</td> </tr>\n", get_status_color(bug_get_field($t_bug_id, 'status')), string_get_bug_view_link($t_bug_id), string_attribute(bug_get_field($t_bug_id, 'summary')));
    }
    echo '</table>';
    echo '</form>';
    echo '</div>';
    if (STATUS_LEGEND_POSITION_BOTTOM == $t_legend_position) {
        echo '<br />';
        html_status_legend();
    }
}
function xmlhttprequest_issue_reporter_combobox()
{
    $f_bug_id = gpc_get_int('issue_id');
    access_ensure_bug_level(config_get('update_bug_threshold'), $f_bug_id);
    $t_reporter_id = bug_get_field($f_bug_id, 'reporter_id');
    $t_project_id = bug_get_field($f_bug_id, 'project_id');
    echo '<select name="reporter_id">';
    print_reporter_option_list($t_reporter_id, $t_project_id);
    echo '</select>';
}
function wiki_dokuwiki_get_page_id_for_issue($p_issue_id)
{
    $c_issue_id = db_prepare_int($p_issue_id);
    $t_project_id = bug_get_field($p_issue_id, 'project_id');
    $t_project_name = project_get_name($t_project_id);
    # create a namespace for the project to contain all project documentation.
    # create within it a namespace for issues.  This is to allow the creation of a _template.txt
    # file to act as the template for issues belonging to this project.
    return $t_project_name . ':issue:' . $c_issue_id;
}
 public function get($request)
 {
     /*
      *      Returns a Response with a representation of the note list.
      *
      *      @param $request - The Request we're responding to
      */
     $this->bug_id = BugnoteList::get_bug_id_from_url($request->url);
     # Access checking and note gathering is based on Mantis's
     # email_build_visible_bug_data().
     $project_id = bug_get_field($this->bug_id, 'project_id');
     $user_id = auth_get_current_user_id();
     $access_level = user_get_access_level($user_id, $project_id);
     if (!access_has_bug_level(VIEWER, $this->bug_id)) {
         throw new HTTPException(403, "Access denied");
     }
     $visible_notes = bugnote_get_all_visible_bugnotes($this->bug_id, $access_level, 'ASC', 0);
     $visible_note_ids = array();
     foreach ($visible_notes as $n) {
         $visible_note_ids[] = (int) $n->id;
     }
     # Apply conditions and sorts
     $sql_to_add = $this->_build_sql_from_querystring($request->query);
     $note_ids = array();
     if ($sql_to_add) {
         $mantis_bugnote_table = config_get('mantis_bugnote_table');
         $query = "SELECT n.id FROM {$mantis_bugnote_table} n {$sql_to_add};";
         $result = db_query($query);
         foreach ($result as $r) {
             if (in_array((int) $r[0], $visible_note_ids)) {
                 $note_ids[] = (int) $r[0];
             }
         }
     } else {
         $note_ids = $visible_note_ids;
     }
     $this->rsrc_data = array();
     $this->rsrc_data['results'] = array();
     foreach ($note_ids as $n) {
         $config = get_config();
         $this->rsrc_data['results'][] = Bugnote::get_url_from_mantis_id($n);
     }
     $resp = new Response();
     $resp->status = 200;
     $resp->body = $this->_repr($request);
     return $resp;
 }
    function display_bug($p_event, $p_bug_id)
    {
        require_once 'Source.ViewAPI.php';
        $t_project_id = bug_get_field($p_bug_id, 'project_id');
        $t_view_threshold = config_get('plugin_Source_view_threshold');
        if (!access_has_project_level($t_view_threshold, $t_project_id)) {
            return;
        }
        $t_changesets = $this->changesets;
        if (count($t_changesets) < 1) {
            return;
        }
        collapse_open('Source');
        ?>
<br/>
<a name="changesets"/>
<table class="width100" cellspacing="1">

<tr>
	<td class="form-title"><?php 
        collapse_icon('Source');
        echo plugin_lang_get('related_changesets', 'Source');
        ?>
</td>
</tr>
		<?php 
        Source_View_Changesets($t_changesets);
        ?>
</table>
<?php 
        collapse_closed('Source');
        ?>
<br/>
<table class="width100" cellspacing="1">

<tr>
	<td class="form-title"><?php 
        collapse_icon('Source');
        echo plugin_lang_get('related_changesets', 'Source');
        ?>
</td>
</tr>

</table>
<?php 
        collapse_end('Source');
    }
function custom_function_default_format_issue_summary($p_issue_id, $p_context = 0)
{
    switch ($p_context) {
        case SUMMARY_CAPTION:
            $t_string = bug_format_id($p_issue_id) . ': ' . string_attribute(bug_get_field($p_issue_id, 'summary'));
            break;
        case SUMMARY_FIELD:
            $t_string = bug_format_id($p_issue_id) . ': ' . string_attribute(bug_get_field($p_issue_id, 'summary'));
            break;
        case SUMMARY_EMAIL:
            $t_string = bug_format_id($p_issue_id) . ': ' . string_attribute(bug_get_field($p_issue_id, 'summary'));
            break;
        default:
            $t_string = string_attribute(bug_get_field($p_issue_id, 'summary'));
            break;
    }
    return $t_string;
}
 /**
  * Load an existing TimecardBug object from the database.
  * @param int Bug ID
  * @return object TimecardBug object
  */
 static function load($p_bug_id, $p_load_updates = true)
 {
     $t_estimate_table = plugin_table('estimate', 'Timecard');
     $t_query = "SELECT * FROM {$t_estimate_table} WHERE bug_id=" . db_param();
     $t_result = db_query_bound($t_query, array($p_bug_id));
     if (db_num_rows($t_result) < 1) {
         $t_project = TimecardProject::load(bug_get_field($p_bug_id, 'project_id'));
         return new TimecardBug($p_bug_id, $t_project->timecard, -1);
     }
     $t_row = db_fetch_array($t_result);
     $t_estimate = new TimecardBug($t_row['bug_id'], $t_row['timecard'], $t_row['estimate']);
     $t_estimate->timestamp = $t_row['timestamp'];
     $t_estimate->new = false;
     if ($p_load_updates) {
         $t_estimate->load_updates();
     }
     return $t_estimate;
 }
/**
 * Print table body
 * @param $status_cols
 */
function print_tbody($status_cols)
{
    $storyboard_db_api = new storyboard_db_api();
    $project_spec_bug_ids = $storyboard_db_api->get_bugarray_by_project(helper_get_current_project());
    $types = $storyboard_db_api->select_all_types();
    echo '<tbody>';
    foreach ($types as $type) {
        echo '<tr>';
        echo '<td class="category">' . $type[1] . '</td>';
        foreach ($status_cols as $status_col) {
            echo '<td class="story_baord">';
            foreach ($project_spec_bug_ids as $project_spec_bug_id) {
                $card = $storyboard_db_api->select_story_card($project_spec_bug_id);
                if ($card[2] == $type[0]) {
                    $bug_status = bug_get_field($project_spec_bug_id, 'status');
                    if ($bug_status == $status_col) {
                        echo '<a href="' . string_get_bug_view_url($project_spec_bug_id) . '" class="rcv_tooltip">';
                        echo '<div class="story_card">';
                        echo string_display_line(bug_format_id($project_spec_bug_id));
                        echo '<span>';
                        print_story_card_title($project_spec_bug_id);
                        print_story_card_info('summary', bug_get_field($project_spec_bug_id, 'summary'), false);
                        print_story_card_info('description', bug_get_text_field($project_spec_bug_id, 'description'), false);
                        print_story_card_info('card_risk', $card[3], true);
                        print_story_card_info('card_story_pt', $card[4], true);
                        print_story_card_info('card_story_pt_post', $card[5], true);
                        print_story_card_info('card_acc_crit', $card[6], true);
                        echo '</span>';
                        echo '</div>';
                        echo '</a><br/><br/><br/>';
                    }
                }
            }
            echo '</td>';
        }
        echo '</tr>';
    }
    echo '</tbody>';
}
Beispiel #11
0
/**
 * Get list of affected issues between a given time period
 * @param integer $p_start_time Timestamp representing start time of the period.
 * @param integer $p_end_time   Timestamp representing end time of the period.
 * @return array
 */
function timeline_get_affected_issues($p_start_time, $p_end_time)
{
    $t_query = 'SELECT DISTINCT(bug_id) from {bug_history} WHERE date_modified >= ' . db_param() . ' AND date_modified < ' . db_param();
    $t_result = db_query($t_query, array($p_start_time, $p_end_time));
    $t_current_project = helper_get_current_project();
    $t_all_issue_ids = array();
    while (($t_row = db_fetch_array($t_result)) !== false) {
        $t_all_issue_ids[] = $t_row['bug_id'];
    }
    bug_cache_array_rows($t_all_issue_ids);
    $t_issue_ids = array();
    foreach ($t_all_issue_ids as $t_issue_id) {
        if ($t_current_project != ALL_PROJECTS && $t_current_project != bug_get_field($t_issue_id, 'project_id')) {
            continue;
        }
        if (!access_has_bug_level(config_get('view_bug_threshold'), $t_issue_id)) {
            continue;
        }
        $t_issue_ids[] = $t_issue_id;
    }
    return $t_issue_ids;
}
Beispiel #12
0
                trigger_error(ERROR_GENERIC, ERROR);
            }
            /** @todo we need to issue a helper_call_custom_function( 'issue_update_validate', array( $t_bug_id, $t_bug_data, $f_bugnote_text ) ); */
            $t_form_var = "custom_field_{$f_custom_field_id}";
            $t_custom_field_value = gpc_get_custom_field($t_form_var, $t_custom_field_def['type'], null);
            custom_field_set_value($f_custom_field_id, $t_bug_id, $t_custom_field_value);
            bug_update_date($t_bug_id);
            helper_call_custom_function('issue_update_notify', array($t_bug_id));
            break;
        default:
            trigger_error(ERROR_GENERIC, ERROR);
    }
    // Bug Action Event
    event_signal('EVENT_BUG_ACTION', array($f_action, $t_bug_id));
}
form_security_purge($t_form_name);
$t_redirect_url = 'view_all_bug_page.php';
if (count($t_failed_ids) > 0) {
    html_page_top();
    echo '<div align="center"><br />';
    echo '<table class="width75">';
    foreach ($t_failed_ids as $t_id => $t_reason) {
        printf("<tr><td width=\"50%%\">%s: %s</td><td>%s</td></tr>\n", string_get_bug_view_link($t_id), bug_get_field($t_id, 'summary'), $t_reason);
    }
    echo '</table><br />';
    print_bracket_link($t_redirect_url, lang_get('proceed'));
    echo '</div>';
    html_page_bottom();
} else {
    print_header_redirect($t_redirect_url);
}
        ?>
" size="4" />
				<input type="text" name="amount" value="<?php 
        echo config_get('minimum_sponsorship_amount');
        ?>
" size="4" />
				<input type="submit" class="button" name="sponsor" value="<?php 
        echo lang_get('sponsor_verb');
        ?>
" />
			</form>
		</td>
	</tr>
<?php 
    }
    $t_total_sponsorship = bug_get_field($f_bug_id, 'sponsorship_total');
    if ($t_total_sponsorship > 0) {
        ?>
	<tr class="row-2">
		<th class="category" width="15%"><?php 
        echo lang_get('sponsors_list');
        ?>
</th>
		<td>
		<?php 
        echo sprintf(lang_get('total_sponsorship_amount'), sponsorship_format_amount($t_total_sponsorship));
        if (access_has_bug_level(config_get('view_sponsorship_details_threshold'), $f_bug_id)) {
            echo '<br /><br />';
            $i = 0;
            foreach ($t_sponsorship_ids as $id) {
                $t_sponsorship = sponsorship_get($id);
Beispiel #14
0
/**
 * Print list of bugs opened from the longest time
 * @return void
 */
function summary_print_by_age()
{
    $t_project_id = helper_get_current_project();
    $t_resolved = config_get('bug_resolved_status_threshold');
    $t_specific_where = helper_project_specific_where($t_project_id);
    if (' 1<>1' == $t_specific_where) {
        return;
    }
    $t_query = 'SELECT * FROM {bug}
				WHERE status < ' . db_param() . '
				AND ' . $t_specific_where . '
				ORDER BY date_submitted ASC, priority DESC';
    $t_result = db_query($t_query, array($t_resolved));
    $t_count = 0;
    $t_private_bug_threshold = config_get('private_bug_threshold');
    while ($t_row = db_fetch_array($t_result)) {
        # as we select all from bug_table, inject into the cache.
        bug_cache_database_result($t_row);
        # Skip private bugs unless user has proper permissions
        if (VS_PRIVATE == bug_get_field($t_row['id'], 'view_state') && false == access_has_bug_level($t_private_bug_threshold, $t_row['id'])) {
            continue;
        }
        if ($t_count++ == 10) {
            break;
        }
        $t_bugid = string_get_bug_view_link($t_row['id']);
        $t_summary = string_display_line($t_row['summary']);
        $t_days_open = intval((time() - $t_row['date_submitted']) / SECONDS_PER_DAY);
        echo '<tr>' . "\n";
        echo '<td class="small">' . $t_bugid . ' - ' . $t_summary . '</td><td class="right">' . $t_days_open . '</td>' . "\n";
        echo '</tr>' . "\n";
    }
}
Beispiel #15
0
function html_buttons_view_bug_page($p_bug_id)
{
    $t_resolved = config_get('bug_resolved_status_threshold');
    $t_status = bug_get_field($p_bug_id, 'status');
    $t_readonly = bug_is_readonly($p_bug_id);
    print '<table><tr class="vcenter">';
    if (!$t_readonly) {
        # UPDATE button
        echo '<td class="center">';
        html_button_bug_update($p_bug_id);
        echo '</td>';
        # ASSIGN button
        echo '<td class="center">';
        html_button_bug_assign_to($p_bug_id);
        echo '</td>';
        # Change State button
        echo '<td class="center">';
        html_button_bug_change_status($p_bug_id);
        echo '</td>';
    }
    # MONITOR/UNMONITOR button
    echo '<td class="center">';
    if (!current_user_is_anonymous()) {
        if (user_is_monitoring_bug(auth_get_current_user_id(), $p_bug_id)) {
            html_button_bug_unmonitor($p_bug_id);
        } else {
            html_button_bug_monitor($p_bug_id);
        }
    }
    echo '</td>';
    if (!$t_readonly) {
        # CREATE CHILD button
        echo '<td class="center">';
        html_button_bug_create_child($p_bug_id);
        echo '</td>';
    }
    if ($t_resolved <= $t_status) {
        # resolved is not the same as readonly
        print '<td class="center">';
        # REOPEN button
        html_button_bug_reopen($p_bug_id);
        print '</td>';
    }
    if (!$t_readonly) {
        # MOVE button
        echo '<td class="center">';
        html_button_bug_move($p_bug_id);
        echo '</td>';
        # DELETE button
        echo '<td class="center">';
        html_button_bug_delete($p_bug_id);
        echo '</td>';
    }
    helper_call_custom_function('print_bug_view_page_custom_buttons', array($p_bug_id));
    echo '</tr></table>';
}
 /**
  * Update custom plugin fields
  *
  * @param $event
  * @param BugData $bug
  */
 function bugUpdateData($event, BugData $bug)
 {
     require_once SPECMANAGEMENT_CORE_URI . 'specmanagement_database_api.php';
     $specmanagement_database_api = new specmanagement_database_api();
     $version_id = null;
     $type_id = null;
     $p_version_id = null;
     $bug_id = $bug->id;
     $project_id = helper_get_current_project();
     $ptime = gpc_get_string('ptime', $specmanagement_database_api->get_ptime_row($bug_id)[2]);
     $type = gpc_get_string('types', '');
     if ($bug_id != null) {
         $target_version = bug_get_field($bug_id, 'target_version');
         if (!is_null($target_version)) {
             $version_id = version_get_id($target_version);
             $version_obj = $specmanagement_database_api->get_plugin_version_row_by_version_id($version_id);
             $p_version_id = $version_obj[0];
             $type_id = $specmanagement_database_api->get_type_id($type);
         }
     }
     $work_package = preg_replace('/\\/\\/+/', '/', gpc_get_string('work_package', ''));
     switch ($event) {
         case 'EVENT_REPORT_BUG':
             $specmanagement_database_api->insert_version_row($project_id, $version_id, $type_id);
             $specmanagement_database_api->insert_source_row($bug_id, $p_version_id, $work_package);
             $specmanagement_database_api->insert_ptime_row($bug_id, $ptime);
             break;
         case 'EVENT_UPDATE_BUG':
             if (strlen($work_package) == 0) {
                 $work_package = $specmanagement_database_api->get_workpackage_by_bug_id($bug_id);
             }
             $specmanagement_database_api->update_version_row($project_id, $version_id, $type_id);
             $specmanagement_database_api->update_source_row($bug_id, $p_version_id, $work_package);
             $specmanagement_database_api->update_ptime_row($bug_id, $ptime);
             break;
     }
 }
<input type="hidden" name="bug_id" value="<?php echo $f_bug_id ?>" />
<div class="width75 form-container">
<table cellspacing="1">
<tr>
	<td class="form-title" colspan="2">
		<?php echo lang_get( 'bug_reminder' ) ?>
	</td>
</tr>
<tr>
	<th class="category">
		<?php echo lang_get( 'to' ) ?>
	</th>
	<td>
		<select name="to[]" multiple="multiple" size="12" class="width20">
			<?php
			$t_project_id = bug_get_field( $f_bug_id, 'project_id' );
			$t_access_level = config_get( 'reminder_receive_threshold' );
			if( $t_bug->view_state === VS_PRIVATE ) {
				$t_private_bug_threshold = config_get( 'private_bug_threshold' );
				if( $t_private_bug_threshold > $t_access_level ) {
					$t_access_level = $t_private_bug_threshold;
				}
			}
			$t_selected_user_id = 0;
			print_user_option_list( $t_selected_user_id, $t_project_id, $t_access_level );
			?>
		</select>
	</td>
</tr>
<tr>
	<th class="category">
Beispiel #18
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;
}
Beispiel #19
0
/**
 * log the changes
 * events should be logged *after* the modification
 * @param int $p_bug_id
 * @param string $p_field_name
 * @param string $p_old_value
 * @return null
 */
function history_log_event($p_bug_id, $p_field_name, $p_old_value)
{
    history_log_event_direct($p_bug_id, $p_field_name, $p_old_value, bug_get_field($p_bug_id, $p_field_name));
}
Beispiel #20
0
/**
 * Gets the custom fields array for the given bug. Array keys are custom field names.
 * Array is sorted by custom field sequence number; Array items are arrays with the next keys:
 * 'type', 'value', 'access_level_r'
 * @param integer $p_bug_id A bug identifier.
 * @return array
 * @access public
 */
function custom_field_get_all_linked_fields($p_bug_id)
{
    global $g_cached_custom_field_lists;
    if (!is_array($g_cached_custom_field_lists)) {
        $g_cached_custom_field_lists = array();
    }
    # is the list in cache ?
    if (!array_key_exists($p_bug_id, $g_cached_custom_field_lists)) {
        $c_project_id = (int) bug_get_field($p_bug_id, 'project_id');
        $t_query = 'SELECT f.name, f.type, f.access_level_r, f.default_value, f.type, s.value
			FROM {custom_field_project} p
				INNER JOIN {custom_field} f ON f.id = p.field_id
				LEFT JOIN {custom_field_string} s
					ON s.field_id = p.field_id AND s.bug_id = ' . db_param() . '
			WHERE p.project_id = ' . db_param() . '
			ORDER BY p.sequence ASC, f.name ASC';
        $t_result = db_query($t_query, array($p_bug_id, $c_project_id));
        $t_custom_fields = array();
        while ($t_row = db_fetch_array($t_result)) {
            if (is_null($t_row['value'])) {
                $t_value = $t_row['default_value'];
            } else {
                $t_value = custom_field_database_to_value($t_row['value'], $t_row['type']);
            }
            $t_custom_fields[$t_row['name']] = array('type' => $t_row['type'], 'value' => $t_value, 'access_level_r' => $t_row['access_level_r']);
        }
        $g_cached_custom_field_lists[$p_bug_id] = $t_custom_fields;
    }
    return $g_cached_custom_field_lists[$p_bug_id];
}
/**
 * return false if there are child bugs not resolved/closed
 * N.B. we don't check if the parent bug is read-only. This is because the answer of this function is indepedent from
 * the state of the parent bug itself.
 * @param integer $p_bug_id A bug identifier.
 * @return boolean
 */
function relationship_can_resolve_bug($p_bug_id)
{
    # retrieve all the relationships in which the bug is the source bug
    $t_relationship = relationship_get_all_src($p_bug_id);
    $t_relationship_count = count($t_relationship);
    if ($t_relationship_count == 0) {
        return true;
    }
    for ($i = 0; $i < $t_relationship_count; $i++) {
        # verify if each bug in relation BUG_DEPENDANT is already marked as resolved
        if ($t_relationship[$i]->type == BUG_DEPENDANT) {
            $t_dest_bug_id = $t_relationship[$i]->dest_bug_id;
            $t_status = bug_get_field($t_dest_bug_id, 'status');
            if ($t_status < config_get('bug_resolved_status_threshold')) {
                # the bug is NOT marked as resolved/closed
                return false;
            }
        }
    }
    return true;
}
Beispiel #22
0
/**
 * Returns the attachment contents
 *
 * @param int $p_file_id
 * @param string $p_type The file type, bug or doc
 * @param int $p_user_id
 * @return string|soap_fault the string contents, or a soap_fault
 */
function mci_file_get($p_file_id, $p_type, $p_user_id)
{
    # we handle the case where the file is attached to a bug
    # or attached to a project as a project doc.
    $query = '';
    switch ($p_type) {
        case 'bug':
            $t_bug_file_table = db_get_table('bug_file');
            $query = "SELECT *\n\t\t\t\tFROM {$t_bug_file_table}\n\t\t\t\tWHERE id='{$p_file_id}'";
            break;
        case 'doc':
            $t_project_file_table = db_get_table('project_file');
            $query = "SELECT *\n\t\t\t\tFROM {$t_project_file_table}\n\t\t\t\tWHERE id='{$p_file_id}'";
            break;
        default:
            return new soap_fault('Server', '', 'Invalid file type ' . $p_type . ' .');
    }
    $result = db_query($query);
    if ($result->EOF) {
        return new soap_fault('Client', '', 'Unable to find an attachment with type ' . $p_type . ' and id ' . $p_file_id . ' .');
    }
    $row = db_fetch_array($result);
    if ($p_type == 'doc') {
        $t_project_id = $row['project_id'];
    } else {
        if ($p_type == 'bug') {
            $t_bug_id = $row['bug_id'];
            $t_project_id = bug_get_field($t_bug_id, 'project_id');
        }
    }
    $t_diskfile = file_normalize_attachment_path($row['diskfile'], $t_project_id);
    $t_content = $row['content'];
    # Check access rights
    switch ($p_type) {
        case 'bug':
            if (!mci_file_can_download_bug_attachments($t_bug_id, $p_user_id)) {
                return mci_soap_fault_access_denied($p_user_id);
            }
            break;
        case 'doc':
            # Check if project documentation feature is enabled.
            if (OFF == config_get('enable_project_documentation')) {
                return mci_soap_fault_access_denied($p_user_id);
            }
            if (!access_has_project_level(config_get('view_proj_doc_threshold'), $t_project_id, $p_user_id)) {
                return mci_soap_fault_access_denied($p_user_id);
            }
            break;
    }
    # dump file content to the connection.
    switch (config_get('file_upload_method')) {
        case DISK:
            if (file_exists($t_diskfile)) {
                return mci_file_read_local($t_diskfile);
            } else {
                return new soap_fault('Client', '', 'Unable to find an attachment with type ' . $p_type . ' and id ' . $p_file_id . ' .');
            }
        case FTP:
            if (file_exists($t_diskfile)) {
                return mci_file_read_local($t_diskfile);
            } else {
                $ftp = file_ftp_connect();
                file_ftp_get($ftp, $t_diskfile, $t_diskfile);
                file_ftp_disconnect($ftp);
                return mci_file_read_local($t_diskfile);
            }
        default:
            return $t_content;
    }
}
/**
 * Print the list of selected issues and the legend for the status colors.
 *
 * @param array $p_bug_ids_array An array of issue ids.
 * @return void
 */
function bug_group_action_print_bug_list(array $p_bug_ids_array)
{
    $t_legend_position = config_get('status_legend_position');
    if (STATUS_LEGEND_POSITION_TOP == $t_legend_position) {
        html_status_legend();
        echo '<br />';
    }
    echo '<div id="action-group-issues-div">';
    echo '<table>';
    echo '<tr class="row-1">';
    echo '<th class="category" colspan="2">';
    echo lang_get('actiongroup_bugs');
    echo '</th>';
    echo '</tr>';
    $t_i = 1;
    foreach ($p_bug_ids_array as $t_bug_id) {
        # choose color based on status
        $t_status_label = html_get_status_css_class(bug_get_field($t_bug_id, 'status'), auth_get_current_user_id(), bug_get_field($t_bug_id, 'project_id'));
        echo sprintf("<tr class=\"%s\"> <td>%s</td> <td>%s</td> </tr>\n", $t_status_label, string_get_bug_view_link($t_bug_id), string_attribute(bug_get_field($t_bug_id, 'summary')));
    }
    echo '</table>';
    echo '</div>';
    if (STATUS_LEGEND_POSITION_BOTTOM == $t_legend_position) {
        echo '<br />';
        html_status_legend();
    }
}
Beispiel #24
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;
}
Beispiel #25
0
            $t_form_var = 'custom_field_' . $f_custom_field_id;
            $t_custom_field_value = gpc_get_custom_field($t_form_var, $t_custom_field_def['type'], null);
            custom_field_set_value($f_custom_field_id, $t_bug_id, $t_custom_field_value);
            bug_update_date($t_bug_id);
            email_bug_updated($t_bug_id);
            helper_call_custom_function('issue_update_notify', array($t_bug_id));
            break;
        default:
            trigger_error(ERROR_GENERIC, ERROR);
    }
    # Bug Action Event
    event_signal('EVENT_BUG_ACTION', array($f_action, $t_bug_id));
}
form_security_purge($t_form_name);
$t_redirect_url = 'view_all_bug_page.php';
if (count($t_failed_ids) > 0) {
    html_page_top();
    echo '<div><br />';
    echo '<table class="width75">';
    $t_separator = lang_get('word_separator');
    foreach ($t_failed_ids as $t_id => $t_reason) {
        $t_label = sprintf(lang_get('label'), string_get_bug_view_link($t_id)) . $t_separator;
        printf("<tr><td width=\"50%%\">%s%s</td><td>%s</td></tr>\n", $t_label, bug_get_field($t_id, 'summary'), $t_reason);
    }
    echo '</table><br />';
    print_bracket_link($t_redirect_url, lang_get('proceed'));
    echo '</div>';
    html_page_bottom();
} else {
    print_header_redirect($t_redirect_url);
}
Beispiel #26
0
/**
 * Copies all attachments from the source bug to the destination bug
 *
 * Does not perform history logging and does not perform access checks.
 *
 * @param integer $p_source_bug_id Source Bug.
 * @param integer $p_dest_bug_id   Destination Bug.
 * @return void
 */
function file_copy_attachments($p_source_bug_id, $p_dest_bug_id)
{
    $t_query = 'SELECT * FROM {bug_file} WHERE bug_id = ' . db_param();
    $t_result = db_query($t_query, array($p_source_bug_id));
    $t_count = db_num_rows($t_result);
    $t_project_id = bug_get_field($p_source_bug_id, 'project_id');
    for ($i = 0; $i < $t_count; $i++) {
        $t_bug_file = db_fetch_array($t_result);
        # prepare the new diskfile name and then copy the file
        $t_source_file = $t_bug_file['folder'] . $t_bug_file['diskfile'];
        if (config_get('file_upload_method') == DISK) {
            $t_source_file = file_normalize_attachment_path($t_source_file, $t_project_id);
            $t_file_path = dirname($t_source_file) . DIRECTORY_SEPARATOR;
        } else {
            $t_file_path = $t_bug_file['folder'];
        }
        $t_new_diskfile_name = file_generate_unique_name($t_file_path);
        $t_new_diskfile_location = $t_file_path . $t_new_diskfile_name;
        $t_new_file_name = file_get_display_name($t_bug_file['filename']);
        if (config_get('file_upload_method') == DISK) {
            # Skip copy operation if file does not exist (i.e. target bug will have missing attachment)
            # @todo maybe we should trigger an error instead in this case ?
            if (file_exists($t_source_file)) {
                copy($t_source_file, $t_new_diskfile_location);
                chmod($t_new_diskfile_location, config_get('attachments_file_permissions'));
            }
        }
        $t_query = 'INSERT INTO {bug_file} (
				bug_id, title, description, diskfile, filename, folder,
				filesize, file_type, date_added, user_id, content
			)
			VALUES ( ' . db_param() . ', ' . db_param() . ', ' . db_param() . ', ' . db_param() . ', ' . db_param() . ', ' . db_param() . ', ' . db_param() . ', ' . db_param() . ', ' . db_param() . ', ' . db_param() . ', ' . db_param() . ')';
        db_query($t_query, array($p_dest_bug_id, $t_bug_file['title'], $t_bug_file['description'], $t_new_diskfile_name, $t_new_file_name, $t_file_path, $t_bug_file['filesize'], $t_bug_file['file_type'], $t_bug_file['date_added'], $t_bug_file['user_id'], $t_bug_file['content']));
    }
}
 /**
  * Given a bug ID, apply the appropriate branch mapping algorithm
  * to find and return the appropriate version ID.
  * @param int Bug ID
  * @return int Version ID
  */
 function apply($p_bug_id)
 {
     static $s_versions = array();
     static $s_versions_sorted = array();
     # if it's explicit, return the version_id before doing anything else
     if ($this->type == SOURCE_EXPLICIT) {
         return $this->version;
     }
     # cache project/version sets, and the appropriate sorting
     $t_project_id = bug_get_field($p_bug_id, 'project_id');
     if (!isset($s_versions[$t_project_id])) {
         $s_versions[$t_project_id] = version_get_all_rows($t_project_id, false);
     }
     # handle empty version sets
     if (count($s_versions[$t_project_id]) < 1) {
         return '';
     }
     # cache the version set based on the current algorithm
     if (!isset($s_versions_sorted[$t_project_id][$this->type])) {
         $s_versions_sorted[$t_project_id][$this->type] = $s_versions[$t_project_id];
         switch ($this->type) {
             case SOURCE_NEAR:
                 usort($s_versions_sorted[$t_project_id][$this->type], array('SourceMapping', 'cmp_near'));
                 break;
             case SOURCE_FAR:
                 usort($s_versions_sorted[$t_project_id][$this->type], array('SourceMapping', 'cmp_far'));
                 break;
             case SOURCE_FIRST:
                 usort($s_versions_sorted[$t_project_id][$this->type], array('SourceMapping', 'cmp_first'));
                 break;
             case SOURCE_LAST:
                 usort($s_versions_sorted[$t_project_id][$this->type], array('SourceMapping', 'cmp_last'));
                 break;
         }
     }
     # pull the appropriate versions set from the cache
     $t_versions = $s_versions_sorted[$t_project_id][$this->type];
     # handle non-regex mappings
     if (is_blank($this->regex)) {
         return $t_versions[0]['version'];
     }
     # handle regex mappings
     foreach ($t_versions as $t_version) {
         if (preg_match($this->regex, $t_version['version'])) {
             return $t_version['version'];
         }
     }
     # no version matches the regex
     return '';
 }
Beispiel #28
0
            # bug_close updates the status and bugnote and sends message
            bug_close($f_bug_id, $f_bugnote_text, $f_private, $f_time_tracking);
            $t_notify = false;
            $t_bug_note_set = true;
            break;
        case config_get('bug_reopen_status'):
            if ($t_old_bug_status >= $t_resolved) {
                bug_set_field($f_bug_id, 'handler_id', $t_bug_data->handler_id);
                # fix: update handler_id before calling bug_reopen
                # bug_reopen updates the status and bugnote and sends message
                bug_reopen($f_bug_id, $f_bugnote_text, $f_time_tracking, $f_private);
                $t_notify = false;
                $t_bug_note_set = true;
                // update bug data with fields that may be updated inside bug_resolve(), otherwise changes will be overwritten
                // in bug_update() call below.
                $t_bug_data->status = bug_get_field($f_bug_id, 'status');
                $t_bug_data->resolution = bug_get_field($f_bug_id, 'resolution');
                break;
            }
            # else fall through to default
    }
}
# Add a bugnote if there is one
if (!$t_bug_note_set) {
    bugnote_add($f_bug_id, $f_bugnote_text, $f_time_tracking, $f_private, 0, '', NULL, FALSE);
}
# Update the bug entry, notify if we haven't done so already
bug_update($f_bug_id, $t_bug_data, true, false == $t_notify);
form_security_purge('bug_update');
helper_call_custom_function('issue_update_notify', array($f_bug_id));
print_successful_redirect_to_bug($f_bug_id);
Beispiel #29
0
/**
 * Check the current user's access against the given value and return true
 * if the user's access is equal to or higher, false otherwise.
 * This function looks up the bugnote's bug and performs an access check
 * against that bug
 * @param int $p_access_level integer representing access level
 * @param int $p_bugnote_id integer representing bugnote id to check access against
 * @param int|null $p_user_id integer representing user id, defaults to null to use current user
 * @return bool whether user has access level specified
 * @access public
 */
function access_has_bugnote_level($p_access_level, $p_bugnote_id, $p_user_id = null)
{
    if (null === $p_user_id) {
        $p_user_id = auth_get_current_user_id();
    }
    $t_bug_id = bugnote_get_field($p_bugnote_id, 'bug_id');
    $t_project_id = bug_get_field($t_bug_id, 'project_id');
    # If the bug is private and the user is not the reporter, then the
    # the user must also have higher access than private_bug_threshold
    if (bugnote_get_field($p_bugnote_id, 'view_state') == VS_PRIVATE && !bugnote_is_user_reporter($p_bugnote_id, $p_user_id)) {
        $t_private_bugnote_threshold = config_get('private_bugnote_threshold', null, $p_user_id, $t_project_id);
        $p_access_level = max($p_access_level, $t_private_bugnote_threshold);
    }
    return access_has_bug_level($p_access_level, $t_bug_id, $p_user_id);
}
Beispiel #30
0
/**
 * Build the bugnotes array for the given bug_id filtered by specified $p_user_access_level.
 * Bugnotes are sorted by date_submitted according to 'bugnote_order' configuration setting.
 * Return BugnoteData class object with raw values from the tables except the field
 * last_modified - it is UNIX_TIMESTAMP.
 * @param int $p_bug_id bug id
 * @param int $p_user_bugnote_order sort order
 * @param int $p_user_bugnote_limit number of bugnotes to display to user
 * @param int $p_user_id user id
 * @return array array of bugnotes
 * @access public
 */
function bugnote_get_all_visible_bugnotes($p_bug_id, $p_user_bugnote_order, $p_user_bugnote_limit, $p_user_id = null)
{
    if ($p_user_id === null) {
        $t_user_id = auth_get_current_user_id();
    } else {
        $t_user_id = $p_user_id;
    }
    $t_project_id = bug_get_field($p_bug_id, 'project_id');
    $t_user_access_level = user_get_access_level($t_user_id, $t_project_id);
    $t_all_bugnotes = bugnote_get_all_bugnotes($p_bug_id);
    $t_private_bugnote_threshold = config_get('private_bugnote_threshold');
    $t_private_bugnote_visible = access_compare_level($t_user_access_level, config_get('private_bugnote_threshold'));
    $t_time_tracking_visible = access_compare_level($t_user_access_level, config_get('time_tracking_view_threshold'));
    $t_bugnotes = array();
    $t_bugnote_count = count($t_all_bugnotes);
    $t_bugnote_limit = $p_user_bugnote_limit > 0 ? $p_user_bugnote_limit : $t_bugnote_count;
    $t_bugnotes_found = 0;
    # build a list of the latest bugnotes that the user can see
    for ($i = 0; $i < $t_bugnote_count && $t_bugnotes_found < $t_bugnote_limit; $i++) {
        $t_bugnote = array_pop($t_all_bugnotes);
        if ($t_private_bugnote_visible || $t_bugnote->reporter_id == $t_user_id || VS_PUBLIC == $t_bugnote->view_state) {
            # If the access level specified is not enough to see time tracking information
            # then reset it to 0.
            if (!$t_time_tracking_visible) {
                $t_bugnote->time_tracking = 0;
            }
            $t_bugnotes[$t_bugnotes_found++] = $t_bugnote;
        }
    }
    # reverse the list for users with ascending view preferences
    if ('ASC' == $p_user_bugnote_order) {
        $t_bugnotes = array_reverse($t_bugnotes);
    }
    return $t_bugnotes;
}