/** * @param IFoundationMember $foundation_member * @param IFoundationMemberRevocationNotification $notification * @param IFoundationMemberRevocationNotificationRepository $notification_repository */ public function send(IFoundationMember $foundation_member, IFoundationMemberRevocationNotification $notification, IFoundationMemberRevocationNotificationRepository $notification_repository) { $email = EmailFactory::getInstance()->buildEmail(REVOCATION_NOTIFICATION_EMAIL_FROM, $foundation_member->Email, REVOCATION_NOTIFICATION_EMAIL_SUBJECT); $email->setTemplate('RevocationNotificationEmail'); do { $hash = $notification->generateHash(); } while ($notification_repository->existsHash($hash)); $link = sprintf('%s/revocation-notifications/%s/action', Director::protocolAndHost(), $hash); $email->populateTemplate(array('TakeActionLink' => $link, 'EmailFrom' => REVOCATION_NOTIFICATION_EMAIL_FROM, 'ExpirationDate' => $notification->expirationDate()->format('F j'))); $email->send(); }
public function deleteFoundationMembership() { $token = $this->request->param('ACTION_TOKEN'); try { $current_member = Member::currentUser(); if (is_null($current_member)) { return Controller::curr()->redirect("Security/login?BackURL=" . urlencode($_SERVER['REQUEST_URI'])); } $notification = $this->notification_repository->getByHash($token); if (!$notification) { return $this->renderWith(array('RevocationNotificationActionPage_error', 'Page')); } if ($notification->recipient()->getIdentifier() != $current_member->ID) { return $this->renderWith(array('RevocationNotificationActionPage_belongs_2_another_user', 'Page'), array('UserName' => $notification->recipient()->Email)); } if ($notification->isExpired()) { return $this->renderWith(array('RevocationNotificationActionPage_expired', 'Page'), array('RevocationDate' => $notification->actionDate()->format('F j'), 'UserName' => $notification->recipient()->Email)); } if (!$notification->isValid()) { return $this->renderWith(array('RevocationNotificationActionPage_error', 'Page')); } $this->notification_manager->deleteAccount($notification); return $this->renderWith(array('RevocationNotificationActionPage_delete', 'Page')); } catch (Exception $ex) { SS_Log::log($ex, SS_Log::ERR); return $this->renderWith(array('RevocationNotificationActionPage_error', 'Page')); } }