/** * Get all categories of a project. * * @param string $p_username The name of the user trying to access the categories. * @param string $p_password The password of the user. * @param integer $p_project_id The id of the project to retrieve the categories for. * @return Array of categorie names */ function mc_project_get_categories($p_username, $p_password, $p_project_id) { $t_user_id = mci_check_login($p_username, $p_password); if ($t_user_id === false) { return mci_soap_fault_login_failed(); } if (!project_exists($p_project_id)) { return new soap_fault('Client', '', "Project '{$p_project_id}' does not exist."); } if (!mci_has_readonly_access($t_user_id, $p_project_id)) { return mci_soap_fault_access_denied($t_user_id); } $t_result = array(); $t_cat_array = category_get_all_rows($p_project_id); foreach ($t_cat_array as $t_category_row) { $t_result[] = $t_category_row['name']; } return $t_result; }
<!-- GLOBAL CATEGORIES --> <a name="categories" /> <div align="center"> <table class="width75" cellspacing="1"> <!-- Title --> <tr> <td class="form-title" colspan="3"> <?php echo lang_get('global_categories'); ?> </td> </tr> <?php $t_categories = category_get_all_rows(ALL_PROJECTS); $t_can_update_global_cat = access_has_global_level(config_get('manage_site_threshold')); if (count($t_categories) > 0) { ?> <tr class="row-category"> <td> <?php echo lang_get('category'); ?> </td> <td> <?php echo lang_get('assign_to'); ?> </td> <?php
function print_category_option_list($p_category_id = 0, $p_project_id = null) { $t_category_table = db_get_table('category'); $t_project_table = db_get_table('project'); if (null === $p_project_id) { $t_project_id = helper_get_current_project(); } else { $t_project_id = $p_project_id; } if (config_get('allow_no_category')) { echo "<option value=\"0\"", check_selected($p_category_id, 0), '>'; echo category_full_name(0, false), '</option>'; } else { if (0 == $p_category_id) { echo "<option value=\"0\"", check_selected($p_category_id, 0), '>'; echo string_attribute(lang_get('select_option')), '</option>'; } } $cat_arr = category_get_all_rows($t_project_id, null, true); foreach ($cat_arr as $t_category_row) { $t_category_id = (int) $t_category_row['id']; echo "<option value=\"{$t_category_id}\""; check_selected($p_category_id, $t_category_id); echo '>' . string_attribute(category_full_name($t_category_id, $t_category_row['project_id'] != $t_project_id)) . '</option>'; } }
/** * Since categories can be orphaned we need to grab all unique instances of category * We check in the project category table and in the bug table * We put them all in one array and make sure the entries are unique * * @param integer $p_category_id A category identifier. * @param integer $p_project_id A project identifier. * @return void */ function print_category_option_list($p_category_id = 0, $p_project_id = null) { if (null === $p_project_id) { $t_project_id = helper_get_current_project(); } else { $t_project_id = $p_project_id; } $t_cat_arr = category_get_all_rows($t_project_id, null, true); if (config_get('allow_no_category')) { echo '<option value="0"'; check_selected($p_category_id, 0); echo '>'; echo category_full_name(0, false), '</option>'; } else { if (0 == $p_category_id) { if (count($t_cat_arr) == 1) { $p_category_id = (int) $t_cat_arr[0]['id']; } else { echo '<option value="0"'; echo check_selected($p_category_id, 0); echo '>'; echo string_attribute(lang_get('select_option')) . '</option>'; } } } foreach ($t_cat_arr as $t_category_row) { $t_category_id = (int) $t_category_row['id']; echo '<option value="' . $t_category_id . '"'; check_selected($p_category_id, $t_category_id); echo '>' . string_attribute(category_full_name($t_category_id, $t_category_row['project_id'] != $t_project_id)) . '</option>'; } }
<br /> <!-- PROJECT CATEGORIES --> <div align="center" id="categories"> <table class="width75" cellspacing="1"> <!-- Title --> <tr> <td class="form-title" colspan="3"> <?php echo lang_get('categories'); ?> </td> </tr> <?php $t_categories = category_get_all_rows($f_project_id); if (count($t_categories) > 0) { ?> <tr class="row-category"> <td> <?php echo lang_get('category'); ?> </td> <td> <?php echo lang_get('assign_to'); ?> </td> <td class="center"> <?php
/** * Construct an enumeration for all categories for the current project. * The enumeration will be empty if current project is ALL PROJECTS. * Enumerations format is: "abc|lmn|xyz" * To use this in a custom field type "=categories" in the possible values field. * @return string */ function custom_function_default_enum_categories() { $t_categories = category_get_all_rows(helper_get_current_project()); $t_enum = array(); foreach ($t_categories as $t_category) { $t_enum[] = $t_category['name']; } $t_possible_values = implode('|', $t_enum); return $t_possible_values; }
# -------------------------------------------------------- # $Id: manage_proj_cat_copy.php,v 1.21 2005/02/27 15:33:01 jlatour Exp $ # -------------------------------------------------------- require_once 'core.php'; $t_core_path = config_get('core_path'); require_once $t_core_path . 'category_api.php'; $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'); 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_CATEGORY_NO_ACTION, ERROR); } } $rows = category_get_all_rows($t_src_project_id); foreach ($rows as $row) { $t_category = $row['category']; if (category_is_unique($t_dst_project_id, $t_category)) { category_add($t_dst_project_id, $t_category); } } print_header_redirect('manage_proj_edit_page.php?project_id=' . $f_project_id);
/** * Convert a category name to a category id for a given project * @param string $p_category_name Category name. * @param integer $p_project_id Project id. * @return integer category id or 0 if not found */ function translate_category_name_to_id($p_category_name, $p_project_id) { if (!isset($p_category_name)) { return 0; } $t_cat_array = category_get_all_rows($p_project_id); foreach ($t_cat_array as $t_category_row) { if ($t_category_row['name'] == $p_category_name) { return $t_category_row['id']; } } return 0; }
} $t_project_index = 0; version_cache_array_rows($t_project_ids); category_cache_array_rows_by_project($t_project_ids); foreach ($t_project_ids as $t_project_id) { $t_project_name = project_get_field($t_project_id, 'name'); $t_can_view_private = access_has_project_level(config_get('private_bug_threshold'), $t_project_id); $t_limit_reporters = config_get('limit_reporters'); $t_user_access_level_is_reporter = REPORTER == access_get_project_level($t_project_id); $t_resolved = config_get('bug_resolved_status_threshold'); $t_bug_table = db_get_table('mantis_bug_table'); $t_relation_table = db_get_table('mantis_bug_relationship_table'); # grab version info for later use $t_version_rows = version_get_all_rows($t_project_id, null, false); # cache category info, but ignore the results for now category_get_all_rows($t_project_id); $t_project_header_printed = false; foreach ($t_version_rows as $t_version_row) { $t_version_header_printed = false; $t_version = $t_version_row['version']; $t_version_id = $t_version_row['id']; # Skip all versions except the specified one (if any). if ($f_version_id != -1 && $f_version_id != $t_version_id) { continue; } $query = "SELECT sbt.*, dbt.fixed_in_version AS parent_version, rt.source_bug_id\n FROM {$t_bug_table} AS sbt\n LEFT JOIN {$t_relation_table} AS rt\n ON sbt.id=rt.destination_bug_id AND rt.relationship_type=" . BUG_DEPENDANT . "\n LEFT JOIN {$t_bug_table} AS dbt ON dbt.id=rt.source_bug_id\n WHERE sbt.project_id=" . db_param() . "\n AND sbt.fixed_in_version=" . db_param() . "\n ORDER BY sbt.status ASC, sbt.last_updated DESC"; $t_description = version_get_field($t_version_id, 'description'); $t_first_entry = true; $t_issue_ids = array(); $t_issue_parents = array(); $t_issue_handlers = array();
# # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with MantisBT. If not, see <http://www.gnu.org/licenses/>. require_once 'core.php'; require_once 'compress_api.php'; require_once 'filter_api.php'; require_once 'last_visited_api.php'; auth_ensure_user_authenticated(); $t_current_user_id = auth_get_current_user_id(); # Improve performance by caching category data in one pass category_get_all_rows(helper_get_current_project()); compress_enable(); # don't index my view page html_robots_noindex(); html_page_top1(plugin_lang_get('title')); if (current_user_get_pref('refresh_delay') > 0) { html_meta_redirect(plugin_page('dashboard', true), current_user_get_pref('refresh_delay') * 60); } html_page_top2(); print_recently_visited(); $f_page_number = gpc_get_int('page_number', 1); $t_per_page = config_get('my_view_bug_count'); $t_bug_count = null; $t_page_count = null; $t_filters = filter_db_get_available_queries(); $t_config_boxes = plugin_config_get('boxes');
/** * Get all categories of a project. * * @param string $p_username The name of the user trying to access the categories. * @param string $p_password The password of the user. * @param integer $p_project_id The id of the project to retrieve the categories for. * @return array An array of category names */ function mc_project_get_categories($p_username, $p_password, $p_project_id) { 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 (!project_exists($p_project_id)) { return SoapObjectsFactory::newSoapFault('Client', 'Project \'' . $p_project_id . '\' does not exist.'); } $g_project_override = $p_project_id; if (!mci_has_readonly_access($t_user_id, $p_project_id)) { return mci_soap_fault_access_denied($t_user_id); } $t_result = array(); $t_cat_array = category_get_all_rows($p_project_id); foreach ($t_cat_array as $t_category_row) { $t_result[] = $t_category_row['name']; } return $t_result; }
/** * Get a distinct array of categories accessible to the current user for * the specified projects. If no project is specified, use the current project. * If the current project is ALL_PROJECTS get all categories for all accessible projects. * For all cases, get global categories and subproject categories according to configured inheritance settings. * @param mixed $p_project_id A specific project or null * @return array A unique array of category names */ function category_get_filter_list( $p_project_id = null ) { if( null === $p_project_id ) { $t_project_id = helper_get_current_project(); } else { $t_project_id = $p_project_id; } if( $t_project_id == ALL_PROJECTS ) { $t_project_ids = current_user_get_accessible_projects(); } else { $t_project_ids = array( $t_project_id ); } $t_subproject_ids = array(); foreach( $t_project_ids as $t_project_id ) { $t_subproject_ids = array_merge( $t_subproject_ids, current_user_get_all_accessible_subprojects( $t_project_id ) ); } $t_project_ids = array_merge( $t_project_ids, $t_subproject_ids ); $t_categories = array(); foreach( $t_project_ids AS $t_id ) { $t_categories = array_merge( $t_categories, category_get_all_rows( $t_id ) ); } $t_unique = array(); foreach( $t_categories AS $t_category ) { if( !in_array( $t_category['name'], $t_unique ) ) { $t_unique[] = $t_category['name']; } } return $t_unique; }
/** * Remove all categories associated with a project * @param int $p_project_id Project ID * @param int $p_new_category_id new category id (to replace existing category) * @return bool * @access public */ function category_remove_all($p_project_id, $p_new_category_id = 0) { project_ensure_exists($p_project_id); if (0 != $p_new_category_id) { category_ensure_exists($p_new_category_id); } # cache category names category_get_all_rows($p_project_id); $t_category_table = db_get_table('category'); $t_bug_table = db_get_table('bug'); # get a list of affected categories $t_query = "SELECT id FROM {$t_category_table} WHERE project_id=" . db_param(); $t_result = db_query_bound($t_query, array($p_project_id)); $t_category_ids = array(); while ($t_row = db_fetch_array($t_result)) { $t_category_ids[] = $t_row['id']; } # Handle projects with no categories if (count($t_category_ids) < 1) { return true; } $t_category_ids = join(',', $t_category_ids); # update bug history entries $t_query = "SELECT id, category_id FROM {$t_bug_table} WHERE category_id IN ( {$t_category_ids} )"; $t_result = db_query_bound($t_query); while ($t_bug_row = db_fetch_array($t_result)) { history_log_event_direct($t_bug_row['id'], 'category', category_full_name($t_bug_row['category_id'], false), category_full_name($p_new_category_id, false)); } # update bug data $t_query = "UPDATE {$t_bug_table} SET category_id=" . db_param() . " WHERE category_id IN ( {$t_category_ids} )"; db_query_bound($t_query, array($p_new_category_id)); # delete categories $t_query = "DELETE FROM {$t_category_table} WHERE project_id=" . db_param(); db_query_bound($t_query, array($p_project_id)); return true; }
/** * 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; }
</a> | <a href="plugin.php?page=MantisKanban/kanban_page&pdisplay=splitted"><?php echo lang_get('project_groups'); ?> </a> <?php } ?> </td> </tr> <tr> <?php $t_per_page = -1; # Improve performance by caching category data in one pass if (helper_get_current_project() == 0) { $rows = category_get_all_rows(0); $t_categories = array(); foreach ($rows as $t_row) { $t_categories[] = $t_row->category_id; } category_cache_array_rows(array_unique($t_categories)); } // get all user set filters $t_filter = current_user_get_bug_filter(); // if viewing all projects, allow to switch between combined and splitted view // (all projects mixed together or separated into rows) $f_default_pdisplay = "combined"; $pdisplay = gpc_get_string('pdisplay', $f_default_pdisplay); // only one project to display? if ($t_project_id || $pdisplay == "combined") { $all_project_ids = array($t_project_id);