Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
31 changed files
with
1,018 additions
and
5 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
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="1478750101" 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,39 @@ | ||
%META:TOPICINFO{author="ProjectContributor" comment="" date="1476996032" format="1.1" version="1"}% | ||
---+!! 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{"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% | ||
</verbatim> | ||
|
||
---++ Templates for "Pending Verification" registrations | ||
<verbatim> | ||
%TMPL:DEF{"VerificationHeader"}%<noautolink> | ||
| *WikiName* | *Email* | *LastName* | *FirstName* | *LoginName* | *Code* | | ||
%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% | ||
</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
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,112 @@ | ||
# 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 = Storable::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 . 'Row' ); | ||
|
||
my $report = ''; | ||
foreach my $field ( sort { lc($a) cmp lc($b) } keys %$hashref ) { | ||
next if $field eq 'form'; | ||
next if $field eq 'Confirm'; # Never show a user's password | ||
next if $field eq 'Password'; | ||
$field =~ s/\$/$/g; # Encode any $, so they are not removed later | ||
$tmpl =~ s/\$$field/$hashref->{$field}/g; | ||
} | ||
$tmpl =~ s/\$\w+//g; # Remove any unused fields | ||
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. |
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
Oops, something went wrong.