From: Chris W. <la...@us...> - 2005-03-15 12:42:50
|
Update of /cvsroot/openinteract/OpenInteract2/lib/OpenInteract2/Action In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18339 Modified Files: Common.pm Log Message: OIN-97: instead of using a reversed hash iterate through the keys/values in the field mapping to find an alternate ID field Index: Common.pm =================================================================== RCS file: /cvsroot/openinteract/OpenInteract2/lib/OpenInteract2/Action/Common.pm,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** Common.pm 13 Mar 2005 06:22:40 -0000 1.23 --- Common.pm 15 Mar 2005 12:42:38 -0000 1.24 *************** *** 155,171 **** # If it's not found using that ID field, see if we've got another # field mapped to the given ID field in the SPOPS object unless ( defined $id ) { my $object_class = $self->param( 'c_object_class' ); my $field_map = eval { $object_class->CONFIG->{field_map} } || {}; ! my %reverse_map = map { $field_map->{ $_ } => $_ } keys %{ $field_map }; ! $alt_id_field = $reverse_map{ $id_field } || $field_map->{ $id_field }; ! if ( $alt_id_field ) { $id = $self->param( $alt_id_field ) || $request->param( $alt_id_field ); ! $log->is_debug && ! $log->debug( "Using mapped ID field '$alt_id_field' ", ! "got ID value '$id'" ); ! $self->param( c_id_field => $alt_id_field ); } } --- 155,187 ---- # If it's not found using that ID field, see if we've got another # field mapped to the given ID field in the SPOPS object + # + # For example, in 'group' using LDAP you have: + # + # id_field = cn + # ... + # [group field_map] + # notes = description + # group_id = cn + # name = cn + + # If you pass in: + # /group/display/?group_id=groupname + # this will see that 'group_id' is mapped to 'cn' and find that + # field value and use it unless ( defined $id ) { my $object_class = $self->param( 'c_object_class' ); my $field_map = eval { $object_class->CONFIG->{field_map} } || {}; ! while ( my ( $alt_id_field, $mapped ) = each %{ $field_map } ) { ! next unless ( $mapped eq $id_field ); $id = $self->param( $alt_id_field ) || $request->param( $alt_id_field ); ! if ( $id ) { ! $log->is_debug && ! $log->debug( "Using mapped ID field '$alt_id_field' ", ! "got ID value '$id'" ); ! $self->param( c_id_field => $alt_id_field ); ! last; ! } } } |