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; }
/** * Make sure that the project file path is valid: add trailing slash and * set it to blank if equal to default path * @param string $p_file_path * @return string * @access public */ function validate_project_file_path($p_file_path) { if (!is_blank($p_file_path)) { # Make sure file path has trailing slash $p_file_path = terminate_directory_path($p_file_path); # If the provided path is the same as the default, make the path blank. # This means that if the default upload path is changed, you don't have # to update the upload path for every single project. if (!strcmp($p_file_path, config_get('absolute_path_default_upload_folder'))) { $p_file_path = ''; } else { file_ensure_valid_upload_path($p_file_path); } } return $p_file_path; }
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 (!is_blank($p_file_path)) { # Make sure file path has trailing slash $p_file_path = terminate_directory_path($p_file_path); file_ensure_valid_upload_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; }