Dear
Matt Thomas,
As we know the Joomla 2.5 support three two king of new account activation, this can be configured in the com_users component perameters , when its set to self, the user can activate their account them self, and currently working fine, and no problem at all,
The problem arrise when its set to admin activation, first when a new user register to a site via the front end of a joomla 2.5 site, initially user has to validate thier email, during the validation , emails should be fired to all the admin or users who has privilage for core.edit.state on com_users component, this is normal follow, and code is show bellow which is copied from registration model
[code]
if (($userParams->get('useractivation') == 2) && !$user->getParam('activate', 0))
{
$uri = JURI::getInstance();
// Compile the admin notification mail values.
$data = $user->getProperties();
$data['activation'] = JApplication::getHash(JUserHelper::genRandomPassword());
$user->set('activation', $data['activation']);
$data['siteurl'] = JUri::base();
$base = $uri->toString(array('scheme', 'user', 'pass', 'host', 'port'));
$data['activate'] = $base.JRoute::_('index.php?option=com_users&task=registration.activate&token='.$data['activation'], false);
$data['fromname'] = $config->get('fromname');
$data['mailfrom'] = $config->get('mailfrom');
$data['sitename'] = $config->get('sitename');
$user->setParam('activate', 1);
$emailSubject = JText::sprintf(
'COM_USERS_EMAIL_ACTIVATE_WITH_ADMIN_ACTIVATION_SUBJECT',
$data['name'],
$data['sitename']
);
$emailBody = JText::sprintf(
'COM_USERS_EMAIL_ACTIVATE_WITH_ADMIN_ACTIVATION_BODY',
$data['sitename'],
$data['name'],
$data['email'],
$data['username'],
$data['siteurl'].'index.php?option=com_users&task=registration.activate&token='.$data['activation']
);
Here see the query which return the users to send approval notification , but query
condition is just check the who is enabled to receive system emails,
$query = 'SELECT name, email, sendEmail, id' .
' FROM #__users' .
' WHERE sendEmail=1';
$db->setQuery( $query );
$rows = $db->loadObjectList();
// Send mail to all superadministrators id
{
$return = JFactory::getMailer()->sendMail($data['mailfrom'], $data['fromname'], $row->email, $emailSubject, $emailBody);
if ($return !== true) {
$this->setError(JText::_('COM_USERS_REGISTRATION_ACTIVATION_NOTIFY_SEND_MAIL_FAILED'));
return false;
}
}
}
[/code]
Here see the query which return the users to send approval notification , but query
condition is just check the who is enabled to receive system emails,
In the above code see line no 92,93 query this query is executed and email are fired , but according to my site there are normal registered level users who is enabled to recieve system email for a different purposes, my problem was , they also getting notifcations email,
how I rewrite query was,
// get all admin users
$query = 'SELECT name, email, sendEmail' .
' FROM #__users usr INNER JOIN #__user_usergroup_map usrgrp ON usr.id=usrgrp.user_id ' .
' WHERE usrgrp.group_id=8 OR usrgrp.group_id=7 AND sendEmail=1';
group id 8 (super user) , 7 (admin)....
and I restrict the approval emails only to admin or super admin who are allowed to recive system emails, but this also not more sepcific, in the front end also we should check whether the user has core.edit.state permision on com_user component...,
In the back end this is not a probelm....
Regards,
Mohamed Akram