[Rt-commit] rt branch, 4.2/auto-apply-user-group-cfs-globally-fix, created. rt-4.0.4-237-g4701889

? sunnavy sunnavy at bestpractical.com
Tue Dec 6 23:17:34 EST 2011


The branch, 4.2/auto-apply-user-group-cfs-globally-fix has been created
        at  4701889f06510e4baf33ff0b240a04986c9b553d (commit)

- Log -----------------------------------------------------------------
commit f49e6f85f26eb72d1f6808acbc01281fd04947e5
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Wed Dec 7 11:20:47 2011 +0800

    we have CF->ApplyGlobally to test if it is a global-only cf

diff --git a/share/html/Admin/CustomFields/Modify.html b/share/html/Admin/CustomFields/Modify.html
index 8a54b21..a19c56c 100644
--- a/share/html/Admin/CustomFields/Modify.html
+++ b/share/html/Admin/CustomFields/Modify.html
@@ -273,7 +273,7 @@ CustomFieldObj => $CustomFieldObj, CustomFieldValueObj => $cfv, ARGSRef => \%ARG
     }
 }
 
-if ( $CustomFieldObj->id && $CustomFieldObj->LookupType =~ /^RT::(?:User|Group)$/ ) {
+if ( $CustomFieldObj->id && $CustomFieldObj->ApplyGlobally ) {
     my ( $ret, $msg );
     my $object = $CustomFieldObj->RecordClassFromLookupType->new( $session{'CurrentUser'} );
 
diff --git a/share/html/Elements/Tabs b/share/html/Elements/Tabs
index 333a1ac..44727ed 100755
--- a/share/html/Elements/Tabs
+++ b/share/html/Elements/Tabs
@@ -354,7 +354,7 @@ my $build_admin_menu = sub {
             $tabs->child( 'group-rights' => title => loc('Group Rights') => path => "/Admin/CustomFields/GroupRights.html?id=" . $id );
             $tabs->child( 'user-rights' => title => loc('User Rights') => path => "/Admin/CustomFields/UserRights.html?id=" . $id );
 
-            unless ( $obj->LookupType =~ /^RT::(?:User|Group)$/ ) {
+            unless ( $obj->ApplyGlobally ) {
                 $tabs->child( 'applies-to' => title => loc('Applies to'), path => "/Admin/CustomFields/Objects.html?id=" . $id );
             }
 

commit 4701889f06510e4baf33ff0b240a04986c9b553d
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Wed Dec 7 11:57:28 2011 +0800

    sync global-only cf's disabled/applied in global config pages.
    
    e.g. /Admin/Global/CustomFields/Users.html

diff --git a/lib/RT/CustomField.pm b/lib/RT/CustomField.pm
index fed4f84..ebaeef3 100644
--- a/lib/RT/CustomField.pm
+++ b/lib/RT/CustomField.pm
@@ -1174,8 +1174,9 @@ the rules here.
 
 sub ApplyGlobally {
     my $self = shift;
+    my $lookup = shift || $self->LookupType;
 
-    return ($self->LookupType =~ /^RT::(?:Group|User)/io);
+    return ($lookup =~ /^RT::(?:Group|User)/io);
 
 }
 
diff --git a/share/html/Admin/Elements/EditCustomFields b/share/html/Admin/Elements/EditCustomFields
index 91d5cff..b48295f 100755
--- a/share/html/Admin/Elements/EditCustomFields
+++ b/share/html/Admin/Elements/EditCustomFields
@@ -133,6 +133,12 @@ if ( $UpdateCFs ) {
             push @results, loc("Couldn't load CustomField #[_1]", $cf_id);
             next;
         }
+
+        if ( $CF->ApplyGlobally ) {
+            my ($status, $msg) = $CF->SetDisabled(0);
+            push @results, $msg;
+        }
+
         my ($status, $msg) = $CF->AddToObject( $Object );
         push @results, $msg;
     }
@@ -145,6 +151,11 @@ if ( $UpdateCFs ) {
         }
         my ($status, $msg) = $CF->RemoveFromObject( $Object );
         push @results, $msg;
+
+        if ( $CF->ApplyGlobally ) {
+            my ($status, $msg) = $CF->SetDisabled(1);
+            push @results, $msg;
+        }
     }
 }
 
@@ -156,6 +167,9 @@ $applied_cfs->LimitToGlobalOrObjectId($id);
 $applied_cfs->ApplySortOrder;
 
 my $not_applied_cfs = RT::CustomFields->new( $session{'CurrentUser'} );
+if ( RT::CustomField->ApplyGlobally($lookup) ) {
+    $not_applied_cfs->FindAllRows();
+}
 $not_applied_cfs->LimitToLookupType($lookup);
 $not_applied_cfs->LimitToNotApplied( $id ? ($id, 0) : (0) );
 

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


More information about the Rt-commit mailing list