Hello everyone,
While customizing and adapting XOOPS 2.0.3 to my needs, I found this bug which I haven't heard anyone else talk about yet (just about every other problem I've encountered has already been solved by someone else!
![](https://xoops.org/uploads/smil42e7a3d4c7b9f.gif)
). What I'm trying to do is send e-mail messages to only those users who are interested in receiving e-mails from the site webmasters. This is accomplished on the user end by leaving "Receive occasional email notices from administrators and moderators?" checked in the user profile. When I go to send a message on my (admin) end, I'm checking "Send message only to users that accept notification messages (optional)" on the Mail Users page. Now this works, but not quite. The first user that is found is "lost". In other words, if it finds only one user who requests e-mails, no e-mails are sent. If it finds 10 users, it only sends e-mail to 9 users (users 2 through 10, or 1 through 9 if you start counting at 0).
I found the reason for this. In mailusers.php, located in /modules/system/admin/mailusers, there is the following code starting on line 164 (or thereabouts):
for ( $i = $mail_start; $i < $mail_end; $i++) {
$xoopsMailer->setToUsers($added[$i]);
}
The problem here is that
$mail_start is never set. Perhaps it is set if PHP's "register_globals" setting is turned on, but if it's turned off, this variable doesn't exist. So the first time this
for statement runs,
$i equals nothing (NULL I suppose), and so the
$added[$i] statement returns nothing. The next time the
for statement runs,
$i equals 1, so it works from then on.
So my solution was simple: add the following statement above that
for statement:
$mail_start = 0;
Now I have no idea if this breaks something, and it probably does. However, in my tests so far, it works fine. Maybe someone can suggest a superior fix now that this issue has been brought to light.
Anyway, I hope this helps, and I look forward to contributing more feedback, bug reports, and other stuff to the XOOPS community in the future.
Regards,
Jared White