From ac102923ce04610e5f92af6aa65da269c4585d5d Mon Sep 17 00:00:00 2001 From: JT Smith Date: Fri, 29 Aug 2003 22:13:19 +0000 Subject: [PATCH] added a rudamentary affiliate tracking program --- docs/upgrades/upgrade_5.4.3-5.5.0.sql | 3 +++ lib/WebGUI.pm | 5 +++-- lib/WebGUI/Operation/Account.pm | 2 +- lib/WebGUI/Session.pm | 1 + lib/WebGUI/User.pm | 29 +++++++++++++++++++++++++++ 5 files changed, 37 insertions(+), 3 deletions(-) diff --git a/docs/upgrades/upgrade_5.4.3-5.5.0.sql b/docs/upgrades/upgrade_5.4.3-5.5.0.sql index 35846553d..3460e058d 100644 --- a/docs/upgrades/upgrade_5.4.3-5.5.0.sql +++ b/docs/upgrades/upgrade_5.4.3-5.5.0.sql @@ -139,4 +139,7 @@ INSERT INTO template VALUES (1,'Default HTTP Proxy','\r\n UPDATE international set message = 'The HTTP Proxy wobject is a very powerful tool. It enables you to embed external sites and applications into your site. For example, if you have a web mail system that you wish your staff could access through the intranet, then you could use the HTTP Proxy to accomplish that.\r\n\r\n

\r\n\r\nURL
\r\nThe starting URL for the proxy.\r\n

\r\n\r\nFollow redirects?
\r\nSometimes the URL to a page, is actually a redirection to another page. Do you wish to follow those redirections when they occur?\r\n

\r\n\r\nRewrite urls?
\r\nSwitch this to No if you want to deeplink an external page.\r\n

\r\n\r\nTimeout
\r\nThe amount of time (in seconds) that WebGUI should wait for a connection before giving up on an external page.\r\n

\r\n\r\nRemove style?
\r\nDo you wish to remove the stylesheet from the proxied content in favor of the stylesheet from your site?\r\n

\r\n\r\nFilter Content
\r\nChoose the level of HTML filtering you wish to apply to the proxied content.\r\n

\r\n\r\nSearch for
\r\nA search string used as starting point. Use this when you want to display only a part of the proxied content. Content before this point is not displayed\r\n

\r\n\r\nStop at
\r\nA search string used as ending point. Content after this point is not displayed.\r\n

\r\nNote: The Search for and Stop at strings are included in the content. You can change this by editing the template for HttpProxy.\r\n

\r\n\r\nAllow proxying of other domains?
\r\nIf you proxy a site like Yahoo! that links to other domains, do you wish to allow the user to follow the links to those other domains, or should the proxy stop them as they try to leave the original site you specified?\r\n

\r\n' where internationalId = 11 and namespace = 'HttpProxy' and languageId = 1; update international set internationalId=1014, namespace='WebGUI' where internationalId='17' and namespace='MessageBoard'; update international set internationalId=1015, namespace='WebGUI' where internationalId='11' and namespace='MessageBoard'; +alter table users add column referringAffiliate int not null default 0; +update users set referringAffiliate=1 where userId<>1; + diff --git a/lib/WebGUI.pm b/lib/WebGUI.pm index df10c29c3..28a3d8f47 100644 --- a/lib/WebGUI.pm +++ b/lib/WebGUI.pm @@ -13,6 +13,7 @@ our $VERSION = "5.5.0"; use strict qw(vars subs); use Tie::CPHash; +use WebGUI::Affiliate; use WebGUI::Cache; use WebGUI::ErrorHandler; use WebGUI::Icon; @@ -77,8 +78,7 @@ sub _generatePage { } if(!WebGUI::Privilege::canViewWobject($wobject->{wobjectId})){ next; } - - if (${$wobject}{namespace} eq "WobjectProxy") { + if (${$wobject}{namespace} eq "WobjectProxy") { $originalWobject = $wobject; my ($wobjectProxy) = WebGUI::SQL->quickHashRef("select * from WobjectProxy where wobjectId=".${$wobject}{wobjectId}); $wobject = WebGUI::SQL->quickHashRef("select * from wobject where wobject.wobjectId=".$wobjectProxy->{proxiedWobjectId}); @@ -225,6 +225,7 @@ sub page { $content = $cache->get; } $operationOutput = _processOperations(); + WebGUI::Affiliate::grabReferral(); $wobjectOutput = _processFunctions(); if ($operationOutput eq "" && $wobjectOutput eq "" && $session{form}{action2} ne "") { _processAction($session{form}{action2}); diff --git a/lib/WebGUI/Operation/Account.pm b/lib/WebGUI/Operation/Account.pm index f153bfe9b..d26a81cd2 100644 --- a/lib/WebGUI/Operation/Account.pm +++ b/lib/WebGUI/Operation/Account.pm @@ -198,7 +198,7 @@ sub www_createAccountSave { $u->profileField($fieldName,${$profile}{$fieldName}); } WebGUI::Authentication::registrationFormSave($u->userId); - WebGUI::Session::start($u->userId); + WebGUI::Session::convertVisitorToUser($session{var}{sessionId},$u->userId); _logLogin($u->userId,"success"); system(WebGUI::Macro::process($session{setting}{runOnRegistration})) if ($session{setting}{runOnRegistration} ne ""); WebGUI::MessageLog::addInternationalizedEntry('',$session{setting}{onNewUserAlertGroup},'',536) if ($session{setting}{alertOnNewUser}); diff --git a/lib/WebGUI/Session.pm b/lib/WebGUI/Session.pm index ebaeeb35a..5d0c74117 100644 --- a/lib/WebGUI/Session.pm +++ b/lib/WebGUI/Session.pm @@ -50,6 +50,7 @@ TIP: The $session variable is a case-insensitive hash. The contents of the has v use WebGUI::Session; WebGUI::Session::close(); WebGUI::Session::convertVisitorToUser($sessionId,$userId); + WebGUI::Session::deleteScratch($name); WebGUI::Session::end($sessionId); $header = WebGUI::Session::httpHeader(); $header = WebGUI::Session::httpRedirect($url); diff --git a/lib/WebGUI/User.pm b/lib/WebGUI/User.pm index b57ffcaef..01d853149 100644 --- a/lib/WebGUI/User.pm +++ b/lib/WebGUI/User.pm @@ -42,6 +42,7 @@ This package provides an object-oriented way of managing WebGUI users as well as $karma = $u->karma; $lastUpdated = $u->lastUpdated; $languagePreference = $u->profileField("language",1); + $referringAffiliate = $u->referringAffiliate; $status = $u->status("somestatus"); $username = $u->username("jonboy"); @@ -305,6 +306,34 @@ sub profileField { #------------------------------------------------------------------- +=head2 referringAffiliate ( [ value ] ) + +Returns the unique identifier of the affiliate the referred this user to the site. + +=over + +=item value + +An integer containing the unique identifier of the affiliate. + +=back + +=cut + +sub referringAffiliate { + my ($class, $value); + $class = shift; + $value = shift; + if (defined $value) { + $class->{_user}{"referringAffiliate"} = $value; + WebGUI::SQL->write("update users set referringAffiliate=".$value.", + lastUpdated=".time()." where userId=$class->{_userId}"); + } + return $class->{_user}{"referringAffiliate"}; +} + +#------------------------------------------------------------------- + =head2 status ( [ value ] ) Returns the status of the user.