[Bps-public-commit] rt-extension-deactiveactionpref branch, master, updated. 3d1ce2b21863384abe0c30ff3116623b09b79680

? sunnavy sunnavy at bestpractical.com
Thu Jul 10 09:30:52 EDT 2014


The branch, master has been updated
       via  3d1ce2b21863384abe0c30ff3116623b09b79680 (commit)
      from  a0c0bcd2267f9aab96f78602535921e6dfecea69 (commit)

Summary of changes:
 META.yml                                           |  1 +
 .../DeactiveActionPref/Elements/Tabs/Privileged    | 35 ++++++++++++++++++++++
 lib/RT/Extension/DeactiveActionPref.pm             | 22 --------------
 3 files changed, 36 insertions(+), 22 deletions(-)
 create mode 100644 html/Callbacks/DeactiveActionPref/Elements/Tabs/Privileged

- Log -----------------------------------------------------------------
commit 3d1ce2b21863384abe0c30ff3116623b09b79680
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Thu Jul 10 21:26:49 2014 +0800

    massage Tabs instead
    
    Because the ->{data} of a LifecycleObj pulls from the global lifecycle cache,
    altering it alters it for the process lifetime.  Under a standalone server, if
    I load a ticket with a user with this preference set to "Respond", it _also_
    affects all other users who don't have the preference set. chmrr++

diff --git a/META.yml b/META.yml
index 1210323..2695963 100644
--- a/META.yml
+++ b/META.yml
@@ -16,6 +16,7 @@ meta-spec:
 name: RT-Extension-DeactiveActionPref
 no_index:
   directory:
+    - html
     - inc
 resources:
   license: http://opensource.org/licenses/gpl-license.php
diff --git a/html/Callbacks/DeactiveActionPref/Elements/Tabs/Privileged b/html/Callbacks/DeactiveActionPref/Elements/Tabs/Privileged
new file mode 100644
index 0000000..05df02b
--- /dev/null
+++ b/html/Callbacks/DeactiveActionPref/Elements/Tabs/Privileged
@@ -0,0 +1,35 @@
+<%init>
+
+my $request_path = $HTML::Mason::Commands::r->path_info;
+$request_path =~ s!/{2,}!/!g;
+
+return unless $request_path =~ m{^/Ticket/} && $DECODED_ARGS->{'id'} &&  $DECODED_ARGS->{'id'} =~ /^(\d+)$/;
+
+my $id  = $1;
+my $ticket = RT::Ticket->new( $session{'CurrentUser'} );
+$ticket->Load($id);
+
+return unless $ticket && $ticket->id;
+
+my $actions = PageMenu()->child( 'actions' );
+my $pref = $session{CurrentUser}->Preferences(RT->System, {});
+return unless $pref && $pref->{DeactiveAction};
+my $update_type = $pref->{DeactiveAction};
+
+my $current = $ticket->Status;
+my $lifecycle = $ticket->LifecycleObj;
+
+for my $info ( $lifecycle->Actions($current) ) {
+    my $next = $info->{'to'};
+    my $key = $info->{'label'} || ucfirst($next);
+    my $action = $actions->child($key);
+
+    next unless $action;
+    next unless $lifecycle->IsInactive($next);
+
+    my $original_action = $info->{'update'} || '';
+    next if $update_type eq $original_action;
+
+    $action->{path} =~ s!(?<=\bAction=)\w+!$update_type!;
+}
+</%init>
diff --git a/lib/RT/Extension/DeactiveActionPref.pm b/lib/RT/Extension/DeactiveActionPref.pm
index 02d0933..0e0fdb4 100644
--- a/lib/RT/Extension/DeactiveActionPref.pm
+++ b/lib/RT/Extension/DeactiveActionPref.pm
@@ -16,28 +16,6 @@ $RT::Config::META{DeactiveAction} = {
     },
 };
 
-no warnings 'redefine';
-use RT::Record::Role::Lifecycle;
-use Scalar::Util 'blessed';
-my $orig_lifecycle = \&RT::Queue::LifecycleObj;
-*RT::Queue::LifecycleObj = sub {
-    my $self = shift;
-    my $res = $orig_lifecycle->($self);
-    if ( blessed($self) && $self->id && $self->CurrentUser->id != RT->SystemUser->id ) {
-        my $pref = $self->CurrentUser->Preferences(RT->System, {});
-        if ( my $update_type = $pref->{DeactiveAction} ) {
-            my @new_actions;
-            for my $action ( @{ $res->{'data'}{'actions'} || [] } ) {
-                if ( $res->IsInactive( $action->{to} ) ) {
-                    push @new_actions, { %$action, update => $update_type };
-                }
-            }
-            $res->{'data'}{'actions'} = \@new_actions;
-        }
-    }
-    return $res;
-};
-
 =head1 NAME
 
 RT-Extension-DeactiveActionPref - Deactive action user pref

-----------------------------------------------------------------------


More information about the Bps-public-commit mailing list