diff --git a/lib/WebGUI/AdSpace.pm b/lib/WebGUI/AdSpace.pm index 9324c0442..83d83384b 100644 --- a/lib/WebGUI/AdSpace.pm +++ b/lib/WebGUI/AdSpace.pm @@ -115,20 +115,28 @@ sub DESTROY { #------------------------------------------------------------------- -=head2 displayImpression () +=head2 displayImpression ( dontCount ) Finds out what the next ad is to display, increments it's impression counter, and returns the HTML to display it. +=head3 dontCount + +A boolean that tells the ad system not to count this impression if true. + =cut sub displayImpression { my $self = shift; + my $dontCount = shift; my ($id, $ad, $priority, $clicks, $clicksBought, $impressions, $impressionsBought) = $self->session->db->quickArray("select adId, renderedAd, priority, clicks, clicksBought, impressions, impressionsBought from advertisement where adSpaceId=? and isActive=1 order by nextInPriority asc limit 1",[$self->getId]); - my $isActive = 1; - if ($clicks >= $clicksBought && $impressions >= $impressionsBought) { - $isActive = 0; + unless ($dontCount) { + my $isActive = 1; + if ($clicks >= $clicksBought && $impressions >= $impressionsBought) { + $isActive = 0; + } + $self->session->db->write("update advertisement set impressions=impressions+1, nextInPriority=?, isActive=? where adId=?", + [time()+$priority, $isActive, $id]); } - $self->session->db->write("update advertisement set impressions=impressions+1, nextInPriority=?, isActive=? where adId=?", [time()+$priority, $isActive, $id]); return $ad; } diff --git a/lib/WebGUI/Operation/AdSpace.pm b/lib/WebGUI/Operation/AdSpace.pm index dc8448f63..72b85b8e3 100644 --- a/lib/WebGUI/Operation/AdSpace.pm +++ b/lib/WebGUI/Operation/AdSpace.pm @@ -321,18 +321,18 @@ sub www_editAdSpace { ); $f->submit; my $ads = ""; + my $code = ""; if (defined $adSpace) { - $ads .= '

'.$i18n->get("macro code prompt").'
^AdSpace('.$adSpace->get("name").');

' - ."

"; - my $rs = $session->db->read("select adId, title from advertisement where adSpaceId=?",[$id]); - while (my ($adId, $title) = $rs->array) { - $ads .= $session->icon->delete("op=deleteAd;adSpaceId=".$id.";adId=".$adId, undef, $i18n->get("confirm ad delete")) + $code = '

'.$i18n->get("macro code prompt").'
^AdSpace('.$adSpace->get("name").');

'; + my $rs = $session->db->read("select adId, title, renderedAd from advertisement where adSpaceId=?",[$id]); + while (my ($adId, $title, $ad) = $rs->array) { + $ads .= '
'.$session->icon->delete("op=deleteAd;adSpaceId=".$id.";adId=".$adId, undef, $i18n->get("confirm ad delete")) .$session->icon->edit("op=editAd;adSpaceId=".$id.";adId=".$adId) - .' '.$title.'
'; + .' '.$title.'
'.$ad.'
'; } - $ads .= "

"; + $ads .= '
'; } - $ac->render($f->print.$ads, $i18n->get("edit ad space")); + $ac->render($code.$f->print.$ads, $i18n->get("edit ad space")); } @@ -380,10 +380,14 @@ sub www_manageAdSpaces { my $output = ""; my $rs = $session->db->read("select adSpaceId, title from adSpace order by title"); while (my ($id, $title) = $rs->array) { - $output .= $session->icon->delete("op=deleteAdSpace;adSpaceId=".$id, undef, $i18n->get("confirm ad space delete")) + $output .= '
' + .$session->icon->delete("op=deleteAdSpace;adSpaceId=".$id, undef, $i18n->get("confirm ad space delete")) .$session->icon->edit("op=editAdSpace;adSpaceId=".$id) - .' '.$title.'
'; + .' '.$title.'
' + .WebGUI::AdSpace->new($session, $id)->displayImpression(1) + .'
'; } + $output .= '
'; $ac->addSubmenuItem($session->url->page("op=editAdSpace"), $i18n->get("add ad space")); return $ac->render($output); }