Example #1
0
 public function addVersion($projID, $version)
 {
     if (MANTIS_LOCAL) {
         if (version_add($projID, $version, true, $version)) {
             $t_version_id = version_get_id($version, $projID);
             if (!is_blank($v_date_order)) {
                 $t_version = version_get($t_version_id);
                 $t_version->date_order = date("Y-m-d H:i:s", strtotime($v_date_order));
                 version_update($t_version);
             }
         }
     } else {
         $this->client->mc_project_version_add(MANTIS_USER, MANTIS_PWD, array('name' => $version, 'project_id' => $projID, 'description' => $version, 'released' => true));
     }
 }
 /**
  * Updates the version and associated type of the document if several issues
  * are updated
  *
  * @param $event
  * @param $event_type
  * @param $bug_id
  */
 function actiongroupUpdateData($event, $event_type, $bug_id)
 {
     require_once SPECMANAGEMENT_CORE_URI . 'specmanagement_database_api.php';
     $specmanagement_database_api = new specmanagement_database_api();
     if ($event_type == 'UP_TARGET_VERSION') {
         $target_version = gpc_get_string('target_version', null);
         $p_version_id = null;
         if (!(is_null($target_version) || $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];
         }
         $specmanagement_database_api->update_source_version($bug_id, $p_version_id);
     }
 }
Example #3
0
 if ($count > 0) {
     echo '<table width="80%" bgcolor="#222222" border="0" cellpadding="10" cellspacing="1">';
     # Headings
     echo '<tr bgcolor="#ffffff"><th width="10%">Bug Id</th><th width="20%">Field Value</th><th width="70%">Status</th></tr>';
 }
 for ($i = 0; $i < $count; $i++) {
     $row = db_fetch_array($result);
     extract($row, EXTR_PREFIX_ALL, 'v');
     # trace bug id back to project
     $t_project_id = bug_get_field($v_bug_id, 'project_id');
     $t_cust_value = $v_value;
     printf("\n<tr %s><td><a href=\"../view.php?id=%d\">%07d</a></td><td>%s</td><td>", helper_alternate_class(), $v_bug_id, $v_bug_id, $v_value);
     # validate field contents
     switch ($f_dest_field) {
         case 'fixed_in_version':
             $t_valid = version_get_id($t_cust_value, $t_project_id) == FALSE ? FALSE : TRUE;
             break;
         default:
             $t_valid = FALSE;
     }
     if ($t_valid) {
         # value was valid, update value
         if (!bug_set_field($v_bug_id, $f_dest_field, $t_cust_value)) {
             echo 'database update failed';
             $t_failures++;
         } else {
             echo 'applied';
         }
     } else {
         echo 'field value was not valid or previously defined';
         $t_failures++;
Example #4
0
/**
 * Update Issue in database
 *
 * Created By KGB
 * @param string   $p_username The name of the user trying to add the issue.
 * @param string   $p_password The password of the user.
 * @param integer  $p_issue_id The issue id of the existing issue being updated.
 * @param stdClass $p_issue    A IssueData structure containing information about the new issue.
 * @return integer The id of the created issue.
 */
function mc_issue_update($p_username, $p_password, $p_issue_id, stdClass $p_issue)
{
    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 . '\' does not exist.');
    }
    if (bug_is_readonly($p_issue_id)) {
        return SoapObjectsFactory::newSoapFault('Client', 'Issue \'' . $p_issue_id . '\' is readonly');
    }
    $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);
    }
    $g_project_override = $t_project_id;
    # ensure that helper_get_current_project() calls resolve to this project id
    $p_issue = SoapObjectsFactory::unwrapObject($p_issue);
    $t_project_id = mci_get_project_id($p_issue['project']);
    $t_reporter_id = isset($p_issue['reporter']) ? mci_get_user_id($p_issue['reporter']) : $t_user_id;
    $t_handler_id = isset($p_issue['handler']) ? mci_get_user_id($p_issue['handler']) : 0;
    $t_project = $p_issue['project'];
    $t_summary = isset($p_issue['summary']) ? $p_issue['summary'] : '';
    $t_description = isset($p_issue['description']) ? $p_issue['description'] : '';
    if ($t_project_id == 0 || !project_exists($t_project_id)) {
        if ($t_project_id == 0) {
            return SoapObjectsFactory::newSoapFault('Client', 'Project \'' . $t_project['name'] . '\' does not exist.');
        }
        return SoapObjectsFactory::newSoapFault('Client', 'Project \'' . $t_project_id . '\' does not exist.');
    }
    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, 'Not enough rights to update issues');
    }
    $t_category = isset($p_issue['category']) ? $p_issue['category'] : null;
    $t_category_id = translate_category_name_to_id($t_category, $t_project_id);
    if ($t_category_id == 0 && !config_get('allow_no_category')) {
        if (isset($p_issue['category']) && !is_blank($p_issue['category'])) {
            return SoapObjectsFactory::newSoapFault('Client', 'Category field must be supplied.');
        } else {
            $t_project_name = project_get_name($t_project_id);
            return SoapObjectsFactory::newSoapFault('Client', 'Category \'' . $p_issue['category'] . '\' not found for project \'' . $t_project_name . '\'.');
        }
    }
    if (isset($p_issue['version']) && !is_blank($p_issue['version']) && !version_get_id($p_issue['version'], $t_project_id)) {
        $t_error_when_version_not_found = config_get('webservice_error_when_version_not_found');
        if ($t_error_when_version_not_found == ON) {
            $t_project_name = project_get_name($t_project_id);
            return SoapObjectsFactory::newSoapFault('Client', 'Version \'' . $p_issue['version'] . '\' does not exist in project \'' . $t_project_name . '\'.');
        } else {
            $t_version_when_not_found = config_get('webservice_version_when_not_found');
            $p_issue['version'] = $t_version_when_not_found;
        }
    }
    if (is_blank($t_summary)) {
        return SoapObjectsFactory::newSoapFault('Client', 'Mandatory field \'summary\' is missing.');
    }
    if (is_blank($t_description)) {
        return SoapObjectsFactory::newSoapFault('Client', 'Mandatory field \'description\' is missing.');
    }
    # fields which we expect to always be set
    $t_bug_data = bug_get($p_issue_id, true);
    $t_bug_data->project_id = $t_project_id;
    $t_bug_data->reporter_id = $t_reporter_id;
    $t_access_check_result = mci_issue_handler_access_check($t_user_id, $t_project_id, $t_bug_data->handler_id, $t_handler_id);
    if ($t_access_check_result !== true) {
        return $t_access_check_result;
    }
    $t_bug_data->handler_id = $t_handler_id;
    $t_bug_data->category_id = $t_category_id;
    $t_bug_data->summary = $t_summary;
    $t_bug_data->description = $t_description;
    # fields which might not be set
    if (isset($p_issue['steps_to_reproduce'])) {
        $t_bug_data->steps_to_reproduce = $p_issue['steps_to_reproduce'];
    }
    if (isset($p_issue['additional_information'])) {
        $t_bug_data->additional_information = $p_issue['additional_information'];
    }
    if (isset($p_issue['priority'])) {
        $t_bug_data->priority = mci_get_priority_id($p_issue['priority']);
    }
    if (isset($p_issue['severity'])) {
        $t_bug_data->severity = mci_get_severity_id($p_issue['severity']);
    }
    if (isset($p_issue['status'])) {
        $t_bug_data->status = mci_get_status_id($p_issue['status']);
    }
    if (isset($p_issue['reproducibility'])) {
        $t_bug_data->reproducibility = mci_get_reproducibility_id($p_issue['reproducibility']);
    }
    if (isset($p_issue['resolution'])) {
        $t_bug_data->resolution = mci_get_resolution_id($p_issue['resolution']);
    }
    if (isset($p_issue['projection'])) {
        $t_bug_data->projection = mci_get_projection_id($p_issue['projection']);
    }
    if (isset($p_issue['eta'])) {
        $t_bug_data->eta = mci_get_eta_id($p_issue['eta']);
    }
    if (isset($p_issue['view_state'])) {
        $t_bug_data->view_state = mci_get_view_state_id($p_issue['view_state']);
    }
    if (isset($p_issue['date_submitted'])) {
        $t_bug_data->date_submitted = $p_issue['date_submitted'];
    }
    if (isset($p_issue['date_updated'])) {
        $t_bug_data->last_updated = $p_issue['last_updated'];
    }
    if (isset($p_issue['profile_id'])) {
        $t_bug_data->profile_id = $p_issue['profile_id'];
    }
    if (isset($p_issue['os'])) {
        $t_bug_data->os = $p_issue['os'];
    }
    if (isset($p_issue['os_build'])) {
        $t_bug_data->os_build = $p_issue['os_build'];
    }
    if (isset($p_issue['build'])) {
        $t_bug_data->build = $p_issue['build'];
    }
    if (isset($p_issue['platform'])) {
        $t_bug_data->platform = $p_issue['platform'];
    }
    if (isset($p_issue['version'])) {
        $t_bug_data->version = $p_issue['version'];
    }
    if (isset($p_issue['fixed_in_version'])) {
        $t_bug_data->fixed_in_version = $p_issue['fixed_in_version'];
    }
    if (isset($p_issue['sticky']) && access_has_bug_level(config_get('set_bug_sticky_threshold'), $t_bug_data->id)) {
        $t_bug_data->sticky = $p_issue['sticky'];
    }
    if (isset($p_issue['due_date']) && access_has_global_level(config_get('due_date_update_threshold'))) {
        $t_bug_data->due_date = SoapObjectsFactory::parseDateTimeString($p_issue['due_date']);
    } else {
        $t_bug_data->due_date = date_get_null();
    }
    if (access_has_project_level(config_get('roadmap_update_threshold'), $t_bug_data->project_id, $t_user_id)) {
        $t_bug_data->target_version = isset($p_issue['target_version']) ? $p_issue['target_version'] : '';
    }
    $t_set_custom_field_error = mci_issue_set_custom_fields($p_issue_id, $p_issue['custom_fields'], true);
    if ($t_set_custom_field_error != null) {
        return $t_set_custom_field_error;
    }
    if (isset($p_issue['monitors'])) {
        mci_issue_set_monitors($p_issue_id, $t_user_id, $p_issue['monitors']);
    }
    if (isset($p_issue['notes']) && is_array($p_issue['notes'])) {
        $t_bugnotes = bugnote_get_all_visible_bugnotes($p_issue_id, 'DESC', 0);
        $t_bugnotes_by_id = array();
        foreach ($t_bugnotes as $t_bugnote) {
            $t_bugnotes_by_id[$t_bugnote->id] = $t_bugnote;
        }
        foreach ($p_issue['notes'] as $t_note) {
            $t_note = SoapObjectsFactory::unwrapObject($t_note);
            if (isset($t_note['view_state'])) {
                $t_view_state = $t_note['view_state'];
            } else {
                $t_view_state = config_get('default_bugnote_view_status');
            }
            if (isset($t_note['id']) && (int) $t_note['id'] > 0) {
                $t_bugnote_id = (int) $t_note['id'];
                $t_view_state_id = mci_get_enum_id_from_objectref('view_state', $t_view_state);
                if (array_key_exists($t_bugnote_id, $t_bugnotes_by_id)) {
                    $t_bugnote_changed = false;
                    if ($t_bugnote->note !== $t_note['text']) {
                        bugnote_set_text($t_bugnote_id, $t_note['text']);
                        $t_bugnote_changed = true;
                    }
                    if ($t_bugnote->view_state != $t_view_state_id) {
                        bugnote_set_view_state($t_bugnote_id, $t_view_state_id == VS_PRIVATE);
                        $t_bugnote_changed = true;
                    }
                    if (isset($t_note['time_tracking']) && $t_note['time_tracking'] != $t_bugnote->time_tracking) {
                        bugnote_set_time_tracking($t_bugnote_id, mci_get_time_tracking_from_note($p_issue_id, $t_note));
                        $t_bugnote_changed = true;
                    }
                    if ($t_bugnote_changed) {
                        bugnote_date_update($t_bugnote_id);
                    }
                }
            } else {
                $t_view_state_id = mci_get_enum_id_from_objectref('view_state', $t_view_state);
                $t_note_type = isset($t_note['note_type']) ? (int) $t_note['note_type'] : BUGNOTE;
                $t_note_attr = isset($t_note['note_type']) ? $t_note['note_attr'] : '';
                bugnote_add($p_issue_id, $t_note['text'], mci_get_time_tracking_from_note($p_issue_id, $t_note), $t_view_state_id == VS_PRIVATE, $t_note_type, $t_note_attr, $t_user_id, false);
            }
        }
        # The issue has been cached earlier in the bug_get() call.  Flush the cache since it is
        # now stale.  Otherwise, the email notification will be based on the cached data.
        bugnote_clear_cache($p_issue_id);
    }
    if (isset($p_issue['tags']) && is_array($p_issue['tags'])) {
        mci_tag_set_for_issue($p_issue_id, $p_issue['tags'], $t_user_id);
    }
    # submit the issue
    log_event(LOG_WEBSERVICE, 'updating issue \'' . $p_issue_id . '\'');
    return $t_bug_data->update(true, true);
}
Example #5
0
 function save_acra_issue($p_project_id, $packages)
 {
     $begin_ts = microtime(true);
     set_time_limit(0);
     $pid = "pid:" . getmypid() . "-" . substr(md5(microtime()), 8, 16) . " ";
     error_log($pid . "save_acra_issue enter");
     $t_app_version = gpc_get_string('APP_VERSION_NAME', '');
     $t_project_id = $p_project_id;
     $t_fingerprint = $this->build_acra_issue_fingerprint(gpc_get_string('STACK_TRACE'), $packages, $pid);
     $t_bug_id = acra_get_bug_id_by_fingerprint($t_fingerprint, $t_app_version);
     if ($t_bug_id != false && $t_bug_id != '0' && $t_bug_id != '-1') {
         //the bug id is valid
         if (bug_is_closed($t_bug_id)) {
             error_log($pid . "the bug " . $t_bug_id . " is closed");
             error_log($pid . "save_acra_issue quit2 " . (microtime(true) - $begin_ts) . 'ms');
             return;
         }
     }
     //save acra issue extionsion
     $acra_ext = new BugDataAcraExt();
     $acra_ext->project_id = $t_project_id;
     $acra_ext->issue_id = 0;
     $acra_ext->report_id = gpc_get_string('REPORT_ID', '');
     $acra_ext->report_fingerprint = $t_fingerprint;
     $acra_ext->file_path = gpc_get_string('FILE_PATH', '');
     $acra_ext->phone_model = gpc_get_string('PHONE_MODEL', '');
     $acra_ext->phone_build = gpc_get_string('BUILD', '');
     $acra_ext->phone_brand = gpc_get_string('BRAND', '');
     $acra_ext->product_name = gpc_get_string('PRODUCT', '');
     $acra_ext->total_mem_size = gpc_get_string('TOTAL_MEM_SIZE', '');
     $acra_ext->available_mem_size = gpc_get_string('AVAILABLE_MEM_SIZE', '');
     $acra_ext->custom_data = gpc_get_string('CUSTOM_DATA', '');
     $acra_ext->initial_configuration = gpc_get_string('INITIAL_CONFIGURATION', '');
     $acra_ext->crash_configuration = gpc_get_string('CRASH_CONFIGURATION', '');
     $acra_ext->display = gpc_get_string('DISPLAY', '');
     $acra_ext->user_comment = gpc_get_string('USER_COMMENT', '');
     $acra_ext->dumpsys_meminfo = gpc_get_string('DUMPSYS_MEMINFO', '');
     $acra_ext->dropbox = gpc_get_string('DROPBOX', '');
     //NOT EXITS, need check with acra, later
     $acra_ext->eventslog = gpc_get_string('EVENTSLOG', '');
     //NOT EXITS, need check with acra, later
     $acra_ext->radiolog = gpc_get_string('RADIOLOG', '');
     //NOT EXITS, need check with acra, later
     $acra_ext->is_silent = gpc_get_string('IS_SILENT', '');
     $acra_ext->device_id = gpc_get_string('INSTALLATION_ID', '');
     //NOT EXITS, need check with acra, later
     $acra_ext->installation_id = gpc_get_string('INSTALLATION_ID', '');
     $acra_ext->user_email = gpc_get_string('USER_EMAIL', '');
     $acra_ext->device_features = gpc_get_string('DEVICE_FEATURES', '');
     $acra_ext->environment = gpc_get_string('ENVIRONMENT', '');
     $acra_ext->settings_system = gpc_get_string('SETTINGS_SYSTEM', '');
     $acra_ext->settings_secure = gpc_get_string('SETTINGS_SECURE', '');
     $acra_ext->shared_preferences = gpc_get_string('SHARED_PREFERENCES', '');
     $acra_ext->android_version = gpc_get_string('ANDROID_VERSION', '');
     $acra_ext->app_version = $t_app_version;
     $acra_ext->crash_date = $this->covertTimeString(gpc_get_string('USER_CRASH_DATE', ''));
     $acra_ext->install_date = $this->covertTimeString(gpc_get_string('USER_APP_START_DATE', ''));
     $t_result = $acra_ext->create();
     if ($t_result === false) {
         error_log($pid . "dumplicated report id");
         return;
     }
     error_log($pid . "save fingerprint " . $acra_ext->report_fingerprint . " to acra issue:" . $acra_ext->id);
     $t_duplicated_bug_id = '0';
     $tries = 0;
     while ($tries < 30) {
         sleep(1);
         //wait one second
         $t_duplicated_bug_id = acra_get_bug_id_by_fingerprint($t_fingerprint, $t_app_version);
         $tries = $tries + 1;
         if ($t_duplicated_bug_id == "-1") {
             $id = acra_get_first_issue_id_by_fingerprint($t_fingerprint, 0);
             if ($id == $acra_ext->id) {
                 $t_duplicated_bug_id = '0';
                 break;
             }
             continue;
         }
         if ($t_duplicated_bug_id == '0') {
             break;
         }
         break;
     }
     if (tries >= 30) {
         $t_duplicated_bug_id = '0';
     }
     $t_user_id = $this->get_user_id();
     if ($t_duplicated_bug_id == '0') {
         //new crash report, save a bug record
         $t_duplicated_bug_id = $this->save_bug($t_project_id, $t_user_id);
         error_log($pid . "create bug " . $t_duplicated_bug_id . ' for acra issue:' . $acra_ext->id . ' fp:' . $t_fingerprint);
         //create version if possible
         $t_version_id = version_get_id($t_app_version, $t_project_id);
         if ($t_version_id === false) {
             version_add($t_project_id, $t_app_version, VERSION_RELEASED);
             event_signal('EVENT_MANAGE_VERSION_CREATE', array($t_version_id));
         }
     } else {
         error_log($pid . "exists bug " . $t_duplicated_bug_id);
         if (!bug_is_closed($t_duplicated_bug_id)) {
             //the bug is open
             $t_notes = bugnote_get_all_bugnotes($t_duplicated_bug_id);
             if (count($t_notes) < 20) {
                 //we only accepts 20 crash records as notes for the reason of the speed of viewing bug detail page.
                 error_log($pid . "acra issue is:" . $acra_ext->id);
                 $note_id = bugnote_add($t_duplicated_bug_id, gpc_get_string('STACK_TRACE'), '0:00', false, BUGNOTE, $acra_ext->id, $t_user_id, false, false);
                 error_log($pid . "add note " . $note_id . " to bug" . $t_duplicated_bug_id);
             } else {
                 bug_update_date($t_duplicated_bug_id);
                 error_log($pid . "update bug" . $t_duplicated_bug_id . " time, not add note");
             }
         } else {
             //the bug is closed, do not accept crash report any more
             acra_delete_bug_ext_by_id($acra_ext->id);
             error_log($pid . "delete the acra issue because the bug" . $t_duplicated_bug_id . " is closed");
             error_log($pid . "save_acra_issue quit1 " . (microtime(true) - $begin_ts) . 'ms');
             return;
         }
         /*
         if( !($t_bug->status == RESOLVED || $t_bug->status == CLOSED
             || $t_bug->resolution == FIXED || $t_bug->resolution == DUPLICATE || $t_bug->resolution == NOT_FIXABLE) ){
             //refresh bug update time
             bug_update_date($t_duplicated_bug_id);
         }
         */
     }
     error_log($pid . "update bug id of acra issues which fingerprint is " . $t_fingerprint);
     acra_update_bug_id_by_fingerprint($t_fingerprint, $t_duplicated_bug_id);
     error_log($pid . "save_acra_issue quit0 " . (microtime(true) - $begin_ts) . 'ms');
 }
Example #6
0
    ?>
</td>
	</tr>
<?php 
    $t_bug_list = array();
    $t_total_owing = 0;
    $t_total_paid = 0;
    for ($i = 0; $i < $t_sponsor_count; ++$i) {
        $t_sponsor_row = $t_sponsors[$i];
        $t_bug = bug_get($t_sponsor_row['bug']);
        $t_sponsor = sponsorship_get($t_sponsor_row['sponsor']);
        $t_buglist[] = $t_sponsor_row['bug'] . ':' . $t_sponsor_row['sponsor'];
        # describe bug
        $t_status = string_attribute(get_enum_element('status', $t_bug->status, auth_get_current_user_id(), $t_bug->project_id));
        $t_resolution = string_attribute(get_enum_element('resolution', $t_bug->resolution, auth_get_current_user_id(), $t_bug->project_id));
        $t_version_id = version_get_id($t_bug->fixed_in_version, $t_bug->project_id);
        if (false !== $t_version_id && VERSION_RELEASED == version_get_field($t_version_id, 'released')) {
            $t_released_label = '<a title="' . lang_get('released') . '">' . $t_bug->fixed_in_version . '</a>';
        } else {
            $t_released_label = $t_bug->fixed_in_version;
        }
        # 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);
        echo '<tr class="' . $t_status_label . '">';
        echo '<td><a href="' . string_get_bug_view_url($t_sponsor_row['bug']) . '">' . bug_format_id($t_sponsor_row['bug']) . '</a></td>';
        echo '<td>' . string_display_line(project_get_field($t_bug->project_id, 'name')) . '&#160;</td>';
        echo '<td class="right">' . $t_released_label . '&#160;</td>';
        echo '<td><a title="' . $t_resolution . '"><span class="underline">' . $t_status . '</span>&#160;</a></td>';
        # summary
        echo '<td>' . string_display_line($t_bug->summary);
        if (VS_PRIVATE == $t_bug->view_state) {
Example #7
0
         if ($f_fixed_in_version === '' || version_get_id($f_fixed_in_version, $t_bug->project_id) !== false) {
             # @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, 'fixed_in_version', $f_fixed_in_version);
             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_version');
         }
     } else {
         $t_failed_ids[$t_bug_id] = lang_get('bug_actiongroup_access');
     }
     break;
 case 'UP_TARGET_VERSION':
     $f_target_version = gpc_get_string('target_version');
     if (access_has_bug_level(config_get('roadmap_update_threshold'), $t_bug_id)) {
         if ($f_target_version === '' || version_get_id($f_target_version, $t_bug->project_id) !== false) {
             # @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, 'target_version', $f_target_version);
             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_version');
         }
     } else {
         $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 ) );
Example #8
0
/**
 * Submit the specified version details.
 *
 * @param string $p_username  The name of the user trying to add the issue.
 * @param string $p_password  The password of the user.
 * @param Array $p_version  A ProjectVersionData structure containing information about the new verison.
 * @return integer  The id of the created version.
 */
function mc_project_version_add($p_username, $p_password, $p_version)
{
    $t_user_id = mci_check_login($p_username, $p_password);
    if ($t_user_id === false) {
        return new soap_fault('Client', '', 'Access Denied', 'Username/password combination was incorrect');
    }
    if (!mci_has_administrator_access($t_user_id)) {
        return new soap_fault('Client', '', 'Access Denied', 'User does not have administrator access');
    }
    extract($p_version, EXTR_PREFIX_ALL, 'v');
    if (is_blank($v_project_id)) {
        return new soap_fault('Client', '', 'Mandatory field "project_id" was missing');
    }
    if (is_blank($v_name)) {
        return new soap_fault('Client', '', 'Mandatory field "name" was missing');
    }
    if (!version_is_unique($v_name, $v_project_id)) {
        return new soap_fault('Client', '', 'Version exists for project', 'The version you attempted to add already exists for this project');
    }
    if ($v_released === false) {
        $v_released = VERSION_FUTURE;
    } else {
        $v_released = VERSION_RELEASED;
    }
    if (version_add($v_project_id, $v_name, $v_released, $v_description)) {
        $t_version_id = version_get_id($v_name, $v_project_id);
        if (!is_blank($v_date_order)) {
            $t_version = version_get($t_version_id);
            $t_version->date_order = date("Y-m-d H:i:s", strtotime($v_date_order));
            version_update($t_version);
        }
        return $t_version_id;
    } else {
        return null;
    }
}
 function getVersionInformation($p_project_id, $p_version = "")
 {
     $t_version_id = version_get_id($p_version, $p_project_id);
     $t_version_id = version_cache_row($t_version_id, false);
     return $t_version_id;
 }
Example #10
0
/**
 * Update Issue in database
 *
 * Created By KGB
 * @param string $p_username The name of the user trying to add the issue.
 * @param string $p_password The password of the user.
 * @param Array $p_issue A IssueData structure containing information about the new issue.
 * @return integer The id of the created issue.
 */
function mc_issue_update( $p_username, $p_password, $p_issue_id, $p_issue ) {
	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 new soap_fault( 'Client', '', "Issue '$p_issue_id' does not exist." );
	}

	$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 );
	}
	
	$g_project_override = $t_project_id; // ensure that helper_get_current_project() calls resolve to this project id

	$t_project_id = mci_get_project_id( $p_issue['project'] );
	$t_reporter_id = isset( $p_issue['reporter'] ) ? mci_get_user_id( $p_issue['reporter'] )  : $t_user_id ;
	$t_handler_id = isset( $p_issue['handler'] ) ? mci_get_user_id( $p_issue['handler'] ) : 0;
	$t_project = $p_issue['project'];
	$t_summary = isset( $p_issue['summary'] ) ? $p_issue['summary'] : '';
	$t_description = isset( $p_issue['description'] ) ? $p_issue['description'] : '';
	
	
	if(( $t_project_id == 0 ) || !project_exists( $t_project_id ) ) {
		if( $t_project_id == 0 ) {
			return new soap_fault( 'Client', '', "Project '" . $t_project['name'] . "' does not exist." );
		}
		return new soap_fault( 'Client', '', "Project '$t_project_id' does not exist." );
	}

	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,  "Not enough rights to update issues" );
	}

	if(( $t_handler_id != 0 ) && !user_exists( $t_handler_id ) ) {
		return new soap_fault( 'Client', '', "User '$t_handler_id' does not exist." );
	}

	$t_category = isset ( $p_issue['category'] ) ? $p_issue['category'] : null;

	$t_category_id = translate_category_name_to_id( $t_category, $t_project_id );
	if ( $t_category_id == 0 && !config_get( 'allow_no_category' ) ) {
		if ( isset( $p_issue['category'] ) && !is_blank( $p_issue['category'] ) ) {
			return new soap_fault( 'Client', '', "Category field must be supplied." );
		} else {
			return new soap_fault( 'Client', '', "Category '" . $p_issue['category'] . "' not found for project '$t_project_name'." );
		}
	}

	if ( isset( $p_issue['version'] ) && !is_blank( $p_issue['version'] ) && !version_get_id( $p_issue['version'], $t_project_id ) ) {
		$t_error_when_version_not_found = config_get( 'mc_error_when_version_not_found' );
		if( $t_error_when_version_not_found == ON ) {
			$t_project_name = project_get_name( $t_project_id );
			return new soap_fault( 'Client', '', "Version '" . $p_issue['version'] . "' does not exist in project '$t_project_name'." );
		} else {
			$t_version_when_not_found = config_get( 'mc_version_when_not_found' );
			$p_issue['version'] = $t_version_when_not_found;
		}
	}

	if ( is_blank( $t_summary ) ) {
		return new soap_fault( 'Client', '', "Mandatory field 'summary' is missing." );
	}

	if ( is_blank( $t_description ) ) {
		return new soap_fault( 'Client', '', "Mandatory field 'description' is missing." );
	}

	// fields which we expect to always be set
	$t_bug_data = bug_get( $p_issue_id, true );
	$t_bug_data->project_id = $t_project_id;
	$t_bug_data->reporter_id = $t_reporter_id;
	$t_bug_data->handler_id = $t_handler_id;
	$t_bug_data->category_id = $t_category_id;
	$t_bug_data->summary = $t_summary;
	$t_bug_data->description = $t_description;

	// fields which might not be set
	if ( isset ( $p_issue['steps_to_reproduce'] ) )
		$t_bug_data->steps_to_reproduce = $p_issue['steps_to_reproduce'];
	if ( isset ( $p_issue['additional_information'] ) )
		$t_bug_data->additional_information = $p_issue['additional_information'];
	if ( isset( $p_issue['priority'] ) )
		$t_bug_data->priority = mci_get_priority_id( $p_issue['priority'] );
	if ( isset( $p_issue['severity'] ) )
		$t_bug_data->severity = mci_get_severity_id( $p_issue['severity'] );
	if ( isset( $p_issue['status'] ) )
		$t_bug_data->status = mci_get_status_id ( $p_issue['status'] );
	if ( isset ( $p_issue['reproducibility'] ) )
		$t_bug_data->reproducibility = mci_get_reproducibility_id( $p_issue['reproducibility'] );
	if ( isset ( $p_issue['resolution'] ) )
		$t_bug_data->resolution = mci_get_resolution_id( $p_issue['resolution'] );
	if ( isset ( $p_issue['projection'] ) )
		$t_bug_data->projection = mci_get_projection_id( $p_issue['projection'] );
	if ( isset ( $p_issue['eta'] ) )
		$t_bug_data->eta = mci_get_eta_id( $p_issue['eta'] );
	if ( isset ( $p_issue['view_state'] ) )
		$t_bug_data->view_state = mci_get_view_state_id( $p_issue['view_state'] );
	if ( isset ( $p_issue['date_submitted'] ) )
		$t_bug_data->date_submitted = $p_issue['date_submitted'];
	if ( isset ( $p_issue['date_updated'] ) )
		$t_bug_data->last_updated = $p_issue['last_updated'];
	if ( isset ( $p_issue['os'] ) )
		$t_bug_data->os = $p_issue['os'];
	if ( isset ( $p_issue['os_build'] ) )
		$t_bug_data->os_build = $p_issue['os_build'];
	if ( isset ( $p_issue['build'] ) )
		$t_bug_data->build = $p_issue['build'];
	if ( isset ( $p_issue['platform'] ) )
		$t_bug_data->platform = $p_issue['platform'];
	if ( isset ( $p_issue['version'] ) )
		$t_bug_data->version = $p_issue['version'];
	if ( isset ( $p_issue['fixed_in_version'] ) )
		$t_bug_data->fixed_in_version = $p_issue['fixed_in_version'];

	if ( isset( $p_issue['due_date'] ) && access_has_global_level( config_get( 'due_date_update_threshold' ) ) ) {
		$t_bug_data->due_date = mci_iso8601_to_timestamp( $p_issue['due_date'] );
	} else {
		$t_bug_data->due_date = date_get_null();
	}

	if( access_has_project_level( config_get( 'roadmap_update_threshold' ), $t_bug_data->project_id, $t_user_id ) ) {
		$t_bug_data->target_version = isset( $p_issue['target_version'] ) ? $p_issue['target_version'] : '';
	}

	mci_issue_set_custom_fields( $p_issue_id, $p_issue['custom_fields'], true );
	if ( isset ( $p_issue['monitors'] ) )
	    mci_issue_set_monitors( $p_issue_id , $t_user_id, $p_issue['monitors'] );

	if ( isset( $p_issue['notes'] ) && is_array( $p_issue['notes'] ) ) {
		foreach ( $p_issue['notes'] as $t_note ) {
			if ( isset( $t_note['view_state'] ) ) {
				$t_view_state = $t_note['view_state'];
			} else {
				$t_view_state = config_get( 'default_bugnote_view_status' );
			}

			if ( isset( $t_note['id'] ) && ( (int)$t_note['id'] > 0 ) ) {
				$t_bugnote_id = (integer)$t_note['id'];
				
				$t_view_state_id = mci_get_enum_id_from_objectref( 'view_state', $t_view_state );

				if ( bugnote_exists( $t_bugnote_id ) ) {
					bugnote_set_text( $t_bugnote_id, $t_note['text'] );
					bugnote_set_view_state( $t_bugnote_id, $t_view_state_id == VS_PRIVATE );
					bugnote_date_update( $t_bugnote_id );
					if ( isset( $t_note['time_tracking'] ) )
						bugnote_set_time_tracking( $t_bugnote_id, mci_get_time_tracking_from_note( $p_issue_id, $t_note ) );
				}
			} else {
				$t_view_state_id = mci_get_enum_id_from_objectref( 'view_state', $t_view_state );
				
				$note_type = isset ( $t_note['note_type'] ) ? (int) $t_note['note_type'] : BUGNOTE;
			    $note_attr = isset ( $t_note['note_type'] ) ? $t_note['note_attr'] : '';
				
				bugnote_add( $p_issue_id, $t_note['text'], mci_get_time_tracking_from_note( $p_issue_id, $t_note ), $t_view_state_id == VS_PRIVATE, $note_type, $note_attr, $t_user_id, FALSE );
			}
		}
	}

	# submit the issue
	return $t_bug_data->update( /* update_extended */ true, /* bypass_email */ true );
	
}
             # @@@ 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, 'fixed_in_version', $f_fixed_in_version);
             helper_call_custom_function('issue_update_notify', array($t_bug_id));
             $t_success = true;
         }
     }
     if (!$t_success) {
         $t_failed_ids[$t_bug_id] = lang_get('bug_actiongroup_access');
     }
     break;
 case 'UP_TARGET_VERSION':
     $f_target_version = gpc_get_string('target_version');
     $t_project_id = bug_get_field($t_bug_id, 'project_id');
     $t_success = false;
     if (access_has_bug_level(config_get('roadmap_update_threshold'), $t_bug_id)) {
         if (version_get_id($f_target_version, $t_project_id) !== false) {
             # @@@ 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, 'target_version', $f_target_version);
             helper_call_custom_function('issue_update_notify', array($t_bug_id));
             $t_success = true;
         }
     }
     if (!$t_success) {
         $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');
         # @@@ 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);
Example #12
0
	foreach ( $statuses as $l_status )
	{
		if ( array_key_exists( $l_status, $bugs) )
		{
			$bug_count_for_column += count( $bugs[$l_status] );
		}
	}

	$bug_percentage_by_column[$column] = ( $bug_count_for_column / $bug_count ) * 100;
}

if ($target_version)
{
	foreach($project_ids as $project_id)
	{
		$version_id = version_get_id($target_version, $project_id, true);
		if ($version_id !== false)
		{
			break;
		}
	}

	$version = version_get($version_id);
	$version_date = $version->date_order;
	$now = time();

	$time_diff = $version_date - $now;
	$time_hours = floor($time_diff / 3600);
	$time_days = floor($time_diff / 86400);
	$time_weeks = floor($time_diff / 604800);
access_ensure_project_level(config_get('manage_project_threshold'), $f_other_project_id);
if ($f_copy_from) {
    $t_src_project_id = $f_other_project_id;
    $t_dst_project_id = $f_project_id;
} else {
    if ($f_copy_to) {
        $t_src_project_id = $f_project_id;
        $t_dst_project_id = $f_other_project_id;
    } else {
        trigger_error(ERROR_VERSION_NO_ACTION, ERROR);
    }
}
# Get all active versions (i.e. exclude obsolete ones)
$t_rows = version_get_all_rows($t_src_project_id);
foreach ($t_rows as $t_row) {
    $t_dst_version_id = version_get_id($t_row['version'], $t_dst_project_id);
    if ($t_dst_version_id === false) {
        # Version does not exist in target project
        version_add($t_dst_project_id, $t_row['version'], $t_row['released'], $t_row['description'], $t_row['date_order']);
    } else {
        # Update existing version
        # Since we're ignoring obsolete versions, those marked as such in the
        # source project after an earlier copy operation will not be updated
        # in the target project.
        $t_version_data = new VersionData($t_row);
        $t_version_data->id = $t_dst_version_id;
        $t_version_data->project_id = $t_dst_project_id;
        version_update($t_version_data);
    }
}
form_security_purge('manage_proj_ver_copy');
Example #14
0
/**
 * Update Issue in database
 *
 * Created By KGB
 * @param string $p_username The name of the user trying to add the issue.
 * @param string $p_password The password of the user.
 * @param Array $p_issue A IssueData structure containing information about the new issue.
 * @return integer The id of the created issue.
 */
function mc_issue_update($p_username, $p_password, $p_issue_id, $p_issue)
{
    $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('Server', '', "Issue '{$p_issue_id}' does not exist.");
    }
    $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');
    }
    extract($p_issue, EXTR_PREFIX_ALL, 'v');
    $t_project_id = mci_get_project_id($v_project);
    $t_handler_id = mci_get_user_id($v_handler);
    $t_priority_id = mci_get_priority_id($v_priority);
    $t_severity_id = mci_get_severity_id($v_severity);
    $t_status_id = mci_get_status_id($v_status);
    $t_reproducibility_id = mci_get_reproducibility_id($v_reproducibility);
    $t_resolution_id = mci_get_resolution_id($v_resolution);
    $t_projection_id = mci_get_projection_id($v_projection);
    $t_eta_id = mci_get_eta_id($v_eta);
    $t_view_state_id = mci_get_view_state_id($v_view_state);
    $t_reporter_id = mci_get_user_id($v_reporter);
    if ($t_reporter_id == 0) {
        $t_reporter_id = $t_user_id;
    }
    if ($t_project_id == 0 || !project_exists($t_project_id)) {
        if ($t_project_id == 0) {
            return new soap_fault('Client', '', "Project '" . $v_project['name'] . "' does not exist.");
        } else {
            return new soap_fault('Client', '', "Project '{$t_project_id}' does not exist.");
        }
    }
    if (!access_has_bug_level(config_get('update_bug_threshold'), $p_issue_id, $t_user_id)) {
        return new soap_fault('Client', '', "User '{$t_user_id}' does not have access right to report issues.");
    }
    if ($t_handler_id != 0 && !user_exists($t_handler_id)) {
        return new soap_fault('Client', '', "User '{$t_handler_id}' does not exist.");
    }
    if (!in_array($v_category, mci_category_get_all_rows($t_project_id, $t_user_id))) {
        $t_error_when_category_not_found = config_get('mc_error_when_category_not_found');
        if ($t_error_when_category_not_found == ON) {
            if (is_blank($v_category) && count(category_get_all_rows($t_project_id)) == 0) {
                $v_category = '';
                // it is ok to have category as empty if project has no categories
            } else {
                return new soap_fault('Client', '', "Category '{$v_category}' does not exist in project '{$t_project_id}'.");
            }
        } else {
            $t_category_when_not_found = config_get('mc_category_when_not_found');
            $v_category = $t_category_when_not_found;
        }
    }
    if (isset($v_version) && !is_blank($v_version) && !version_get_id($v_version, $t_project_id)) {
        $t_error_when_version_not_found = config_get('mc_error_when_version_not_found');
        if ($t_error_when_version_not_found == ON) {
            $t_project_name = project_get_name($t_project_id);
            return new soap_fault('Client', '', "Version '{$v_version}' does not exist in project '{$t_project_name}'.");
        } else {
            $t_version_when_not_found = config_get('mc_version_when_not_found');
            $v_version = $t_version_when_not_found;
        }
    }
    if (is_blank($v_summary)) {
        return new soap_fault('Client', '', "Mandatory field 'summary' is missing.");
    }
    if (is_blank($v_description)) {
        return new soap_fault('Client', '', "Mandatory field 'description' is missing.");
    }
    if ($v_priority == 0) {
        $v_priority = config_get('default_bug_priority');
    }
    if ($v_severity == 0) {
        $v_severity = config_get('default_bug_severity');
    }
    if ($v_view_state == 0) {
        $v_view_state = config_get('default_bug_view_status');
    }
    if ($v_reproducibility == 0) {
        $v_reproducibility = 10;
    }
    $t_bug_data = new BugData();
    $t_bug_data->project_id = $t_project_id;
    $t_bug_data->reporter_id = $t_reporter_id;
    $t_bug_data->handler_id = $t_handler_id;
    $t_bug_data->priority = $t_priority_id;
    $t_bug_data->severity = $t_severity_id;
    $t_bug_data->reproducibility = $t_reproducibility_id;
    $t_bug_data->status = $t_status_id;
    $t_bug_data->resolution = $t_resolution_id;
    $t_bug_data->projection = $t_projection_id;
    $t_bug_data->category = $v_category;
    $t_bug_data->date_submitted = isset($v_date_submitted) ? $v_date_submitted : '';
    $t_bug_data->last_updated = isset($v_last_updated) ? $v_last_updated : '';
    $t_bug_data->eta = $t_eta_id;
    $t_bug_data->os = isset($v_os) ? $v_os : '';
    $t_bug_data->os_build = isset($v_os_build) ? $v_os_build : '';
    $t_bug_data->platform = isset($v_platform) ? $v_platform : '';
    $t_bug_data->version = isset($v_version) ? $v_version : '';
    $t_bug_data->fixed_in_version = isset($v_fixed_in_version) ? $v_fixed_in_version : '';
    $t_bug_data->build = isset($v_build) ? $v_build : '';
    $t_bug_data->view_state = $t_view_state_id;
    $t_bug_data->summary = $v_summary;
    $t_bug_data->sponsorship_total = isset($v_sponsorship_total) ? $v_sponsorship_total : 0;
    # omitted:
    # var $bug_text_id
    # $t_bug_data->profile_id;
    # extended info
    $t_bug_data->description = $v_description;
    $t_bug_data->steps_to_reproduce = isset($v_steps_to_reproduce) ? $v_steps_to_reproduce : '';
    $t_bug_data->additional_information = isset($v_additional_information) ? $v_additional_information : '';
    # submit the issue
    $t_is_success = bug_update($p_issue_id, $t_bug_data, true, false);
    mci_issue_set_custom_fields($p_issue_id, $v_custom_fields);
    if (isset($v_notes) && is_array($v_notes)) {
        foreach ($v_notes as $t_note) {
            if (isset($t_note['view_state'])) {
                $t_view_state = $t_note['view_state'];
            } else {
                $t_view_state = config_get('default_bugnote_view_status');
            }
            // TODO: consider supporting updating of bugnotes and detecting the ones that haven't changed.
            $t_view_state_id = mci_get_enum_id_from_objectref('view_state', $t_view_state);
            bugnote_add($p_issue_id, $t_note['text'], '0:00', $t_view_state_id == VS_PRIVATE, BUGNOTE, '', $t_user_id, FALSE);
        }
    }
    return $t_is_success;
}
Example #15
0
function get_restore_file_by_version_name($version)
{
    $ver_id = version_get_id($version);
    if ($ver_id === false) {
        return false;
    }
    $t_acra_ver_table = plugin_table("version");
    $query = "SELECT * FROM {$t_acra_ver_table} WHERE `version_id` = " . $ver_id;
    $result = db_query_bound($query);
    $row = db_fetch_array($result);
    if ($row === false) {
        return false;
    }
    return $row['map_file'];
}
Example #16
0
$t_show_product_build = $t_show_versions && in_array('product_build', $t_fields) && config_get('enable_product_build') == ON;
$t_product_build = $t_show_product_build ? string_display_line($t_bug->build) : '';
$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_product_version_string = '';
$t_target_version_string = '';
$t_fixed_in_version_string = '';
if ($t_show_product_version || $t_show_fixed_in_version || $t_show_target_version) {
    $t_version_rows = version_get_all_rows($t_bug->project_id);
    if ($t_show_product_version) {
        $t_product_version_string = prepare_version_string($t_bug->project_id, version_get_id($t_bug->version, $t_bug->project_id));
    }
    if ($t_show_target_version) {
        $t_target_version_string = prepare_version_string($t_bug->project_id, version_get_id($t_bug->target_version, $t_bug->project_id));
    }
    if ($t_show_fixed_in_version) {
        $t_fixed_in_version_string = prepare_version_string($t_bug->project_id, version_get_id($t_bug->fixed_in_version, $t_bug->project_id));
    }
}
$t_product_version_string = string_display_line($t_product_version_string);
$t_target_version_string = string_display_line($t_target_version_string);
$t_fixed_in_version_string = string_display_line($t_fixed_in_version_string);
$t_bug_id = $f_bug_id;
$t_form_title = lang_get('bug_view_title');
$t_wiki_link = config_get_global('wiki_enable') == ON ? 'wiki.php?id=' . $f_bug_id : '';
if (access_has_bug_level(config_get('view_history_threshold'), $f_bug_id)) {
    $t_history_link = "view.php?id={$f_bug_id}&history=1#history";
} else {
    $t_history_link = '';
}
$t_show_reminder_link = !current_user_is_anonymous() && !bug_is_readonly($f_bug_id) && access_has_bug_level(config_get('bug_reminder_threshold'), $f_bug_id);
$t_bug_reminder_link = 'bug_reminder_page.php?bug_id=' . $f_bug_id;
Example #17
0
$t_eta = string_display_line(get_enum_element('eta', $t_bug->eta));
$t_summary = string_display_line_links(bug_format_summary($f_bug_id, SUMMARY_FIELD));
$t_description = string_display_links($t_bug->description);
$t_steps_to_reproduce = string_display_links($t_bug->steps_to_reproduce);
$t_additional_information = string_display_links($t_bug->additional_information);
$t_view_state = $t_show_view_state ? get_enum_element('view_state', $t_bug->view_state) : '';
if ($t_show_due_date) {
    if (!date_is_null($t_bug->due_date)) {
        $t_due_date = date(config_get('normal_date_format'), $t_bug->due_date);
    } else {
        $t_due_date = '';
    }
}
$t_product_version = $t_show_product_version ? string_display_line(prepare_version_string($t_bug->project_id, version_get_id($t_bug->version, $t_bug->project_id))) : '';
$t_target_version = $t_show_target_version ? string_display_line(prepare_version_string($t_bug->project_id, version_get_id($t_bug->target_version, $t_bug->project_id))) : '';
$t_fixed_in_version = $t_show_fixed_in_version ? string_display_line(prepare_version_string($t_bug->project_id, version_get_id($t_bug->fixed_in_version, $t_bug->project_id))) : '';
html_page_top1(bug_format_summary($f_bug_id, SUMMARY_CAPTION));
html_head_end();
html_body_begin();
echo '<br />';
echo '<table class="width100" cellspacing="1">';
echo '<tr>';
echo '<td class="form-title" colspan="6">';
echo '<div class="center">', $t_window_title;
if (!is_blank($t_project_name)) {
    echo ' - ' . $t_project_name;
}
echo '</div></td>';
echo '</tr>';
echo '<tr>';
echo '<td class="form-title" colspan="6">', lang_get('bug_view_title'), '</td>';
Example #18
0
/**
 * Submit the specified version details.
 *
 * @param string   $p_username The name of the user trying to add the issue.
 * @param string   $p_password The password of the user.
 * @param stdClass $p_version  A ProjectVersionData structure containing information about the new version.
 * @return integer  The id of the created version.
 */
function mc_project_version_add($p_username, $p_password, stdClass $p_version)
{
    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();
    }
    $p_version = SoapObjectsFactory::unwrapObject($p_version);
    $t_project_id = $p_version['project_id'];
    $g_project_override = $t_project_id;
    $t_name = $p_version['name'];
    $t_released = $p_version['released'];
    $t_description = $p_version['description'];
    $t_date_order = $p_version['date_order'];
    if (is_blank($t_date_order)) {
        $t_date_order = null;
    } else {
        $t_date_order = SoapObjectsFactory::parseDateTimeString($t_date_order);
    }
    $t_obsolete = isset($p_version['obsolete']) ? $p_version['obsolete'] : false;
    if (is_blank($t_project_id)) {
        return SoapObjectsFactory::newSoapFault('Client', 'Mandatory field "project_id" was missing');
    }
    if (!project_exists($t_project_id)) {
        return SoapObjectsFactory::newSoapFault('Client', 'Project \'' . $t_project_id . '\' does not exist.');
    }
    if (!mci_has_readwrite_access($t_user_id, $t_project_id)) {
        return mci_soap_fault_access_denied($t_user_id);
    }
    if (!mci_has_access(config_get('manage_project_threshold'), $t_user_id, $t_project_id)) {
        return mci_soap_fault_access_denied($t_user_id);
    }
    if (is_blank($t_name)) {
        return SoapObjectsFactory::newSoapFault('Client', 'Mandatory field "name" was missing');
    }
    if (!version_is_unique($t_name, $t_project_id)) {
        return SoapObjectsFactory::newSoapFault('Client', 'Version exists for project');
    }
    if ($t_released === false) {
        $t_released = VERSION_FUTURE;
    } else {
        $t_released = VERSION_RELEASED;
    }
    if (version_add($t_project_id, $t_name, $t_released, $t_description, $t_date_order, $t_obsolete)) {
        return version_get_id($t_name, $t_project_id);
    }
    return null;
}
Example #19
0
/**
 * Submit the specified version details.
 *
 * @param string $p_username  The name of the user trying to add the issue.
 * @param string $p_password  The password of the user.
 * @param Array $p_version  A ProjectVersionData structure containing information about the new verison.
 * @return integer  The id of the created version.
 */
function mc_project_version_add($p_username, $p_password, $p_version)
{
    $t_user_id = mci_check_login($p_username, $p_password);
    if ($t_user_id === false) {
        return mci_soap_fault_login_failed();
    }
    $t_project_id = $p_version['project_id'];
    $t_name = $p_version['name'];
    $t_released = $p_version['released'];
    $t_description = $p_version['description'];
    $t_date_order = $p_version['date_order'];
    if (is_blank($t_project_id)) {
        return new soap_fault('Client', '', 'Mandatory field "project_id" was missing');
    }
    if (!project_exists($t_project_id)) {
        return new soap_fault('Client', '', "Project '{$t_project_id}' does not exist.");
    }
    if (!mci_has_readwrite_access($t_user_id, $t_project_id)) {
        return mci_soap_fault_access_denied($t_user_id);
    }
    if (!mci_has_access(config_get('manage_project_threshold'), $t_user_id, $t_project_id)) {
        return mci_soap_fault_access_denied($t_user_id);
    }
    if (is_blank($t_name)) {
        return new soap_fault('Client', '', 'Mandatory field "name" was missing');
    }
    if (!version_is_unique($t_name, $t_project_id)) {
        return new soap_fault('Client', '', 'Version exists for project', 'The version you attempted to add already exists for this project');
    }
    if ($t_released === false) {
        $t_released = VERSION_FUTURE;
    } else {
        $t_released = VERSION_RELEASED;
    }
    if (version_add($t_project_id, $t_name, $t_released, $t_description)) {
        $t_version_id = version_get_id($t_name, $t_project_id);
        if (!is_blank($t_date_order)) {
            $t_version = version_get($t_version_id);
            $t_version->date_order = date("Y-m-d H:i:s", strtotime($t_date_order));
            version_update($t_version);
        }
        return $t_version_id;
    }
    return null;
}
Example #20
0
$tpl_show_product_build = $tpl_show_versions && in_array('product_build', $t_fields) && config_get('enable_product_build') == ON;
$tpl_product_build = $tpl_show_product_build ? string_display_line($tpl_bug->build) : '';
$tpl_show_target_version = $tpl_show_versions && in_array('target_version', $t_fields) && access_has_bug_level(config_get('roadmap_view_threshold'), $f_bug_id);
$tpl_product_version_string = '';
$tpl_target_version_string = '';
$tpl_fixed_in_version_string = '';
if ($tpl_show_product_version || $tpl_show_fixed_in_version || $tpl_show_target_version) {
    $t_version_rows = version_get_all_rows($tpl_bug->project_id);
    if ($tpl_show_product_version) {
        $tpl_product_version_string = prepare_version_string($tpl_bug->project_id, version_get_id($tpl_bug->version, $tpl_bug->project_id), $t_version_rows);
    }
    if ($tpl_show_target_version) {
        $tpl_target_version_string = prepare_version_string($tpl_bug->project_id, version_get_id($tpl_bug->target_version, $tpl_bug->project_id), $t_version_rows);
    }
    if ($tpl_show_fixed_in_version) {
        $tpl_fixed_in_version_string = prepare_version_string($tpl_bug->project_id, version_get_id($tpl_bug->fixed_in_version, $tpl_bug->project_id), $t_version_rows);
    }
}
$tpl_product_version_string = string_display_line($tpl_product_version_string);
$tpl_target_version_string = string_display_line($tpl_target_version_string);
$tpl_fixed_in_version_string = string_display_line($tpl_fixed_in_version_string);
$tpl_bug_id = $f_bug_id;
$tpl_form_title = lang_get('bug_view_title');
$tpl_wiki_link = config_get_global('wiki_enable') == ON ? 'wiki.php?id=' . $f_bug_id : '';
if (access_has_bug_level(config_get('view_history_threshold'), $f_bug_id)) {
    $tpl_history_link = "view.php?id={$f_bug_id}&history=1#history";
} else {
    $tpl_history_link = '';
}
$tpl_show_reminder_link = !current_user_is_anonymous() && !bug_is_readonly($f_bug_id) && access_has_bug_level(config_get('bug_reminder_threshold'), $f_bug_id);
$tpl_bug_reminder_link = 'bug_reminder_page.php?bug_id=' . $f_bug_id;
    $t_version = trim($t_version);
    if (version_is_unique($t_version, $f_project_id)) {
        version_add($f_project_id, $t_version);
    } else {
        if (1 == $t_version_count) {
            # We only error out on duplicates when a single value was
            #  given.  If multiple values were given, we just add the
            #  ones we can.  The others already exist so it isn't really
            #  an error.
            trigger_error(ERROR_VERSION_DUPLICATE, ERROR);
        }
    }
}
form_security_purge('manage_proj_ver_add');
if (true == $f_add_and_edit) {
    $t_version_id = version_get_id($t_version, $f_project_id);
    $t_redirect_url = 'manage_proj_ver_edit_page.php?version_id=' . $t_version_id;
} else {
    $t_redirect_url = 'manage_proj_edit_page.php?project_id=' . $f_project_id;
}
html_page_top1();
html_meta_redirect($t_redirect_url);
html_page_top2();
?>

<br />
<div align="center">
<?php 
echo lang_get('operation_successful') . '<br />';
print_bracket_link($t_redirect_url, lang_get('proceed'));
?>
Example #22
0
/**
 * Check whether the version name is unique
 * Returns true if the name is unique, false otherwise
 * @param string $p_version
 * @param int $p_project_id
 * @return bool
 */
function version_is_unique($p_version, $p_project_id = null)
{
    return version_get_id($p_version, $p_project_id) === false;
}
Example #23
0
function print_version_option_list($p_version = '', $p_project_id = null, $p_released = null, $p_leading_blank = true, $p_with_subs = false)
{
    if (null === $p_project_id) {
        $c_project_id = helper_get_current_project();
    } else {
        $c_project_id = db_prepare_int($p_project_id);
    }
    if ($p_with_subs) {
        $versions = version_get_all_rows_with_subs($c_project_id, $p_released, null);
    } else {
        $versions = version_get_all_rows($c_project_id, $p_released, null);
    }
    # Ensure the selected version (if specified) is included in the list
    # Note: Filter API specifies selected versions as an array
    if (!is_array($p_version)) {
        if (!empty($p_version)) {
            $t_version_id = version_get_id($p_version, $c_project_id);
            if ($t_version_id !== false) {
                $versions[] = version_cache_row($t_version_id);
            }
        }
    }
    if ($p_leading_blank) {
        echo '<option value=""></option>';
    }
    $t_listed = array();
    $t_max_length = config_get('max_dropdown_length');
    $t_show_version_dates = access_has_project_level(config_get('show_version_dates_threshold'));
    $t_short_date_format = config_get('short_date_format');
    foreach ($versions as $version) {
        # If the current version is obsolete, and current version not equal to $p_version,
        # then skip it.
        if ((int) $version['obsolete'] == 1) {
            if ($version['version'] != $p_version) {
                continue;
            }
        }
        $t_version = string_attribute($version['version']);
        if (!in_array($t_version, $t_listed)) {
            $t_listed[] = $t_version;
            echo '<option value="' . $t_version . '"';
            check_selected($p_version, $version['version']);
            $t_version_string = string_attribute(prepare_version_string($c_project_id, $version['id']));
            echo '>', string_shorten($t_version_string, $t_max_length), '</option>';
        }
    }
}
Example #24
0
/**
 * Update Issue in database
 *
 * Created By KGB
 * @param string $p_username The name of the user trying to add the issue.
 * @param string $p_password The password of the user.
 * @param Array $p_issue A IssueData structure containing information about the new issue.
 * @return integer The id of the created issue.
 */
function mc_issue_update($p_username, $p_password, $p_issue_id, $p_issue)
{
    $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 new soap_fault('Client', '', "Issue '{$p_issue_id}' does not exist.");
    }
    $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);
    }
    $t_project_id = mci_get_project_id($p_issue['project']);
    $t_handler_id = isset($p_issue['handler']) ? mci_get_user_id($p_issue['handler']) : 0;
    $t_priority_id = isset($p_issue['priority']) ? mci_get_priority_id($p_issue['priority']) : config_get('default_bug_priority');
    $t_severity_id = isset($p_issue['severity']) ? mci_get_severity_id($p_issue['severity']) : config_get('default_bug_severity');
    $t_status_id = isset($p_issue['status']) ? mci_get_status_id($p_issue['status']) : config_get('bug_submit_status');
    $t_reproducibility_id = isset($p_issue['reproducibility']) ? mci_get_reproducibility_id($p_issue['reproducibility']) : config_get('default_bug_reproducibility');
    $t_resolution_id = isset($p_issue['resolution']) ? mci_get_resolution_id($p_issue['resolution']) : config_get('default_bug_resolution');
    $t_projection_id = isset($p_issue['projection']) ? mci_get_projection_id($p_issue['projection']) : config_get('default_bug_resolution');
    $t_eta_id = isset($p_issue['eta']) ? mci_get_eta_id($p_issue['eta']) : config_get('default_bug_eta');
    $t_view_state_id = isset($p_issue['view_state']) ? mci_get_view_state_id($p_issue['view_state']) : config_get('default_bug_view_status');
    $t_reporter_id = isset($p_issue['reporter']) ? mci_get_user_id($p_issue['reporter']) : 0;
    $t_project = $p_issue['project'];
    $t_summary = isset($p_issue['summary']) ? $p_issue['summary'] : '';
    $t_description = isset($p_issue['description']) ? $p_issue['description'] : '';
    $t_additional_information = isset($p_issue['additional_information']) ? $p_issue['additional_information'] : '';
    $t_steps_to_reproduce = isset($p_issue['steps_to_reproduce']) ? $p_issue['steps_to_reproduce'] : '';
    $t_build = isset($p_issue['build']) ? $p_issue['build'] : '';
    $t_platform = isset($p_issue['platform']) ? $p_issue['platform'] : '';
    $t_os = isset($p_issue['os']) ? $p_issue['os'] : '';
    $t_os_build = isset($p_issue['os_build']) ? $p_issue['os_build'] : '';
    $t_sponsorship_total = isset($p_issue['sponsorship_total']) ? $p_issue['sponsorship_total'] : 0;
    if ($t_reporter_id == 0) {
        $t_reporter_id = $t_user_id;
    }
    if ($t_project_id == 0 || !project_exists($t_project_id)) {
        if ($t_project_id == 0) {
            return new soap_fault('Client', '', "Project '" . $t_project['name'] . "' does not exist.");
        }
        return new soap_fault('Client', '', "Project '{$t_project_id}' does not exist.");
    }
    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, "Not enough rights to update issues");
    }
    if ($t_handler_id != 0 && !user_exists($t_handler_id)) {
        return new soap_fault('Client', '', "User '{$t_handler_id}' does not exist.");
    }
    $t_category = isset($p_issue['category']) ? $p_issue['category'] : null;
    $t_category_id = translate_category_name_to_id($t_category, $t_project_id);
    if ($t_category_id == 0 && !config_get('allow_no_category')) {
        if (isset($p_issue['category']) && !is_blank($p_issue['category'])) {
            return new soap_fault('Client', '', "Category field must be supplied.");
        } else {
            return new soap_fault('Client', '', "Category '" . $p_issue['category'] . "' not found for project '{$t_project_name}'.");
        }
    }
    if (isset($p_issue['version']) && !is_blank($p_issue['version']) && !version_get_id($p_issue['version'], $t_project_id)) {
        $t_error_when_version_not_found = config_get('mc_error_when_version_not_found');
        if ($t_error_when_version_not_found == ON) {
            $t_project_name = project_get_name($t_project_id);
            return new soap_fault('Client', '', "Version '" . $p_issue['version'] . "' does not exist in project '{$t_project_name}'.");
        } else {
            $t_version_when_not_found = config_get('mc_version_when_not_found');
            $p_issue['version'] = $t_version_when_not_found;
        }
    }
    if (is_blank($t_summary)) {
        return new soap_fault('Client', '', "Mandatory field 'summary' is missing.");
    }
    if (is_blank($t_description)) {
        return new soap_fault('Client', '', "Mandatory field 'description' is missing.");
    }
    if ($t_priority_id == 0) {
        $t_priority_id = config_get('default_bug_priority');
    }
    if ($t_severity_id == 0) {
        $t_severity_id = config_get('default_bug_severity');
    }
    if ($t_view_state_id == 0) {
        $t_view_state_id = config_get('default_bug_view_status');
    }
    if ($t_reproducibility_id == 0) {
        $t_reproducibility_id = config_get('default_bug_reproducibility');
    }
    $t_bug_data = new BugData();
    $t_bug_data->id = $p_issue_id;
    $t_bug_data->project_id = $t_project_id;
    $t_bug_data->reporter_id = $t_reporter_id;
    $t_bug_data->handler_id = $t_handler_id;
    $t_bug_data->priority = $t_priority_id;
    $t_bug_data->severity = $t_severity_id;
    $t_bug_data->reproducibility = $t_reproducibility_id;
    $t_bug_data->status = $t_status_id;
    $t_bug_data->resolution = $t_resolution_id;
    $t_bug_data->projection = $t_projection_id;
    $t_bug_data->category_id = $t_category_id;
    $t_bug_data->date_submitted = isset($v_date_submitted) ? $v_date_submitted : '';
    $t_bug_data->last_updated = isset($v_last_updated) ? $v_last_updated : '';
    $t_bug_data->eta = $t_eta_id;
    $t_bug_data->os = $t_os;
    $t_bug_data->os_build = $t_os_build;
    $t_bug_data->platform = $t_platform;
    $t_bug_data->version = isset($p_issue['version']) ? $p_issue['version'] : '';
    $t_bug_data->fixed_in_version = isset($p_issue['fixed_in_version']) ? $p_issue['fixed_in_version'] : '';
    $t_bug_data->build = $t_build;
    $t_bug_data->view_state = $t_view_state_id;
    $t_bug_data->summary = $t_summary;
    $t_bug_data->sponsorship_total = $t_sponsorship_total;
    if (isset($p_issue['due_date']) && access_has_global_level(config_get('due_date_update_threshold'))) {
        $t_bug_data->due_date = mci_iso8601_to_timestamp($p_issue['due_date']);
    } else {
        $t_bug_data->due_date = date_get_null();
    }
    if (access_has_project_level(config_get('roadmap_update_threshold'), $t_bug_data->project_id, $t_user_id)) {
        $t_bug_data->target_version = isset($p_issue['target_version']) ? $p_issue['target_version'] : '';
    }
    # omitted:
    # var $bug_text_id
    # $t_bug_data->profile_id;
    # extended info
    $t_bug_data->description = $t_description;
    $t_bug_data->steps_to_reproduce = isset($t_steps_to_reproduce) ? $t_steps_to_reproduce : '';
    $t_bug_data->additional_information = isset($t_additional_information) ? $t_additional_information : '';
    # submit the issue
    $t_is_success = $t_bug_data->update(true, true);
    mci_issue_set_custom_fields($p_issue_id, $p_issue['custom_fields'], true);
    if (isset($p_issue['notes']) && is_array($p_issue['notes'])) {
        foreach ($p_issue['notes'] as $t_note) {
            if (isset($t_note['view_state'])) {
                $t_view_state = $t_note['view_state'];
            } else {
                $t_view_state = config_get('default_bugnote_view_status');
            }
            if (isset($t_note['id']) && (int) $t_note['id'] > 0) {
                $t_bugnote_id = (int) $t_note['id'];
                if (bugnote_exists($t_bugnote_id)) {
                    bugnote_set_text($t_bugnote_id, $t_note['text']);
                    bugnote_set_view_state($t_bugnote_id, $t_view_state_id == VS_PRIVATE);
                    bugnote_date_update($t_bugnote_id);
                    if (isset($t_note['time_tracking'])) {
                        bugnote_set_time_tracking($t_bugnote_id, mci_get_time_tracking_from_note($p_issue_id, $t_note));
                    }
                }
            } else {
                $t_view_state_id = mci_get_enum_id_from_objectref('view_state', $t_view_state);
                bugnote_add($p_issue_id, $t_note['text'], mci_get_time_tracking_from_note($p_issue_id, $t_note), $t_view_state_id == VS_PRIVATE, BUGNOTE, '', $t_user_id, FALSE);
            }
        }
    }
    return $t_is_success;
}