How to fix custom fields on Users?

Hello All,

I have just tried to create a custom field that applies to users – and it
didn’t work. That is, I created the field all right, was able to search users
based on it’s value on Admin/Users/, but was not able to set that field.

I tracked the problem down to RT::User->CustomFields generating a query
joined with table ObjectCustomFields, but there is no matching row in there.
I found, that during custom field creation, a record is placed in that table,
but not for user and group custom fields.

So as a quick-fix, I placed this in lib/RT/User_Local.pm:

sub CustomFields {
my $self = shift;
my $cfs = RT::CustomFields->new( $self->CurrentUser );
$cfs->UnLimit;

# XXX handle multiple types properly
foreach my $lookup ($self->_LookupTypes) {
    $cfs->LimitToLookupType($lookup);
}

return $cfs;
}

which is really just the method taken from RT::Record, with row reading

$cfs->LimitToGlobalOrObjectId($self->_LookupId($lookup));

removed. This fix seems to work.

Now I’d like to know whether the correct fix is to remove this limit for
RT::User and RT::Group, or to make LimitToGlobalOrObjectId work for them.
I also assume it would be better to remove this check from RT::Record and
override in RT::Ticket, rather than the other way around.

I’d be willing to produce a patch, but want to know which fix would be
considered better.

					 Jan 'Bulb' Hudec <bulb@ucw.cz>

signature.asc (189 Bytes)

I have just tried to create a custom field that applies to users – and it
didn’t work. That is, I created the field all right, was able to search users
based on it’s value on Admin/Users/, but was not able to set that field.

Sorry, my fault.

					 Jan 'Bulb' Hudec <bulb@ucw.cz>

signature.asc (189 Bytes)