/**
  * Whether to skip this event after access checks
  * @return boolean
  */
 function skip()
 {
     if (!access_has_bug_level(config_get('view_handler_threshold'), $this->issue_id)) {
         return true;
     }
     return false;
 }
Example #2
0
function mci_file_can_download_bug_attachments($p_bug_id, $p_user_id)
{
    $t_can_download = access_has_bug_level(config_get('download_attachments_threshold'), $p_bug_id);
    if ($t_can_download) {
        return true;
    }
    $t_reported_by_me = bug_is_user_reporter($p_bug_id, $p_user_id);
    return $t_reported_by_me && config_get('allow_download_own_attachments');
}
/**
 * Validates the action on the specified bug id.
 *
 * @param $p_bug_id Bug ID
 * @return string|null On failure: the reason why the action could not be validated. On success: null.
 */
function action_update_product_build_validate($p_bug_id)
{
    $t_bug_id = (int) $p_bug_id;
    if (bug_is_readonly($t_bug_id)) {
        return lang_get('actiongroup_error_issue_is_readonly');
    }
    if (!access_has_bug_level(config_get('update_bug_threshold'), $t_bug_id)) {
        return lang_get('access_denied');
    }
    return null;
}
/**
 * Delete an issue attachment given its id.
 *
 * @param string $p_username  The name of the user trying to add an attachment to an issue.
 * @param string $p_password  The password of the user.
 * @param integer $p_issue_attachment_id  The id of the attachment to be deleted.
 * @return true: success, false: failure
 */
function mc_issue_attachment_delete( $p_username, $p_password, $p_issue_attachment_id ) {
	$t_user_id = mci_check_login( $p_username, $p_password );
	if( $t_user_id === false ) {
		return mci_soap_fault_login_failed();
	}
	$t_bug_id = file_get_field( $p_issue_attachment_id, 'bug_id' );
	if( !access_has_bug_level( config_get( 'update_bug_threshold' ), $t_bug_id, $t_user_id ) ) {
		return mci_soap_fault_access_denied( $t_user_id );
	}
	return file_delete( $p_issue_attachment_id, 'bug' );
}
/**
 * Validates the action on the specified bug id.
 *
 * @return string|null On failure: the reason why the action could not be validated. On success: null.
 */
function action_update_severity_validate($p_bug_id)
{
    $f_severity = gpc_get_string('severity');
    $t_update_severity_threshold = config_get('update_bug_threshold');
    $t_bug_id = $p_bug_id;
    if (bug_is_readonly($t_bug_id)) {
        return lang_get('actiongroup_error_issue_is_readonly');
    }
    if (!access_has_bug_level($t_update_severity_threshold, $t_bug_id)) {
        return lang_get('access_denied');
    }
    return null;
}
/**
 * Validates the action on the specified bug id.
 *
 * @param $p_bug_id Bug ID
 * @return true|array  Action can be applied., bug_id => reason for failure
 */
function action_update_product_build_validate($p_bug_id)
{
    $t_bug_id = (int) $p_bug_id;
    if (bug_is_readonly($t_bug_id)) {
        $t_failed_validation_ids = array();
        $t_failed_validation_ids[$t_bug_id] = lang_get('actiongroup_error_issue_is_readonly');
        return $t_failed_validation_ids;
    }
    if (!access_has_bug_level(config_get('update_bug_threshold'), $t_bug_id)) {
        $t_failed_validation_ids = array();
        $t_failed_validation_ids[$t_bug_id] = lang_get('access_denied');
        return $t_failed_validation_ids;
    }
    return true;
}
/**
 * Validates the action on the specified bug id.
 *
 * @returns true    Action can be applied.
 * @returns array( bug_id => reason for failure )
 */
function action_update_severity_validate($p_bug_id)
{
    $f_severity = gpc_get_string('severity');
    $t_failed_validation_ids = array();
    $t_update_severity_threshold = config_get('update_bug_threshold');
    $t_bug_id = $p_bug_id;
    if (bug_is_readonly($t_bug_id)) {
        $t_failed_validation_ids[$t_bug_id] = lang_get('actiongroup_error_issue_is_readonly');
        return $t_failed_validation_ids;
    }
    if (!access_has_bug_level($t_update_severity_threshold, $t_bug_id)) {
        $t_failed_validation_ids[$t_bug_id] = lang_get('access_denied');
        return $t_failed_validation_ids;
    }
    return true;
}
/**
 * Validates the Attach Tags group action.
 * Gets called for every bug, but performs the real tag validation only
 * the first time.  Any invalid tags will be skipped, as there is no simple
 * or clean method of presenting these errors to the user.
 * @param integer Bug ID
 * @return boolean True
 */
function action_attach_tags_validate($p_bug_id)
{
    global $g_action_attach_tags_valid;
    if (!isset($g_action_attach_tags_valid)) {
        $f_tag_string = gpc_get_string('tag_string');
        $f_tag_select = gpc_get_string('tag_select');
        global $g_action_attach_tags_attach, $g_action_attach_tags_create, $g_action_attach_tags_failed;
        $g_action_attach_tags_attach = array();
        $g_action_attach_tags_create = array();
        $g_action_attach_tags_failed = array();
        $t_tags = tag_parse_string($f_tag_string);
        $t_can_attach = access_has_bug_level(config_get('tag_attach_threshold'), $p_bug_id);
        $t_can_create = access_has_global_level(config_get('tag_create_threshold'));
        foreach ($t_tags as $t_tag_row) {
            if (-1 == $t_tag_row['id']) {
                if ($t_can_create && $t_can_attach) {
                    $g_action_attach_tags_create[] = $t_tag_row;
                } else {
                    $g_action_attach_tags_failed[] = $t_tag_row;
                }
            } else {
                if (-2 == $t_tag_row['id']) {
                    $g_action_attach_tags_failed[] = $t_tag_row;
                } else {
                    if ($t_can_attach) {
                        $g_action_attach_tags_attach[] = $t_tag_row;
                    } else {
                        $g_action_attach_tags_failed[] = $t_tag_row;
                    }
                }
            }
        }
        if (0 < $f_tag_select && tag_exists($f_tag_select)) {
            if ($t_can_attach) {
                $g_action_attach_tags_attach[] = tag_get($f_tag_select);
            } else {
                $g_action_attach_tags_failed[] = tag_get($f_tag_select);
            }
        }
    }
    global $g_action_attach_tags_attach, $g_action_attach_tags_create, $g_action_attach_tags_failed;
    return true;
}
/**
 * Delete an issue attachment given its id.
 *
 * @param string $p_username  The name of the user trying to add an attachment to an issue.
 * @param string $p_password  The password of the user.
 * @param integer $p_issue_attachment_id  The id of the attachment to be deleted.
 * @return true: success, false: failure
 */
function mc_issue_attachment_delete($p_username, $p_password, $p_issue_attachment_id)
{
    $t_user_id = mci_check_login($p_username, $p_password);
    if ($t_user_id === false) {
        return mci_soap_fault_login_failed();
    }
    $t_bug_id = file_get_field($p_issue_attachment_id, 'bug_id');
    # Perform access control checks
    $t_attachment_owner = file_get_field($p_issue_attachment_id, 'user_id');
    $t_current_user_is_attachment_owner = $t_attachment_owner == $t_user_id;
    # Factor in allow_delete_own_attachments=ON|OFF
    if (!$t_current_user_is_attachment_owner || $t_current_user_is_attachment_owner && !config_get('allow_delete_own_attachments')) {
        # Check access against delete_attachments_threshold
        if (!access_has_bug_level(config_get('delete_attachments_threshold'), $t_bug_id, $t_user_id)) {
            return mci_soap_fault_access_denied($t_user_id);
        }
    }
    return file_delete($p_issue_attachment_id, 'bug');
}
Example #10
0
 function worklogmenu()
 {
     if (ON == plugin_config_get('promote_text')) {
         $bugid = gpc_get_int('id');
         if (access_has_bug_level(plugin_config_get('promote_threshold'), $bugid)) {
             $t_bug_p = bug_get($bugid, true);
             if (OFF == plugin_config_get('project_text')) {
                 $proj_id = 0;
             } else {
                 $proj_id = $t_bug_p->project_id;
             }
             $subject = urlencode($t_bug_p->description);
             $subject .= " ";
             $subject .= urlencode($t_bug_p->additional_information);
             $content = category_full_name($t_bug_p->category_id);
             $content .= " -> ";
             $content .= urlencode($t_bug_p->summary);
             if (ON == plugin_config_get('worklog_view_check')) {
                 $import_page = 'worklog_add_page2.php';
             } else {
                 $import_page = 'worklog_add.php';
             }
             $import_page .= '&log_type=0&';
             $import_page .= '&ref_log_ids=';
             $import_page .= '&ref_issue_ids=';
             $import_page .= '&log_begin=';
             $import_page .= '&log_end=';
             $import_page .= '&content=';
             $import_page .= $content;
             $import_page .= '&subject=';
             $import_page .= $subject;
             $import_page .= '&project_id=';
             $import_page .= $proj_id;
             if (ON == plugin_config_get('worklog_view_check')) {
                 return array(plugin_lang_get('import_worklog') => plugin_page($import_page) . '" target=_new>');
             } else {
                 return array(plugin_lang_get('import_worklog') => plugin_page($import_page));
             }
         }
     }
 }
Example #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;
}
Example #12
0
 function faqmenu()
 {
     if (ON == plugin_config_get('promote_text')) {
         $bugid = gpc_get_int('id');
         if (access_has_bug_level(plugin_config_get('promote_threshold'), $bugid)) {
             $t_bug_p = bug_get($bugid, true);
             if (OFF == plugin_config_get('project_text')) {
                 $proj_id = 0;
             } else {
                 $proj_id = $t_bug_p->project_id;
             }
             $answer = urlencode($t_bug_p->description);
             $answer .= " ";
             $answer .= urlencode($t_bug_p->additional_information);
             $question = category_full_name($t_bug_p->category_id);
             $question .= " -> ";
             $question .= urlencode($t_bug_p->summary);
             if (ON == plugin_config_get('faq_view_check')) {
                 $import_page = 'faq_add_page2.php';
             } else {
                 $import_page = 'faq_add.php';
             }
             $import_page .= '&question=';
             $import_page .= $question;
             $import_page .= '&answere=';
             $import_page .= $answer;
             $import_page .= '&project_id=';
             $import_page .= $proj_id;
             if (ON == plugin_config_get('faq_view_check')) {
                 return array(plugin_lang_get('import_faq') => plugin_page($import_page) . '" target=_new>');
             } else {
                 return array(plugin_lang_get('import_faq') => plugin_page($import_page));
             }
         }
     }
 }
Example #13
0
function print_column_handler_id($p_row, $p_columns_target = COLUMNS_TARGET_VIEW_PAGE)
{
    echo '<td class="center">';
    if ($p_row['handler_id'] > 0 && access_has_bug_level(config_get('view_handler_threshold'), $p_row['id'])) {
        echo prepare_user_name($p_row['handler_id']);
    }
    echo '</td>';
}
Example #14
0
         $t_failed_ids[$t_bug_id] = lang_get('bug_actiongroup_access');
     }
     break;
 case 'VIEW_STATUS':
     if (access_has_bug_level(config_get('change_view_status_threshold'), $t_bug_id)) {
         $f_view_status = gpc_get_int('view_status');
         # @todo we need to issue a helper_call_custom_function( 'issue_update_validate', array( $t_bug_id, $t_bug_data, $f_bugnote_text ) );
         bug_set_field($t_bug_id, 'view_state', $f_view_status);
         email_bug_updated($t_bug_id);
         helper_call_custom_function('issue_update_notify', array($t_bug_id));
     } else {
         $t_failed_ids[$t_bug_id] = lang_get('bug_actiongroup_access');
     }
     break;
 case 'SET_STICKY':
     if (access_has_bug_level(config_get('set_bug_sticky_threshold'), $t_bug_id)) {
         $f_sticky = bug_get_field($t_bug_id, 'sticky');
         # The new value is the inverted old value
         # @todo we need to issue a helper_call_custom_function( 'issue_update_validate', array( $t_bug_id, $t_bug_data, $f_bugnote_text ) );
         bug_set_field($t_bug_id, 'sticky', intval(!$f_sticky));
         helper_call_custom_function('issue_update_notify', array($t_bug_id));
     } else {
         $t_failed_ids[$t_bug_id] = lang_get('bug_actiongroup_access');
     }
     break;
 case 'CUSTOM':
     if (0 === $f_custom_field_id) {
         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;
function show_revision($t_revision)
{
    static $s_can_drop = null;
    static $s_drop_token = null;
    static $s_user_access = null;
    if (is_null($s_can_drop)) {
        $s_can_drop = access_has_bug_level(config_get('bug_revision_drop_threshold'), $t_revision['bug_id']);
        $s_drop_token = form_security_param('bug_revision_drop');
    }
    switch ($t_revision['type']) {
        case REV_DESCRIPTION:
            $t_label = lang_get('description');
            break;
        case REV_STEPS_TO_REPRODUCE:
            $t_label = lang_get('steps_to_reproduce');
            break;
        case REV_ADDITIONAL_INFO:
            $t_label = lang_get('additional_information');
            break;
        case REV_BUGNOTE:
            if (is_null($s_user_access)) {
                $s_user_access = access_has_bug_level(config_get('private_bugnote_threshold'), $t_revision['bug_id']);
            }
            if (!$s_user_access) {
                return null;
            }
            $t_label = lang_get('bugnote');
            break;
        default:
            $t_label = '';
    }
    $t_by_string = sprintf(lang_get('revision_by'), string_display_line(date(config_get('normal_date_format'), $t_revision['timestamp'])), string_display_line(user_get_name($t_revision['user_id'])));
    ?>
<tr class="spacer"><td><a id="revision-<?php 
    echo $t_revision['id'];
    ?>
"></a></td></tr>

<tr <?php 
    echo helper_alternate_class();
    ?>
>
<th class="category"><?php 
    echo lang_get('revision');
    ?>
</th>
<td colspan="2"><?php 
    echo $t_by_string;
    ?>
</td>
<td class="center" width="5%">
<?php 
    if ($s_can_drop) {
        print_bracket_link('bug_revision_drop.php?id=' . $t_revision['id'] . $s_drop_token, lang_get('revision_drop'));
    }
    ?>
</tr>

<tr <?php 
    echo helper_alternate_class();
    ?>
>
<th class="category"><?php 
    echo $t_label;
    ?>
</th>
<td colspan="3"><?php 
    echo string_display_links($t_revision['value']);
    ?>
</td>
</tr>

	<?php 
}
Example #16
0
$f_dest_bug_id_array = explode('|', $f_dest_bug_id_string);
foreach ($f_dest_bug_id_array as $f_dest_bug_id) {
    $f_dest_bug_id = (int) $f_dest_bug_id;
    # source and destination bugs are the same bug...
    if ($f_src_bug_id == $f_dest_bug_id) {
        trigger_error(ERROR_RELATIONSHIP_SAME_BUG, ERROR);
    }
    # the related bug exists...
    bug_ensure_exists($f_dest_bug_id);
    # bug is not read-only...
    if (bug_is_readonly($f_src_bug_id)) {
        error_parameters($f_src_bug_id);
        trigger_error(ERROR_BUG_READ_ONLY_ACTION_DENIED, ERROR);
    }
    # user can access to the related bug at least as viewer...
    if (!access_has_bug_level(VIEWER, $f_dest_bug_id)) {
        error_parameters($f_dest_bug_id);
        trigger_error(ERROR_RELATIONSHIP_ACCESS_LEVEL_TO_DEST_BUG_TOO_LOW, ERROR);
    }
    $t_bug = bug_get($f_src_bug_id, true);
    if ($t_bug->project_id != helper_get_current_project()) {
        # in case the current project is not the same project of the bug we are viewing...
        # ... override the current project. This to avoid problems with categories and handlers lists etc.
        $g_project_override = $t_bug->project_id;
    }
    # check if there is other relationship between the bugs...
    $t_old_id_relationship = relationship_same_type_exists($f_src_bug_id, $f_dest_bug_id, $f_rel_type);
    if ($t_old_id_relationship == -1) {
        # the relationship type is exactly the same of the new one. No sense to proceed
        trigger_error(ERROR_RELATIONSHIP_ALREADY_EXISTS, ERROR);
    } else {
Example #17
0
	</td>
</tr>
<?php 
    event_signal('EVENT_VIEW_BUGNOTE', array($f_bug_id, $t_bugnote->id, VS_PRIVATE == $t_bugnote->view_state));
    ?>
<tr class="spacer">
	<td colspan="2"></td>
</tr>
<?php 
}
# end for loop
event_signal('EVENT_VIEW_BUGNOTES_END', $f_bug_id);
?>
</table>
<?php 
if ($t_total_time > 0 && access_has_bug_level(config_get('time_tracking_view_threshold'), $f_bug_id)) {
    echo '<p class="time-tracking-total">', sprintf(lang_get('total_time_for_issue'), '<span class="time-tracked">' . db_minutes_to_hhmm($t_total_time) . '</span>'), '</p>';
}
collapse_closed('bugnotes');
?>

<table class="width100" cellspacing="1">
<tr>
	<td class="form-title" colspan="2">
		<?php 
collapse_icon('bugnotes');
?>
		<?php 
echo lang_get('bug_notes_title');
?>
	</td>
</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);
                $t_date_added = date(config_get('normal_date_format'), $t_sponsorship->date_submitted);
                echo $i > 0 ? '<br />' : '';
                $i++;
                echo sprintf(lang_get('label'), $t_date_added) . lang_get('word_separator');
                print_user($t_sponsorship->user_id);
                echo ' (' . sponsorship_format_amount($t_sponsorship->amount) . ')';
                if (access_has_bug_level(config_get('handle_sponsored_bugs_threshold'), $f_bug_id)) {
                    echo ' ' . get_enum_element('sponsorship', $t_sponsorship->paid);
                }
            }
        }
        ?>
		</td>
		</tr>
<?php 
    }
    ?>
</table>

<?php 
    collapse_closed('sponsorship');
    ?>
Example #19
0
/**
 * Print column content for column overdue
 *
 * @param BugData $p_bug bug object
 * @param int $p_columns_target see COLUMNS_TARGET_* in constant_inc.php
 * @return null
 * @access public
 */
function print_column_overdue($p_bug, $p_columns_target = COLUMNS_TARGET_VIEW_PAGE)
{
    global $t_icon_path;
    echo '<td class="column-overdue">';
    if (access_has_bug_level(config_get('due_date_view_threshold'), $p_bug->id) && !date_is_null($p_bug->due_date) && bug_is_overdue($p_bug->id)) {
        $t_overdue_text = lang_get('overdue');
        $t_overdue_text_hover = $t_overdue_text . '. Due date was: ' . string_display_line(date(config_get('short_date_format'), $p_bug->due_date));
        echo '<img src="' . $t_icon_path . 'overdue.png" alt="' . $t_overdue_text . '" title="' . $t_overdue_text_hover . '" />';
    } else {
        echo '&#160;';
    }
    echo '</td>';
}
Example #20
0
if (access_has_bug_level(config_get('private_bugnote_threshold'), $t_bug_id)) {
    echo '<tr>';
    echo '<th class="category">' . lang_get('private') . '</th>';
    echo '<td colspan="5">';
    $t_default_bugnote_view_status = config_get('default_bugnote_view_status');
    if (access_has_bug_level(config_get('set_view_status_threshold'), $t_bug_id)) {
        echo '<input ', helper_get_tab_index(), ' type="checkbox" id="private" name="private" ', check_checked(config_get('default_bugnote_view_status'), VS_PRIVATE), ' />';
        echo lang_get('private');
    } else {
        echo get_enum_element('view_state', $t_default_bugnote_view_status);
    }
    echo '</td></tr>';
}
# Time Tracking (if permitted)
if (config_get('time_tracking_enabled')) {
    if (access_has_bug_level(config_get('time_tracking_edit_threshold'), $t_bug_id)) {
        echo '<tr>';
        echo '<th class="category"><label for="time_tracking">' . lang_get('time_tracking') . '</label></th>';
        echo '<td colspan="5"><input type="text" id="time_tracking" name="time_tracking" size="5" placeholder="hh:mm" /></td></tr>';
    }
}
event_signal('EVENT_BUGNOTE_ADD_FORM', array($t_bug_id));
# Submit Button
if ($t_bottom_buttons_enabled) {
    ?>
			<tfoot>
				<tr>
					<td class="center" colspan="6">
						<input <?php 
    helper_get_tab_index();
    ?>
Example #21
0
$t_show_status = in_array('status', $t_fields);
$t_show_resolution = in_array('resolution', $t_fields);
$t_show_projection = in_array('projection', $t_fields);
$t_show_eta = in_array('eta', $t_fields);
$t_show_versions = version_should_show_product_version($t_bug->project_id);
$t_show_product_version = $t_show_versions && in_array('product_version', $t_fields);
$t_show_product_build = $t_show_versions && in_array('product_build', $t_fields) && config_get('enable_product_build');
$t_show_fixed_in_version = $t_show_versions && in_array('fixed_in_version', $t_fields);
$t_show_target_version = $t_show_versions && in_array('target_version', $t_fields) && access_has_bug_level(config_get('roadmap_view_threshold'), $f_bug_id);
$t_show_summary = in_array('summary', $t_fields);
$t_show_description = in_array('description', $t_fields);
$t_show_steps_to_reproduce = in_array('steps_to_reproduce', $t_fields);
$t_show_additional_information = in_array('additional_info', $t_fields);
$t_show_tags = in_array('tags', $t_fields);
$t_show_attachments = in_array('attachments', $t_fields);
$t_show_history = access_has_bug_level(config_get('view_history_threshold'), $f_bug_id);
$t_window_title = string_display_line(config_get('window_title'));
$t_project_name = $t_show_project ? string_display_line(project_get_name($t_bug->project_id)) : '';
$t_formatted_bug_id = $t_show_id ? bug_format_id($f_bug_id) : '';
$t_category_name = $t_show_category ? string_display_line(category_full_name($t_bug->category_id)) : '';
$t_severity = string_display_line(get_enum_element('severity', $t_bug->severity));
$t_reproducibility = string_display_line(get_enum_element('reproducibility', $t_bug->reproducibility));
$t_date_submitted = $t_show_date_submitted ? string_display_line(date(config_get('normal_date_format'), $t_bug->date_submitted)) : '';
$t_last_updated = $t_show_last_updated ? string_display_line(date(config_get('normal_date_format'), $t_bug->last_updated)) : '';
$t_platform = string_display_line($t_bug->platform);
$t_os = string_display_line($t_bug->os);
$t_os_version = string_display_line($t_bug->os_build);
$t_is = string_display_line($t_bug->os);
$t_status = string_display_line(get_enum_element('status', $t_bug->status));
$t_priority = string_display_line(get_enum_element('priority', $t_bug->priority));
$t_resolution = string_display_line(get_enum_element('resolution', $t_bug->resolution));
Example #22
0
/**
 * Returns time tracking information from a bug note.
 *
 * @param integer $p_issue_id The id of the issue.
 * @param array   $p_note     A note as passed to the soap api methods.
 *
 * @return String the string time entry to be added to the bugnote, in 'HH:mm' format
 */
function mci_get_time_tracking_from_note($p_issue_id, array $p_note)
{
    if (!access_has_bug_level(config_get('time_tracking_view_threshold'), $p_issue_id)) {
        return '00:00';
    }
    if (!isset($p_note['time_tracking'])) {
        return '00:00';
    }
    return db_minutes_to_hhmm($p_note['time_tracking']);
}
Example #23
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";
    }
}
require_api('authentication_api.php');
require_api('bugnote_api.php');
require_api('config_api.php');
require_api('constant_inc.php');
require_api('current_user_api.php');
require_api('database_api.php');
require_api('gpc_api.php');
require_api('lang_api.php');
require_api('print_api.php');
require_api('string_api.php');
require_api('user_api.php');
$f_bug_id = gpc_get_int('bug_id');
# grab the user id currently logged in
$t_user_id = auth_get_current_user_id();
$c_bug_id = (int) $f_bug_id;
if (!access_has_bug_level(config_get('private_bugnote_threshold'), $f_bug_id)) {
    $t_restriction = 'AND view_state=' . VS_PUBLIC;
} else {
    $t_restriction = '';
}
# get the bugnote data
$t_bugnote_order = current_user_get_pref('bugnote_order');
$t_query = 'SELECT * FROM {bugnote}
		WHERE bug_id=' . db_param() . ' ' . $t_restriction . '
		ORDER BY date_submitted ' . $t_bugnote_order;
$t_result = db_query($t_query, array($c_bug_id));
$t_num_notes = db_num_rows($t_result);
?>

<br />
<table class="width100" cellspacing="1">
/**
 * print HTML relationship form
 * @param integer $p_bug_id A bug identifier.
 * @return void
 */
function relationship_view_box($p_bug_id)
{
    ?>
<br/>

<?php 
    collapse_open('relationships');
    ?>
<table class="width100" cellspacing="1">
<tr class="row-2">
	<td width="15%" class="form-title" colspan="2">
		<?php 
    collapse_icon('relationships');
    echo lang_get('bug_relationships');
    if (ON == config_get('relationship_graph_enable')) {
        ?>
		<span class="small"><?php 
        print_bracket_link('bug_relationship_graph.php?bug_id=' . $p_bug_id . '&graph=relation', lang_get('relation_graph'));
        ?>
</span>
		<span class="small"><?php 
        print_bracket_link('bug_relationship_graph.php?bug_id=' . $p_bug_id . '&graph=dependency', lang_get('dependency_graph'));
        ?>
</span>
		<?php 
    }
    ?>
	</td>
</tr>
<?php 
    # bug not read-only and user authenticated
    if (!bug_is_readonly($p_bug_id)) {
        # user access level at least updater
        if (access_has_bug_level(config_get('update_bug_threshold'), $p_bug_id)) {
            ?>
<tr class="row-1">
	<th class="category"><?php 
            echo lang_get('add_new_relationship');
            ?>
</th>
	<td><?php 
            echo lang_get('this_bug');
            ?>
		<form method="post" action="bug_relationship_add.php">
		<?php 
            echo form_security_field('bug_relationship_add');
            ?>
		<input type="hidden" name="src_bug_id" value="<?php 
            echo $p_bug_id;
            ?>
" size="4" />
		<?php 
            relationship_list_box(config_get('default_bug_relationship'));
            ?>
		<input type="text" name="dest_bug_id" value="" />
		<input type="submit" name="add_relationship" class="button" value="<?php 
            echo lang_get('add_new_relationship_button');
            ?>
" />
		</form>
	</td></tr>
<?php 
        }
    }
    ?>
<tr>
	<td colspan="2"><?php 
    echo relationship_get_summary_html($p_bug_id);
    ?>
</td>
</tr>
</table>

<?php 
    collapse_closed('relationships');
    ?>
<table class="width100" cellspacing="1">
<tr>
	<td class="form-title">
		<?php 
    collapse_icon('relationships');
    echo lang_get('bug_relationships');
    ?>
	</td>
</tr>
</table>

<?php 
    collapse_end('relationships');
}
<?php 
if ($t_custom_fields_found) {
    ?>
<!-- spacer -->
<tr class="spacer">
	<td colspan="6"></td>
</tr>
<?php 
}
# custom fields found
?>


<!-- Attachments -->
<?php 
$t_show_attachments = $t_bug->reporter_id == auth_get_current_user_id() || access_has_bug_level(config_get('view_attachments_threshold'), $f_bug_id);
if ($t_show_attachments) {
    ?>
<tr <?php 
    echo helper_alternate_class();
    ?>
>
	<td class="category">
		<a name="attachments" id="attachments" />
		<?php 
    echo lang_get('attached_files');
    ?>
	</td>
	<td colspan="5">
		<?php 
    file_list_attachments($f_bug_id);
Example #27
0
/**
 * Check if the specified bug can be reopened
 * @param BugData $p_bug Bug 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 to reopen bugs
 * @access public
 */
function access_can_reopen_bug($p_bug, $p_user_id = null)
{
    if (!bug_is_resolved($p_bug->id)) {
        # Can't reopen a bug that's not resolved
        return false;
    }
    if ($p_user_id === null) {
        $p_user_id = auth_get_current_user_id();
    }
    # If allow_reporter_reopen is enabled, then reporters can always reopen
    # their own bugs as long as their access level is reporter or above
    if (ON == config_get('allow_reporter_reopen', null, null, $p_bug->project_id) && bug_is_user_reporter($p_bug->id, $p_user_id) && access_has_project_level(config_get('report_bug_threshold', null, $p_user_id, $p_bug->project_id), $p_bug->project_id, $p_user_id)) {
        return true;
    }
    # Other users's access level must allow them to reopen bugs
    $t_reopen_bug_threshold = config_get('reopen_bug_threshold', null, null, $p_bug->project_id);
    if (access_has_bug_level($t_reopen_bug_threshold, $p_bug->id, $p_user_id)) {
        $t_reopen_status = config_get('bug_reopen_status', null, null, $p_bug->project_id);
        # User must be allowed to change status to reopen status
        $t_reopen_status_threshold = access_get_status_threshold($t_reopen_status, $p_bug->project_id);
        return access_has_bug_level($t_reopen_status_threshold, $p_bug->id, $p_user_id);
    }
    return false;
}
Example #28
0
function mci_tag_set_for_issue($p_issue_id, $p_tags, $p_user_id)
{
    $t_tag_ids_to_attach = array();
    $t_tag_ids_to_detach = array();
    $t_submitted_tag_ids = array();
    $t_attached_tags = tag_bug_get_attached($p_issue_id);
    $t_attached_tag_ids = array();
    foreach ($t_attached_tags as $t_attached_tag) {
        $t_attached_tag_ids[] = $t_attached_tag['id'];
    }
    foreach ($p_tags as $t_tag) {
        $t_tag = SoapObjectsFactory::unwrapObject($t_tag);
        $t_submitted_tag_ids[] = $t_tag['id'];
        if (in_array($t_tag['id'], $t_attached_tag_ids)) {
            continue;
        } else {
            $t_tag_ids_to_attach[] = $t_tag['id'];
        }
    }
    foreach ($t_attached_tag_ids as $t_attached_tag_id) {
        if (in_array($t_attached_tag_id, $t_submitted_tag_ids)) {
            continue;
        } else {
            $t_tag_ids_to_detach[] = $t_attached_tag_id;
        }
    }
    foreach ($t_tag_ids_to_detach as $t_tag_id) {
        if (access_has_bug_level(config_get('tag_detach_threshold'), $p_issue_id, $p_user_id)) {
            tag_bug_detach($t_tag_id, $p_issue_id);
        }
    }
    foreach ($t_tag_ids_to_attach as $t_tag_id) {
        if (access_has_bug_level(config_get('tag_attach_threshold'), $p_issue_id, $p_user_id)) {
            tag_bug_attach($t_tag_id, $p_issue_id);
        }
    }
}
Example #29
0
 * @uses print_api.php
 * @uses string_api.php
 */
if (!defined('HISTORY_INC_ALLOW')) {
    return;
}
require_api('access_api.php');
require_api('collapse_api.php');
require_api('config_api.php');
require_api('helper_api.php');
require_api('history_api.php');
require_api('lang_api.php');
require_api('print_api.php');
require_api('string_api.php');
$t_access_level_needed = config_get('view_history_threshold');
if (!access_has_bug_level($t_access_level_needed, $f_bug_id)) {
    return;
}
?>

<a id="history"></a><br />

<?php 
collapse_open('history', '', 'table-container');
$t_history = history_get_events_array($f_bug_id);
?>
<table>
	<thead>
		<tr>
			<td class="form-title" colspan="4">
<?php 
Example #30
0
function html_button_wiki($p_bug_id)
{
    if (ON == config_get('wiki_enable')) {
        if (access_has_bug_level(config_get('update_bug_threshold'), $p_bug_id)) {
            html_button('wiki.php', lang_get_defaulted('Wiki'), array('id' => $p_bug_id, 'type' => 'issue'), 'get');
        }
    }
}