Skip to content

Commit

Permalink
Item14260: Improve pending registrations report
Browse files Browse the repository at this point in the history
Don't show if not authorized.

Alert if the corresponding feature is not enabled.

Alert if there is nothing currently pending.
  • Loading branch information
gac410 committed Dec 28, 2016
1 parent d64ed8d commit 619cb74
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 12 deletions.
8 changes: 5 additions & 3 deletions core/data/System/PendingRegistrations.txt
@@ -1,11 +1,13 @@
%META:TOPICINFO{author="ProjectContributor" comment="" date="1478750101" format="1.1" version="1"}%
%META:TOPICINFO{author="ProjectContributor" comment="" date="1482950646" format="1.1" version="1"}%
---+ %MAKETEXT{"Pending Registrations"}%
---++ %MAKETEXT{"Registrations awaiting Email verification"}%

<dirtyarea>
%PENDINGREGISTRATIONS{"Verification"}%
</dirtyarea>

---++ %MAKETEXT{"Registrations awaiting approval"}%

%MAKETEXT{"You can use the \"approve\" or \"reject\" links to approve or reject these registrations"}%

<dirtyarea>
%PENDINGREGISTRATIONS{"Approval"}%
</dirtyarea>
12 changes: 10 additions & 2 deletions core/data/System/PendingRegistrationsTemplate.txt
@@ -1,4 +1,4 @@
%META:TOPICINFO{author="ProjectContributor" comment="" date="1476996032" format="1.1" version="1"}%
%META:TOPICINFO{author="ProjectContributor" comment="" date="1482950646" format="1.1" version="1"}%
---+!! Pending Registrations Template
%TOC%
---++ Tailoring instructions:
Expand All @@ -18,6 +18,11 @@ Both this topic, and the PendingRegistrations topic must be in the same web for
| *WikiName* | *Email* | *LastName* | *FirstName* | *LoginName* | *Code* | *Action* |
%TMPL:END%

%TMPL:DEF{"approvalNotEnabled"}%<div class="foswikiAlert">%MAKETEXT{"Registration approval is not enabled."}%</div>%TMPL:END%
%TMPL:DEF{"approveAction"}%
%MAKETEXT{"You can use the \"approve\" or \"reject\" links to approve or reject these registrations"}%
%TMPL:END%

%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"}%]] |
Expand All @@ -30,10 +35,13 @@ Both this topic, and the PendingRegistrations topic must be in the same web for
| *WikiName* | *Email* | *LastName* | *FirstName* | *LoginName* | *Code* |
%TMPL:END%

%TMPL:DEF{"verifyNotEnabled"}%<div class="foswikiAlert">%MAKETEXT{"Email verification is not enabled."}%</div>%TMPL:END%

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

---++ Common templates
<verbatim>
%TMPL:DEF{"accessdenied"}%<div class="foswikiAlert">%MAKETEXT{"Access to pending registrations is restricted to administrators"}%</div>%TMPL:END%
%TMPL:DEF{"accessdenied"}%<div class="foswikiAlert">%MAKETEXT{"Access to pending registrations is restricted to administrators."}%</div>%TMPL:END%
%TMPL:DEF{"nothingPending"}%<div class="foswikiAlert">%MAKETEXT{"No registrations are pending."}%</div>%TMPL:END%
</verbatim>
27 changes: 20 additions & 7 deletions core/lib/Foswiki/Macros/PENDINGREGISTRATIONS.pm
Expand Up @@ -17,16 +17,30 @@ sub PENDINGREGISTRATIONS {

my $report;

unless ( $this->_checkAccess() ) {
return Foswiki::Func::expandTemplate('accessdenied');
}

if ( ( !defined $params->{_DEFAULT} )
|| lc( $params->{_DEFAULT} ) eq 'approval' )
{
$report .= $this->_checkPendingRegistrations('Approval');
if ( $Foswiki::cfg{Register}{NeedApproval} ) {
$report .= $this->_checkPendingRegistrations('Approval');
}
else {
$report .= Foswiki::Func::expandTemplate('verifyNotEnabled');
}
}

if ( ( !defined $params->{_DEFAULT} )
|| lc( $params->{_DEFAULT} ) eq 'verification' )
{
$report .= $this->_checkPendingRegistrations('Verification');
if ( $Foswiki::cfg{Register}{NeedVerification} ) {
$report .= $this->_checkPendingRegistrations('Verification');
}
else {
$report .= Foswiki::Func::expandTemplate('approvalNotEnabled');
}
}

return $report;
Expand All @@ -48,10 +62,6 @@ sub _checkPendingRegistrations {
my $check = shift;
my $report = '';

unless ( $this->_checkAccess() ) {
return Foswiki::Func::expandTemplate('accessdenied');
}

my $dir = "$Foswiki::cfg{WorkingDir}/registration_approvals/";

if ( opendir( my $d, "$dir" ) ) {
Expand All @@ -69,6 +79,9 @@ sub _checkPendingRegistrations {
if ($report) {
$header = Foswiki::Func::expandTemplate( $check . 'Header' );
}
else {
$report = Foswiki::Func::expandTemplate('nothingPending');
}
return $header . $report;
}

Expand All @@ -87,7 +100,7 @@ sub _reportPending {
$tmpl =~ s/\$$field/$hashref->{$field}/g;
}
$tmpl =~ s/\$\w+//g; # Remove any unused fields
return "$tmpl";
return "$tmpl\n";
}

1;
Expand Down

0 comments on commit 619cb74

Please sign in to comment.