diff options
Diffstat (limited to 'LedgerSMB/DBObject/User.pm')
-rw-r--r-- | LedgerSMB/DBObject/User.pm | 57 |
1 files changed, 49 insertions, 8 deletions
diff --git a/LedgerSMB/DBObject/User.pm b/LedgerSMB/DBObject/User.pm index 0ca6bcfc..00a7e9db 100644 --- a/LedgerSMB/DBObject/User.pm +++ b/LedgerSMB/DBObject/User.pm @@ -90,6 +90,7 @@ sub get { } $self->{roles} = \@rolstore; + $self->{entity_id} = $self->{entity}->{id}; print STDERR "Got all user information"; #$user->{user} = $u->get($id); @@ -145,16 +146,56 @@ sub save_contact { my $self = shift @_; my $id = shift @_; + my $class = shift @_; my $contact = shift @_; + my @ret; + + print STDERR Dumper($self->{entity}->{id}); + if ($id) { + print STDERR "Found ID.."; + @ret = $self->exec_method(funcname=>"person__save_contact", + args=>[ + $self->{entity}->{id}, + $self->{contacts}->[$id]->{contact_class}, + $self->{contacts}->[$id]->{contact}, + $contact + ] + ); + } + else{ + print STDERR "Did not find an ID, attempting to save a new contact..\n"; + print STDERR ($class."\n"); + print STDERR ($contact."\n"); + print STDERR ($self->{entity_id}."\n"); + @ret = $self->exec_method(funcname=>"person__save_contact", + args=>[ + $self->{entity_id}, + $class, + undef, + $contact + ] + ); + } + print STDERR Dumper(\@ret); + if ($ret[0]->{person__save_contact} == 1){ + $self->{dbh}->commit(); + } + else{ + $self->error("Couldn't save contact..."); + } + return 1; +} + +sub delete_contact { + + my $self = shift @_; + my $id = shift @_; + + # Okay + # ID doesn't actually conform to any database entry + # We're basically cheating outrageously here. + - my @ret = $self->exec_method(funcname=>"person__save_contact", - args=>[ - $self->{entity_id}, - $self->{contacts}->[$id]->{contact_class}, - $self->{contacts}->[$id]->{contact}, - $contact - ] - ); } 1; |