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.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

joachim’s picture

Component: og.module » og-ui
Status: Active » Needs review
FileSize
478 bytes
shushu’s picture

Status: Needs review » Needs work

Thanks. 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.

joachim’s picture

Status: Needs work » Needs review
FileSize
1.18 KB

I 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.

shushu’s picture

Status: Needs review » Reviewed & tested by the community

Thanks. Works as expected.

amitaibu’s picture

Status: Reviewed & tested by the community » Fixed

Committed, thanks.

  • Commit c77aa1d on 7.x-2.x authored by joachim, committed by Amitaibu:
    Issue #2248127 by joachim: Permissions admin UI sorts incorrectly.
    

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.