forked from symbiote/silverstripe-memberprofiles
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge from upstream - https://github.com/ajshort/silverstripe-memberp…
- Loading branch information
Showing
6 changed files
with
210 additions
and
27 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
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,64 @@ | ||
<?php | ||
/** | ||
* @package silverstripe-memberprofiles | ||
*/ | ||
class MemberApprovalController extends Page_Controller { | ||
|
||
public static $url_handlers = array( | ||
'$ID' => 'index' | ||
); | ||
|
||
public static $allowed_actions = array( | ||
'index' | ||
); | ||
|
||
public function index($request) { | ||
$id = $request->param('ID'); | ||
$token = $request->getVar('token'); | ||
|
||
if (!$id || !ctype_digit($id)) { | ||
$this->httpError(404, 'A member ID was not specified.'); | ||
} | ||
|
||
$member = DataObject::get_by_id('Member', $id); | ||
|
||
if (!$member) { | ||
$this->httpError(404, 'The specified member could not be found.'); | ||
} | ||
|
||
if (!$member->canEdit()) { | ||
return Security::permissionFailure(); | ||
} | ||
|
||
if ($token != $member->ValidationKey) { | ||
$this->httpError(400, 'An invalid token was specified.'); | ||
} | ||
|
||
if (!$member->NeedsApproval) { | ||
$title = _t('MemberProfiles.ALREADYAPPROVED', 'Already Approved'); | ||
$content = _t('MemberProfiles.ALREADYAPPROVEDNOTE', 'This member has already been approved'); | ||
|
||
return $this->render(array( | ||
'Title' => $title, | ||
'Content' => "<p>$content</p>" | ||
)); | ||
} | ||
|
||
$member->NeedsApproval = false; | ||
$member->write(); | ||
|
||
$title = _t('MemberProfiles.MEMBERAPPROVED', 'Member Approved'); | ||
$content = _t('MemberProfiles.MEMBERAPPROVED', 'The member "%s" has been approved and can now log in.'); | ||
$content = sprintf($content, Convert::raw2xml("$member->Name <$member->Email>")); | ||
|
||
return $this->render(array( | ||
'Title' => $title, | ||
'Content' => $content | ||
)); | ||
} | ||
|
||
public function Link($action = null) { | ||
return Controller::join_links(Director::baseURL(), 'member-approval', $action); | ||
} | ||
|
||
} |
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,7 @@ | ||
;(function($) { | ||
$("#Form_EditForm_RequireApproval").livequery(function() { | ||
$(this) | ||
.change(function() { $("#ApprovalGroups").toggle(this.checked); }) | ||
.trigger("change"); | ||
}); | ||
})(jQuery); |
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,25 @@ | ||
<p> | ||
A new member has registered for $SiteConfig.Title, and requires approval | ||
before they can log in: | ||
</p> | ||
|
||
<% control Member %> | ||
<dl> | ||
<dt>Name:</dt> | ||
<dd>$Name</dd> | ||
<dt>Email:</dt> | ||
<dd>$Email</dd> | ||
<dt>Registered:</dt> | ||
<dd>$Created.Date</dd> | ||
</dl> | ||
<% end_control %> | ||
|
||
<p> | ||
Please visit the link below to confirm this member. Once approved they will | ||
be sent a confirmation email if configured. If you do not approve this member | ||
then they will not be able to log in. | ||
</p> | ||
|
||
<p> | ||
<a href="$ApproveLink">$ApproveLink</a> | ||
</p> |