Commit 6ac5f7b6 authored by Kevin Falcone's avatar Kevin Falcone
Browse files

Merge branch '3.0/add-constituency-cf-rights' into 3.0-trunk

parents 05ef4c1f fd303d05
......@@ -188,3 +188,23 @@ not practical to script updates and they will need to be done
through the UI.
=cut
=head1 UPGRADING FROM 3.0.1 AND EARLIER
=head2 add_constituency fixes
If you previously used the C<etc/add_constituency> script to set up a
Constituency, it did not set your Custom Field rights properly. The
version included in 3.0.2 can safely be re-run as
etc/add_constituency --name Name
It will apply the missing rights on custom fields.
As part of this fix, there has been a behavior change. Constituency Duty
Teams are now given rights on all Custom Fields applied to RTIR queues
(modify or read only depending on the type of duty team).
Previously they were only granted rights on the default RTIR Custom Fields.
Rights are managed at the Custom Field level by this script, so it's
straightforward to remove rights after constituency creation.
......@@ -248,13 +248,14 @@ sub grant_group_queue_rights {
foreach my $queue (values %$queues) {
debug "Granting rights for queue " .$queue->Name. " to group ". $group->Name;
foreach my $right (@rights) {
my ($val,$msg) = $group->PrincipalObj->GrantRight(Right => $right, Object=>$queue);
debug "\t$right\n";
if ( $group->PrincipalObj->HasRight( Right => $right, Object => $queue ) ) {
debug "\t...skipped, already granted";
next;
}
my ($val,$msg) = $group->PrincipalObj->GrantRight(Right => $right, Object=>$queue);
if ( $val ) {
debug "\t...done.";
}
elsif ( $msg =~ /That principal already has that right/i ) {
debug "\t...skipped, already granted.\n";
} else {
die "Failed to grant $right to ". $group->Name ." for Queue ". $queue->Name;
}
......@@ -268,18 +269,22 @@ sub grant_group_cf_rights {
my @rights = (@_);
my $cfs = RT::CustomFields->new($RT::SystemUser);
$cfs->Limit( FIELD => 'Name', OPERATOR => 'STARTSWITH', VALUE => '_RTIR' );
for my $queue (@queue_prefixes) {
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;
foreach my $right (@rights) {
my ($val,$msg) = $group->PrincipalObj->GrantRight(Right => $right, Object=>$cf);
debug "\t$right";
if ( $group->PrincipalObj->HasRight( Right => $right, Object => $cf ) ) {
debug "\t...skipped, already granted";
next;
}
my ($val,$msg) = $group->PrincipalObj->GrantRight(Right => $right, Object=>$cf);
if ( $val ) {
debug "\t...done.";
}
elsif ( $msg =~ /That principal already has that right/i ) {
debug "\t...skipped, already granted.\n";
} else {
die "Failed to grant $right to ".$group->Name. " for Custom Field ". $cf->Name
.".\nError: $msg";
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment