henmedia wrote:rony76 wrote:It's sort of a raw implementation, in that I didn't take into account the case when moderators are part of a group, but that could be easily added.
If this just generates duplicate email adresses, it does not matter as dupes are filtered before sending the mail.
Yes, I had seen that, which is cool!
I meant something else, though: according to the data model, I think that an administrator can specify that a specific forum is moderated by one or more user, supplying their user names, or a proper group of users; if the latter is the case, I don't walk the tables path to find all the users in the group.
Anyway, after the invocation of newpost2mail, at line 15 on my copy of the newpost2mail.php file, I added a function definition:
Code: Select all
function loadModeratorEmailAddressesForForum($forumId) {
global $db;
$sql_array = array(
'SELECT' => 'u.user_email',
'FROM' => array(MODERATOR_CACHE_TABLE => 'm', USERS_TABLE => 'u'),
'WHERE' => 'm.user_id = u.user_id and m.forum_id = ' . $forumId
);
$sql = $db->sql_build_query('SELECT', $sql_array);
$result = $db->sql_query($sql, 3600);
$moderatorEmailAddresses = array();
while ($row = $db->sql_fetchrow($result))
{
$moderatorEmailAddresses[] = $row['user_email'];
}
$db->sql_freeresult($result);
return $moderatorEmailAddresses;
}
... and after the
n2m_MAILTO_ADD_FORUM_MODERATORS setting is checked (at what becomes line 278), I checked the newly introduced
n2m_MAILTO_ADD_FORUM_MODERATORS setting.
Code: Select all
if ($n2m_MAILTO_ADD_FORUM_MODERATORS) {
$moderatorEmailAddresses = loadModeratorEmailAddressesForForum($data[forum_id]);
$n2m_MAILTO = array_merge($n2m_MAILTO, $moderatorEmailAddresses);
}
As a said before, the query does not extract email addresses for users who are part of a group of moderators, which can be considered a
"TODO" item.
Take care, Rony