Skip to content

Commit 9f485c5

Browse files
committed
Simplified configuration
Now instead of having per-issue settings, it's just per-project and per-user.
1 parent 7ca0b48 commit 9f485c5

File tree

2 files changed

+12
-21
lines changed

2 files changed

+12
-21
lines changed

ProjectNotifications.php

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,10 @@ public function include_users( $p_event_name, $p_bug_id, $p_notify_type ) {
5757
return $users_to_include;
5858
}
5959

60-
foreach ( $t_project_config as $username => $enabled_notifications ) {
61-
if ( in_array( $p_notify_type, $enabled_notifications ) ) {
62-
$t_user_id = user_get_id_by_name( $username );
63-
array_push( $users_to_include, $t_user_id );
64-
log_event( LOG_PLUGIN, "user '%s' added as notification recipient for project %s", $username, $t_project_name );
65-
}
60+
foreach ( $t_project_config as $username ) {
61+
$t_user_id = user_get_id_by_name( $username );
62+
array_push( $users_to_include, $t_user_id );
63+
log_event( LOG_PLUGIN, "user '%s' added as notification recipient for project %s", $username, $t_project_name );
6664
}
6765

6866
return $users_to_include;
@@ -90,14 +88,9 @@ public function get_user_notification_preference( $p_event_name, $p_notify, $p_p
9088
return $t_return;
9189
}
9290

93-
$user_config = $project_config[$t_username];
94-
if ( !is_array( $user_config ) ) {
95-
log_event( LOG_PLUGIN, "notification settings for user %s don't exist for project %s", $t_username, $t_project_name );
96-
return $t_return;
97-
}
98-
9991
// Only change notification settings if all sanity checks passed
100-
if ( in_array( $p_notify_type, $user_config ) ) {
92+
if ( in_array( $t_username, $project_config ) ) {
93+
log_event( LOG_PLUGIN, "user %s notifications settings for project %s set to ON", $t_username, $t_project_name );
10194
$t_return[0] = ON;
10295
}
10396

@@ -128,6 +121,11 @@ private function get_config_for_project( $p_project_name ) {
128121
return null;
129122
}
130123

124+
if ( !array_key_exists( $p_project_name, $notification_config ) ) {
125+
log_event( LOG_PLUGIN, "notification settings for project %s don't exist", $p_project_name );
126+
return null;
127+
}
128+
131129
$project_config = $notification_config[$p_project_name];
132130

133131
return is_array( $project_config ) ? $project_config : null;

files/config/notification_inc.php

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,5 @@
3232
* according to Mantis' settings.
3333
*/
3434
$notification_config = array(
35-
"project1" => array(
36-
"samir" => ["resolved"],
37-
"samir2" => ["new", "reopened", "closed"]
38-
),
39-
"project2" => array(
40-
"samir" => ["bugnote", "acknowledged", "new"],
41-
"samir2" => ["new", "reopened", "closed"]
42-
)
35+
"project2" => array("samir", "samir2")
4336
);

0 commit comments

Comments
 (0)