Permalink
Browse files

Moved campaign tracking into StartupAPI init, fixed campaign reportin…

…g on user profile page.
  • Loading branch information...
sergeychernyshev committed May 5, 2016
1 parent e5ccc8b commit bfc0a4349e0eed20cd91b3f3f384d25a5a76ac53
Showing with 21 additions and 15 deletions.
  1. +4 −1 admin/campaigns.php
  2. +5 −5 admin/user.php
  3. +2 −0 classes/CampaignTracker.php
  4. +5 −0 classes/StartupAPI.php
  5. +5 −5 classes/User.php
  6. +0 −4 users.php
@@ -29,6 +29,9 @@
</div>
<?php
foreach ($tables as $slug => $header) {
if (!array_key_exists($slug, $campaigns)) {
continue;
}
?>
<div class="span9">
<h3><?php echo $header ?></h3>
@@ -70,4 +73,4 @@
</div>
<?php
}
require_once(__DIR__ . '/footer.php');
require_once(__DIR__ . '/footer.php');
@@ -239,27 +239,27 @@ class="icon-signal"></i> See activity</a>
<?php
}
if (array_key_exists('cmp_name', $campaign)) {
if (array_key_exists('cmp_name', $campaign) && !is_null($campaign['cmp_name'])) {
?>
<p>Name: <b><?php echo UserTools::escape($campaign['cmp_name']) ?></b></p>
<?php
}
if (array_key_exists('cmp_source', $campaign)) {
if (array_key_exists('cmp_source', $campaign) && !is_null($campaign['cmp_source'])) {
?>
<p>Source: <b><?php echo UserTools::escape($campaign['cmp_source']) ?></b></p>
<?php
}
if (array_key_exists('cmp_medium', $campaign)) {
if (array_key_exists('cmp_medium', $campaign) && !is_null($campaign['cmp_medium'])) {
?>
<p>Medium: <b><?php echo UserTools::escape($campaign['cmp_medium']) ?></b></p>
<?php
}
if (array_key_exists('cmp_keywords', $campaign)) {
if (array_key_exists('cmp_keywords', $campaign) && !is_null($campaign['cmp_keywords'])) {
?>
<p>Keywords: <b><?php echo UserTools::escape($campaign['cmp_keywords']) ?></b></p>
<?php
}
if (array_key_exists('cmp_content', $campaign)) {
if (array_key_exists('cmp_content', $campaign) && !is_null($campaign['cmp_content'])) {
?>
<p>Content: <b><?php echo UserTools::escape($campaign['cmp_content']) ?></b></p>
<?php
@@ -64,6 +64,8 @@ public static function recordCampaignVariables() {
return;
}
self::$campaign = $campaign;
$storage = new MrClay_CookieStorage(array(
'secret' => UserConfig::$SESSION_SECRET,
'mode' => MrClay_CookieStorage::MODE_ENCRYPT,
@@ -2,6 +2,7 @@
require_once(__DIR__ . '/User.php');
require_once(__DIR__ . '/Plan.php');
require_once(__DIR__ . '/CampaignTracker.php');
require_once(__DIR__ . '/API/Endpoint.php');
@@ -181,6 +182,10 @@ static function _init() {
if (UserConfig::$enable_startupapi_apis) {
\StartupAPI\API\Endpoint::registerCoreEndpoints();
}
// do this on each page view where StartupAPI code is executed
CampaignTracker::preserveReferer();
CampaignTracker::recordCampaignVariables();
}
/**
@@ -357,11 +357,11 @@ public function getCampaign() {
if ($stmt = $db->prepare('SELECT cmp.name, cmp_content.content, cmp_keywords.keywords, cmp_medium.medium, cmp_source.source
FROM ' . UserConfig::$mysql_prefix . 'users AS users
INNER JOIN ' . UserConfig::$mysql_prefix . 'cmp AS cmp ON users.reg_cmp_name_id = cmp.id
INNER JOIN ' . UserConfig::$mysql_prefix . 'cmp_content AS cmp_content ON users.reg_cmp_content_id = cmp_content.id
INNER JOIN ' . UserConfig::$mysql_prefix . 'cmp_keywords AS cmp_keywords ON users.reg_cmp_keywords_id = cmp_keywords.id
INNER JOIN ' . UserConfig::$mysql_prefix . 'cmp_medium AS cmp_medium ON users.reg_cmp_medium_id = cmp_medium.id
INNER JOIN ' . UserConfig::$mysql_prefix . 'cmp_source AS cmp_source ON users.reg_cmp_source_id = cmp_source.id
LEFT JOIN ' . UserConfig::$mysql_prefix . 'cmp AS cmp ON users.reg_cmp_name_id = cmp.id
LEFT JOIN ' . UserConfig::$mysql_prefix . 'cmp_content AS cmp_content ON users.reg_cmp_content_id = cmp_content.id
LEFT JOIN ' . UserConfig::$mysql_prefix . 'cmp_keywords AS cmp_keywords ON users.reg_cmp_keywords_id = cmp_keywords.id
LEFT JOIN ' . UserConfig::$mysql_prefix . 'cmp_medium AS cmp_medium ON users.reg_cmp_medium_id = cmp_medium.id
LEFT JOIN ' . UserConfig::$mysql_prefix . 'cmp_source AS cmp_source ON users.reg_cmp_source_id = cmp_source.id
WHERE users.id = ?')) {
if (!$stmt->bind_param('i', $this->userid)) {
throw new DBBindParamException($db, $stmt);
@@ -11,9 +11,5 @@
require_once(__DIR__.'/classes/Account.php');
require_once(__DIR__.'/classes/Cohort.php');
require_once(__DIR__.'/classes/Feature.php');
require_once(__DIR__.'/classes/CampaignTracker.php');
// do this on each page view (where user.php is included)
CampaignTracker::preserveReferer();
CampaignTracker::recordCampaignVariables();
User::updateReturnActivity(); // only if user is logged in

0 comments on commit bfc0a43

Please sign in to comment.