Esempio n. 1
0
function project_update($p_project_id, $p_name, $p_description, $p_status, $p_view_state, $p_file_path, $p_enabled)
{
    # Make sure file path has trailing slash
    $p_file_path = terminate_directory_path($p_file_path);
    $c_project_id = db_prepare_int($p_project_id);
    $c_name = db_prepare_string($p_name);
    $c_description = db_prepare_string($p_description);
    $c_status = db_prepare_int($p_status);
    $c_view_state = db_prepare_int($p_view_state);
    $c_file_path = db_prepare_string($p_file_path);
    $c_enabled = db_prepare_bool($p_enabled);
    if (is_blank($p_name)) {
        trigger_error(ERROR_PROJECT_NAME_INVALID, ERROR);
    }
    $t_old_name = project_get_field($p_project_id, 'name');
    if (strcasecmp($p_name, $t_old_name) != 0) {
        project_ensure_name_unique($p_name);
    }
    if (!is_blank($p_file_path)) {
        file_ensure_valid_upload_path($p_file_path);
    }
    $t_project_table = config_get('mantis_project_table');
    $query = "UPDATE {$t_project_table}\r\n\t\t\t\t  SET name='{$c_name}',\r\n\t\t\t\t\tstatus='{$c_status}',\r\n\t\t\t\t\tenabled='{$c_enabled}',\r\n\t\t\t\t\tview_state='{$c_view_state}',\r\n\t\t\t\t\tfile_path='{$c_file_path}',\r\n\t\t\t\t\tdescription='{$c_description}'\r\n\t\t\t\t  WHERE id='{$c_project_id}'";
    db_query($query);
    project_clear_cache($p_project_id);
    # db_query errors on failure so:
    return true;
}
Esempio n. 2
0
function project_update($p_project_id, $p_name, $p_description, $p_status, $p_view_state, $p_file_path, $p_enabled, $p_inherit_global)
{
    $p_project_id = (int) $p_project_id;
    $c_enabled = db_prepare_bool($p_enabled);
    $c_inherit_global = db_prepare_bool($p_inherit_global);
    if (is_blank($p_name)) {
        trigger_error(ERROR_PROJECT_NAME_INVALID, ERROR);
    }
    $t_old_name = project_get_field($p_project_id, 'name');
    if (strcasecmp($p_name, $t_old_name) != 0) {
        project_ensure_name_unique($p_name);
    }
    if (DATABASE !== config_get('file_upload_method', null, null, $p_project_id)) {
        $p_file_path = validate_project_file_path($p_file_path);
    }
    $t_project_table = db_get_table('project');
    $query = "UPDATE {$t_project_table}\n\t\t\t\t  SET name=" . db_param() . ",\n\t\t\t\t\tstatus=" . db_param() . ",\n\t\t\t\t\tenabled=" . db_param() . ",\n\t\t\t\t\tview_state=" . db_param() . ",\n\t\t\t\t\tfile_path=" . db_param() . ",\n\t\t\t\t\tdescription=" . db_param() . ",\n\t\t\t\t\tinherit_global=" . db_param() . "\n\t\t\t\t  WHERE id=" . db_param();
    db_query_bound($query, array($p_name, (int) $p_status, $c_enabled, (int) $p_view_state, $p_file_path, $p_description, $c_inherit_global, $p_project_id));
    project_clear_cache($p_project_id);
    # db_query errors on failure so:
    return true;
}
Esempio n. 3
0
/**
 * Update a project
 * @param integer $p_project_id     The project identifier being updated.
 * @param string  $p_name           The project name.
 * @param string  $p_description    A description of the project.
 * @param integer $p_status         The current status of the project.
 * @param integer $p_view_state     The view state of the project - public or private.
 * @param string  $p_file_path      The attachment file path for the project, if not storing in the database.
 * @param boolean $p_enabled        Whether the project is enabled.
 * @param boolean $p_inherit_global Whether the project inherits global categories.
 * @return void
 */
function project_update($p_project_id, $p_name, $p_description, $p_status, $p_view_state, $p_file_path, $p_enabled, $p_inherit_global)
{
    $p_project_id = (int) $p_project_id;
    $c_enabled = (bool) $p_enabled;
    $c_inherit_global = (bool) $p_inherit_global;
    if (is_blank($p_name)) {
        trigger_error(ERROR_PROJECT_NAME_INVALID, ERROR);
    }
    $t_old_name = project_get_field($p_project_id, 'name');
    # If project is becoming private, save current user's access level
    # so we can add them to the project afterwards so they don't lock
    # themselves out
    $t_old_view_state = project_get_field($p_project_id, 'view_state');
    $t_is_becoming_private = VS_PRIVATE == $p_view_state && VS_PRIVATE != $t_old_view_state;
    if ($t_is_becoming_private) {
        $t_user_id = auth_get_current_user_id();
        $t_access_level = user_get_access_level($t_user_id, $p_project_id);
        $t_manage_project_threshold = config_get('manage_project_threshold');
    }
    if (strcasecmp($p_name, $t_old_name) != 0) {
        project_ensure_name_unique($p_name);
    }
    if (DATABASE !== config_get('file_upload_method', null, null, $p_project_id)) {
        $p_file_path = validate_project_file_path($p_file_path);
    }
    $t_query = 'UPDATE {project}
				  SET name=' . db_param() . ',
					status=' . db_param() . ',
					enabled=' . db_param() . ',
					view_state=' . db_param() . ',
					file_path=' . db_param() . ',
					description=' . db_param() . ',
					inherit_global=' . db_param() . '
				  WHERE id=' . db_param();
    db_query($t_query, array($p_name, (int) $p_status, $c_enabled, (int) $p_view_state, $p_file_path, $p_description, $c_inherit_global, $p_project_id));
    project_clear_cache($p_project_id);
    # User just locked themselves out of the project by making it private,
    # so we add them to the project with their previous access level
    if ($t_is_becoming_private && !access_has_project_level($t_manage_project_threshold, $p_project_id)) {
        project_add_user($p_project_id, $t_user_id, $t_access_level);
    }
}