[Rt-commit] rt branch, 4.2/expose-cf-to-cfvs, created. rt-4.2.9-45-g0731d19

Kevin Falcone falcone at bestpractical.com
Thu Dec 4 18:35:26 EST 2014


The branch, 4.2/expose-cf-to-cfvs has been created
        at  0731d196de7da4897dec268b4c53d8fab0370160 (commit)

- Log -----------------------------------------------------------------
commit 0731d196de7da4897dec268b4c53d8fab0370160
Author: Kevin Falcone <falcone at bestpractical.com>
Date:   Wed Dec 3 11:10:21 2014 -0500

    Keep track of which Custom Field Object these Values belong to
    
    While you can reverse the Custom Field by looking at
    $cfvs->First->CustomFieldObj you lose the Context Object of the Custom
    Field (and more importantly, the ACLEquivalenceObjects).
    
    Knowing this lets you know what Queue a CF was loaded against so if you're
    writing an External Custom Field (or otherwise massaging values) you
    could tweak the output based on the Queue.

diff --git a/lib/RT/CustomField.pm b/lib/RT/CustomField.pm
index 91ffdc3..18bb2ba 100644
--- a/lib/RT/CustomField.pm
+++ b/lib/RT/CustomField.pm
@@ -604,6 +604,7 @@ sub Values {
         $class->require or die "Can't load $class: $@";
     }
     my $cf_values = $class->new( $self->CurrentUser );
+    $cf_values->SetCustomField( $self );
     # if the user has no rights, return an empty object
     if ( $self->id && $self->CurrentUserHasRight( 'SeeCustomField') ) {
         $cf_values->LimitToCustomField( $self->Id );
@@ -1029,7 +1030,6 @@ sub ValidateContextObject {
     return $self->IsAdded($added_to->id);
 }
 
-
 sub _Set {
     my $self = shift;
 
diff --git a/lib/RT/CustomFieldValues.pm b/lib/RT/CustomFieldValues.pm
index 25d5d69..9bc9b39 100644
--- a/lib/RT/CustomFieldValues.pm
+++ b/lib/RT/CustomFieldValues.pm
@@ -93,6 +93,17 @@ sub LimitToCustomField {
     );
 }
 
+sub SetCustomField {
+    my $self = shift;
+    return $self->{'custom_field'} = shift;
+}
+
+sub CustomField {
+    my $self = shift;
+    return $self->{'custom_field'};
+}
+
+
 RT::Base->_ImportOverlays();
 
 1;

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


More information about the rt-commit mailing list