View Issue Details

IDProjectCategoryView StatusLast Update
0007322mantisbtadministrationpublic2007-05-22 09:53
Reporterbrody Assigned To 
PrioritynormalSeveritytweakReproducibilityN/A
Status newResolutionopen 
Product Version1.0.5 
Summary0007322: email notification not only for general manager on new signup
Description

Hi,
per default only role "administrator" is notified, if a user signs up in a mantis installation. Because I have a manager for each (private) project I host in my mantis installation and managers have the possibility to add (new) users to their managed project, it would be helpful, if also all (or a subgroup) of managers can be notified, if a new user has signed up.

Setting the configuration item of "$g_notify_new_user_created_threshold_min" to role MANAGER (instead of ADMINISTRATOR) seems to be not the solution (or does not work correctly), because my managers are only managers for their project, but not in general.

An idea would be, to have a flag which decides the use of general role and/or additional a projects role. Other possibility is to create a list of users, which anyway will be notified.

Any comments?

TagsNo tags attached.
Attached Files
Patch_2007_03_16_Publish.diff (2,721 bytes)   
diff -cr core/email_api.php core/email_api.php
*** core/email_api.php	2007-03-16 14:17:30.000000000 +0100
--- core/email_api.php	2007-03-16 10:35:14.000000000 +0100
***************
*** 408,413 ****
--- 408,420 ----
  
  		$t_threshold_min = config_get( 'notify_new_user_created_threshold_min' );
  		$t_threshold_users = project_get_all_user_rows( ALL_PROJECTS, $t_threshold_min );
+ 		
+ 		if (config_get( 'activate_notify_new_user_created_threshold_min_projects' ))
+ 		{
+ 			$t_threshold_min = config_get( 'notify_new_user_created_threshold_min_projects' );
+ 			$t_threshold_users_projects = all_projects_get_all_user_rows( $t_threshold_min );
+ 			$t_threshold_users = array_merge ($t_threshold_users, $t_threshold_users_projects);
+ 		}
  
  		foreach( $t_threshold_users as $t_user ) {
  			lang_push( user_pref_get_language( $t_user['id'] ) );
diff -cr core/project_api.php core/project_api.php
*** core/project_api.php	2007-03-16 14:17:41.000000000 +0100
--- core/project_api.php	2007-03-16 10:35:14.000000000 +0100
***************
*** 442,447 ****
--- 442,487 ----
  	}
  
  	# --------------------
+ 	# Return an array of info about users who have access to all projects. (depending on access level)
+ 	# For each user we have 'id', 'username', and 'access_level' (overall access level)
+ 	# Return only users with an access level higher than the given value in the first parameter.
+ 	function all_projects_get_all_user_rows( $p_access_level = ANYBODY ) 
+ 	{
+ 		$c_access_level	= db_prepare_int( $p_access_level );
+ 		
+ 		# Optimization when access_level is NOBODY
+ 		if ( NOBODY == $p_access_level ) 
+ 		{
+ 			return array();
+ 		}
+ 		
+ 		$t_user_table = config_get( 'mantis_user_table' );
+ 		$t_project_user_list_table = config_get( 'mantis_project_user_list_table' );
+ 		$t_project_table = config_get( 'mantis_project_table' );
+ 		
+ 		$t_on = ON;
+ 		$t_users = array();
+ 	
+ 		# Get the project overrides
+ 		$query = "SELECT u.id, u.username, u.realname, l.access_level
+ 					FROM $t_project_user_list_table l, $t_user_table u
+ 					WHERE l.user_id = u.id
+ 					AND u.enabled = $t_on
+ 					AND l.access_level >= $c_access_level
+ 					GROUP BY u.id";
+ 		
+ 		$result = db_query( $query );
+ 		$t_row_count = db_num_rows( $result );
+ 		for ( $i=0 ; $i < $t_row_count ; $i++ ) {
+ 			$row = db_fetch_array( $result );
+ 			$t_users[$row['id']] = $row;
+ 		}
+ 	
+ 		return array_values( $t_users );
+ 	}
+ 	
+ 	
+ 	# --------------------
  	# Return an array of info about users who have access to the the given project
  	# For each user we have 'id', 'username', and 'access_level' (overall access level)
  	# If the second parameter is given, return only users with an access level
Patch_2007_03_16_Publish.diff (2,721 bytes)   

Activities

dufrenoy

dufrenoy

2007-03-16 11:42

reporter   ~0014194

Hi,
I had the same problem.

I resolved it writing a new function which browses and extracts all of the managers. Then I just needed to merge the result of my function with the standard result of $g_notify_new_user_created_threshold_min. (Mantis function)

You can configure my function in your config_inc.php file. (1 variable allowing to enable or disable my function and an other to modify access level)

Installation :

  1. Copy the patch file in your mantis directory (root directory of mantis)
  2. Execute : $patch -p0 < Patch_2007_03_16_Publish.diff
  3. Add the 2 following lines in your config_inc.php.
    $g_notify_new_user_created_threshold_min_projects = MANAGER;
    $g_activate_notify_new_user_created_threshold_min_projects = ON;
  4. That's all...

Have fun...

brody

brody

2007-05-22 09:53

reporter   ~0014591

@Dufrenoy: Seems to be good work - I'm not able to test it yet. Thus, two questions:
a) "patch" is a tool from unix. Is there an adequate (free) tool on Windows available
b) In the meantime, I switched to release 1.0.7 (and I plan to test with current alpha 1.1.0). Are there patches available for that versions or does your patch work there, too.