[Rt-commit] rt branch, config-callbacks, created. rt-4.4.1-1-g3e8dad2

Aaron Kondziela aaron at bestpractical.com
Fri Feb 24 00:29:56 EST 2017


The branch, config-callbacks has been created
        at  3e8dad20dbbf9480af9934dbcceb4b778301e10b (commit)

- Log -----------------------------------------------------------------
commit 3e8dad20dbbf9480af9934dbcceb4b778301e10b
Author: Aaron Kondziela <aaron at bestpractical.com>
Date:   Fri Feb 24 00:24:01 2017 -0500

    Add AfterUpdate callbacks to Admin section of web UI
    
    The AfterUpdate callbacks support logging, auditing, etc., for changes made
    to RT configuration via the Admin section.
    
    Fixes T#180410

diff --git a/lib/RT/Interface/Web.pm b/lib/RT/Interface/Web.pm
index e3cf905..6271794 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,6 +2793,14 @@ sub ProcessACLs {
         }
     }
 
+    # Fire the AfterUpdate callback if any updates happen.
+    $m->callback(
+        CallbackName => 'AfterUpdate',
+        Object => undef,
+        ARGSRef => $ARGSref,
+        Results => \@results
+    ) if ( $updated );
+
     return (@results);
 }
 
diff --git a/share/html/Admin/Articles/Classes/Modify.html b/share/html/Admin/Articles/Classes/Modify.html
index f4a6f78..420caed 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 ( (grep {defined $_ and $_ ne ''} @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..f003f77 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 ( (grep {defined $_ and $_ ne ''} @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..487696d 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 => undef,
+    ARGSRef => \%ARGS,
+    Results => \@results
+) if ( (grep {defined $_ and $_ ne ''} @results) );
+
+
 </%INIT>
 
 
diff --git a/share/html/Admin/Assets/Catalogs/Create.html b/share/html/Admin/Assets/Catalogs/Create.html
index 65a18ba..13c84ac 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 ( (grep {defined $_ and $_ ne ''} @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..5609873 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 ( (grep {defined $_ and $_ ne ''} @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..f94fbfe 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 ( (grep {defined $_ and $_ ne ''} @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..7ca940b 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 ( (grep {defined $_ and $_ ne ''} @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..06a81bf 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 ( (grep {defined $_ and $_ ne ''} @results) );
+
 </%INIT>
 <%ARGS>
 $id => undef
diff --git a/share/html/Admin/CustomRoles/Modify.html b/share/html/Admin/CustomRoles/Modify.html
index 1905cc2..d19289a 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 ( (grep {defined $_ and $_ ne ''} @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..7fcbca9 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 ( (grep {defined $_ and $_ ne ''} @results) and $role->id );
+
     MaybeRedirectForResults(
         Actions   => \@results,
         Arguments => {
diff --git a/share/html/Admin/Elements/EditCustomField b/share/html/Admin/Elements/EditCustomField
index 4dba36d..000d57c 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 ( (grep {defined $_ and $_ ne ''} @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..cedc347 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 => undef,
+    ARGSRef => \%ARGS,
+    Results => \@actions
+) if ( (grep {defined $_ and $_ ne ''} @actions) );
+
 </%init>
 
 <%ARGS>
diff --git a/share/html/Admin/Elements/EditTemplates b/share/html/Admin/Elements/EditTemplates
index 6b7fe19..addf7d6 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 => undef,
+    ARGSRef => \%ARGS,
+    Results => \@actions
+) if ( (grep {defined $_ and $_ ne ''} @actions) );
+
 </%INIT>
 <%ARGS>
 $id => 0
diff --git a/share/html/Admin/Elements/MembershipsPage b/share/html/Admin/Elements/MembershipsPage
index 75afd49..4ee20ed 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 ( (grep {defined $_ and $_ ne ''} @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..2302007 100644
--- a/share/html/Admin/Global/DashboardsInMenu.html
+++ b/share/html/Admin/Global/DashboardsInMenu.html
@@ -101,6 +101,8 @@ my @panes = $m->comp(
                 Content => $conf,
             );
         }
+
+
         push @actions, $status ? loc('Global dashboards in menu saved.') : $msg;
     }
 );
@@ -108,6 +110,15 @@ my @panes = $m->comp(
 $m->comp( '/Widgets/SelectionBox:process', %ARGS, self => $_ )
     for @panes;
 
+if ($ARGS{'dashboards_in_menu-Submit'}) {
+    # Fire the AfterUpdate callback if any updates happen.
+    $m->callback(
+        CallbackName => 'AfterUpdate',
+        Object => undef,
+        ARGSRef => \%ARGS,
+        Results => \@actions
+    );
+}
 
 </%init>
 
diff --git a/share/html/Admin/Global/MyRT.html b/share/html/Admin/Global/MyRT.html
index 2f3374a..e417b92 100644
--- a/share/html/Admin/Global/MyRT.html
+++ b/share/html/Admin/Global/MyRT.html
@@ -105,6 +105,15 @@ my @panes = $m->comp(
 $m->comp( '/Widgets/SelectionBox:process', %ARGS, self => $_ )
     for @panes;
 
+if ($ARGS{'body-Submit'}) {
+    # Fire the AfterUpdate callback if any updates happen.
+    $m->callback(
+        CallbackName => 'AfterUpdate',
+        Object => $default_portlets,
+        ARGSRef => \%ARGS,
+        Results => \@actions
+    );
+}
 
 </%init>
 
diff --git a/share/html/Admin/Global/Template.html b/share/html/Admin/Global/Template.html
index 4e15dda..ee97572 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
+    ) if(grep {defined $_ and $_ ne ''} @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..e5ecf97 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 ( (grep {defined $_ and $_ ne ''} @results) );
+
 </%INIT>
 
 <%ARGS>
diff --git a/share/html/Admin/Groups/Modify.html b/share/html/Admin/Groups/Modify.html
index 4c1dd4f..b9e14a7 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 ( (grep {defined $_ and $_ ne ''} @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..0f169af 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 ( (grep {defined $_ and $_ ne ''} @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..8caac9c 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 ( (grep {defined $_ and $_ ne ''} @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..6cd3c01 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 ( (grep {defined $_ and $_ ne ''} @results) );
 
 </%INIT>
 <%ARGS>
diff --git a/share/html/Admin/Scrips/Create.html b/share/html/Admin/Scrips/Create.html
index 7cc3406..8d9897e 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 ( (grep {defined $_ and $_ ne ''} @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..c1a45f5 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 ( (grep {defined $_ and $_ ne ''} @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..350a904 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 ( (grep {defined $_ and $_ ne ''} @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..16faf03 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 ( (grep {defined $_ and $_ ne ''} @actions) );
+
+
 </%init>
 <%ARGS>
 $id => undef
diff --git a/share/html/Admin/Users/Keys.html b/share/html/Admin/Users/Keys.html
index 85e0d52..308ec31 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 ( (grep {defined $_ and $_ ne ''} @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 ( (grep {defined $_ and $_ ne ''} @results) );
     }
 }
 
diff --git a/share/html/Admin/Users/Modify.html b/share/html/Admin/Users/Modify.html
index 0b30780..ee4f73b 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 ( (grep {defined $_ and $_ ne ''} @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