diff --git a/controller/Controller.class.php b/controller/Controller.class.php index 5c46ae82..3d52ae5b 100644 --- a/controller/Controller.class.php +++ b/controller/Controller.class.php @@ -39,6 +39,8 @@ class Controller { case '/': return ContentActions::executeHome(); + case '/get': + return ContentActions::executeGet(); case '/postcommit': return OpsActions::executePostCommit(); case '/list-subscribe': diff --git a/controller/Session.class.php b/controller/Session.class.php index 3f6e2395..c300d5b4 100644 --- a/controller/Session.class.php +++ b/controller/Session.class.php @@ -7,6 +7,8 @@ */ class Session { + const KEY_MAILCHIMP_LIST_IDS = 'mailchimp_list_ids'; + public static function init() { session_start(); diff --git a/controller/action/ContentActions.class.php b/controller/action/ContentActions.class.php index 9eb42f36..dbd92864 100644 --- a/controller/action/ContentActions.class.php +++ b/controller/action/ContentActions.class.php @@ -11,6 +11,13 @@ class ContentActions extends Actions { return ['page/home', []]; } + + public static function executeGet() + { + return ['page/get', [ + 'isSubscribed' => $_GET['email'] || in_array(Mailchimp::LIST_GENERAL_ID, Session::get(Session::KEY_MAILCHIMP_LIST_IDS, [])) + ]]; + } // // protected static function validateDownloadAccess() // { diff --git a/controller/action/MailActions.class.php b/controller/action/MailActions.class.php index a23c2132..5c686657 100644 --- a/controller/action/MailActions.class.php +++ b/controller/action/MailActions.class.php @@ -26,8 +26,11 @@ class MailActions extends Actions else { $mcApi = new Mailchimp(); - if ($mcApi->listSubscribe($_POST['listId'], $email, [], 'html', false)) + $mcListId = $_POST['listId']; + $mergeFields = isset($_POST['mergeFields']) ? unserialize($_POST['mergeFields']) : []; + if ($mcApi->listSubscribe($mcListId, $email, $mergeFields, 'html', false)) { + Session::set(Session::KEY_MAILCHIMP_LIST_IDS, array_merge(Session::get(Session::KEY_MAILCHIMP_LIST_IDS, []), [$mcListId])); Session::set('list_success', __('Great success! Welcome to LBRY.')); } else @@ -36,7 +39,7 @@ class MailActions extends Actions } } - Controller::redirect($_POST['return_url'] ?: '/get'); + Controller::redirect(isset($_POST['return_url']) && $_POST['return_url'] ? $_POST['return_url'] : '/get'); } public static function prepareJoinList(array $vars) diff --git a/controller/action/OpsActions.class.php b/controller/action/OpsActions.class.php index 62e3a69a..ba51598c 100644 --- a/controller/action/OpsActions.class.php +++ b/controller/action/OpsActions.class.php @@ -5,7 +5,7 @@ * * @author jeremy */ -class OpsActions +class OpsActions extends Actions { public static function executePostCommit() { diff --git a/view/mail/joinList.php b/view/mail/joinList.php index 0c1fc9fc..53cf48de 100644 --- a/view/mail/joinList.php +++ b/view/mail/joinList.php @@ -9,5 +9,8 @@ + + + \ No newline at end of file diff --git a/view/page/get.php b/view/page/get.php index b6864457..29bed6fc 100644 --- a/view/page/get.php +++ b/view/page/get.php @@ -12,6 +12,7 @@ 'Go', 'listId' => Mailchimp::LIST_GENERAL_ID, + 'mergeFields' => ['CLI' => 'No'], 'btnClass' => 'btn-alt' ]) ?> @@ -23,16 +24,30 @@
Earn early adopter rewards and interact directly with developers via our Alpha client.
- + +