[Rt-commit] [rtir] 18/22: Add Everyone and Owner role rights for constituency queues

Jesse Vincent jesse at bestpractical.com
Sun Mar 29 02:51:04 EDT 2015


This is an automated email from the git hooks/post-receive script.

jesse pushed a commit to branch 3.4/remove_old_constituencies
in repository rtir.

commit c95a29128c673242d89c0bfde5470e61e6f7fbb6
Author: Jesse Vincent <jesse at bestpractical.com>
Date:   Sat Mar 28 23:14:29 2015 -0700

    Add Everyone and Owner role rights for constituency queues
---
 bin/add_constituency.in | 61 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 61 insertions(+)

diff --git a/bin/add_constituency.in b/bin/add_constituency.in
index fe6c692..92a18f1 100755
--- a/bin/add_constituency.in
+++ b/bin/add_constituency.in
@@ -285,6 +285,67 @@ sub add_cf_value {
     return $cf;
 }
 
+sub grant_role_queue_rights {
+    my $queues = shift;
+    my $everyone = RT::Group->new( RT->SystemUser );
+    $everyone->LoadSystemInternalGroup('Everyone');
+    foreach my $queue ( values %$queues ) {
+        debug "Granting role rights to Everyone for queue " . $queue->Name . "\n";
+        my @rights;
+
+        if ( $queue->Lifecycle eq 'incident_reports' ) {
+            @rights = RT::IR->EveryoneIncidentReportRights();
+        } elsif ( $queue->Lifecycle eq 'incidents' ) {
+            @rights = RT::IR->EveryoneIncidentRights();
+
+        }
+        if ( $queue->Lifecycle eq 'investigations' ) {
+            @rights = RT::IR->EveryoneInvestigationRights();
+
+        } elsif ( $queue->Lifecycle eq 'countermeaures' ) {
+            @rights = RT::IR->EveryoneBlockRights();
+        }
+        # grant 'everyone' rights
+        for my $right (@rights) {
+            debug "\t$right...";
+            
+            if ( $everyone->PrincipalObj->HasRight(
+                Object => $queue,
+                Right  => $right)) {
+            debug "skipping, already granted\n";
+            } else { 
+            my ( $val, $msg ) = $everyone->PrincipalObj->GrantRight(
+                Object => $queue,
+                Right  => $right
+            );
+            if ( !$val ) { die $msg }
+            debug  "done\n";
+        }
+        }
+
+        # grant 'owner' rights
+        debug "\tGranting role rights to Owners on " . $queue->Name . "\n";
+        for my $right ( RT::IR->OwnerAllQueueRights ) {
+            debug "\t$right...";
+            my $owner = $queue->RoleGroup('Owner');
+            if( $owner->PrincipalObj->HasRight(
+                Object => $queue,
+                Right  => $right
+            )) {
+            debug "skipping, already granted\n";
+            } else { 
+            my ( $val, $msg ) = $owner->PrincipalObj->GrantRight(
+                Object => $queue,
+                Right  => $right
+            );
+
+            if ( !$val ) { die $msg }
+            debug  "done\n";
+        }
+        }
+    }
+}
+
 sub grant_group_queue_rights {
     my $group  = shift;
     my $queues = shift;

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the rt-commit mailing list