[Rt-commit] rt branch, config-callbacks-wip, created. rt-4.4.1-1-g0adee36
Aaron Kondziela
aaron at bestpractical.com
Sat Feb 18 01:21:02 EST 2017
The branch, config-callbacks-wip has been created
at 0adee36713e27b7dd69cb580c823c3f012550ebf (commit)
- Log -----------------------------------------------------------------
commit 0adee36713e27b7dd69cb580c823c3f012550ebf
Author: Aaron Kondziela <aaron at bestpractical.com>
Date: Sat Feb 18 01:19:51 2017 -0500
WIP ticket 180410 config change callback system
diff --git a/etc/RT_Config.pm.in b/etc/RT_Config.pm.in
index 7722558..00e0c4c 100644
--- a/etc/RT_Config.pm.in
+++ b/etc/RT_Config.pm.in
@@ -3731,6 +3731,21 @@ Set(%AdminSearchResultRows,
Assets => 50,
);
+
+=item C<$ConfigChangeCallback>
+
+When a user makes a configuration change in the Admin section of the web
+interface, a callback in the templates calls the function assigned to this
+option:
+
+ Set( $ConfigChangeCallback, sub {...} );
+
+This is set to undef by default.
+
+=cut
+
+Set( $ConfigChangeCallback, undef );
+
=back
diff --git a/lib/RT/Interface/Web.pm b/lib/RT/Interface/Web.pm
index e3cf905..9d20dbe 100644
--- a/lib/RT/Interface/Web.pm
+++ b/lib/RT/Interface/Web.pm
@@ -2685,7 +2685,8 @@ submitted.
sub ProcessACLs {
my $ARGSref = shift;
- my (%state, @results);
+ my (%state, @results, $updated);
+ my $m = $HTML::Mason::Commands::m;
my $CheckACL = $ARGSref->{'CheckACL'};
my @check = grep { defined } (ref $CheckACL eq 'ARRAY' ? @$CheckACL : $CheckACL);
@@ -2771,6 +2772,7 @@ sub ProcessACLs {
# Has right and shouldn't have right
my ($val, $msg) = $principal->RevokeRight( Object => $obj, Right => $right );
push @results, $msg;
+ $updated = 1;
}
# For everything left, they don't have the right but they should
@@ -2778,6 +2780,7 @@ sub ProcessACLs {
delete $state{$tuple}->{$right};
my ($val, $msg) = $principal->GrantRight( Object => $obj, Right => $right );
push @results, $msg;
+ $updated = 1;
}
# Check our state for leftovers
@@ -2790,7 +2793,15 @@ sub ProcessACLs {
}
}
- return (@results);
+ # Fire the AfterUpdate callback if any updates happen.
+ $m->callback(
+ CallbackName => 'AfterUpdate',
+ Object => $principal,
+ ARGSRef => \%ARGS,
+ Results => \@results
+ ) if ( $updated );
+
+ return @results;
}
=head2 _ParseACLNewPrincipal
diff --git a/share/html/Admin/Articles/Classes/Modify.html b/share/html/Admin/Articles/Classes/Modify.html
index f4a6f78..5c71990 100644
--- a/share/html/Admin/Articles/Classes/Modify.html
+++ b/share/html/Admin/Articles/Classes/Modify.html
@@ -216,6 +216,14 @@ if ( $ClassObj->id && $Submitted ) {
}
}
+# Fire the AfterUpdate callback if any updates happen.
+$m->callback(
+ CallbackName => 'AfterUpdate',
+ Object => $ClassObj,
+ ARGSRef => \%ARGS,
+ Results => \@results
+) if ( @results and $ClassObj->id );
+
# This code does automatic redirection if any updates happen.
MaybeRedirectForResults(
Actions => \@results,
diff --git a/share/html/Admin/Articles/Classes/Objects.html b/share/html/Admin/Articles/Classes/Objects.html
index 9cc95d1..a668159 100644
--- a/share/html/Admin/Articles/Classes/Objects.html
+++ b/share/html/Admin/Articles/Classes/Objects.html
@@ -133,6 +133,14 @@ if ( $UpdateObjs ) {
}
}
+# Fire the AfterUpdate callback if any updates happen.
+$m->callback(
+ CallbackName => 'AfterUpdate',
+ Object => $Class,
+ ARGSRef => \%ARGS,
+ Results => \@results
+) if ( @results );
+
my $is_global = $Class->IsApplied(0);
my $applied = $Class->AppliedTo;
diff --git a/share/html/Admin/Articles/Elements/Topics b/share/html/Admin/Articles/Elements/Topics
index f29c94a..2a166cc 100644
--- a/share/html/Admin/Articles/Elements/Topics
+++ b/share/html/Admin/Articles/Elements/Topics
@@ -204,6 +204,15 @@ for my $topic (@todo) {
push @results, "Reparented orphan ".$topic->Id." to root";
}
+# Fire the AfterUpdate callback if any updates happen.
+$m->callback(
+ CallbackName => 'AfterUpdate',
+ Object => $topic,
+ ARGSRef => \%ARGS,
+ Results => \@results
+) if ( @results );
+
+
</%INIT>
diff --git a/share/html/Admin/Assets/Catalogs/Create.html b/share/html/Admin/Assets/Catalogs/Create.html
index 65a18ba..635ebc4 100644
--- a/share/html/Admin/Assets/Catalogs/Create.html
+++ b/share/html/Admin/Assets/Catalogs/Create.html
@@ -77,6 +77,14 @@ if ($id eq "new") {
push @results, $msg, @{$nonfatal || []};
if ($ok) {
+ # Fire the AfterUpdate callback if any updates happen.
+ $m->callback(
+ CallbackName => 'AfterUpdate',
+ Object => $catalog,
+ ARGSRef => \%ARGS,
+ Results => \@results
+ ) if ( @results and $catalog->id );
+
MaybeRedirectForResults(
Actions => \@results,
Path => "/Admin/Assets/Catalogs/Modify.html",
diff --git a/share/html/Admin/Assets/Catalogs/Modify.html b/share/html/Admin/Assets/Catalogs/Modify.html
index e4e37b8..34a7240 100644
--- a/share/html/Admin/Assets/Catalogs/Modify.html
+++ b/share/html/Admin/Assets/Catalogs/Modify.html
@@ -80,6 +80,14 @@ if ($Update) {
ARGSRef => \%ARGS,
);
+ # Fire the AfterUpdate callback if any updates happen.
+ $m->callback(
+ CallbackName => 'AfterUpdate',
+ Object => $catalog,
+ ARGSRef => \%ARGS,
+ Results => \@results
+ ) if ( @results and $catalog->id );
+
MaybeRedirectForResults(
Actions => \@results,
Arguments => { id => $catalog->id },
diff --git a/share/html/Admin/Assets/Catalogs/Roles.html b/share/html/Admin/Assets/Catalogs/Roles.html
index 37dd9e9..3717d85 100644
--- a/share/html/Admin/Assets/Catalogs/Roles.html
+++ b/share/html/Admin/Assets/Catalogs/Roles.html
@@ -74,6 +74,14 @@ my @results;
if ($Update) {
push @results, ProcessAssetRoleMembers( $catalog => %ARGS );
+ # Fire the AfterUpdate callback if any updates happen.
+ $m->callback(
+ CallbackName => 'AfterUpdate',
+ Object => $catalog,
+ ARGSRef => \%ARGS,
+ Results => \@results
+ ) if ( @results and $catalog->id );
+
MaybeRedirectForResults(
Actions => \@results,
Arguments => { id => $catalog->id },
diff --git a/share/html/Admin/CustomFields/Modify.html b/share/html/Admin/CustomFields/Modify.html
index f9a7324..24d1205 100644
--- a/share/html/Admin/CustomFields/Modify.html
+++ b/share/html/Admin/CustomFields/Modify.html
@@ -344,6 +344,14 @@ if ( $CustomFieldObj->id && $CustomFieldObj->IsOnlyGlobal ) {
$id = $CustomFieldObj->id if $CustomFieldObj->id;
+# Fire the AfterUpdate callback if any updates happen.
+$m->callback(
+ CallbackName => 'AfterUpdate',
+ Object => $CustomFieldObj,
+ ARGSRef => \%ARGS,
+ Results => \@results
+) if ( @results and $CustomFieldObj->id );
+
# This code does automatic redirection if any updates happen.
MaybeRedirectForResults(
Actions => \@results,
diff --git a/share/html/Admin/CustomFields/Objects.html b/share/html/Admin/CustomFields/Objects.html
index b3aa4fe..c12ca5b 100644
--- a/share/html/Admin/CustomFields/Objects.html
+++ b/share/html/Admin/CustomFields/Objects.html
@@ -153,6 +153,14 @@ my $rows = RT->Config->Get('AdminSearchResultRows')->{$collection_class} || 50;
my $title = loc('Modify associated objects for [_1]', $CF->Name);
+# Fire the AfterUpdate callback if any updates happen.
+$m->callback(
+ CallbackName => 'AfterUpdate',
+ Object => $CF,
+ ARGSRef => \%ARGS,
+ Results => \@results
+) if ( @results );
+
</%INIT>
<%ARGS>
$id => undef
diff --git a/share/html/Admin/CustomRoles/Modify.html b/share/html/Admin/CustomRoles/Modify.html
index 1905cc2..8b58614 100644
--- a/share/html/Admin/CustomRoles/Modify.html
+++ b/share/html/Admin/CustomRoles/Modify.html
@@ -167,6 +167,14 @@ if ( $RoleObj->Id ) {
$title = loc("Create a custom role");
}
+# Fire the AfterUpdate callback if any updates happen.
+$m->callback(
+ CallbackName => 'AfterUpdate',
+ Object => $RoleObj,
+ ARGSRef => \%ARGS,
+ Results => \@results
+) if ( @results and $RoleObj->id );
+
MaybeRedirectForResults(
Actions => \@results,
Arguments => { id => $RoleObj->Id },
diff --git a/share/html/Admin/CustomRoles/Objects.html b/share/html/Admin/CustomRoles/Objects.html
index 323229c..80ae3be 100644
--- a/share/html/Admin/CustomRoles/Objects.html
+++ b/share/html/Admin/CustomRoles/Objects.html
@@ -120,6 +120,15 @@ if ( $Update ) {
push @results, $msg;
}
}
+
+ # Fire the AfterUpdate callback if any updates happen.
+ $m->callback(
+ CallbackName => 'AfterUpdate',
+ Object => $role,
+ ARGSRef => \%ARGS,
+ Results => \@results
+ ) if ( @results and $role->id );
+
MaybeRedirectForResults(
Actions => \@results,
Arguments => {
diff --git a/share/html/Admin/Elements/EditCustomField b/share/html/Admin/Elements/EditCustomField
index 4dba36d..db074a2 100644
--- a/share/html/Admin/Elements/EditCustomField
+++ b/share/html/Admin/Elements/EditCustomField
@@ -145,6 +145,13 @@ $id = $CustomFieldObj->id;
}
+# Fire the AfterUpdate callback if any updates happen.
+$m->callback(
+ CallbackName => 'AfterUpdate',
+ Object => $CustomFieldObj,
+ ARGSRef => \%ARGS,
+ Results => \@results
+) if ( @results );
</%INIT>
<%ARGS>
diff --git a/share/html/Admin/Elements/EditCustomFields b/share/html/Admin/Elements/EditCustomFields
index a9cd76b..d58c158 100644
--- a/share/html/Admin/Elements/EditCustomFields
+++ b/share/html/Admin/Elements/EditCustomFields
@@ -97,6 +97,7 @@ if ($id and !$Object->CurrentUserHasRight('AssignCustomFields')) {
}
my @results;
+my $updated;
my $lookup = $ObjectType;
$lookup .= "-$SubType" if $SubType;
@@ -112,6 +113,7 @@ if ( $MoveCustomFieldUp ) { {
my ($status, $msg) = $record->MoveUp;
push @results, $msg;
+ $updated = 1;
} }
if ( $MoveCustomFieldDown ) { {
my $record = RT::ObjectCustomField->new( $session{'CurrentUser'} );
@@ -123,6 +125,7 @@ if ( $MoveCustomFieldDown ) { {
my ($status, $msg) = $record->MoveDown;
push @results, $msg;
+ $updated = 1;
} }
if ( $UpdateCFs ) {
@@ -136,6 +139,7 @@ if ( $UpdateCFs ) {
}
my ($status, $msg) = $CF->AddToObject( $Object );
push @results, $msg;
+ $updated = 1;
}
foreach my $cf_id ( @RemoveCustomField ) {
my $CF = RT::CustomField->new( $session{'CurrentUser'} );
@@ -147,6 +151,7 @@ if ( $UpdateCFs ) {
}
my ($status, $msg) = $CF->RemoveFromObject( $Object );
push @results, $msg;
+ $updated = 1;
}
}
@@ -170,6 +175,14 @@ my $display_format = $id
: ("'__CheckBox.{RemoveCustomField}__',". $format .", '__MoveCF.{$id}__'");
$m->callback(CallbackName => 'EditDisplayFormat', DisplayFormat => \$display_format, id => $id);
+# Fire the AfterUpdate callback if any updates happen.
+$m->callback(
+ CallbackName => 'AfterUpdate',
+ Object => undef,
+ ARGSRef => \%ARGS,
+ Results => \@results
+) if ( $updated );
+
</%INIT>
<%ARGS>
$Object
diff --git a/share/html/Admin/Elements/EditScrips b/share/html/Admin/Elements/EditScrips
index 8334cf2..e21d63a 100644
--- a/share/html/Admin/Elements/EditScrips
+++ b/share/html/Admin/Elements/EditScrips
@@ -180,6 +180,14 @@ if ( $MoveScripDown ) {
}
}
+# Fire the AfterUpdate callback if any updates happen.
+$m->callback(
+ CallbackName => 'AfterUpdate',
+ Object => $scrip,
+ ARGSRef => \%ARGS,
+ Results => \@actions
+) if ( @actions );
+
</%init>
<%ARGS>
diff --git a/share/html/Admin/Elements/EditTemplates b/share/html/Admin/Elements/EditTemplates
index 6b7fe19..2b37fea 100644
--- a/share/html/Admin/Elements/EditTemplates
+++ b/share/html/Admin/Elements/EditTemplates
@@ -116,6 +116,15 @@ foreach my $id( @DeleteTemplates ) {
push @actions, $msg;
}
}
+
+# Fire the AfterUpdate callback if any updates happen.
+$m->callback(
+ CallbackName => 'AfterUpdate',
+ Object => $TemplateObj,
+ ARGSRef => \%ARGS,
+ Results => \@actions
+) if ( @actions );
+
</%INIT>
<%ARGS>
$id => 0
diff --git a/share/html/Admin/Elements/MembershipsPage b/share/html/Admin/Elements/MembershipsPage
index 75afd49..46ad222 100644
--- a/share/html/Admin/Elements/MembershipsPage
+++ b/share/html/Admin/Elements/MembershipsPage
@@ -113,6 +113,15 @@ if ( $Update ) {
my ($status, $msg) = $group->DeleteMember( $id );
push @results, $msg;
}
+
+ # Fire the AfterUpdate callback if any updates happen.
+ $m->callback(
+ CallbackName => 'AfterUpdate',
+ Object => $object,
+ ARGSRef => \%ARGS,
+ Results => \@results
+ ) if ( @results and $object->id );
+
MaybeRedirectForResults(
Arguments => { id => $id },
Actions => \@results,
diff --git a/share/html/Admin/Global/DashboardsInMenu.html b/share/html/Admin/Global/DashboardsInMenu.html
index 68de513..cd0c9e3 100644
--- a/share/html/Admin/Global/DashboardsInMenu.html
+++ b/share/html/Admin/Global/DashboardsInMenu.html
@@ -101,6 +101,15 @@ my @panes = $m->comp(
Content => $conf,
);
}
+
+ # Fire the AfterUpdate callback if any updates happen.
+ $m->callback(
+ CallbackName => 'AfterUpdate',
+ Object => $dashboard_attr,
+ ARGSRef => \%ARGS,
+ Results => \@actions
+ ) if ( $status and $dashboard_attr->id );
+
push @actions, $status ? loc('Global dashboards in menu saved.') : $msg;
}
);
diff --git a/share/html/Admin/Global/MyRT.html b/share/html/Admin/Global/MyRT.html
index 2f3374a..df7c53c 100644
--- a/share/html/Admin/Global/MyRT.html
+++ b/share/html/Admin/Global/MyRT.html
@@ -98,6 +98,14 @@ my @panes = $m->comp(
else {
$default_portlets->SetContent( $conf );
push @actions, loc( 'Global portlet [_1] saved.', $pane );
+
+ # Fire the AfterUpdate callback if any updates happen.
+ $m->callback(
+ CallbackName => 'AfterUpdate',
+ Object => $default_portlets,
+ ARGSRef => \%ARGS,
+ Results => \@actions
+ );
}
}
);
diff --git a/share/html/Admin/Global/Template.html b/share/html/Admin/Global/Template.html
index 4e15dda..8b337f6 100644
--- a/share/html/Admin/Global/Template.html
+++ b/share/html/Admin/Global/Template.html
@@ -89,6 +89,14 @@ if ($TemplateObj->Id()) {
ARGSRef => \%ARGS);
push @results, @aresults;
+ # Fire the AfterUpdate callback if any updates happen.
+ $m->callback(
+ CallbackName => 'AfterUpdate',
+ Object => $TemplateObj,
+ ARGSRef => \%ARGS,
+ Results => \@results
+ );
+
my ($ok, $msg) = $TemplateObj->CompileCheck;
push @results, $msg if !$ok;
} else {
diff --git a/share/html/Admin/Groups/Members.html b/share/html/Admin/Groups/Members.html
index f6fba06..5a1b34e 100644
--- a/share/html/Admin/Groups/Members.html
+++ b/share/html/Admin/Groups/Members.html
@@ -160,6 +160,15 @@ foreach my $member (grep $_, @AddMembersGroups) {
my ($val, $msg) = $Group->AddMember($principal->PrincipalId);
push (@results, $msg);
}
+
+# Fire the AfterUpdate callback if any updates happen.
+$m->callback(
+ CallbackName => 'AfterUpdate',
+ Object => $Group,
+ ARGSRef => \%ARGS,
+ Results => \@results
+) if ( @results );
+
</%INIT>
<%ARGS>
diff --git a/share/html/Admin/Groups/Modify.html b/share/html/Admin/Groups/Modify.html
index 4c1dd4f..3ee9bed 100644
--- a/share/html/Admin/Groups/Modify.html
+++ b/share/html/Admin/Groups/Modify.html
@@ -153,6 +153,14 @@ if ( $Group->Id and ($SetEnabled) and ( $Disabled != $Group->Disabled) ) {
push @results, $msg;
}
+# Fire the AfterUpdate callback if any updates happen.
+$m->callback(
+ CallbackName => 'AfterUpdate',
+ Object => $Group,
+ ARGSRef => \%ARGS,
+ Results => \@results
+) if ( @results and $Group->id );
+
# This code does automatic redirection if any updates happen.
MaybeRedirectForResults(
Actions => \@results,
diff --git a/share/html/Admin/Queues/DefaultValues.html b/share/html/Admin/Queues/DefaultValues.html
index 0eccee7..8ca8c28 100644
--- a/share/html/Admin/Queues/DefaultValues.html
+++ b/share/html/Admin/Queues/DefaultValues.html
@@ -173,6 +173,14 @@ elsif ( $ARGS{Update} ) {
}
}
+# Fire the AfterUpdate callback if any updates happen.
+$m->callback(
+ CallbackName => 'AfterUpdate',
+ Object => $queue,
+ ARGSRef => \%ARGS,
+ Results => \@results
+) if ( @results and $queue->id );
+
MaybeRedirectForResults(
Actions => \@results,
Arguments => { id => $queue->id },
diff --git a/share/html/Admin/Queues/Modify.html b/share/html/Admin/Queues/Modify.html
index e4e9673..c5a6677 100644
--- a/share/html/Admin/Queues/Modify.html
+++ b/share/html/Admin/Queues/Modify.html
@@ -245,6 +245,14 @@ if ( $QueueObj->Id ) {
my $InternalQueue = ($QueueObj->Id and $QueueObj->Disabled == 2);
+# Fire the AfterUpdate callback if any updates happen.
+$m->callback(
+ CallbackName => 'AfterUpdate',
+ Object => $QueueObj,
+ ARGSRef => \%ARGS,
+ Results => \@results
+) if ( @results and $QueueObj->id );
+
# This code does automatic redirection if any updates happen.
MaybeRedirectForResults(
Actions => \@results,
diff --git a/share/html/Admin/Queues/People.html b/share/html/Admin/Queues/People.html
index 456c582..103be3c 100644
--- a/share/html/Admin/Queues/People.html
+++ b/share/html/Admin/Queues/People.html
@@ -136,7 +136,7 @@
<%INIT>
-my ($field, @results, $User, $Users, $Groups, $watcher, $user_msg, $group_msg);
+my ($field, @results, $User, $Users, $Groups, $watcher, $user_msg, $group_msg, $updated);
my $QueueObj = RT::Queue->new($session{'CurrentUser'});
$QueueObj->Load($id) || Abort(loc("Couldn't load queue", $id));
@@ -151,6 +151,7 @@ unless ($OnlySearchForPeople or $OnlySearchForGroup) {
my ($code, $msg) = $QueueObj->DeleteWatcher(Type => $1,
PrincipalId => $2);
push @results, $msg;
+ $updated = 1;
}
}
@@ -168,6 +169,7 @@ unless ($OnlySearchForPeople or $OnlySearchForGroup) {
PrincipalId => $id,
);
push @results, $msg;
+ $updated = 1;
}
}
@@ -180,7 +182,7 @@ if ( $ARGS{'UserString'} ) {
);
} else {
$user_msg = loc("No principals selected.");
- }
+}
if ( $ARGS{'GroupString'} ) {
$Groups = RT::Groups->new( $session{'CurrentUser'} );
@@ -193,6 +195,15 @@ if ( $ARGS{'GroupString'} ) {
$group_msg = loc("No principals selected.");
}
my $title = loc('People related to queue [_1]', $QueueObj->Name);
+
+# Fire the AfterUpdate callback if any updates happen.
+$m->callback(
+ CallbackName => 'AfterUpdate',
+ Object => $QueueObj,
+ ARGSRef => \%ARGS,
+ Results => \@results
+) if ( $updated );
+
</%INIT>
<%ARGS>
diff --git a/share/html/Admin/Queues/Template.html b/share/html/Admin/Queues/Template.html
index faee796..77cf0ab 100644
--- a/share/html/Admin/Queues/Template.html
+++ b/share/html/Admin/Queues/Template.html
@@ -114,6 +114,13 @@ if ($Create) {
$title = loc( 'Modify template [_1] for queue [_2]', loc( $TemplateObj->Name()), $QueueObj->Name );
$SubmitLabel = loc('Save Changes');
}
+# Fire the AfterUpdate callback if any updates happen.
+$m->callback(
+ CallbackName => 'AfterUpdate',
+ Object => $TemplateObj,
+ ARGSRef => \%ARGS,
+ Results => \@results
+) if ( @results );
</%INIT>
<%ARGS>
diff --git a/share/html/Admin/Scrips/Create.html b/share/html/Admin/Scrips/Create.html
index 7cc3406..9d47849 100644
--- a/share/html/Admin/Scrips/Create.html
+++ b/share/html/Admin/Scrips/Create.html
@@ -127,6 +127,14 @@ if ( $Create ) {
CustomIsApplicableCode => $ARGS{"CustomIsApplicableCode"},
);
+ # Fire the AfterUpdate callback if any updates happen.
+ $m->callback(
+ CallbackName => 'AfterUpdate',
+ Object => $scrip,
+ ARGSRef => \%ARGS,
+ Results => \@results
+ ) if ( @results and $scrip->id );
+
MaybeRedirectForResults(
Force => 1,
Actions => [ $msg ],
diff --git a/share/html/Admin/Scrips/Modify.html b/share/html/Admin/Scrips/Modify.html
index 618c48d..59d33a3 100644
--- a/share/html/Admin/Scrips/Modify.html
+++ b/share/html/Admin/Scrips/Modify.html
@@ -123,6 +123,15 @@ if ( $Update ) {
Object => $scrip,
ARGSRef => \%ARGS
);
+
+ # Fire the AfterUpdate callback if any updates happen.
+ $m->callback(
+ CallbackName => 'AfterUpdate',
+ Object => $scrip,
+ ARGSRef => \%ARGS,
+ Results => \@results
+ ) if ( @results and $scrip->id );
+
MaybeRedirectForResults(
Actions => \@results,
Arguments => {
diff --git a/share/html/Admin/Scrips/Objects.html b/share/html/Admin/Scrips/Objects.html
index 7b012dc..0cdba64 100644
--- a/share/html/Admin/Scrips/Objects.html
+++ b/share/html/Admin/Scrips/Objects.html
@@ -152,6 +152,15 @@ if ( $Update ) {
my ($status, $msg) = $global->SetStage($Stage);
push @results, $msg;
}
+
+ # Fire the AfterUpdate callback if any updates happen.
+ $m->callback(
+ CallbackName => 'AfterUpdate',
+ Object => $scrip,
+ ARGSRef => \%ARGS,
+ Results => \@results
+ ) if ( @results and $scrip->id );
+
MaybeRedirectForResults(
Actions => \@results,
Arguments => {
diff --git a/share/html/Admin/Tools/Shredder/index.html b/share/html/Admin/Tools/Shredder/index.html
index 4440691..6081550 100644
--- a/share/html/Admin/Tools/Shredder/index.html
+++ b/share/html/Admin/Tools/Shredder/index.html
@@ -179,4 +179,14 @@ if( $Plugin && ( $Search || $Wipeout ) ) { { # use additional block({}) to effec
push @{ $messages{Success} }, loc('see object list below');
}
} }
+
+# Fire the AfterUpdate callback if any updates happen.
+$m->callback(
+ CallbackName => 'AfterUpdate',
+ Object => undef,
+ ARGSRef => \%ARGS,
+ Results => $messages{Success}
+) if ( @{$messages{Success}} );
+
+
</%INIT>
diff --git a/share/html/Admin/Tools/Theme.html b/share/html/Admin/Tools/Theme.html
index 2cc079f..42c06b9 100644
--- a/share/html/Admin/Tools/Theme.html
+++ b/share/html/Admin/Tools/Theme.html
@@ -244,6 +244,8 @@ my $imgdata;
my $colors;
my $valid_image_types;
+my $updated;
+
if (not RT->Config->Get('DisableGD') and Convert::Color->require) {
require GD;
@@ -317,6 +319,7 @@ if (my $file_hash = _UploadedFile( 'logo-upload' )) {
colors => $colors,
},
);
+ $updated = 1;
push @results, loc("Unable to set UserLogo: [_1]", $msg) unless $id;
@@ -324,6 +327,7 @@ if (my $file_hash = _UploadedFile( 'logo-upload' )) {
}
elsif ($ARGS{'reset_logo'}) {
RT->System->DeleteAttribute('UserLogo');
+ $updated = 1;
}
else {
if (my $attr = RT->System->FirstAttribute('UserLogo')) {
@@ -341,11 +345,13 @@ else {
Description => "User-provided logo",
Content => $content,
);
+ $updated = 1;
}
}
}
else {
RT->System->DeleteAttribute('UserLogo');
+ $updated = 1;
}
}
}
@@ -361,6 +367,7 @@ if ($user_css) {
Content => $user_css );
push @results, loc("Unable to set UserCSS: [_1]", $msg) unless $id;
}
+ $updated = 1;
}
if (!$user_css) {
@@ -372,6 +379,15 @@ if (!$user_css) {
} @sections
);
}
+
+# Fire the AfterUpdate callback if any updates happen.
+$m->callback(
+ CallbackName => 'AfterUpdate',
+ Object => undef,
+ ARGSRef => \%ARGS,
+ Results => \@results
+) if ( $updated );
+
</%INIT>
<%ARGS>
$user_css => ''
diff --git a/share/html/Admin/Users/DashboardsInMenu.html b/share/html/Admin/Users/DashboardsInMenu.html
index 53e7356..4fa99e6 100644
--- a/share/html/Admin/Users/DashboardsInMenu.html
+++ b/share/html/Admin/Users/DashboardsInMenu.html
@@ -112,6 +112,15 @@ my @panes = $m->comp(
$m->comp( '/Widgets/SelectionBox:process', %ARGS, self => $_ )
for @panes;
+# Fire the AfterUpdate callback if any updates happen.
+$m->callback(
+ CallbackName => 'AfterUpdate',
+ Object => $UserObj,
+ ARGSRef => \%ARGS,
+ Results => \@actions
+) if ( @actions );
+
+
</%init>
<%ARGS>
$id => undef
diff --git a/share/html/Admin/Users/Keys.html b/share/html/Admin/Users/Keys.html
index 85e0d52..2b1b7dd 100644
--- a/share/html/Admin/Users/Keys.html
+++ b/share/html/Admin/Users/Keys.html
@@ -114,6 +114,15 @@ if (RT::Crypt->UseForOutgoing eq 'GnuPG') {
if (($ARGS{'PrivateKey'}||'') ne ($UserObj->PrivateKey||'')) {
my ($status, $msg) = $UserObj->SetPrivateKey( $ARGS{'PrivateKey'} );
push @results, $msg;
+ # Fire the AfterUpdate callback if any updates happen.
+ # Sanitize the private key first
+ $ARGS{'PrivateKey'} = 'REDACTED';
+ $m->callback(
+ CallbackName => 'AfterUpdate',
+ Object => $UserObj,
+ ARGSRef => \%ARGS,
+ Results => \@results
+ ) if ( @results );
}
} else {
push @results, loc("Invalid key [_1] for address '[_2]'", $ARGS{'PrivateKey'}, $email);
@@ -125,6 +134,14 @@ if (RT::Crypt->UseForOutgoing eq 'SMIME') {
if ( $Update and ($ARGS{'SMIMECertificate'}||'') ne ($UserObj->SMIMECertificate||'') ) {
my ($status, $msg) = $UserObj->SetSMIMECertificate( $ARGS{'SMIMECertificate'} );
push @results, $msg;
+ # Fire the AfterUpdate callback if any updates happen.
+ $ARGS{'SMIMECertificate'} = 'REDACTED';
+ $m->callback(
+ CallbackName => 'AfterUpdate',
+ Object => $UserObj,
+ ARGSRef => \%ARGS,
+ Results => \@results
+ ) if ( @results );
}
}
diff --git a/share/html/Admin/Users/Modify.html b/share/html/Admin/Users/Modify.html
index 0b30780..bdf5a80 100644
--- a/share/html/Admin/Users/Modify.html
+++ b/share/html/Admin/Users/Modify.html
@@ -303,6 +303,14 @@ if ( $UserObj->Id ) {
}
}
+# Fire the AfterUpdate callback if any updates happen.
+$m->callback(
+ CallbackName => 'AfterUpdate',
+ Object => $UserObj,
+ ARGSRef => \%ARGS,
+ Results => \@results
+) if ( @results and $UserObj->id );
+
# This code does automatic redirection if any updates happen.
MaybeRedirectForResults(
Actions => \@results,
diff --git a/share/html/Admin/Users/MyRT.html b/share/html/Admin/Users/MyRT.html
index 0bd2473..10504f7 100644
--- a/share/html/Admin/Users/MyRT.html
+++ b/share/html/Admin/Users/MyRT.html
@@ -65,7 +65,7 @@
% }
<%init>
-my @actions;
+my (@actions, $updated);
my $UserObj = RT::User->new($session{'CurrentUser'});
$UserObj->Load($id) || Abort("Couldn't load user '" . ($id || '') . "'");
my $title = loc("RT at a glance for the user [_1]", $UserObj->Name);
@@ -73,6 +73,7 @@ my $title = loc("RT at a glance for the user [_1]", $UserObj->Name);
if ($ARGS{Reset}) {
my ($ok, $msg) = $UserObj->SetPreferences('HomepageSettings', {});
push @actions, $ok ? loc('Preferences saved for user [_1].', $UserObj->Name) : $msg;
+ $updated = 1;
}
my ($default_portlets) = RT::System->new($session{'CurrentUser'})->Attributes->Named('HomepageSettings');
@@ -115,12 +116,22 @@ my @panes = $m->comp(
my ( $conf, $pane ) = @_;
my ($ok, $msg) = $UserObj->SetPreferences( 'HomepageSettings', $conf );
push @actions, $ok ? loc('Preferences [_1] for user [_2].', $pane, $UserObj->Name) : $msg;
+ $updated = 1;
}
);
$m->comp( '/Widgets/SelectionBox:process', %ARGS, self => $_ )
for @panes;
+# Fire the AfterUpdate callback if any updates happen.
+$m->callback(
+ CallbackName => 'AfterUpdate',
+ Object => $UserObj,
+ ARGSRef => \%ARGS,
+ Results => \@results
+) if ( $updated );
+
+
</%init>
<%ARGS>
$id => undef
-----------------------------------------------------------------------
More information about the rt-commit
mailing list