Skip to content

Commit

Permalink
FEATURE: make SubscriptionPage notification email UnsubscribeLink usi…
Browse files Browse the repository at this point in the history
…ng AutoLoginHash

ENHANCEMENT: if case no Member found, we still return an generic UnsubscibeLink for NewletterEmail
(manually merged from r114346, not merged automatically during git migration)
  • Loading branch information
chillu committed Mar 9, 2011
1 parent efab19f commit dd2e5a0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
2 changes: 2 additions & 0 deletions code/email/NewsletterEmail.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ function UnsubscribeLink(){
}
$nlTypeID = $this->nlType->ID;
return Director::absoluteBaseURL() . "unsubscribe/index/".$member->AutoLoginHash."/$nlTypeID";
}else{
return Director::absoluteBaseURL() . "unsubscribe/index/";
}
}

Expand Down
13 changes: 10 additions & 3 deletions code/pages/SubscriptionPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -253,8 +253,15 @@ function doSubscribe($data, $form, $request){

if(!$member) {
$member = new Member();
$form->saveInto($member);
$member->write();
}
$form->saveInto($member);
$member->write();

if($member->AutoLoginHash){
$member->AutoLoginExpired = date('Y-m-d', time() + (86400 * 2));
$member->write();
}else{
$member->generateAutologinHash();
}

$newsletters = array();
Expand Down Expand Up @@ -307,7 +314,7 @@ function doSubscribe($data, $form, $request){
'FirstName' => $member->FirstName,
'MemberInfoSection' => $emailableFields,
'Newsletters' => new DataObjectSet( $newsletters ),
'UnsubscribeLink' => Director::baseURL() . 'unsubscribe/index/' . $member->Email
'UnsubscribeLink' => Director::baseURL() . 'unsubscribe/index/' . $member->AutoLoginHash
);

if($this->SendNotification){
Expand Down

0 comments on commit dd2e5a0

Please sign in to comment.