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)); } }
trigger_error(ERROR_EMPTY_FIELD, ERROR); } # We reverse the array so that if the user enters multiple versions # they will likely appear with the last item entered at the top of the list # (i.e. in reverse chronological order). Unless we find a way to make the # date_order fields different for each one, however, this is fragile, since # the DB may actually pull the rows out in any order $t_versions = array_reverse(explode('|', $f_version)); $t_version_count = count($t_versions); foreach ($t_versions as $t_version) { if (is_blank($t_version)) { continue; } $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 {
/** * 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; }
/** * 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; } }
auth_reauthenticate(); require_once SPECMANAGEMENT_CORE_URI . 'specmanagement_database_api.php'; $specmanagement_database_api = new specmanagement_database_api(); $update = gpc_get_bool('update', false); $addversion = gpc_get_bool('addversion', false); /** * Submit new version */ if ($addversion && isset($_POST['new_version_name']) && isset($_POST['new_version_date'])) { $project_id = helper_get_current_project(); $new_version_date = new DateTime($_POST['new_version_date']); $new_version_date_timestamp = date_timestamp_get($new_version_date); $new_version_name = $_POST['new_version_name']; $new_version_name_trimmed = trim(preg_replace('/\\s+/', ' ', $new_version_name)); if (version_is_unique($new_version_name_trimmed, $project_id) && strlen($new_version_name_trimmed) > 0) { version_add($project_id, $new_version_name_trimmed, false, '', $new_version_date_timestamp); } } /** * Change all existing versions */ if ($update && isset($_POST['version_ids'])) { $version_ids = $_POST['version_ids']; $versions = $_POST['version']; $date_order = $_POST['date_order']; $type = $_POST['type']; $description = $_POST['description']; for ($version_index = 0; $version_index < count($version_ids); $version_index++) { $version = version_get($version_ids[$version_index]); $version_id = $version->id; $project_id = version_get_field($version_id, 'project_id');
/** * 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; }
require_api('version_api.php'); form_security_validate('manage_proj_ver_copy'); auth_reauthenticate(); $f_project_id = gpc_get_int('project_id'); $f_other_project_id = gpc_get_int('other_project_id'); $f_copy_from = gpc_get_bool('copy_from'); $f_copy_to = gpc_get_bool('copy_to'); project_ensure_exists($f_project_id); project_ensure_exists($f_other_project_id); access_ensure_project_level(config_get('manage_project_threshold'), $f_project_id); 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); } } $t_rows = version_get_all_rows($t_src_project_id); foreach ($t_rows as $t_row) { if (version_is_unique($t_row['version'], $t_dst_project_id)) { $t_version_id = version_add($t_dst_project_id, $t_row['version'], $t_row['released'], $t_row['description'], $t_row['date_order']); event_signal('EVENT_MANAGE_VERSION_CREATE', array($t_version_id)); } } form_security_purge('manage_proj_ver_copy'); print_header_redirect('manage_proj_edit_page.php?project_id=' . $f_project_id);
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'); }