Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Item14201: Don't pollute Main with admin topics.
Document customization a bit more, and encode $ found in any field
contents, so they are not accidentally removed.
  • Loading branch information
gac410 committed Oct 22, 2016
1 parent fe0585c commit 86a0d0f
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 20 deletions.
11 changes: 0 additions & 11 deletions core/data/Main/PendingRegistrations.txt

This file was deleted.

17 changes: 14 additions & 3 deletions core/data/System/PendingRegistrationsTemplate.txt
@@ -1,13 +1,24 @@
%META:TOPICINFO{author="ProjectContributor" comment="" date="1476996032" format="1.1" version="1"}%
Copy this topic to %USERSWEB%.PendingRegistrationsTemplate for customized display.
---+!! Pending Registrations Template
%TOC%
---++ Tailoring instructions:
The contents of the Pending Registrations report can be modified to report any fields collected on a customized UserRegistration form. Each formfield name
is substituted with the similarly named token in the row definition: For example, if your User Registration form includes the =Organization= field, it can
be included by adding =$Organization= to the below !ApprovalRow and !VerificationRow templates.

Both this topic, and the PendingRegistrations topic must be in the same web for the override to work:
1 Copy this template topic to %IF{"istopic '%USERSWEB%.PendingRegistrationsTemplate'" else="!$percntUSERSWEB$percnt.PendingRegistrationsTemplate" then="[[$percntUSERSWEB$percnt.PendingRegistrationsTemplate]] ...done"}%
1 Edit %IF{"istopic '%USERSWEB%.PendingRegistrationsTemplate'" else="!$percntUSERSWEB$percnt.PendingRegistrationsTemplate" then="[[$percntUSERSWEB$percnt.PendingRegistrationsTemplate]]"}% and make the desired changes.
1 Copy %SYSTEMWEB%.PendingRegistrations to %IF{"istopic '%USERSWEB%.PendingRegistrations'" else="!$percntUSERSWEB$percnt.PendingRegistrations" then="[[$percntUSERSWEB$percnt.PendingRegistrations]] ...done"}%.
1 %USERSWEB%.PendingRegistrations will now generate a report using your tailored layout.

---++ Templates for "Pending Approval" registrations
<verbatim>
%TMPL:DEF{"ApprovalHeader"}%<noautolink>
| *WikiName* | *Email* | *LastName* | *FirstName* | *LoginName* | *Code* | *Action* |
%TMPL:END%

%TMPL:DEF{"Approval"}%| $WikiName | $Email | $LastName | $FirstName | $LoginName | $ApprovalCode |\
%TMPL:DEF{"ApprovalRow"}%| $WikiName | $Email | $LastName | $FirstName | $LoginName | $ApprovalCode |\
[[%SCRIPTURLPATH{"register" action="approve" code="$ApprovalCode" referee="%WIKINAME%"}%][%MAKETEXT{"Approve"}%]] / \
[[%SCRIPTURLPATH{"register" action="disapprove" code="$ApprovalCode" referee="%WIKINAME%"}%][%MAKETEXT{"Reject"}%]] |
%TMPL:END%
Expand All @@ -19,7 +30,7 @@ Copy this topic to %USERSWEB%.PendingRegistrationsTemplate for customized displa
| *WikiName* | *Email* | *LastName* | *FirstName* | *LoginName* | *Code* |
%TMPL:END%

%TMPL:DEF{"Verification"}%| $WikiName | $Email | $LastName | $FirstName | $LoginName | $VerificationCode |%TMPL:END%
%TMPL:DEF{"VerificationRow"}%| $WikiName | $Email | $LastName | $FirstName | $LoginName | $VerificationCode |%TMPL:END%
</verbatim>

---++ Common templates
Expand Down
11 changes: 5 additions & 6 deletions core/lib/Foswiki/Macros/PENDINGREGISTRATIONS.pm
Expand Up @@ -58,7 +58,7 @@ sub _checkPendingRegistrations {
foreach my $f ( grep { /^.*\.[0-9]{1,8}$/ } readdir $d ) {
my $regFile = Foswiki::Sandbox::untaintUnchecked("$dir$f");

my $data = retrieve($regFile);
my $data = Storable::retrieve($regFile);
next unless defined $data;
next unless $data->{ $check . 'Code' };
$report .= _reportPending( $data, $check );
Expand All @@ -76,18 +76,17 @@ sub _reportPending {
my $hashref = shift;
my $check = shift;

my $tmpl = Foswiki::Func::expandTemplate($check);
my $tmpl = Foswiki::Func::expandTemplate( $check . 'Row' );

my $report = '';
foreach my $field ( sort { lc($a) cmp lc($b) } keys %$hashref ) {
next if $field eq 'form';
next if $field eq 'Confirm';
next if $field eq 'Confirm'; # Never show a user's password
next if $field eq 'Password';
$field =~ s/\$/&#36;/g; # Encode any $, so they are not removed later
$tmpl =~ s/\$$field/$hashref->{$field}/g;

#$report .= "$field: $hashref->{$field}\n";
}
print STDERR Data::Dumper::Dumper( \$hashref );
$tmpl =~ s/\$\w+//g; # Remove any unused fields
return "$tmpl";
}

Expand Down

0 comments on commit 86a0d0f

Please sign in to comment.