require_api('html_api.php'); require_api('lang_api.php'); require_api('print_api.php'); require_api('utility_api.php'); form_security_validate('manage_proj_cat_update'); auth_reauthenticate(); $f_category_id = gpc_get_int('category_id'); $f_project_id = gpc_get_int('project_id', ALL_PROJECTS); $f_name = trim(gpc_get_string('name')); $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_name)) { trigger_error(ERROR_EMPTY_FIELD, ERROR); } $t_row = category_get_row($f_category_id); $t_old_name = $t_row['name']; $t_project_id = $t_row['project_id']; # check for duplicate if (utf8_strtolower($f_name) != utf8_strtolower($t_old_name)) { category_ensure_unique($t_project_id, $f_name); } category_update($f_category_id, $f_name, $f_assigned_to); form_security_purge('manage_proj_cat_update'); if ($f_project_id == ALL_PROJECTS) { $t_redirect_url = 'manage_proj_page.php'; } else { $t_redirect_url = 'manage_proj_edit_page.php?project_id=' . $f_project_id; } html_page_top(null, $t_redirect_url); html_operation_successful($t_redirect_url); html_page_bottom();
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')); ?> </div>
/** * Update a category 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. * @param string $p_category_name The name of the category to rename * @param string $p_category_name_new The new name of the category to rename * @param int $p_assigned_to User ID that category is assigned to * @return bool returns true or false depending on the success of the update action */ function mc_project_rename_category_by_name($p_username, $p_password, $p_project_id, $p_category_name, $p_category_name_new, $p_assigned_to) { $t_user_id = mci_check_login($p_username, $p_password); if (null === $p_assigned_to) { return new soap_fault('Client', '', 'p_assigned_to needed'); } if ($t_user_id === false) { return new soap_fault('Client', '', 'Access Denied'); } if (!project_exists($p_project_id)) { return new soap_fault('Client', '', "Project '{$p_project_id}' does not exist."); } if (!mci_has_access(config_get('manage_project_threshold'), $t_user_id, $p_project_id)) { return new soap_fault('Client', '', 'Access Denied'); } // find the id of the category $p_category_id = category_get_id_by_name($p_category_name, $p_project_id); // update the category return category_update($p_category_id, $p_category_name_new, $p_assigned_to); }
/** * Update a category 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. * @param string $p_category_name The name of the category to rename. * @param string $p_category_name_new The new name of the category to rename. * @param integer $p_assigned_to User ID that category is assigned to. * @return boolean returns true or false depending on the success of the update action */ function mc_project_rename_category_by_name($p_username, $p_password, $p_project_id, $p_category_name, $p_category_name_new, $p_assigned_to) { global $g_project_override; $t_user_id = mci_check_login($p_username, $p_password); if (null === $p_assigned_to) { return SoapObjectsFactory::newSoapFault('Client', 'p_assigned_to needed'); } if ($t_user_id === false) { return mci_soap_fault_access_denied(); } 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_access(config_get('manage_project_threshold'), $t_user_id, $p_project_id)) { return mci_soap_fault_access_denied(); } # find the id of the category $p_category_id = category_get_id_by_name($p_category_name, $p_project_id); # update the category return category_update($p_category_id, $p_category_name_new, $p_assigned_to); }