Implementation of the 'Main Group feature'

11 years 3 months ago - 11 years 2 months ago #217421 by newlog
Hi everyone

You dreamed of it ...



... now it's here!

The implementation of the Main Group feature (in CB 1.9+) !!!

This is a simple, non-intrusive hack, replacing a previous attempt . The latter was fully working, but only half the way towards a truely cool feature.

For those who want a complete account, this is here .

For normal humans, here is a project summary.

The implementation is a a simple 7-file hack, easy to understand and implement. It proves VERY useful.

It consists in using the 'usertype' field of the Joomla database to store and update a 'Main Group' among the existing user's Groups. Currently the Joomla 'usertype' is merely a legacy field, unset except for Super USers with the value 'deprecated'.

It is therefore possible to use this field in Joomla 2.5+, while at the same time leaving its legacy mode (Joomla 1.5 or earlier) unchanged.

This Main Group is then available as a CB field with the same name 'usertype', which proves useful in building CB Lists or using Auto Actions.

To summarize:
  • for legacy usage (J1.5 or earlier): usertype = the (unique) user's Group
  • for current usage (J2.5 or later): usertype = a Group selected among the user's Groups
As noted above, the 'usertype' field is unset for non-Super Users (in J2.5+): simply saving a profile will set it to its 'automatic' default value, the one currently computed by the CB core. For more details, or for a complete workflow of how this field works, refer to the complete account here .

Thereafter the usage of the Main Group is seamless:
  • If you do not set it again, it will automatically update to its automatic value when user's Groups are changed. In this case you need to be aware of the limitations of this automatic determination
  • At any rate a check of compatibility with respect to the user's existing Groups is carried out every time the Main Group OR the user's Groups are changed. If the Main Group was default, it will update to (a new) default as explained above. Else, it will be accepted, or rejected (with a clear warning message) if not part of the user's Groups.
The selection of the Main Group takes place
  • in backend through the same list as the one displayed for the selection of the user's Groups, except that the former is single-select and the latter multi-select. Also, the first entry of the list is 'Default Group' instead of 'Public': this permits to set or reset the Main Group to its default 'automatic' value, as explained above
  • in frontend through a text field, provided that the 'usertype' CB field (which carries the Main Group) has not been set to read-only. This is to comply with the display policy of fields in frontend, but could be easily changed.
Everything has been thoroughly tested.

To install this feature, three options:
  1. Follow instructions here
  2. Use the alternative CB 1.9 installer available on Aide-Joomla or on the Aide-Joomla forum
  3. Use the set of modified files available here . These files also implement the quick fixes and enhancements described here .
Enjoy, and happy 2013
Fabrice
Attachments:

Please Log in to join the conversation.

Moderators: beatnantkrileon
Time to create page: 0.172 seconds

Facebook Twitter LinkedIn