[Rt-commit] rtir branch, 3.4/duty-team-constituency-field-rights, created. 3.3.0-75-g88f88de
Dustin Graves
dustin at bestpractical.com
Tue May 17 20:29:01 EDT 2016
The branch, 3.4/duty-team-constituency-field-rights has been created
at 88f88deff3d7150ba93d0af24c33acbe5b4bdcba (commit)
- Log -----------------------------------------------------------------
commit 88f88deff3d7150ba93d0af24c33acbe5b4bdcba
Author: Dustin Graves <dustin at bestpractical.com>
Date: Mon May 16 23:51:26 2016 +0000
make sure 'RTIR Constituency' custom field gets appropriate rights in DutyTeam and ReadOnly groups when adding a new constituency
Fixes: I#31972
diff --git a/bin/add_constituency.in b/bin/add_constituency.in
index 6215b7e..bbcf80f 100755
--- a/bin/add_constituency.in
+++ b/bin/add_constituency.in
@@ -384,6 +384,42 @@ sub grant_group_queue_rights {
return 1;
}
+sub grant_group_single_cf_rights {
+ my ( $cf, $group, $rights_ref ) = @_;
+ my @rights = @$rights_ref;
+
+ debug "Granting rights for custom field "
+ . $cf->Name
+ . " to group "
+ . $group->Name . "\n";
+
+ foreach my $right (@rights) {
+ debug "\t$right";
+ if ($group->PrincipalObj->HasRight(
+ Right => $right,
+ Object => $cf
+ )
+ )
+ {
+ debug "\t...skipped, already granted\n";
+ next;
+ }
+ my ( $val, $msg ) = $group->PrincipalObj->GrantRight(
+ Right => $right,
+ Object => $cf
+ );
+ if ($val) {
+ debug "\t...done.\n";
+ } else {
+ die "Failed to grant $right to "
+ . $group->Name
+ . " for Custom Field "
+ . $cf->Name
+ . ".\nError: $msg";
+ }
+ }
+}
+
# XXX TODO this should be looking at cfs on the new queues
sub grant_group_cf_rights {
my $group = shift;
@@ -394,38 +430,15 @@ sub grant_group_cf_rights {
my $q = load_queue($queue);
$cfs->LimitToObjectId( $q->Id );
}
- while ( my $cf = $cfs->Next ) {
- debug "Granting rights for custom field "
- . $cf->Name
- . " to group "
- . $group->Name . "\n";
- foreach my $right (@rights) {
- debug "\t$right";
- if ($group->PrincipalObj->HasRight(
- Right => $right,
- Object => $cf
- )
- )
- {
- debug "\t...skipped, already granted\n";
- next;
- }
- my ( $val, $msg ) = $group->PrincipalObj->GrantRight(
- Right => $right,
- Object => $cf
- );
- if ($val) {
- debug "\t...done.\n";
- } else {
- die "Failed to grant $right to "
- . $group->Name
- . " for Custom Field "
- . $cf->Name
- . ".\nError: $msg";
- }
- }
+ while ( my $cf = $cfs->Next ) {
+ grant_group_single_cf_rights( $cf, $group, \@rights );
}
+
+ # explicitly grant rights on 'RTIR Constituency' cf as well
+ my $rtir_constituency_cf = get_constituency_cf();
+ grant_group_single_cf_rights( $rtir_constituency_cf, $group, \@rights );
+
return 1;
}
-----------------------------------------------------------------------
More information about the rt-commit
mailing list