View Issue Details

IDProjectCategoryView StatusLast Update
0011789mantisbtemailpublic2016-04-25 03:59
Reporterobones Assigned To 
PrioritynormalSeverityfeatureReproducibilityalways
Status newResolutionopen 
Summary0011789: Email notification when a file is added
Description

Hello,

Would it be possible to have a notification email sent when a file is added?
This is especially handy when the user uploading the file does not add a note to indicated it added said file.

Tagspatch
Attached Files
mail_when_file_add_del.txt (1,740 bytes)   
/* addition to config_inc.php
$g_email_file_action = ON;


/* Addition to email_api.php
/**
 * Send notices that a user has added a file.
 * @param int $p_bug_id
 * @param int $p_user_id
 * @return null
 */
function email_file_added( $p_bug_id, $p_user_id,$p_file_name  ) {
	$t_opt = array();
	$t_opt[] = bug_format_id( $p_bug_id );
	$t_opt[] = user_get_name( $p_user_id );
	email_generic( $p_bug_id, 'bugnote', 'email_notification_title_for_action_addfile', $t_opt, array( $p_user_id ) );
}
/**
 * Send notices that a user has added a file.
 * @param int $p_bug_id
 * @param int $p_user_id
 * @return null
 */
function email_file_deleted( $p_bug_id, $p_user_id,$p_file_name  ) {
	$t_opt = array();
	$t_opt[] = bug_format_id( $p_bug_id );
	$t_opt[] = user_get_name( $p_user_id );
	email_generic( $p_bug_id, 'bugnote', 'email_notification_title_for_action_delfile', $t_opt, array( $p_user_id ) );
}
 

/ *Addition to the various strings scripts (or minimum to custom_strings_inc.php)
$s_email_notification_title_for_action_addfile = 'Issue %1$s, file added by user %2$s.'; 
$s_email_notification_title_for_action_delfile = 'Issue %1$s, file deleted by user %2$s.'; 

/* addition fo file_api.php
/**
 * requires email_api
 */
require_once( 'email_api.php' ); 


// now find function file_add
// and add as last line before the closing bracket
	//
	// send email
	//
	if( config_get( 'email_file_action' ) == ON ){
		email_file_added( $t_bug_id,$c_user_id ); 
	}
	
// Next find function File_delete
// and add at the end, just before : Return true;
	//
	// send email
	//
	if( config_get( 'email_file_action' ) == ON ){
		email_file_deleted( $p_bug_id,auth_get_current_user_id() ); 
	}
mail_when_file_add_del.txt (1,740 bytes)   

Relationships

related to 0003380 acknowledged E-mail notification on editing bugnotes and adding files 
related to 0011790 confirmed Event notification when a file is added 

Activities

M.C.S.

M.C.S.

2010-11-22 03:54

reporter   ~0027443

Voting for this, too :-)

cas

cas

2010-11-22 06:04

reporter   ~0027446

so to whom should the message be sent, just to Reporter and Handler?

obones

obones

2010-11-22 07:34

reporter   ~0027447

To whoever is receiving emails for the issue, just like when a note is posted.

M.C.S.

M.C.S.

2010-11-22 12:11

reporter   ~0027453

Good question. IMHO, "Note added" is a really good choice for this.

M.C.S.

M.C.S.

2010-11-23 12:34

reporter   ~0027460

Last edited: 2010-11-23 12:34

Don't know if marking this as duplicate is a good idea. The original ticket seems to be pending because there are two issues reported. The question if editing notes should trigger an email is still open - and probably blocks the progress of the "file added" email.

cas

cas

2010-11-24 06:38

reporter   ~0027468

Here how to do this:
/* Addition to email_api.php

/**

  • Send notices that a user has added a file.
  • @param int $p_bug_id
  • @param int $p_user_id
  • @return null
    */
    function email_file_added( $p_bug_id, $p_user_id ) {
    log_event( LOG_EMAIL, sprintf( 'Issue #%d , file added by user @U%d', $p_bug_id, $p_user_id ) );

    $t_opt = array();
    $t_opt[] = bug_format_id( $p_bug_id );
    $t_opt[] = user_get_name( $p_user_id );

    email_generic( $p_bug_id, 'bugnote', 'email_notification_title_for_action_addfile', $t_opt, array( $p_user_id ) );
    }

/ *Addition to the various strings scripts (or minimum to custom_strings_inc.php)
$s_email_notification_title_for_action_addfile = 'Issue %1$s, file added by user %2$s.';

/* addition fo file_api.php
/**

  • requires email_api
    */
    require_once( 'email_api.php' );

// now find function file_add
// and add as last line before the closing bracket
email_file_added( $p_bug_id,$c_user_id );

Now if someone was to copy this into core, clearly sending this email should be configurable.

cas

cas

2010-11-24 07:58

reporter   ~0027472

here is the code to receive conditional emails when adding/deleting files