[rt-devel] Sorting rights in SelectRights

Peter E. Popovich peter at popovich.net
Thu Jan 10 18:19:55 EST 2002


> > Having gotten no comments, I'm wondering if this would be welcomed as a
> > patch.
>
> Haven't really had time to look at it. Sorry :/

S'cool. I just wasn't sure if there was something about the code I'd
proposed that made it undesireable on its face. "Whenever you can get around
to it" will be plenty soon enough.

The purpose of the change is to sort the rights assigned to users and
groups, rather than leaving them sorted by the ordering in which ACLObj
returns them.

In the init section, I added a hash, %RightIds, populated with each
$right->Id using $right-RightName as its key. In the page display section,
instead of iterating ACLObj->Next(), I simply iterate on (sort keys
%RightIds).

The diffs in context form:

*** ./rt2/WebRT/html/Admin/Elements/SelectRights.orig   Mon Jan  7 17:12:01
2002
--- ./rt2/WebRT/html/Admin/Elements/SelectRights        Thu Jan 10 15:04:41
2002
***************
*** 14,29 ****
  <TD valign=top>
  <h3>Current rights</h3>
  <i>(Check box to revoke right)</i> <BR>
! % while (my $right = $ACLObj->Next()) {
! % if ($right->RightName) {
! <input type=checkbox value="<%$right->Id%>" name="RevokeACE">
<%$right->RightName%><br>
  % }
- %  }
  </TD>
  </TR>
  </TABLE>
  <%INIT>
!     my ($right, $ACLDesc, $AppliesTo, %Rights);


      my $ACLObj = new RT::ACL($session{'CurrentUser'});
--- 14,27 ----
  <TD valign=top>
  <h3>Current rights</h3>
  <i>(Check box to revoke right)</i> <BR>
! % foreach $right (sort keys %RightIds) {
! <input type=checkbox value="<%$RightIds{$right}%>" name="RevokeACE">
<%$right%><br>
  % }
  </TD>
  </TR>
  </TABLE>
  <%INIT>
!     my ($right, $ACLDesc, $AppliesTo, %Rights, %RightIds);


      my $ACLObj = new RT::ACL($session{'CurrentUser'});
***************
*** 48,53 ****
--- 46,57 ----
      }

      $ACLDesc = "$PrincipalType-".$PrincipalObj->Id."-$Scope-$AppliesTo";
+
+     while (my $right = $ACLObj->Next()) {
+       if ($right->RightName) {
+         $RightIds{$right->RightName}=$right->Id;
+       }
+     }
  </%INIT>

  <%ARGS>





More information about the Rt-devel mailing list