Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Item14201: Initial commit for PendingRegistrationsReport
- Loading branch information
Showing
5 changed files
with
156 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
%META:TOPICINFO{author="ProjectContributor" comment="" date="1477007062" format="1.1" version="1"}% | ||
---+ %MAKETEXT{"Pending Registrations"}% | ||
---++ %MAKETEXT{"Registrations awaiting Email verification"}% | ||
|
||
%PENDINGREGISTRATIONS{"Verification"}% | ||
|
||
---++ %MAKETEXT{"Registrations awaiting approval"}% | ||
|
||
%MAKETEXT{"You can use the \"approve\" or \"reject\" links to approve or reject these registrations"}% | ||
|
||
%PENDINGREGISTRATIONS{"Approval"}% |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
%META:TOPICINFO{author="ProjectContributor" comment="" date="1476996032" format="1.1" version="1"}% | ||
Copy this topic to %USERSWEB%.PendingRegistrationsTemplate for customized display. | ||
|
||
---++ 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 |\ | ||
[[%SCRIPTURLPATH{"register" action="approve" code="$ApprovalCode" referee="%WIKINAME%"}%][%MAKETEXT{"Approve"}%]] / \ | ||
[[%SCRIPTURLPATH{"register" action="disapprove" code="$ApprovalCode" referee="%WIKINAME%"}%][%MAKETEXT{"Reject"}%]] | | ||
%TMPL:END% | ||
</verbatim> | ||
|
||
---++ Templates for "Pending Verification" registrations | ||
<verbatim> | ||
%TMPL:DEF{"VerificationHeader"}%<noautolink> | ||
| *WikiName* | *Email* | *LastName* | *FirstName* | *LoginName* | *Code* | | ||
%TMPL:END% | ||
|
||
%TMPL:DEF{"Verification"}%| $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% | ||
</verbatim> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
# See bottom of file for license and copyright information | ||
package Foswiki; | ||
|
||
use strict; | ||
use warnings; | ||
|
||
use File::Spec; | ||
use Data::Dumper; | ||
use Foswiki::Func; | ||
use Config; | ||
use Storable; | ||
|
||
sub PENDINGREGISTRATIONS { | ||
my ( $this, $params ) = @_; | ||
|
||
Foswiki::Func::loadTemplate('PendingRegistrations'); | ||
|
||
my $report; | ||
|
||
if ( ( !defined $params->{_DEFAULT} ) | ||
|| lc( $params->{_DEFAULT} ) eq 'approval' ) | ||
{ | ||
$report .= $this->_checkPendingRegistrations('Approval'); | ||
} | ||
|
||
if ( ( !defined $params->{_DEFAULT} ) | ||
|| lc( $params->{_DEFAULT} ) eq 'verification' ) | ||
{ | ||
$report .= $this->_checkPendingRegistrations('Verification'); | ||
} | ||
|
||
return $report; | ||
} | ||
|
||
sub _checkAccess { | ||
my $this = shift; | ||
|
||
return ( | ||
$this->{users}->isAdmin( $this->{user} ) | ||
|| ( $Foswiki::cfg{Register}{Approvers} | ||
&& $Foswiki::cfg{Register}{Approvers} =~ m/\b\Q$this->{user}\E\b/ ) | ||
); | ||
} | ||
|
||
# Check pending registrations for duplicate email, or expiration | ||
sub _checkPendingRegistrations { | ||
my $this = shift; | ||
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" ) ) { | ||
foreach my $f ( grep { /^.*\.[0-9]{1,8}$/ } readdir $d ) { | ||
my $regFile = Foswiki::Sandbox::untaintUnchecked("$dir$f"); | ||
|
||
my $data = retrieve($regFile); | ||
next unless defined $data; | ||
next unless $data->{ $check . 'Code' }; | ||
$report .= _reportPending( $data, $check ); | ||
} | ||
closedir($d); | ||
} | ||
my $header = ''; | ||
if ($report) { | ||
$header = Foswiki::Func::expandTemplate( $check . 'Header' ); | ||
} | ||
return $header . $report; | ||
} | ||
|
||
sub _reportPending { | ||
my $hashref = shift; | ||
my $check = shift; | ||
|
||
my $tmpl = Foswiki::Func::expandTemplate($check); | ||
|
||
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 'Password'; | ||
$tmpl =~ s/\$$field/$hashref->{$field}/g; | ||
|
||
#$report .= "$field: $hashref->{$field}\n"; | ||
} | ||
print STDERR Data::Dumper::Dumper( \$hashref ); | ||
return "$tmpl"; | ||
} | ||
|
||
1; | ||
|
||
__END__ | ||
Foswiki - The Free and Open Source Wiki, http://foswiki.org/ | ||
Copyright (C) 2014-2016 Foswiki Contributors. Foswiki Contributors | ||
are listed in the AUTHORS file in the root of this distribution. | ||
NOTE: Please extend that file, not this notice. | ||
This program is free software; you can redistribute it and/or | ||
modify it under the terms of the GNU General Public License | ||
as published by the Free Software Foundation; either version 2 | ||
of the License, or (at your option) any later version. For | ||
more details read LICENSE in the root of this distribution. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
As per the GPL, removal of this notice is prohibited. |