Skip to content

Commit

Permalink
Fix #3723: No ability to edit or even delete news is associated proje…
Browse files Browse the repository at this point in the history
…ct was deleted.

M core/news_api.php
- (news_delete_all): Delete all news associated with a project.

M core/projects_api.php
- (project_delete): Call news_delete_all to delete news associated with a project.

M news_delete.php
- Delete news with checking project access level if project no longer exists.  This is to allow deleting the news entries which should have been deleted when their corresponding projects were deleted.


git-svn-id: http://mantisbt.svn.sourceforge.net/svnroot/mantisbt/trunk@2496 f5dc347c-c33d-0410-90a0-b07cc1902cb9
  • Loading branch information
vboctor committed Apr 21, 2004
1 parent 55d884e commit f417fe8
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 6 deletions.
17 changes: 16 additions & 1 deletion core/news_api.php
Expand Up @@ -6,7 +6,7 @@
# See the README and LICENSE files for details

# --------------------------------------------------------
# $Id: news_api.php,v 1.15 2004-04-08 18:04:53 prescience Exp $
# $Id: news_api.php,v 1.16 2004-04-21 14:15:32 vboctor Exp $
# --------------------------------------------------------

### News API ###
Expand Down Expand Up @@ -56,6 +56,21 @@ function news_delete( $p_news_id ) {
return true;
}
# --------------------
# Delete the news entry
function news_delete_all( $p_project_id ) {
$c_project_id = db_prepare_int( $p_project_id );

$t_news_table = config_get( 'mantis_news_table' );

$query = "DELETE FROM $t_news_table
WHERE project_id='$c_project_id'";

db_query( $query );

# db_query() errors on failure so:
return true;
}
# --------------------
# Update news item
function news_update( $p_news_id, $p_project_id, $p_view_state, $p_announcement, $p_headline, $p_body ) {
$c_news_id = db_prepare_int( $p_news_id );
Expand Down
6 changes: 5 additions & 1 deletion core/project_api.php
Expand Up @@ -6,7 +6,7 @@
# See the README and LICENSE files for details

# --------------------------------------------------------
# $Id: project_api.php,v 1.50 2004-04-08 22:44:59 prescience Exp $
# $Id: project_api.php,v 1.51 2004-04-21 14:16:01 vboctor Exp $
# --------------------------------------------------------

$t_core_dir = dirname( __FILE__ ).DIRECTORY_SEPARATOR;
Expand All @@ -15,6 +15,7 @@
require_once( $t_core_dir . 'version_api.php' );
require_once( $t_core_dir . 'bug_api.php' );
require_once( $t_core_dir . 'file_api.php' );
require_once( $t_core_dir . 'news_api.php' );

### Project API ###

Expand Down Expand Up @@ -257,6 +258,9 @@ function project_delete( $p_project_id ) {
# Delete the records assigning users to this project
project_remove_all_users( $p_project_id );

# Delete all news entries associated with the project being deleted
news_delete_all( $p_project_id );

# Delete the project entry
$query = "DELETE FROM $t_project_table
WHERE id='$c_project_id'";
Expand Down
1 change: 1 addition & 0 deletions doc/ChangeLog
Expand Up @@ -25,6 +25,7 @@ Mantis ChangeLog
* Fix #3641: 'Date submited' in reports is always '12-31-69'.
* Fix #3646: Error in core/obsolete.php.
* Fix #3691: Parse error in Romanian localisation.
* Fix #3723: No ability to edit or even delete news is associated project was deleted.
* Fix #3728: CSV export shows " instead of real quotes in bug title.
* New Config: set_view_status_threshold (default REPORTER) - threshold needed to set the view status while reporting a bug / bugnote.
* New Config: change_view_status_threshold (default UPDATER) - threshold needed to update the view status while updating a bug / bugnote.
Expand Down
11 changes: 7 additions & 4 deletions news_delete.php
Expand Up @@ -6,7 +6,7 @@
# See the README and LICENSE files for details

# --------------------------------------------------------
# $Id: news_delete.php,v 1.20 2004-01-11 07:16:07 vboctor Exp $
# $Id: news_delete.php,v 1.21 2004-04-21 14:15:25 vboctor Exp $
# --------------------------------------------------------
?>
<?php
Expand All @@ -21,13 +21,16 @@

$row = news_get_row( $f_news_id );

access_ensure_project_level( config_get( 'manage_news_threshold' ), $row['project_id'] );
# This check is to allow deleting of news items that were left orphan due to bug #3723
if ( project_exists( $row['project_id'] ) ) {
access_ensure_project_level( config_get( 'manage_news_threshold' ), $row['project_id'] );
}

helper_ensure_confirmed( lang_get( 'delete_news_sure_msg' ),
lang_get( 'delete_news_item_button' ) );

news_delete( $f_news_id );
news_delete( $f_news_id );

$t_redirect_url = 'news_menu_page.php';
$t_redirect_url = 'news_menu_page.php';
print_header_redirect( $t_redirect_url );
?>

0 comments on commit f417fe8

Please sign in to comment.