Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
The permissions UI builds up a list of permissions grouped by module:
foreach (og_get_permissions() as $perm => $value) {
$module = $value['module'];
$permissions_by_module[$module][$perm] = $value;
}
It then does asort() on this. This is probably not what is intended, as it sorts the values. Here the values are arrays, and so (AFAICT) what happens is that the modules in the form are sorted by the number of permissions they each provide. That doesn't seem useful to me.
Perhaps this was meant to be ksort()? That would sort by module machine name.
Comment | File | Size | Author |
---|---|---|---|
#3 | 2248127.3.og_.admin-ui-permissions-sort.patch | 1.18 KB | joachim |
#1 | 2248127.og_.admin-ui-permissions-sort.patch | 478 bytes | joachim |
Comments
Comment #1
joachim CreditAttribution: joachim commentedComment #2
shushu CreditAttribution: shushu commentedThanks. The patch works, and order by module machine name.
Thinking about it, we better sort by
$module_info[$module]['name']
and not machine name, since in some cases the result won't be the same.Comment #3
joachim CreditAttribution: joachim commentedI agree that's better, but it's a lot trickier too!
Here's a patch to do that. Given that Drupal 7 officially supports PHP 5.2, we can't use an anonymous function for sorting, so rather than add a function just to be a sort callback, I've gone with prepping the order of the permissions array by making it out of the sorted modules array.
Comment #4
shushu CreditAttribution: shushu commentedThanks. Works as expected.
Comment #5
amitaibuCommitted, thanks.