onCompletePurchase should pull userId from the transaction, instead of the session, since the session could be owned by spectre and not the user. Fixes bug #11385
This commit is contained in:
parent
fbfe6387c4
commit
5934ba8fce
3 changed files with 33 additions and 30 deletions
|
|
@ -315,49 +315,51 @@ inserts the ad into the adspace...
|
|||
=cut
|
||||
|
||||
sub onCompletePurchase {
|
||||
my $self = shift;
|
||||
my $item = shift;
|
||||
my $self = shift;
|
||||
my $session = $self->session;
|
||||
my $item = shift;
|
||||
my $options = $self->getOptions;
|
||||
my $ad;
|
||||
|
||||
# LATER: if we use Temp Storage for the image we need to move it to perm storage
|
||||
|
||||
my $userId = $item->transaction->get('userId');
|
||||
if( $options->{adId} ne '' ) {
|
||||
$ad = WebGUI::AdSpace::Ad->new($self->session,$options->{adId});
|
||||
my $clicks = $options->{clicks} + $ad->get('clicksBought');
|
||||
$ad = WebGUI::AdSpace::Ad->new($session, $options->{adId});
|
||||
my $clicks = $options->{clicks} + $ad->get('clicksBought');
|
||||
my $impressions = $options->{impressions} + $ad->get('impressionsBought');
|
||||
$ad->set({
|
||||
title => $options->{'adtitle'},
|
||||
clicksBought => $clicks,
|
||||
impressionsBought => $impressions,
|
||||
url => $options->{'link'},
|
||||
storageId => $options->{'image'},
|
||||
title => $options->{'adtitle'},
|
||||
clicksBought => $clicks,
|
||||
impressionsBought => $impressions,
|
||||
url => $options->{'link'},
|
||||
storageId => $options->{'image'},
|
||||
});
|
||||
}
|
||||
else {
|
||||
$ad = WebGUI::AdSpace::Ad->create($self->session,$self->get('adSpace'),{
|
||||
title => $options->{'adtitle'},
|
||||
clicksBought => $options->{'clicks'},
|
||||
impressionsBought => $options->{'impressions'},
|
||||
url => $options->{'link'},
|
||||
storageId => $options->{'image'},
|
||||
ownerUserId => $self->session->user->userId,
|
||||
isActive => 1,
|
||||
type => 'image',
|
||||
priority => $self->get('priority'),
|
||||
adSpace => $self->get('adSpace'),
|
||||
$ad = WebGUI::AdSpace::Ad->create($session, $self->get('adSpace'), {
|
||||
title => $options->{'adtitle'},
|
||||
clicksBought => $options->{'clicks'},
|
||||
impressionsBought => $options->{'impressions'},
|
||||
url => $options->{'link'},
|
||||
storageId => $options->{'image'},
|
||||
ownerUserId => $userId,
|
||||
isActive => 1,
|
||||
type => 'image',
|
||||
priority => $self->get('priority'),
|
||||
adSpace => $self->get('adSpace'),
|
||||
});
|
||||
}
|
||||
|
||||
WebGUI::AssetCollateral::Sku::Ad::Ad->create($self->session,{
|
||||
userId => $item->transaction->get('userId'),
|
||||
transactionItemId => $item->getId,
|
||||
adId => $ad->getId,
|
||||
clicksPurchased => $options->{'clicks'},
|
||||
impressionsPurchased => $options->{'impressions'},
|
||||
dateOfPurchase => $item->transaction->get('dateOfPurchase'),
|
||||
storedImage => $options->{'image'},
|
||||
isDeleted => 0,
|
||||
WebGUI::AssetCollateral::Sku::Ad::Ad->create($session, {
|
||||
userId => $userId,
|
||||
transactionItemId => $item->getId,
|
||||
adId => $ad->getId,
|
||||
clicksPurchased => $options->{'clicks'},
|
||||
impressionsPurchased => $options->{'impressions'},
|
||||
dateOfPurchase => $item->transaction->get('dateOfPurchase'),
|
||||
storedImage => $options->{'image'},
|
||||
isDeleted => 0,
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -257,7 +257,7 @@ sub onCompletePurchase {
|
|||
my ($self, $item) = @_;
|
||||
my $badgeInfo = $self->getOptions;
|
||||
$badgeInfo->{purchaseComplete} = 1;
|
||||
$badgeInfo->{userId} = $self->session->user->userId; # they have to be logged in at this point
|
||||
$badgeInfo->{userId} = $item->transaction->get('userId'); # they have to be logged in at this point
|
||||
$badgeInfo->{transactionItemId} = $item->getId;
|
||||
$self->session->db->setRow("EMSRegistrant","badgeId", $badgeInfo);
|
||||
return undef;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue