Simple Machines Community Forum

SMF Development => Bug Reports => Topic started by: asmith on March 26, 2014, 09:07:08 AM

Title: Newsletter to Regular Members
Post by: asmith on March 26, 2014, 09:07:08 AM
Hello,

SMF 2.0.7
Trying to use newsletter to only regular members fails.

How to reproduce:
Try sending email or pm to regulars members ONLY. (Admin => newletters)

Reason:
When in the composing mail page (admin, area=news, sa=mailingcompose)
The hidden input for values contains only 0 value which stands for regular members group:

<input type="hidden" name="groups" value="0" />

After clicking to send:
File: Sources/ManageNews.php, line 493:

// Cleaning groups is simple - although deal with both checkbox and commas.
if (!empty($_POST['groups']))



empty() will return true because the value is 0, while it should consider that group.

Solution:
File: Sources/ManageNews.php, line 493:

Replace: (line 493)

if (!empty($_POST['groups']))


With:

if (isset($_POST['groups']) && (is_array($_POST['groups']) && !empty($_POST['groups'])) || (!is_array($_POST['groups']) && trim($_POST['groups']) != ''))


First time visiting newsletter page (selecting recipients page), groups is an array. Second time in compose mail, groups is string.