Beispiel #1
0
/**
 * Delete 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 delete
 * @return bool returns true or false depending on the success of the delete action
 */
function mc_project_delete_category($p_username, $p_password, $p_project_id, $p_category_name)
{
    $t_user_id = mci_check_login($p_username, $p_password);
    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);
    // delete the category and link all the issue to the general category by default
    return category_remove($p_category_id, 1);
}
/**
 * Delete 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 delete.
 * @return boolean returns true or false depending on the success of the delete action
 */
function mc_project_delete_category($p_username, $p_password, $p_project_id, $p_category_name)
{
    global $g_project_override;
    $t_user_id = mci_check_login($p_username, $p_password);
    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);
    # delete the category and link all the issue to the default category
    return category_remove($p_category_id, config_get('default_category_for_moves'));
}
require_once 'category_api.php';
form_security_validate('manage_proj_cat_delete');
auth_reauthenticate();
$f_category_id = gpc_get_int('id');
$f_project_id = gpc_get_int('project_id');
$t_row = category_get_row($f_category_id);
$t_name = category_full_name($f_category_id);
$t_project_id = $t_row['project_id'];
access_ensure_project_level(config_get('manage_project_threshold'), $t_project_id);
# Get a bug count
$t_bug_table = db_get_table('mantis_bug_table');
$t_query = "SELECT COUNT(id) FROM {$t_bug_table} WHERE category_id=" . db_param();
$t_bug_count = db_result(db_query_bound($t_query, array($f_category_id)));
# Confirm with the user
helper_ensure_confirmed(sprintf(lang_get('category_delete_sure_msg'), string_display_line($t_name), $t_bug_count), lang_get('delete_category_button'));
category_remove($f_category_id);
form_security_purge('manage_proj_cat_delete');
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);
?>
<br />
<div align="center">
<?php 
echo lang_get('operation_successful') . '<br />';
print_bracket_link($t_redirect_url, lang_get('proceed'));
?>
</div>
# You should have received a copy of the GNU General Public License
# along with Mantis.  If not, see <http://www.gnu.org/licenses/>.
# --------------------------------------------------------
# $Id: manage_proj_cat_delete.php,v 1.23.2.1 2007-10-13 22:33:31 giallu Exp $
# --------------------------------------------------------
require_once 'core.php';
$t_core_path = config_get('core_path');
require_once $t_core_path . 'category_api.php';
form_security_validate('manage_proj_cat_delete');
auth_reauthenticate();
$f_project_id = gpc_get_int('project_id');
$f_category = gpc_get_string('category');
access_ensure_project_level(config_get('manage_project_threshold'), $f_project_id);
# Confirm with the user
helper_ensure_confirmed(lang_get('category_delete_sure_msg') . '<br/>' . lang_get('category') . ': ' . $f_category, lang_get('delete_category_button'));
category_remove($f_project_id, $f_category);
form_security_purge('manage_proj_cat_delete');
$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>

<?php