From c36fb4b2affe9c3928b08734cbb5e5d86e1013f9 Mon Sep 17 00:00:00 2001 From: Jeremy Kauffman Date: Tue, 3 Nov 2015 19:02:49 -0500 Subject: [PATCH] collect email on way in for get page, track user email as CLI user yes/no, fix deploy process (I think), and revise homepage meta --- controller/Controller.class.php | 2 ++ controller/Session.class.php | 2 ++ controller/action/ContentActions.class.php | 7 +++++ controller/action/MailActions.class.php | 7 +++-- controller/action/OpsActions.class.php | 2 +- view/mail/joinList.php | 3 ++ view/page/get.php | 35 +++++++++++++++------- view/page/home.php | 2 ++ web/bootstrap.php | 2 +- 9 files changed, 48 insertions(+), 14 deletions(-) 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.

-
- -
+ +
+ 'Go', + 'listId' => Mailchimp::LIST_GENERAL_ID, + 'mergeFields' => ['CLI' => 'Yes'], + 'returnUrl' => '/get?email=1' + ]) ?> +
+
+ Already sign up or really hate sharing your email? Click here. +
+ +
+ +
+ diff --git a/view/page/home.php b/view/page/home.php index d90b857a..d71b329c 100644 --- a/view/page/home.php +++ b/view/page/home.php @@ -1,4 +1,6 @@
+ + true]) ?>
diff --git a/web/bootstrap.php b/web/bootstrap.php index 7e31776b..4040c7c3 100644 --- a/web/bootstrap.php +++ b/web/bootstrap.php @@ -3,4 +3,4 @@ include $_SERVER['ROOT_DIR'] . '/autoload.php'; i18n::register(); Session::init(); -Controller::dispatch($_SERVER['REQUEST_URI']); \ No newline at end of file +Controller::dispatch(strtok($_SERVER['REQUEST_URI'], '?')); \ No newline at end of file