@@ -102,42 +102,42 @@ private function getEmailReceivers($emailGroups): array
102102 return [];
103103 }
104104
105- $ emailReceivers = [];
106-
107- // Get the users of all groups in the emailGroups
105+ $ emailReceivers = [];
106+
107+ // Get the users of all groups in the emailGroups
108108 $ usersModel = Factory::getApplication ()->bootComponent ('com_users ' )
109109 ->getMVCFactory ()->createModel ('Users ' , 'Administrator ' );
110-
111- $ usersModel ->setState ('filter.groups ' , $ emailGroups );
112- $ usersModel ->setState ('filter.block ' , (int ) 0 );
113-
114- $ usersInGroup = $ usersModel ->getItems ();
115-
116- if (empty ($ usersInGroup )) {
117- return [];
118- }
119-
120- // Only users with valid email address who are not blocked can receive the email
121- foreach ($ usersInGroup as $ user ) {
122- if (MailHelper::isEmailAddress ($ user ->email ) && $ user ->sendEmail === 1 ) {
123- $ user ->email = strtolower (trim ($ user ->email ));
124-
125- // Check if the email already exists in the emailReceivers array
126- $ exist = false ;
127- foreach ($ emailReceivers as $ rec ) {
128- if ($ rec ->email === $ user ->email ) {
129- $ exist = true ;
130- break ;
131- }
132- }
133-
134- // Add to the list if it is not already in the list
135- if (!$ exist ) {
136- $ emailReceivers [] = $ user ;
137- }
138- }
139- }
140-
141- return $ emailReceivers ;
110+
111+ $ usersModel ->setState ('filter.groups ' , $ emailGroups );
112+ $ usersModel ->setState ('filter.block ' , (int ) 0 );
113+
114+ $ usersInGroup = $ usersModel ->getItems ();
115+
116+ if (empty ($ usersInGroup )) {
117+ return [];
118+ }
119+
120+ // Only users with valid email address who are not blocked can receive the email
121+ foreach ($ usersInGroup as $ user ) {
122+ if (MailHelper::isEmailAddress ($ user ->email ) && $ user ->sendEmail === 1 ) {
123+ $ user ->email = strtolower (trim ($ user ->email ));
124+
125+ // Check if the email already exists in the emailReceivers array
126+ $ exist = false ;
127+ foreach ($ emailReceivers as $ rec ) {
128+ if ($ rec ->email === $ user ->email ) {
129+ $ exist = true ;
130+ break ;
131+ }
132+ }
133+
134+ // Add to the list if it is not already in the list
135+ if (!$ exist ) {
136+ $ emailReceivers [] = $ user ;
137+ }
138+ }
139+ }
140+
141+ return $ emailReceivers ;
142142 }
143143}
0 commit comments