Gossamer Forum
Home : Products : DBMan SQL : Discussion :

Re: [olivers] change the data of registration

Quote Reply
Re: [olivers] change the data of registration In reply to
Hey TheStone

just wanted to say thank you! I'm glad that you've checked the code and that it's ok Smile

As far as the additional feature for the required and the optional fields is concerned, I have modified your code like this:

Code:

$COMPILE{profile} = <<'END_OF_SUB';
sub profile {
#------------------------------------------------------------------------
# Modify profile (custom)
#
my $self = shift;
my $user_tab = $self->{cfg}->{'user_table_use'};
my $db = $self->{sql}->table($user_tab);
my $cols = $db->cols;
my $req = {};
my $opt = {};


foreach my $c ( keys %$cols ) {
next if ( ! $self->{cgi}->{'req_'.$c} );
next if ( $c =~ /^(Username|Status|ReceiveMail|Newsletter|view_p|add_p|delete_p|modify_p|admin_p)/ );
$req->{$c} = $self->{cgi}->{"req_$c"};
}
$db->update($req, { 'Username' => $self->{user}->{Username} }) if ( $req );


foreach my $d ( keys %$cols ) {
next if ( $d =~ /^(Username|Status|ReceiveMail|Newsletter|view_p|add_p|delete_p|modify_p|admin_p)/ );
$opt->{$d} = $self->{cgi}->{"opt_$d"} if (defined $self->{cgi}->{"opt_$d"});
}
$db->update($opt, { 'Username' => $self->{user}->{Username} }) if ( $opt );


$self->auth_logging('profile change ') if ( $self->{cfg}->{log_file} );
return ('profile_form.html', {
msg => $self->_language('MSG_PROFILE_OK'),
header => $self->_language('HEA_HOME')
});
}
END_OF_SUB


It seems that this code does what I wanted:
- in the profile form, you can add "req_" or "opt_" in front of the fieldname (e.g. req_address, req_city, opt_handy)
- optional fileds can be deleted by just submitting a blank field (by deleting the content of the field)
- required fields can't be deleted... they can just be updated with another value

I'd be glad if you could check the above code for errors or if you have any other suggestions for optimization. I will try to create a plugin later and I'd like to have the code optimized first Cool

Cheers,
Oliver
Subject Author Views Date
Thread change the data of registration hoefti 10922 Aug 1, 2002, 9:01 AM
Thread Re: [hoefti] change the data of registration
604 10745 Aug 13, 2002, 4:36 PM
Thread Re: [TheStone] change the data of registration
olivers 10486 Feb 29, 2004, 9:44 AM
Thread Re: [olivers] change the data of registration
604 10416 Mar 1, 2004, 5:05 PM
Thread Re: [TheStone] change the data of registration
olivers 10388 Mar 3, 2004, 6:39 AM
Thread Re: [olivers] change the data of registration
604 10414 Mar 3, 2004, 9:55 AM
Post Re: [TheStone] change the data of registration
olivers 10363 Mar 4, 2004, 3:17 AM
Post Re: [TheStone] change the data of registration
olivers 10347 Mar 6, 2004, 10:01 AM
Thread Re: [TheStone] change the data of registration
olivers 10286 Mar 20, 2004, 12:52 PM
Thread Re: [olivers] change the data of registration
604 10328 Mar 22, 2004, 10:38 AM
Thread Re: [TheStone] change the data of registration
olivers 10286 Mar 29, 2004, 9:35 AM
Thread Re: [olivers] change the data of registration
olivers 10156 Apr 5, 2004, 7:37 AM
Thread Re: [olivers] change the data of registration
604 10146 Apr 5, 2004, 10:16 AM
Thread Re: [TheStone] change the data of registration
olivers 10150 Apr 5, 2004, 11:08 AM
Thread Re: [olivers] change the data of registration
olivers 10134 Apr 12, 2004, 10:03 AM
Thread Re: [olivers] change the data of registration
olivers 10114 Apr 13, 2004, 1:23 PM
Thread Re: [olivers] change the data of registration
megaline 9869 Jul 7, 2004, 4:00 PM
Thread Re: [megaline] change the data of registration
megaline 9848 Jul 8, 2004, 7:04 AM
Post Re: [megaline] change the data of registration
olivers 9829 Jul 8, 2004, 3:48 PM