Question
I want to extend the
bin/register script. This is what already works:
- The new user topic is initialized from NewUserTemplate like discussed in AddingFormToTWikiUsers. The template has a form attached.
- Variables of the form
%VarName% in the template text are replaced by the transmitted form values by $text =~ s/%$name%/$value/g;
Now I want to do the same for the form values hidden inside the meta structure. Can anybody tell me, which methods I need to
- get the form values
- process the values in a loop
- write back the form values after updating
- Do I have to call a clean method explicitly that removes line breaks etc. from the values?
Is there any additional documentation or other resources describing how to apply the code components in
bin/ and
lib/?
Thanks,
Alex
Environment
--
AlexanderStedile - 29 Nov 2005
Answer
Now it works. Here are my changes to
register. Is there a better solution?
$ diff register.bak register
179a180
> # AS 2005-11-29: Adapted for new NewUserTemplate.
181c182,183
< my $row = "";
---
> my $firstName = "";
> my $lastName = "";
183,184c185
< $text = "%SPLIT%\n\t* %KEY%: %VALUE%%SPLIT%\n" unless $text;
< ( $before, $repeat, $after) = split( /%SPLIT%/, $text );
---
> my @fields = $meta->find( "FIELD" );
192,195c193,211
< $row = $repeat;
< $row =~ s/%KEY%/$name/go;
< $row =~ s/%VALUE%/$value/go;
< $before .= $row;
---
> if ($name eq "Name")
> {
> ($firstName, $lastName) = ($value =~ /^(.*)\s+(\S+)$/);
> $text =~ s/%NameFirst%/$firstName/g;
> $text =~ s/%NameLast%/$lastName/g;
> foreach $f (@fields)
> {
> $f->{value} =~ s/%NameFirst%/$firstName/g;
> $f->{value} =~ s/%NameLast%/$lastName/g;
> }
> }
> else
> {
> $text =~ s/%$name%/$value/g;
> foreach $f (@fields)
> {
> $f->{value} =~ s/%$name%/$value/g;
> }
> }
198,199d213
< $text = "$before$after";
<
--
AlexanderStedile - 30 Nov 2005
That looks OK to me.
Note that registration has been totally reworked in the forthcoming
DakarRelease.
--
CrawfordCurrie - 30 Nov 2005
Thanks.
--
AlexanderStedile - 01 Dec 2005
A valuable follow-up would be an indication of how the above was accommodated (or not) in Dakar and beyond, and maybe even pointers to the set of changes which were part of the rework.
--
PaulReiber - 2009-07-23