MiniVend Akopia Services

[Date Prev][Date Next][Thread Prev][Thread Next][Minivend by date ][Minivend by thread ]

removing a user from userdb



Hi all,

In the simple demo after the stop shopping button you have the possibility to remove contents of cart or to remove all info. The latter option doesn't work so I started searching in the mailinglist archives for a solution. I found one (below) but I can't seem to get this to work. My perl knowledge is not very good so I decided to post this message.

Is there someone on this list who did get this piece of code working. Or is there someone who has a solution for giving users the option to delete their user info from the database??
I hope someone can help...

Jeroen

---------------------------------------------------------------------------------------------
Add this to userdb.pm:

sub delete_username {

 my $self;

 $self = shift
  if ref $_[0];

 my(%options) = @_;

 eval {
  unless($self) {
   $self = new Vend::UserDB %options;
  }

  die "Bad object.\n" unless defined $self;

  my $pass = $self->{DB}->delete_record(
      $self->{USERNAME}
      );
  die "Database access error.\n" unless defined $pass;
  $self->log('delete username') if $options{'log'};
 };

 if($@) {
  if(defined $self) {
   $self->{ERROR} = $@;
   $self->log('delete username failed') if $options{'log'};
  }
  else {
   logError( errmsg('UserDB.pm:3', "Vend::UserDB error: %s", $@ ) );
  }
  return undef;
 }

Add to sub userdb:

elsif($function eq 'delete_username') {
    $user = new Vend::UserDB %options;
    unless (defined $user) {
   $Vend::Session->{failure} = "Unable to access user database.";
   return undef;
  }
  if($status = $user->delete_username(%options)) {
  }
 }
1;
}

You can call this function with [userdb delete_username].

First set all the userdb vars for the user to "" and then call this function
to also delete the username itself.
--------------------------------------------------------------------------------------------

-- M P H A S I S  M E D I A  /  M E D I A T A ----------------------------
Jeroen de Koning                              Phone:  +31 (0)71 5238575
Weversbaan 9                                  Fax:    +31 (0)71 5238576
2352 BZ  Leiderdorp, the Netherlands          
www.mphasis.com / www.mediata.nl              E-Mail: jdkoning@mediata.nl 


Search for: Match: Format: Sort by: