Skip to content

Add simplify plugin#10347

Closed
rdeutz wants to merge 4 commits intojoomla:stagingfrom
rdeutz:add_simplify_plugin
Closed

Add simplify plugin#10347
rdeutz wants to merge 4 commits intojoomla:stagingfrom
rdeutz:add_simplify_plugin

Conversation

@rdeutz
Copy link
Copy Markdown
Contributor

@rdeutz rdeutz commented May 8, 2016

Executive summary

This new plugin allow registration of a user only with an email address. If the plugin is enabled the username field is not available in forms. As default also the name field isn’t available but this can be configured.

Backwards compatibility

Problems can occur when a template overwrite has changed one of the following views:

  • com_users/views/login/default_login.php
  • com_users/views/profile/default_core.php
  • com_users/views/registration/default.php

Same is possible for the login module.

A small problem can be if someone has a direct link to the „Username Reminder Request“ as we have in our test data. This doesn’t makes sense in this configuration.

Translation impact

Two new language files with 8 new language tags.

Core changes

  • New User Plugin Event „onUserBeforeDataValidation“
  • New User Plugin Event „onUserAfterDataValidation“
  • New JForm Class method getFieldXml as public getter for the protected method findField
  • New parameter path for the setField method of JForm, allows to add a field at a specific place in the xml tree.

All core changes are only additions and full B/C, even if the plugin isn’t accepted these changes allow more flexibility for JForm.

Testing instruction

  • Apply the patch
  • Go to extensions and discover install the new plugin
  • Enable the plugin
  • Enable user registration
  1. Test registration process
  2. Test login
  3. Test profile edit frontend
  4. Test user data change backend

rdeutz added 3 commits May 8, 2016 23:41
# Executive summary
This new plugin allow registration of a user only with an email address. If the plugin is enabled the username fields is not available in forms. As default also the name field isn’t available but this can be configured.

# Backwards compatibility
A problems can occur when a template overwrite has the changed one of the following views:
* com_users/views/login/default_login.php
* com_users/views/profile/default_core.php
* com_users/views/registration/default.php

Same is possible for the login module.

A small problem can be if someone has a direct link to the „Username Reminder Request“ as we have in our test data. This doesn’t makes sense in this case.

# Translation impact
Two new language files with 8 new language tags.

# Core changes
* New User Plugin Event „onUserBeforeDataValidation“
* New User Plugin Event „onUserAfterDataValidation“
* New JForm Class method getFieldXml as public getter for the protected method findField
* New parameter path for the setField method of JForm, allows to add a field at a specific place in the xml tree.

All core changes are only additions and full B/C, even if the plugin isn’t accepted these changes allow more flexibility for JForm.

# Testing instruction

* Apply the patch
* go to extensions and discover install the new plugin
* enable the plugin
* enable user registration

1) Test registration process
2) Test login
3) Test profile edit frontend
4) Test user data change backend
PLG_USER_SIMPLIFY_EMAIL="Email (username)"
PLG_USER_SIMPLIFY_USERNAME="Email"
PLG_USER_SIMPLIFY_FIELD_REMOVENAME_DESC="Remove name field from forms."
PLG_USER__SIMPLIFY_FIELD_REMOVENAME_LABEL="Remove Name"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why 2 underscores in this text name?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just a typo

@joomla-cms-bot joomla-cms-bot removed this from the Joomla 3.6.0 milestone May 8, 2016
PLG_USER_SIMPLIFY_USERNAME="Email"
PLG_USER_SIMPLIFY_FIELD_REMOVENAME_DESC="Remove name field from forms."
PLG_USER__SIMPLIFY_FIELD_REMOVENAME_LABEL="Remove Name"
PLG_USER_SIMPLIFY_XML_DESCRIPTION="Simplify the user registration, allows registration only with email address"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it would be better as

+PLG_USER_SIMPLIFY_XML_DESCRIPTION="Simplify the user registration process. This allows registration only with email address."

@brianteeman
Copy link
Copy Markdown
Contributor

Made som en-GB suggestions inline


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/10347.

@smz
Copy link
Copy Markdown
Contributor

smz commented May 8, 2016

A very good idea... with a not so good name!
I find "simplify" to be a too broad concept/name: why not "emailonly"?


$plugin = JPluginHelper::getPlugin('user', 'simplify');

$params = (new JRegistry)->loadString($plugin->params);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You've got PHP 5.4 code here

@rdeutz rdeutz added this to the Joomla 3.6.0 milestone May 9, 2016
@rdeutz
Copy link
Copy Markdown
Contributor Author

rdeutz commented May 9, 2016

I made the suggested changes, thanks all for looking into it. I don't care so much about the name. Maybe @mikeveeckmans can make a suggestion with the marketing hat on.

@SharkyKZ
Copy link
Copy Markdown
Contributor

SharkyKZ commented May 9, 2016

Are you sure a plugin is the correct approach here? Wouldn't it be better off as an option in com_users?

@roland-d
Copy link
Copy Markdown
Contributor

roland-d commented May 9, 2016

@pe7er Are you not doing something similar?

$data['name'] = $value;
}

if ($this->params->get('remove_username_field', 1) == 1)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no option for "remove username field" in the plugin options we just have the first one

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for spotting this, I changed my mind and removed the option because you can simple disable the plugin to achieve the same

@zero-24
Copy link
Copy Markdown
Contributor

zero-24 commented May 9, 2016

We need the languagetag change also for the com_joomlaupdate login view :)

@rdeutz
Copy link
Copy Markdown
Contributor Author

rdeutz commented May 9, 2016

@SharkyKZ if you do it in com_user then you would simply allow the make some fields optional, that sounds easier but it is a big change that would effect also other extensions. The plugin just copies some data and does a bit of reordering fields. I think that is the minimalistic way to achieve the goal and has (hopefully) no side effects.

@zero-24 not sure what you are talking about, I didn't made the SQL changes so that the plugin is part of the package, though before spending time on this I will make sure it goes in :-)

@infograf768
Copy link
Copy Markdown
Member

hmm, a new plugin. You also have to modify the admin language/en-GB/install.xml

@rdeutz
Copy link
Copy Markdown
Contributor Author

rdeutz commented May 9, 2016

Thanks for all the notes what I have to do but if nobody tests this it will go to nowhere :-)

@zero-24
Copy link
Copy Markdown
Contributor

zero-24 commented May 9, 2016

@rdeutz see: https://github.com/joomla/joomla-cms/blob/staging/administrator/components/com_joomlaupdate/views/upload/tmpl/captive.php

Its a login view too so it needs to be catched here too.

A test is on my todo list but it is not that easy on phone ;)

We also need to add update SQL changes and the script php. Let me know if i should send it as pull request to your branch ;)

@infograf768
Copy link
Copy Markdown
Member

I have tested this item 🔴 unsuccessfully on d71ee98

When the plugin is enabled, when the user is editing in back-end his profile the values of name and username are changed to the user email.


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/10347.

@brianteeman
Copy link
Copy Markdown
Contributor

Does this needs to be in the core. There are several extensions that already do this.

@rdeutz
Copy link
Copy Markdown
Contributor Author

rdeutz commented May 9, 2016

@infograf768 that's expected behaviour. These fields aren't available, if I allow to change the username I can't really know how I should login someone.

@infograf768
Copy link
Copy Markdown
Member

@rdeutz
This is not B/C at all. It broke my Super User credentials.

@rdeutz
Copy link
Copy Markdown
Contributor Author

rdeutz commented May 9, 2016

@infograf768 let me guess, username is now the same as you email, right?

@brianteeman good question, I have seen one that does it over a special register form. It is not really the same

@infograf768
Copy link
Copy Markdown
Member

As I said : the Name (It was Super User) and Username (was admin) are changed to the user email

@rdeutz
Copy link
Copy Markdown
Contributor Author

rdeutz commented May 9, 2016

As I said: expected behaviour. You can't have both, register with only email/password and then login with a username

@infograf768
Copy link
Copy Markdown
Member

Yes, this is why I say it is not B/C and vote against this plugin which can be enabled without the knowledge of its consequences.
It should respect existing user credentials while providing, if desired, the new type of credentials.

@brianteeman
Copy link
Copy Markdown
Contributor

This is one on the JED. There may be more I can't really use the JED on my phone.

http://extensions.joomla.org/extensions/extension/access-a-security/site-access/email-as-username

@brianteeman
Copy link
Copy Markdown
Contributor

Also I guess this is not suitable for any site that displays an author name. As with this plugin it would display the email address as the author.

@infograf768
Copy link
Copy Markdown
Member

and not cloaked...

@rdeutz
Copy link
Copy Markdown
Contributor Author

rdeutz commented May 9, 2016

@brianteeman you can enable the name field

@pe7er
Copy link
Copy Markdown
Contributor

pe7er commented May 9, 2016

@roland-d Yeah, last week I was trying to write my own plugin to register with your Email address only. My reason was to lower the threshold to register at a website.

My plugin would remove the Name, Username, 2nd Email + 1st Password + 2nd Password field. Username + Password would be generated by the plugin. I noticed that some events were missing and ran into problems sending the right data in the email notification.

Having new events would make it much easier to change the registration form.

@rdeutz
Copy link
Copy Markdown
Contributor Author

rdeutz commented May 9, 2016

@pe7er I though about removing the 2nd email/password fields. I also run into some problems with JForm and the fact that the validation runs on the request data (what makes 100% sense). If you check my code you will see I added new events and called it in the models. I might split this PR into 2, one with the non plugin code changes and another with the plugin itself.

@bembelimen
Copy link
Copy Markdown
Contributor

I don't like the fact, that com_users output looks explicit if this plugin is installed/activated. Because I have my own plugin which do something similar + split the name field. If I want to use this feature, I have to activate this plugin and override every change with my own.
Perhaps it's possible to add a more general approach

@Bakual
Copy link
Copy Markdown
Contributor

Bakual commented May 9, 2016

I wouldn't put such a plugin into core, but I think we should make the life easier for those who want to create such plugins.
So if it's the plugin events that are missing, lets add those and make com_users more extendible but don't necessary add an own plugin.

@rdeutz
Copy link
Copy Markdown
Contributor Author

rdeutz commented May 9, 2016

ok, let me spilt it. As long as we make these things possible I don't care if the plugin goes into core or not

@SharkyKZ
Copy link
Copy Markdown
Contributor

SharkyKZ commented May 9, 2016

you can enable the name field

Also consider 3rd party extensions which display usernames instead of names. I've seen many of those. Perhaps add options to customize usernames (e.g. based on IDs, randomly generated, etc.). And then use actual email for authentication.

In any case, I still think this should be a part of com_users rather than a separate plugin.

@rdeutz rdeutz removed this from the Joomla 3.6.0 milestone May 9, 2016
@rdeutz
Copy link
Copy Markdown
Contributor Author

rdeutz commented May 9, 2016

Closing this one here, I have created #10350 and #10351 with the need functions to make a plugin like this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.