diff --git a/docs/changelog/6.x.x.txt b/docs/changelog/6.x.x.txt index f4ea11c9d..98b962273 100644 --- a/docs/changelog/6.x.x.txt +++ b/docs/changelog/6.x.x.txt @@ -23,6 +23,7 @@ - Removed start/end dates from assets in favor of the workflow system. - Readded the purge option to the trash manager. - Added an advertising management system. + - Added a field set grouping mechanism to HTMLForm and TabForm. - Added archive/unarchive options to CS threads. - Increased the performance of CS Thread viewing by 500%. - Added a database cache option as an alternative to memcached. diff --git a/docs/upgrades/upgrade_6.8.7-6.99.0.pl b/docs/upgrades/upgrade_6.8.7-6.99.0.pl index 1a3f27bf9..19470e1df 100644 --- a/docs/upgrades/upgrade_6.8.7-6.99.0.pl +++ b/docs/upgrades/upgrade_6.8.7-6.99.0.pl @@ -105,6 +105,12 @@ sub addAdManager { renderedAd text )"); $session->db->write("alter table advertisement add index adSpaceId_isActive (adSpaceId, isActive)"); + my $macros = $session->config->get("macros"); + $macros->{AdSpace} = "AdSpace"; + $session->config->set("macros",$macros); + my $group = WebGUI::Group->new($session, "new", "pbgroup000000000000017"); + $group->name("Ad Manager"); + $group->description("These users will be able to manage advertisements."); } #------------------------------------------------- diff --git a/lib/WebGUI/AdminConsole.pm b/lib/WebGUI/AdminConsole.pm index f49a2ab3d..e816a51a0 100644 --- a/lib/WebGUI/AdminConsole.pm +++ b/lib/WebGUI/AdminConsole.pm @@ -170,6 +170,15 @@ sub getAdminFunction { op=>"manageWorkflows", group=>"pbgroup000000000000015" }, + "adSpace"=>{ + title=>{ + id=>"topicName", + namespace=>"AdSpace" + }, + icon=>"advertising.gif", + op=>"manageAdSpaces", + group=>"pbgroup000000000000017" + }, "cron"=>{ title=>{ id=>"topicName", diff --git a/lib/WebGUI/Auth.pm b/lib/WebGUI/Auth.pm index 36591bee6..e10244cca 100644 --- a/lib/WebGUI/Auth.pm +++ b/lib/WebGUI/Auth.pm @@ -264,8 +264,6 @@ sub createAccountSave { WebGUI::MessageLog::addEntry($self->userId,"",$i18n->get(870),$self->getSetting("welcomeMessage").$authInfo); } $self->session->user({user=>$u}); - $self->session->var->end($self->session->var->get("sessionId")); - $self->session->var->start($userId,$self->session->getId); $self->_logLogin($userId,"success"); $self->session->http->setStatus(201,"Account Registration Successful"); if ($self->session->setting->get("runOnRegistration")) { @@ -574,7 +572,6 @@ sub login { #Create a new user $uid = $self->userId; $u = WebGUI::User->new($self->session,$uid); - $self->session->user({user=>$u}); $self->session->var->start($uid,$self->session->getId); $u->karma($self->session->setting->get("karmaPerLogin"),"Login","Just for logging in.") if ($self->session->setting->get("useKarma")); $self->_logLogin($uid,"success"); diff --git a/lib/WebGUI/Form/Control.pm b/lib/WebGUI/Form/Control.pm index f2829487f..a13296ee2 100644 --- a/lib/WebGUI/Form/Control.pm +++ b/lib/WebGUI/Form/Control.pm @@ -598,8 +598,8 @@ sub toHtmlWithWrapper { if ($self->passUiLevelCheck) { my ($fieldClass, $rowClass, $labelClass, $hoverHelp, $subtext) = $self->prepareWrapper; return ' - - '.$self->toHtml().$subtext." + + '.$self->toHtml().$subtext." \n"; } else { return $self->toHtmlAsHidden; diff --git a/lib/WebGUI/HTMLForm.pm b/lib/WebGUI/HTMLForm.pm index e5e6cd3d3..8090ca2ce 100644 --- a/lib/WebGUI/HTMLForm.pm +++ b/lib/WebGUI/HTMLForm.pm @@ -107,6 +107,46 @@ sub DESTROY { } +#------------------------------------------------------------------- + +=head2 fieldSetEnd ( ) + +Closes a field set that was opened by fieldSetStart(); + +=cut + +sub fieldSetEnd { + my $self = shift; + my $legend = shift; + $self->{_data} .= "\n" + ."\n" + ."{_tableExtras}.'">' + ."\n"; +} + + +#------------------------------------------------------------------- + +=head2 fieldSetStart ( legend ) + +Adds a field set grouping to the form. Note, must be closed with fieldSetEnd(). + +=head3 legend + +A text label to appear with the field set. + +=cut + +sub fieldSetStart { + my $self = shift; + my $legend = shift; + $self->{_data} .= "
\n" + ."
\n".$legend."\n" + ."{_tableExtras}.'">' + ."\n"; +} + + #------------------------------------------------------------------- =head2 new ( [ action, method, extras, enctype, tableExtras ] ) @@ -150,10 +190,10 @@ sub new { method=>($param{method} || $param{'-method'}), enctype=>($param{enctype} || $param{'-enctype'}) }); - $header .= "\n
'; + $header .= "\n
'; $footer = "
\n" ; $footer .= WebGUI::Form::formFooter($session); - bless {_session=>$session, _uiLevelOverride=>$param{uiLevelOverride}, _header => $header, _footer => $footer, _data => ''}, $class; + bless {_session=>$session, _tableExtras=>$param{tableExtras}, _uiLevelOverride=>$param{uiLevelOverride}, _header => $header, _footer => $footer, _data => ''}, $class; } #------------------------------------------------------------------- diff --git a/lib/WebGUI/Macro/AdSpace.pm b/lib/WebGUI/Macro/AdSpace.pm new file mode 100644 index 000000000..bebff0a8b --- /dev/null +++ b/lib/WebGUI/Macro/AdSpace.pm @@ -0,0 +1,43 @@ +package WebGUI::Macro::AdSpace; + +#------------------------------------------------------------------- +# WebGUI is Copyright 2001-2006 Plain Black Corporation. +#------------------------------------------------------------------- +# Please read the legal notices (docs/legal.txt) and the license +# (docs/license.txt) that came with this distribution before using +# this software. +#------------------------------------------------------------------- +# http://www.plainblack.com info@plainblack.com +#------------------------------------------------------------------- + +use strict; +use WebGUI::AdSpace; + +=head1 NAME + +Package WebGUI::Macro::AdSpace + +=head1 DESCRIPTION + +Macro for displaying ads from the ad management system in WebGUI. + +=head2 process ( name ) + +=head3 name + +The unique name of an Ad Space. + +=cut + +#------------------------------------------------------------------- +sub process { + my $session = shift; + my $name = shift; + my $adSpace = WebGUI::AdSpace->newByName($session, $name); + return undef unless defined $adSpace; + return $adSpace->displayImpression; +} + +1; + + diff --git a/lib/WebGUI/Operation.pm b/lib/WebGUI/Operation.pm index 750dd73af..55328f9cc 100644 --- a/lib/WebGUI/Operation.pm +++ b/lib/WebGUI/Operation.pm @@ -77,6 +77,13 @@ Returns a hash reference containing operation and package names. sub getOperations { return { + 'deleteAd' => 'WebGUI::Operation::AdSpace', + 'deleteAdSpace' => 'WebGUI::Operation::AdSpace', + 'editAd' => 'WebGUI::Operation::AdSpace', + 'editAdSave' => 'WebGUI::Operation::AdSpace', + 'editAdSpace' => 'WebGUI::Operation::AdSpace', + 'editAdSpaceSave' => 'WebGUI::Operation::AdSpace', + 'manageAdSpaces' => 'WebGUI::Operation::AdSpace', 'clickAd' => 'WebGUI::Operation::AdSpace', 'editVersionTag' => 'WebGUI::Operation::VersionTag', 'editVersionTagSave' => 'WebGUI::Operation::VersionTag', diff --git a/lib/WebGUI/Operation/AdSpace.pm b/lib/WebGUI/Operation/AdSpace.pm index 708b9777e..f43d5db5b 100644 --- a/lib/WebGUI/Operation/AdSpace.pm +++ b/lib/WebGUI/Operation/AdSpace.pm @@ -12,6 +12,10 @@ package WebGUI::Operation::AdSpace; use strict; use WebGUI::AdSpace; +use WebGUI::AdSpace::Ad; +use WebGUI::AdminConsole; +use WebGUI::International; +use WebGUI::HTMLForm; =head1 NAME @@ -40,6 +44,246 @@ sub www_clickAd { return "Redirecting to $url"; } +#------------------------------------------------------------------- + +=head2 www_editAd ( ) + +Displays form for editing an ad. + +=cut + +sub www_editAd { + my $session = shift; + return $session->privilege->insufficient unless ($session->user->isInGroup("pbgroup000000000000017")); + my $id = $session->form->param("adId") || "new"; + my $ac = WebGUI::AdminConsole->new($session,"adSpace"); + my $i18n = WebGUI::International->new($session,"AdSpace"); + my $ad = WebGUI::AdSpace::Ad->new($session,$id); + $ac->addSubmenuItem($session->url->page("op=editAdSpace;adSpace=".$session->form->param("adSpace")), $i18n->get("edit this ad space")); + $ac->addSubmenuItem($session->url->page("op=editAdSpace"), $i18n->get("add ad space")); + $ac->addSubmenuItem($session->url->page("op=manageAdSpaces"), $i18n->get("manage ad spaces")); + my $f = WebGUI::HTMLForm->new($session); + $f->submit; + $f->hidden(name=>"adId", value=>$id); + $f->hidden(name=>"adSpaceId", value=> $session->form->param("adSpaceId")); + $f->readOnly(label=>$i18n->get("ad id"), value=>$id); + $f->hidden(name=>"op", value=>"editAdSpaceSave"); + my $value = $ad->get("isActive") if defined $ad; + $f->yesNo( + name=>"isActive", + value=>$value, + hoverHelp => $i18n->get("is active help"), + label=>$i18n->get("is active") + ); + my $value = $ad->get("title") if defined $ad; + $f->text( + name=>"title", + value=>$value, + hoverHelp => $i18n->get("title help"), + label=>$i18n->get("title") + ); + my $value = $ad->get("impressionsBought") if defined $ad; + $f->integer( + name=>"impressionsBought", + value=>$value, + hoverHelp => $i18n->get("impressions bought help"), + label=>$i18n->get("impressions bought"), + subtext=> defined $ad ? $i18n->get("used").": ".$ad->get("impressions") : undef + ); + my $value = $ad->get("clicksBought") if defined $ad; + $f->integer( + name=>"clicksBought", + value=>$value, + hoverHelp => $i18n->get("clicks bought help"), + label=>$i18n->get("clicks bought"), + subtext=> defined $ad ? $i18n->get("used").": ".$ad->get("clicks") : undef + ); + my $value = $ad->get("type") if defined $ad; + $f->selectBox( + name=>"type", + value=>$value, + options=>{ + text=>$i18n->get("text"), + image=>$i18n->get("image"), + rich=>$i18n->get("rich"), + }, + defaultValue=>"text", + hoverHelp => $i18n->get("top help"), + label=>$i18n->get("title") + ); + $f->fieldSetStart($i18n->get("text")); + my $value = $ad->get("adText") if defined $ad; + $f->text( + name=>"adText", + value=>$value, + hoverHelp => $i18n->get("ad text help"), + label=>$i18n->get("ad text") + ); + my $value = $ad->get("borderColor") if defined $ad; + $f->color( + name=>"borderColor", + value=>$value, + defaultValue=>"#000000", + hoverHelp => $i18n->get("border color help"), + label=>$i18n->get("border color text") + ); + my $value = $ad->get("textColor") if defined $ad; + $f->color( + name=>"textColor", + value=>$value, + defaultValue=>"#000000", + hoverHelp => $i18n->get("text color help"), + label=>$i18n->get("text color text") + ); + my $value = $ad->get("backgroundColor") if defined $ad; + $f->color( + name=>"backgroundColor", + value=>$value, + defaultValue=>"#ffffff", + hoverHelp => $i18n->get("background color help"), + label=>$i18n->get("background color text") + ); + $f->fieldSetEnd; + $f->fieldSetStart($i18n->get("image")); + $f->image( + label=>$i18n->get("image") + ); + $f->fieldSetEnd; + $f->fieldSetStart($i18n->get("rich")); + my $value = $ad->get("richMedia") if defined $ad; + $f->codearea( + name=>"richMedia", + label=>$i18n->get("rich"), + value=>$value, + hoverHelp=>$i18n->get("rich help") + ); + $f->fieldSetEnd; + $f->submit; + $ac->render($f->print, $i18n->get("edit advertisement")); +} + +#------------------------------------------------------------------- + +=head2 www_editAdSpace ( ) + +Edit or add an ad space form. + +=cut + +sub www_editAdSpace { + my $session = shift; + return $session->privilege->insufficient unless ($session->user->isInGroup("pbgroup000000000000017")); + my $id = $session->form->param("adSpaceId") || "new"; + my $ac = WebGUI::AdminConsole->new($session,"adSpace"); + my $i18n = WebGUI::International->new($session,"AdSpace"); + my $adSpace = WebGUI::AdSpace->new($session, $id); + $ac->addSubmenuItem($session->url->page("op=editAd"), $i18n->get("add an ad")) if defined $adSpace; + $ac->addSubmenuItem($session->url->page("op=manageAdSpaces"), $i18n->get("manage ad spaces")); + my $f = WebGUI::HTMLForm->new($session); + $f->hidden(name=>"adSpaceId", value=>$id); + $f->readOnly(label=>$i18n->get("ad space id"), value=>$id); + $f->hidden(name=>"op", value=>"editAdSpaceSave"); + my $value = $adSpace->get("name") if defined $adSpace; + $f->text( + name=>"name", + value=>$value, + hoverHelp => $i18n->get("name help"), + label=>$i18n->get("name") + ); + my $value = $adSpace->get("title") if defined $adSpace; + $f->text( + name=>"title", + value=>$value, + hoverHelp => $i18n->get("title help"), + label=>$i18n->get("title") + ); + my $value = $adSpace->get("description") if defined $adSpace; + $f->textarea( + name=>"description", + value=>$value, + hoverHelp => $i18n->get("description help"), + label=>$i18n->get("description") + ); + my $value = $adSpace->get("width") if defined $adSpace; + $f->integer( + name=>"width", + value=>$value, + defaultValue=>468, + hoverHelp => $i18n->get("width help"), + label=>$i18n->get("width") + ); + my $value = $adSpace->get("height") if defined $adSpace; + $f->integer( + name=>"height", + value=>$value, + defaultValue=>60, + hoverHelp => $i18n->get("height help"), + label=>$i18n->get("height") + ); + $f->submit; + my $ads = ""; + if (defined $adSpace) { + my $rs = $session->db->read("select adId, title from advertisement where adId=?",[$id]); + while (my ($adId, $title) = $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.'
'; + } + } + $ac->render($f->print.$ads, $i18n->get("edit ad space")); +} + + +#------------------------------------------------------------------- + +=head2 www_editAdSpaceSave () + +Save the www_editAdSpace method. + +=cut + +sub www_editAdSpaceSave { + my $session = shift; + return $session->privilege->insufficient unless ($session->user->isInGroup("pbgroup000000000000017")); + my %properties = ( + name=>$session->form->process("name", "text"), + title=>$session->form->process("title", "text"), + description=>$session->form->process("description", "textarea"), + width=>$session->form->process("width", "integer"), + height=>$session->form->process("height", "integer"), + ); + if ($session->form->param("adSpaceId") eq "new") { + WebGUI::AdSpace->create($session, \%properties); + } else { + my $adSpace = WebGUI::AdSpace->new($session, $session->form->param("adSpaceId")); + $adSpace->set(\%properties); + } + return www_manageAdSpaces($session); +} + +#------------------------------------------------------------------- + +=head2 www_manageAdSpaces ( ) + +Manage ad spaces. + +=cut + +sub www_manageAdSpaces { + my $session = shift; + return $session->privilege->insufficient unless ($session->user->isInGroup("pbgroup000000000000017")); + my $ac = WebGUI::AdminConsole->new($session,"adSpace"); + my $i18n = WebGUI::International->new($session,"AdSpace"); + 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")) + .$session->icon->edit("op=editAdSpace;adSpaceId=".$id) + .' '.$title.'
'; + } + $ac->addSubmenuItem($session->url->page("op=editAdSpace"), $i18n->get("add ad space")); + return $ac->render($output); +} 1; diff --git a/lib/WebGUI/Operation/Profile.pm b/lib/WebGUI/Operation/Profile.pm index a187acee6..6370ab8c1 100644 --- a/lib/WebGUI/Operation/Profile.pm +++ b/lib/WebGUI/Operation/Profile.pm @@ -223,17 +223,12 @@ sub www_editProfileSave { my $session = shift; my ($profile, $fieldName, $error, $u, $warning); return WebGUI::Operation::Auth::www_auth($session, "init") if ($session->user->userId eq '1'); - ($profile, $error, $warning) = validateProfileData($session); $error .= $warning; - return www_editProfile('
    '.$error.'
') if($error ne ""); - - $u = WebGUI::User->new($session,$session->user->userId); foreach $fieldName (keys %{$profile}) { - $u->profileField($fieldName,$profile->{$fieldName}); + $session->user->profileField($fieldName,$profile->{$fieldName}); } - $session->user({user=>$u}); return WebGUI::Operation::Auth::www_auth($session); } diff --git a/lib/WebGUI/Operation/User.pm b/lib/WebGUI/Operation/User.pm index 3f644f955..067079a73 100644 --- a/lib/WebGUI/Operation/User.pm +++ b/lib/WebGUI/Operation/User.pm @@ -225,7 +225,6 @@ sub www_becomeUser { my $session = shift; return $session->privilege->adminOnly() unless ($session->user->isInGroup(3)); return unless WebGUI::User->validUserId($session, $session->form->process("uid")); - $session->user({userId=>$session->form->process("uid")}); $session->var->end($session->var->get("sessionId")); $session->var->start($session->form->process("uid"),$session->getId); return ""; diff --git a/lib/WebGUI/Session.pm b/lib/WebGUI/Session.pm index e72c23e8a..667a028b5 100644 --- a/lib/WebGUI/Session.pm +++ b/lib/WebGUI/Session.pm @@ -567,6 +567,7 @@ sub user { delete $self->{_stow}; $self->{_user} = $option->{user} || WebGUI::User->new($self, $userId); $self->request->user($self->{_user}->username) if ($self->request); + $self->var->start($self->{_user}->userId,$self->getId); } elsif (!exists $self->{_user}) { $self->{_user} = WebGUI::User->new($self, $self->var->get('userId')); } diff --git a/lib/WebGUI/i18n/English/AdSpace.pm b/lib/WebGUI/i18n/English/AdSpace.pm new file mode 100644 index 000000000..c235452f9 --- /dev/null +++ b/lib/WebGUI/i18n/English/AdSpace.pm @@ -0,0 +1,209 @@ +package WebGUI::i18n::English::AdSpace; + +our $I18N = { + + 'ad text' => { + message => q|Ad Text|, + lastUpdated => 0, + context => q|a form property in the ad editor| + }, + + 'ad text help' => { + message => q|Please type up to 255 characters of text that you'd like to see appear in this ad. Keep in mind that depending upon the size of your ad, the whole amount of text may not be seen if it's long. We recommend keeping it to 60 characters or less.|, + lastUpdated => 0, + context => q|help for a form property in the ad editor| + }, + + 'type' => { + message => q|Type|, + lastUpdated => 0, + context => q|a form property in the ad editor| + }, + + 'type help' => { + message => q|What kind of ad are we running?|, + lastUpdated => 0, + context => q|help for a form property in the ad editor| + }, + + 'text' => { + message => q|Text|, + lastUpdated => 0, + context => q|a type of ad that is text only| + }, + + 'image' => { + message => q|Image|, + lastUpdated => 0, + context => q|a type of ad that displays a banner image| + }, + + 'rich' => { + message => q|Rich Media|, + lastUpdated => 0, + context => q|a type of ad that contains javascript, flash, html forms, or some other rich media| + }, + + 'ad id' => { + message => q|Ad Id|, + lastUpdated => 0, + }, + + 'edit this ad space' => { + message => q|Edit this ad space.|, + lastUpdated => 0, + context => q|a menu label for manageing ad spaces| + }, + + 'manage ad spaces' => { + message => q|Manage ad spaces.|, + lastUpdated => 0, + context => q|a menu label for manageing ad spaces| + }, + + 'add an ad' => { + message => q|Add an ad.|, + lastUpdated => 0, + context => q|a menu label for adding a new advertisement| + }, + + 'used' => { + message => q|Used|, + lastUpdated => 0, + context => q|the number of impressions displayed or clicks will be displayed after this label| + }, + + 'is active' => { + message => q|Is active?|, + lastUpdated => 0, + context => q|a form property in the ad editor| + }, + + 'is active help' => { + message => q|Should this ad be included in the rotation?|, + lastUpdated => 0, + context => q|help for a form property in the ad editor| + }, + + 'clicks bought' => { + message => q|Clicks Purchased|, + lastUpdated => 0, + context => q|a form property in the ad editor| + }, + + 'clicks bought help' => { + message => q|How many clicks has the advertiser purchased? If they purchased a number of impressions you can leave this at zero.|, + lastUpdated => 0, + context => q|help for a form property in the ad editor| + }, + + 'impressions bought' => { + message => q|Impressions Purchased|, + lastUpdated => 0, + context => q|a form property in the ad editor| + }, + + 'impressions bought help' => { + message => q|How many impressions (individual displays of the ad) has the advertiser purchased? If they purchased a number of clicks you can leave this at zero.|, + lastUpdated => 0, + context => q|help for a form property in the ad editor| + }, + + 'edit advertisement' => { + message => q|Edit Advertisement|, + lastUpdated => 0, + context => q|title of ad space edit screen| + }, + + 'edit ad space' => { + message => q|Edit Ad Space|, + lastUpdated => 0, + context => q|title of ad space edit screen| + }, + + 'ad space id' => { + message => q|Ad Space Id|, + lastUpdated => 0, + context => q|a form property in the ad manager| + }, + + 'name' => { + message => q|Name|, + lastUpdated => 0, + context => q|a form property in the ad manager| + }, + + 'name help' => { + message => q|This string is used in combination with the AdSpace macro to place ads on the site. It should contain no spaces and only alpha-numeric chracters.|, + lastUpdated => 0, + context => q|help for a form property in the ad manager| + }, + + 'description' => { + message => q|Description|, + lastUpdated => 0, + context => q|a form property in the ad manager| + }, + + 'description help' => { + message => q|A full description of where this ad space will be located on the site.|, + lastUpdated => 0, + context => q|help for a form property in the ad manager| + }, + + 'title' => { + message => q|Title|, + lastUpdated => 0, + context => q|a form property in the ad manager| + }, + + 'title help' => { + message => q|A human readable label.|, + lastUpdated => 0, + context => q|help for a form property in the ad manager| + }, + + 'height' => { + message => q|Height|, + lastUpdated => 0, + context => q|a form property in the ad manager| + }, + + 'height help' => { + message => q|How tall (in pixels) should the ad space be.|, + lastUpdated => 0, + context => q|help for a form property in the ad manager| + }, + + 'width' => { + message => q|Width|, + lastUpdated => 0, + context => q|a form property in the ad manager| + }, + + 'width help' => { + message => q|How wide (in pixels) should the ad space be.|, + lastUpdated => 0, + context => q|help for a form property in the ad manager| + }, + + 'confirm ad space delete' => { + message => q|Are you certain you want to delete this ad space and all the ads attached to it?|, + lastUpdated => 0, + context => q|menu item in ad manager| + }, + + 'add ad space' => { + message => q|Add ad space.|, + lastUpdated => 0, + context => q|menu item in ad manager| + }, + + 'topicName' => { + message => q|Advertising|, + lastUpdated => 0, + }, + +}; + +1;