Skip to content

Commit

Permalink
* bug_api
Browse files Browse the repository at this point in the history
  (bug_reopen): new function
  (bug_monitor): new function
  (bug_unmonitor): new function
* file_api
  (file_delete): new function to delete a file
  (file_add): update the bug's date when adding a file


git-svn-id: http://mantisbt.svn.sourceforge.net/svnroot/mantisbt/trunk@1589 f5dc347c-c33d-0410-90a0-b07cc1902cb9
  • Loading branch information
Julian Fitzell committed Oct 23, 2002
1 parent 6583295 commit 1fe1aa0
Show file tree
Hide file tree
Showing 2 changed files with 104 additions and 3 deletions.
66 changes: 65 additions & 1 deletion core/bug_api.php
Expand Up @@ -6,7 +6,7 @@
# See the files README and LICENSE for details

# --------------------------------------------------------
# $Id: bug_api.php,v 1.14 2002-10-10 12:42:23 vboctor Exp $
# $Id: bug_api.php,v 1.15 2002-10-23 04:54:01 jfitzell Exp $
# --------------------------------------------------------

###########################################################################
Expand Down Expand Up @@ -556,6 +556,23 @@ function bug_resolve( $p_bug_id, $p_resolution, $p_bugnote_text='' ) {
return true;
}
# --------------------
# reopen the given bug
function bug_reopen( $p_bug_id, $p_bugnote_text='' ) {
$p_bugnote_text = trim( $p_bugnote_text );

bug_set_field( $p_bug_id, 'status', FEEDBACK );
bug_set_field( $p_bug_id, 'resolution', REOPENED );

# Add bugnote if supplied
if ( $p_bugnote_text != '' ) {
bugnote_add( $p_bug_id, $p_bugnote_text );
}

email_reopen( $p_bug_id );

return true;
}
# --------------------
# updates the last_updated field
function bug_update_date( $p_bug_id ) {
$c_bug_id = db_prepare_int( $p_bug_id );
Expand All @@ -569,4 +586,51 @@ function bug_update_date( $p_bug_id ) {

return true;
}

# --------------------
#
function bug_monitor( $p_bug_id, $p_user_id ) {
$c_bug_id = db_prepare_int( $p_bug_id );
$c_user_id = db_prepare_int( $p_user_id );

# Make sure we aren't already monitoring this bug
if ( user_is_monitoring_bug( $p_user_id, $p_bug_id ) ) {
return true;
}

$t_bug_monitor_table = config_get( 'mantis_bug_monitor_table' );

# Insert monitoring record
$query ="INSERT ".
"INTO $t_bug_monitor_table ".
"( user_id, bug_id ) ".
"VALUES ".
"( '$c_user_id', '$c_bug_id' )";
db_query($query);

# log new monitoring action
history_log_event_special( $p_bug_id, BUG_MONITOR, $c_user_id );

return true;
}

# --------------------
#
function bug_unmonitor( $p_bug_id, $p_user_id ) {
$c_bug_id = db_prepare_int( $p_bug_id );
$c_user_id = db_prepare_int( $p_user_id );

$t_bug_monitor_table = config_get( 'mantis_bug_monitor_table' );

# Delete monitoring record
$query ="DELETE ".
"FROM $t_bug_monitor_table ".
"WHERE user_id = '$c_user_id' AND bug_id = '$c_bug_id'";
db_query($query);

# log new un-monitor action
history_log_event_special( $p_bug_id, BUG_UNMONITOR, $p_user_id );

return true;
}
?>
41 changes: 39 additions & 2 deletions core/file_api.php
Expand Up @@ -6,7 +6,7 @@
# See the README and LICENSE files for details

# --------------------------------------------------------
# $Id: file_api.php,v 1.13 2002-10-20 23:59:49 jfitzell Exp $
# $Id: file_api.php,v 1.14 2002-10-23 04:54:01 jfitzell Exp $
# --------------------------------------------------------

###########################################################################
Expand Down Expand Up @@ -43,7 +43,7 @@ function file_list_attachments ( $p_bug_id ) {
echo "<a href=\"file_download.php?f_file_id=$v_id&amp;f_type=bug\">".file_get_display_name($v_filename)."</a> ($v_filesize bytes) <span class=\"italic\">$v_date_added</span>";

if ( access_level_check_greater_or_equal( config_get( 'handle_bug_threshold' ) ) ) {
echo " [<a class=\"small\" href=\"bug_file_delete.php?f_bug_id=$p_bug_id&amp;f_file_id=$v_id\">" . lang_get('delete_link') . '</a>]';
echo " [<a class=\"small\" href=\"bug_file_delete.php?f_file_id=$v_id\">" . lang_get('delete_link') . '</a>]';
}

if ( ( FTP == config_get( 'file_upload_method' ) ) && file_exists ( $v_diskfile ) ) {
Expand Down Expand Up @@ -162,6 +162,40 @@ function file_get_field( $p_file_id, $p_field_name ) {
return db_result( $result );
}
# --------------------
function file_delete( $p_file_id ) {
$c_file_id = db_prepare_int( $p_file_id );

$t_bug_file_table = config_get( 'mantis_bug_file_table' );

$t_upload_method = config_get( 'file_upload_method' );
$t_filename = file_get_field( $p_file_id, 'filename' );
$t_bug_id = file_get_field( $p_file_id, 'bug_id' );

if ( ( DISK == $t_upload_method ) || ( FTP == $t_upload_method ) ) {
$t_diskfile = file_get_field( $p_file_id, 'diskfile' );

if ( FTP == $t_upload_method ) {
$ftp = file_ftp_connect();
file_ftp_delete ( $ftp, $t_filename );
file_ftp_disconnect( $ftp );
}

if ( file_exists( $t_diskfile ) ) {
file_delete_local ( $t_diskfile );
}
}

$query = "DELETE FROM $t_bug_file_table
WHERE id='$c_file_id'";
db_query( $query );

# log file deletion
history_log_event_special( $t_bug_id, FILE_DELETED, file_get_display_name ( $t_filename ) );

# db_query() errors on failure so:
return true;
}
# --------------------
# File type check
function file_type_check( $p_file_name ) {
$t_allowed_files = config_get( 'allowed_files' );
Expand Down Expand Up @@ -249,6 +283,9 @@ function file_add( $p_bug_id, $p_tmp_file, $p_file_name, $p_file_type='' ) {
break;
}

# updated the last_updated date
$result = bug_update_date( $p_bug_id );

# log new bug
history_log_event_special( $p_bug_id, FILE_ADDED, $p_file_name );
}
Expand Down

0 comments on commit 1fe1aa0

Please sign in to comment.