[Rt-commit] r4789 - in rt/branches/3.7-EXPERIMENTAL: . html/Admin/CustomFields lib/RT/Interface

ruz at bestpractical.com ruz at bestpractical.com
Wed Mar 22 09:57:52 EST 2006


Author: ruz
Date: Wed Mar 22 09:57:51 2006
New Revision: 4789

Modified:
   rt/branches/3.7-EXPERIMENTAL/   (props changed)
   rt/branches/3.7-EXPERIMENTAL/html/Admin/CustomFields/GroupRights.html
   rt/branches/3.7-EXPERIMENTAL/html/Admin/CustomFields/UserRights.html
   rt/branches/3.7-EXPERIMENTAL/html/Admin/Elements/SelectRights
   rt/branches/3.7-EXPERIMENTAL/lib/RT/Interface/Web.pm

Log:
 r2180 at cubic-pc:  cubic | 2006-03-22 14:20:58 +0300
 * we've dropped deprecated API, but didn't update users.
 * revoking was broken


Modified: rt/branches/3.7-EXPERIMENTAL/html/Admin/CustomFields/GroupRights.html
==============================================================================
--- rt/branches/3.7-EXPERIMENTAL/html/Admin/CustomFields/GroupRights.html	(original)
+++ rt/branches/3.7-EXPERIMENTAL/html/Admin/CustomFields/GroupRights.html	Wed Mar 22 09:57:51 2006
@@ -57,7 +57,7 @@
       
 <h1><&|/l&>System groups</&></h1>
 <table>
-% $Groups = RT::Groups->new($session{'CurrentUser'});
+% my $Groups = RT::Groups->new($session{'CurrentUser'});
 % $Groups->LimitToSystemInternalGroups();
 %	while (my $Group = $Groups->Next()) {
   <tr align="right"> 
@@ -93,11 +93,6 @@
   </form>
   
 <%INIT>
- 
-
-
-
-  
 
 if (!defined $id) {
     $m->comp("/Elements/Error", Why => loc("No CustomField defined"));
@@ -106,63 +101,10 @@
 my $CustomFieldObj = RT::CustomField->new($session{'CurrentUser'});
 $CustomFieldObj->Load($id) || $m->comp("/Elements/Error", Why => loc("Couldn't load CustomField [_1]",$id));
 
-my $Groups;
-  
-  my ( $ACL, @results );
+my $title = loc('Modify group rights for custom field [_1]', $CustomFieldObj->Name);
 
-    foreach my $arg (keys %ARGS) {
-        if ($arg =~ /GrantRight-(\d+)-(.*?)-(\d+)$/) {
-            my $principal_id = $1;
-            my $object_type = $2;
-            my $object_id = $3;
-            my $rights = $ARGS{$arg};
-
-            my $principal = RT::Principal->new($session{'CurrentUser'});
-            $principal->Load($principal_id);
-            my $obj;
-
-            if ($object_type eq 'RT::CustomField') {
-                $obj = RT::CustomField->new($session{'CurrentUser'});
-                $obj->Load($object_id);
-            } else {
-                push (@results, loc("System Error").
-                                loc("Rights could not be granted for [_1]", $object_type));
-                next;
-            }
-
-            my @rights = ref($ARGS{$arg}) eq 'ARRAY' ? @{$ARGS{$arg}} : ($ARGS{$arg});
-            foreach my $right (@rights) {
-                next unless ($right);
-                my ($val, $msg) = $principal->GrantRight(Object => $obj, Right => $right);
-                push (@results, $msg);
-            }
-        }
-     elsif ($arg =~ /RevokeRight-(\d+)-(.*?)-(\d+)-(.*?)$/) {
-            my $principal_id = $1;
-            my $object_type = $2;
-            my $object_id = $3;
-            my $right = $4;
-
-            my $principal = RT::Principal->new($session{'CurrentUser'});
-            $principal->Load($principal_id);
-            next unless ($right);
-            my $obj;
-
-            if ($object_type eq 'RT::CustomField') {
-                $obj = RT::CustomField->new($session{'CurrentUser'});
-                $obj->Load($object_id);
-            } else {
-                push (@results, loc("System Error").
-                                loc("Rights could not be revoked for [_1]", $object_type));
-                next;
-            }
-            my ($val, $msg) = $principal->RevokeRight(Object => $obj, Right => $right);
-            push (@results, $msg);
-        }
-} 
+my @results = ProcessACLChanges( \%ARGS );
 
-my $title = loc('Modify group rights for custom field [_1]', $CustomFieldObj->Name);
-    
 </%INIT>
 
 <%ARGS>

Modified: rt/branches/3.7-EXPERIMENTAL/html/Admin/CustomFields/UserRights.html
==============================================================================
--- rt/branches/3.7-EXPERIMENTAL/html/Admin/CustomFields/UserRights.html	(original)
+++ rt/branches/3.7-EXPERIMENTAL/html/Admin/CustomFields/UserRights.html	Wed Mar 22 09:57:51 2006
@@ -77,65 +77,8 @@
   
 <%INIT>
  
-  #Update the acls.
-  my @results;
-foreach my $arg (keys %ARGS) {
-        if ($arg =~ /GrantRight-(\d+)-(.*?)-(\d+)$/) {
-            my $principal_id = $1;
-            my $object_type = $2;
-            my $object_id = $3;
-            my $rights = $ARGS{$arg};
-
-            my $principal = RT::Principal->new($session{'CurrentUser'});
-            $principal->Load($principal_id);
-            my $obj;
-
-            if ($object_type eq 'RT::CustomField') {
-                $obj = RT::CustomField->new($session{'CurrentUser'});
-                $obj->Load($object_id);
-
-            } else {
-                push (@results, loc("System Error").
-                                loc("Rights could not be granted for [_1]",
-$object_type));
-                next;
-            }
-
-            my @rights = ref($ARGS{$arg}) eq 'ARRAY' ? @{$ARGS{$arg}} :
-($ARGS{$arg});
-            foreach my $right (@rights) {
-                next unless ($right);
-                my ($val, $msg) = $principal->GrantRight(Object => $obj, Right
-=> $right);
-                push (@results, $msg);
-            }
-        }
-     elsif ($arg =~ /RevokeRight-(\d+)-(.*?)-(\d+)-(.*?)$/) {
-            my $principal_id = $1;
-            my $object_type = $2;
-            my $object_id = $3;
-            my $right = $4;
-
-            my $principal = RT::Principal->new($session{'CurrentUser'});
-            $principal->Load($principal_id);
-            next unless ($right);
-            my $obj;
-
-            if ($object_type eq 'RT::CustomField') {
-                $obj = RT::CustomField->new($session{'CurrentUser'});
-                $obj->Load($object_id);
-            } else {
-                push (@results, loc("System Error").
-                                loc("Rights could not be revoked for [_1]",
-$object_type));
-                next;
-            }
-            my ($val, $msg) = $principal->RevokeRight(Object => $obj, Right =>
-$right);
-            push (@results, $msg);
-        }
-} 
-  
+#Update the acls.
+my @results = ProcessACLChanges( \%ARGS );
 
 # {{{ Deal with setting up the display of current rights.
 
@@ -153,7 +96,6 @@
 $Privileged->LoadSystemInternalGroup('Privileged');
 my $Users = $Privileged->MembersObj();
 
-    
 my $title = loc('Modify user rights for custom field [_1]', $CustomFieldObj->Name);
   
 # }}}

Modified: rt/branches/3.7-EXPERIMENTAL/html/Admin/Elements/SelectRights
==============================================================================
--- rt/branches/3.7-EXPERIMENTAL/html/Admin/Elements/SelectRights	(original)
+++ rt/branches/3.7-EXPERIMENTAL/html/Admin/Elements/SelectRights	Wed Mar 22 09:57:51 2006
@@ -56,7 +56,7 @@
 % while (my $right = $ACLObj->Next()) {
 % if ($right->RightName) {
 % $current_rights{$right->RightName} = 1;
-<input type="checkbox" class="checkbox" value="<%$right->Id%>" name="RevokeRight-<%$ACLDesc%>-<%$right->RightName%>" /> <% loc($right->RightName) %><br />
+<input type="checkbox" class="checkbox" value="<% $right->RightName %>" name="RevokeRight-<%$ACLDesc%>" /> <% loc($right->RightName) %><br />
 % }
 %  }
 % }

Modified: rt/branches/3.7-EXPERIMENTAL/lib/RT/Interface/Web.pm
==============================================================================
--- rt/branches/3.7-EXPERIMENTAL/lib/RT/Interface/Web.pm	(original)
+++ rt/branches/3.7-EXPERIMENTAL/lib/RT/Interface/Web.pm	Wed Mar 22 09:57:51 2006
@@ -909,10 +909,7 @@
             @rights = $ARGSref->{$arg};
         }
         @rights = grep $_, @rights;
-        unless( @rights ) {
-            $RT::Logger->error("empty rights argument");
-            next;
-        }
+        next unless @rights;
 
         my $principal = RT::Principal->new( $session{'CurrentUser'} );
         $principal->Load( $principal_id );


More information about the Rt-commit mailing list