# -------------------------------------------------------- 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_category = gpc_get_string('category'); $f_new_category = gpc_get_string('new_category'); $f_assigned_to = gpc_get_int('assigned_to', 0); access_ensure_project_level(config_get('manage_project_threshold'), $f_project_id); if (is_blank($f_new_category)) { trigger_error(ERROR_EMPTY_FIELD, ERROR); } $f_category = trim($f_category); $f_new_category = trim($f_new_category); # check for duplicate if (strtolower($f_category) == strtolower($f_new_category) || category_is_unique($f_project_id, $f_new_category)) { category_update($f_project_id, $f_category, $f_new_category, $f_assigned_to); } else { trigger_error(ERROR_CATEGORY_DUPLICATE, ERROR); } $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')); ?>
auth_reauthenticate(); $f_project_id = gpc_get_int('project_id'); $f_name = gpc_get_string('name'); access_ensure_project_level(config_get('manage_project_threshold'), $f_project_id); if (is_blank($f_name)) { error_parameters(lang_get('category')); trigger_error(ERROR_EMPTY_FIELD, ERROR); } $t_names = explode('|', $f_name); $t_category_count = count($t_names); foreach ($t_names as $t_name) { if (is_blank($t_name)) { continue; } $t_name = trim($t_name); if (category_is_unique($f_project_id, $t_name)) { category_add($f_project_id, $t_name); } else { if (1 == $t_category_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_CATEGORY_DUPLICATE, ERROR); } } } form_security_purge('manage_proj_cat_add'); if ($f_project_id == ALL_PROJECTS) { $t_redirect_url = 'manage_proj_page.php'; } else {
# -------------------------------------------------------- # $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);
/** * Check whether the category is unique within a project * Trigger an error if it is not * @param int $p_project_id Project id * @param string $p_name Category Name * @return null * @access public */ function category_ensure_unique( $p_project_id, $p_name ) { if( !category_is_unique( $p_project_id, $p_name ) ) { trigger_error( ERROR_CATEGORY_DUPLICATE, ERROR ); } }