-
Notifications
You must be signed in to change notification settings - Fork 11
Allow the setting of weights in metadata to influence sorting #8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
By default discopower sorts the display alphabetically by English name. This is good where there are lots of identity providers, but where there are smaller numbers (eg social providers) it may be desirable to override the sort order to influence user behaviour. This introduces a 'discopower.weight' to all entries to be weighted so that they appear higher or lower than they normally would.
Codecov Report
@@ Coverage Diff @@
## master #8 +/- ##
=============================================
+ Coverage 0.00% 20.81% +20.81%
- Complexity 78 82 +4
=============================================
Files 1 1
Lines 188 197 +9
=============================================
+ Hits 0 41 +41
+ Misses 188 156 -32 |
The uasort function is static, and needs a static config variable :(
|
Thanks again Guy! Two thoughts..
Regardless of the above, this needs a unit test.. |
I chose 50 to try and match what users of SSP might expect. The authproc filters set an implicit scale of 0-100, with 50 being used as the "default" in the documentation. Nevertheless, am not wedded to it, and am happy to change it to 100.
Hmm. A hook. I'll have a look at this. Even so, I think that weights are still useful as a simple mechanism. If I have four social providers I want to order (as I do), I don't want to have to write a hook to fix the order; weights in the metadata config are much easier.
I knew you'd say that, and I'd have done so if there were already unit tests for PowerIdPDisco.php. I think this is a bigger problem than just this change. IMHO some documentation is just as important, perhaps more so. |
|
Yeah, unit testing is a bigger problem.. But you gotta start somewhere, so that's why I asked :) |
|
Woah, that's great work Guy! 🚀 |
|
After giving @tvdijen's callback idea some thought, it seems the easiest and most flexible way to do this is simply to call a hook if it exists. If we use the existing hook functionality, that requires passing the entire metadata array to the hook. However, that in turn gives the user/admin complete control of the sorting including using functions other than uasort. I think I'm all done here now :) |
|
Thanks Guy!! |
By default, discopower sorts the display alphabetically by English name. This is good where there are lots of identity providers, but where there are smaller numbers (eg social providers) it may be desirable to override the sort order to influence user behaviour.
This introduces a
discopower.weightto all entries to be weighted so that they appear higher or lower than they normally would.If
discopower.weightis not set, the value ofdefaultweightfrom the configuration is used. This allows us to push up or down a single entry with ease, as all others remain sorted alphabetically (and equal weights are always alphabetical).If no weights are set, the previous behaviour remains unchanged.