The "New User" email is generated at Joomla framework level in backend instead of Application-level

222 views
Skip to first unread message

Beat

unread,
Feb 16, 2011, 9:33:00 AM2/16/11
to joomla-dev...@googlegroups.com
I believe this is a bug, but before opening a tracker item, I need to understand if I misunderstood something:

The JUser::save() method behaves differently if called in frontend or in backend.

- in frontend, it is silent as it should be.
- in backend, it is not silent as it sends the "new user email" with username and *cleartext password* in the email (!) when called in backend.

Looking in details, it's the Joomla User framework-plugin which now sends that email in 1.6, instead of the Application like in Joomla 1.5.

I didn't find any way to disable this email when using the JUser save() method to create a Joomla user.

I don't wish to use the database or database object, as JUser does some useful validations and triggerings, but the effect is that users now either get:

- an unwanted email when bulk creating users in backend, moreover with cleartext website+username+password in the email, which is a security concern btw
or
- 2 emails when creating a user in a component that already handles the emailing like in joomla 1.5. Switching off the component email is not an option as it contains additional information for the user.

Did I miss something ?
How to create a user silently using Joomla Framework in same way in front-end and backend ?
Is that a bug ?

Thanks a lot in advance for your insight in this.

Best Regards,
Beat

Phil Snell

unread,
Feb 16, 2011, 9:59:27 AM2/16/11
to joomla-dev...@googlegroups.com
I prefer if the framework parts work silently, so that the dev can
script with them as needed, and notify when / if they want. So I agree,
it should be in the application that notice is sent, or at the very
least, have a param to tell the framework method whether to notify or not.

> --
> You received this message because you are subscribed to the Google
> Groups "Joomla! Framework Development" group.
> To post to this group, send an email to
> joomla-dev...@googlegroups.com.
> To unsubscribe from this group, send email to
> joomla-dev-frame...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/joomla-dev-framework?hl=en-GB.

Matt Thomas

unread,
Feb 16, 2011, 10:38:15 AM2/16/11
to joomla-dev...@googlegroups.com
+1 on at least having the parameter.

Best,

Matt Thomas
betweenbrain | Construct Unified Template Framework for Joomla! 1.5, 1.6, Molajo and Nooku Server

Andrew Eddie

unread,
Feb 17, 2011, 3:04:30 AM2/17/11
to joomla-dev...@googlegroups.com
Not necessarily a but but I'll concede an oversight causing a change
in behaviour.

Just to clarify, the plugin is a "user" plugin, not a "framework"
plugin and the email was moved there so site builders had a way of
overriding the automatic email generation that is impossible when you
tightly couple mail functions to the application layer. As noted, the
frontend should also use this one method (DRY).

In order to accommodate a range of different scenarios, the solution
should probably:

1. Add appropriate parameters to the Joomla user plugin to more finely
control when emails are sent.

2. A 5th $options variable is added to the onUserAfterSave event
argument list that can hold a "switch" to indicate whether an email
should be sent (also future proofs against more new options).

3. JUser save also includes a $options variable as a new 2nd argument
and this is passed to the onUserAfterSave. This allows extreme
flexibility for custom user plugins and programmatic usage of
JUser::save. Alternatively, $updateOnly could be recycled into an
options variable and the type is checked to ensure backward compat.

4. Similar rationalisation could be done to other events.

5. Convert frontend emails to use the plugin event as well to reduce
code duplication.

I think this is more logical to fix in 1.7 than to try and hot fix it
in 1.6 given that we aren't far away from merge.

My 2c

Regards,
Andrew Eddie
http://learn.theartofjoomla.com - training videos for Joomla 1.6 developers

Beat

unread,
Feb 17, 2011, 5:47:05 PM2/17/11
to Joomla! Framework Development
Hi Andrew,

Thanks for your reply. I understand now why that email was moved there
from a site designer perspective (and which was not understandable
from a component developer perspective). Btw, that parameter or
override could have gone at application level too, from a designer
perspective. Then it could have applied to any "user" plugin, and not
only to the "core"-joomla-"user" plugin. ;-) . But a param can be ok
too, although in my opinion the default behavior should be "silent".

However, my question remains: In Joomla 1.6: and from within a
*component*, how to create a user silently using Joomla Framework in
same way in front-end and backend ?

Having to wait for Joomla 1.7 before extensions developers' components
are able to create Joomla users without unwanted emails being sent out
is not really an option. ;-)

Thanks again for all the answers above, and many thanks for a Joomla
1.6 solution too, I looked hard, but didn't find an applicable one in
Joomla 1.6.0 yet.

Beat
http://www.joomlapolis.com/
> Andrew Eddiehttp://learn.theartofjoomla.com- training videos for Joomla 1.6 developers
>
> On 17 February 2011 01:38, Matt Thomas <m...@betweenbrain.com> wrote:
>
>
>
> > +1 on at least having the parameter.
>
> > Best,
>
> > Matt Thomas
> > betweenbrain | Construct Unified Template Framework for Joomla! 1.5, 1.6,
> > Molajo and Nooku Server
>

Phil Snell

unread,
Feb 17, 2011, 6:13:20 PM2/17/11
to joomla-dev...@googlegroups.com
is it not the same as 1.5?  I just use JTableUser.  some snip example from a JModel sub class...  The reset / unset stuff was something that helped with looping over this for batch imports.


    $tableUser = clone(JTable::getInstance('user'));
 
         
        if (!$tableUser->bind($user_data)) { 
            $this->setError('bind(1) : ' . $user_data['email'] . ' : ' . $tableUser->getError());
            return false;
        }
 
        if (!$tableUser->check()) {      
            $this->setError('check(1) : ' . $user_data['email'] . ' : ' . $tableUser->getError());
            return false;
        }
 
        $tableUser->reset();
        unset($tableUser);
                 
        if (!$user->bind($user_data)) { 
            $this->setError('bind(2) : ' . $user_data['email'] . ' : ' . $tableUser->getError());
            return false;
        }
         
        if (!$user->save()) {
            $this->setError('save : ' . $user_data['email'] . ' : ' . $tableUser->getError());
            return false;

Phil Snell

unread,
Feb 17, 2011, 6:14:46 PM2/17/11
to joomla-dev...@googlegroups.com
oh and $user in there is $user = clone(JFactory::getUser(0));
Reply all
Reply to author
Forward
0 new messages