Ignore:
Timestamp:
05/10/09 19:03:39 (15 years ago)
Author:
nanardon
Message:
  • allow to sync specific object
File:
1 edited

Legend:

Unmodified
Added
Removed
  • LATMOS-Accounts/lib/LATMOS/Accounts/Bases.pm

    r74 r83  
    276276} 
    277277 
     278=head2 sync_object 
     279 
     280Synchronise an object into this base 
     281 
     282=cut 
     283 
     284sub sync_object { 
     285    my ($self, $srcobj, %options) = @_; 
     286    $self->is_supported_object($srcobj->type) or return; 
     287    my @fields = $options{attrs} 
     288        ? @{ $options{attrs} } 
     289        : $self->list_canonicals_fields($srcobj->type, 'w'); 
     290    my %data; 
     291    foreach (@fields) { 
     292        $srcobj->get_field_name($_) or next; 
     293        $data{$_} = $srcobj->get_c_field($_); 
     294    } 
     295    if (my $dstobj = $self->get_object($srcobj->type, $srcobj->id)) { 
     296        return $dstobj->set_c_fields(%data); 
     297    } elsif(!$options{nocreate}) { 
     298        return $self->create_c_object($srcobj->type, $srcobj->id, %data); 
     299    } else { 
     300        return 0; 
     301    } 
     302} 
     303 
    2783041; 
    279305 
Note: See TracChangeset for help on using the changeset viewer.